refactor(pyargus): make pyargus depend only on argus
This commit is contained in:
parent
db3a63f9e1
commit
444d60197d
6 changed files with 32 additions and 64 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
pub mod prelude {
|
pub use argus_core::signals::{AnySignal, Signal};
|
||||||
pub use argus_core::prelude::*;
|
pub use argus_core::{expr, signals, ArgusResult, Error};
|
||||||
pub use argus_parser::parse_str;
|
|
||||||
pub use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};
|
pub use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ name = "pyargus"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
argus-core = { version = "0.1.0", path = "../argus-core" }
|
argus = { version = "0.1.0", path = "../argus" }
|
||||||
argus-semantics = { version = "0.1.0", path = "../argus-semantics" }
|
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
paste = "1.0.14"
|
paste = "1.0.14"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use argus_core::prelude::*;
|
use argus::expr::*;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::pyclass::CompareOp;
|
use pyo3::pyclass::CompareOp;
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub struct ConstInt;
|
||||||
impl ConstInt {
|
impl ConstInt {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(val: i64) -> (Self, PyNumExpr) {
|
fn new(val: i64) -> (Self, PyNumExpr) {
|
||||||
(Self, Box::new(NumExpr::IntLit(argus_core::expr::IntLit(val))).into())
|
(Self, Box::new(NumExpr::IntLit(argus::expr::IntLit(val))).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ pub struct ConstUInt;
|
||||||
impl ConstUInt {
|
impl ConstUInt {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(val: u64) -> (Self, PyNumExpr) {
|
fn new(val: u64) -> (Self, PyNumExpr) {
|
||||||
(Self, Box::new(NumExpr::UIntLit(argus_core::expr::UIntLit(val))).into())
|
(Self, Box::new(NumExpr::UIntLit(argus::expr::UIntLit(val))).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,10 +91,7 @@ pub struct ConstFloat;
|
||||||
impl ConstFloat {
|
impl ConstFloat {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(val: f64) -> (Self, PyNumExpr) {
|
fn new(val: f64) -> (Self, PyNumExpr) {
|
||||||
(
|
(Self, Box::new(NumExpr::FloatLit(argus::expr::FloatLit(val))).into())
|
||||||
Self,
|
|
||||||
Box::new(NumExpr::FloatLit(argus_core::expr::FloatLit(val))).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,10 +103,7 @@ pub struct VarInt;
|
||||||
impl VarInt {
|
impl VarInt {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(name: String) -> (Self, PyNumExpr) {
|
fn new(name: String) -> (Self, PyNumExpr) {
|
||||||
(
|
(Self, Box::new(NumExpr::IntVar(argus::expr::IntVar { name })).into())
|
||||||
Self,
|
|
||||||
Box::new(NumExpr::IntVar(argus_core::expr::IntVar { name })).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,10 +115,7 @@ pub struct VarUInt;
|
||||||
impl VarUInt {
|
impl VarUInt {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(name: String) -> (Self, PyNumExpr) {
|
fn new(name: String) -> (Self, PyNumExpr) {
|
||||||
(
|
(Self, Box::new(NumExpr::UIntVar(argus::expr::UIntVar { name })).into())
|
||||||
Self,
|
|
||||||
Box::new(NumExpr::UIntVar(argus_core::expr::UIntVar { name })).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,10 +127,7 @@ pub struct VarFloat;
|
||||||
impl VarFloat {
|
impl VarFloat {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(name: String) -> (Self, PyNumExpr) {
|
fn new(name: String) -> (Self, PyNumExpr) {
|
||||||
(
|
(Self, Box::new(NumExpr::FloatVar(argus::expr::FloatVar { name })).into())
|
||||||
Self,
|
|
||||||
Box::new(NumExpr::FloatVar(argus_core::expr::FloatVar { name })).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +140,7 @@ impl Negate {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
||||||
let arg = arg.0;
|
let arg = arg.0;
|
||||||
(Self, Box::new(NumExpr::Neg(argus_core::expr::Neg { arg })).into())
|
(Self, Box::new(NumExpr::Neg(argus::expr::Neg { arg })).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +155,7 @@ impl Add {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
||||||
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||||
(Self, Box::new(NumExpr::Add(argus_core::expr::Add { args })).into())
|
(Self, Box::new(NumExpr::Add(argus::expr::Add { args })).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,7 +168,7 @@ impl Sub {
|
||||||
fn new(lhs: PyNumExpr, rhs: PyNumExpr) -> (Self, PyNumExpr) {
|
fn new(lhs: PyNumExpr, rhs: PyNumExpr) -> (Self, PyNumExpr) {
|
||||||
let lhs = lhs.0;
|
let lhs = lhs.0;
|
||||||
let rhs = rhs.0;
|
let rhs = rhs.0;
|
||||||
(Self, Box::new(NumExpr::Sub(argus_core::expr::Sub { lhs, rhs })).into())
|
(Self, Box::new(NumExpr::Sub(argus::expr::Sub { lhs, rhs })).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +180,7 @@ impl Mul {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
||||||
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||||
(Self, Box::new(NumExpr::Mul(argus_core::expr::Mul { args })).into())
|
(Self, Box::new(NumExpr::Mul(argus::expr::Mul { args })).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +195,7 @@ impl Div {
|
||||||
let divisor = divisor.0;
|
let divisor = divisor.0;
|
||||||
(
|
(
|
||||||
Self,
|
Self,
|
||||||
Box::new(NumExpr::Div(argus_core::expr::Div { dividend, divisor })).into(),
|
Box::new(NumExpr::Div(argus::expr::Div { dividend, divisor })).into(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +208,7 @@ impl Abs {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
||||||
let arg = arg.0;
|
let arg = arg.0;
|
||||||
(Self, Box::new(NumExpr::Abs(argus_core::expr::Abs { arg })).into())
|
(Self, Box::new(NumExpr::Abs(argus::expr::Abs { arg })).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,7 +242,7 @@ pub struct ConstBool;
|
||||||
impl ConstBool {
|
impl ConstBool {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(val: bool) -> (Self, PyBoolExpr) {
|
fn new(val: bool) -> (Self, PyBoolExpr) {
|
||||||
(Self, Box::new(BoolExpr::BoolLit(argus_core::expr::BoolLit(val))).into())
|
(Self, Box::new(BoolExpr::BoolLit(argus::expr::BoolLit(val))).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,10 +253,7 @@ pub struct VarBool;
|
||||||
impl VarBool {
|
impl VarBool {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(name: String) -> (Self, PyBoolExpr) {
|
fn new(name: String) -> (Self, PyBoolExpr) {
|
||||||
(
|
(Self, Box::new(BoolExpr::BoolVar(argus::expr::BoolVar { name })).into())
|
||||||
Self,
|
|
||||||
Box::new(BoolExpr::BoolVar(argus_core::expr::BoolVar { name })).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,10 +269,7 @@ impl Cmp {
|
||||||
let op = op.0;
|
let op = op.0;
|
||||||
let lhs = lhs.0;
|
let lhs = lhs.0;
|
||||||
let rhs = rhs.0;
|
let rhs = rhs.0;
|
||||||
(
|
(Self, Box::new(BoolExpr::Cmp(argus::expr::Cmp { op, lhs, rhs })).into())
|
||||||
Self,
|
|
||||||
Box::new(BoolExpr::Cmp(argus_core::expr::Cmp { op, lhs, rhs })).into(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,7 +314,7 @@ impl Not {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
||||||
let arg = arg.0;
|
let arg = arg.0;
|
||||||
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus_core::expr::Not { arg }))))
|
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus::expr::Not { arg }))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -344,10 +326,7 @@ impl And {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
||||||
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||||
(
|
(Self, PyBoolExpr(Box::new(BoolExpr::And(argus::expr::And { args }))))
|
||||||
Self,
|
|
||||||
PyBoolExpr(Box::new(BoolExpr::And(argus_core::expr::And { args }))),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -359,7 +338,7 @@ impl Or {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
||||||
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||||
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus_core::expr::Or { args }))))
|
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus::expr::Or { args }))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,10 +350,7 @@ impl Next {
|
||||||
#[new]
|
#[new]
|
||||||
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
||||||
let arg = arg.0;
|
let arg = arg.0;
|
||||||
(
|
(Self, PyBoolExpr(Box::new(BoolExpr::Next(argus::expr::Next { arg }))))
|
||||||
Self,
|
|
||||||
PyBoolExpr(Box::new(BoolExpr::Next(argus_core::expr::Next { arg }))),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -395,7 +371,7 @@ impl Always {
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
Self,
|
Self,
|
||||||
PyBoolExpr(Box::new(BoolExpr::Always(argus_core::expr::Always { arg, interval }))),
|
PyBoolExpr(Box::new(BoolExpr::Always(argus::expr::Always { arg, interval }))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -417,7 +393,7 @@ impl Eventually {
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
Self,
|
Self,
|
||||||
PyBoolExpr(Box::new(BoolExpr::Eventually(argus_core::expr::Eventually {
|
PyBoolExpr(Box::new(BoolExpr::Eventually(argus::expr::Eventually {
|
||||||
arg,
|
arg,
|
||||||
interval,
|
interval,
|
||||||
}))),
|
}))),
|
||||||
|
|
@ -443,11 +419,7 @@ impl Until {
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
Self,
|
Self,
|
||||||
PyBoolExpr(Box::new(BoolExpr::Until(argus_core::expr::Until {
|
PyBoolExpr(Box::new(BoolExpr::Until(argus::expr::Until { lhs, rhs, interval }))),
|
||||||
lhs,
|
|
||||||
rhs,
|
|
||||||
interval,
|
|
||||||
}))),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ mod expr;
|
||||||
mod semantics;
|
mod semantics;
|
||||||
mod signals;
|
mod signals;
|
||||||
|
|
||||||
use argus_core::ArgusError;
|
use argus::Error as ArgusError;
|
||||||
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyTypeError, PyValueError};
|
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyTypeError, PyValueError};
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyBool, PyFloat, PyInt, PyType};
|
use pyo3::types::{PyBool, PyFloat, PyInt, PyType};
|
||||||
|
|
@ -12,7 +12,7 @@ struct PyArgusError(ArgusError);
|
||||||
|
|
||||||
impl From<PyArgusError> for PyErr {
|
impl From<PyArgusError> for PyErr {
|
||||||
fn from(value: PyArgusError) -> Self {
|
fn from(value: PyArgusError) -> Self {
|
||||||
use argus_core::Error::*;
|
use argus::Error::*;
|
||||||
match value.0 {
|
match value.0 {
|
||||||
err @ (IncompleteArgs | InvalidOperation | IdentifierRedeclaration | InvalidInterval { reason: _ }) => {
|
err @ (IncompleteArgs | InvalidOperation | IdentifierRedeclaration | InvalidInterval { reason: _ }) => {
|
||||||
PyValueError::new_err(err.to_string())
|
PyValueError::new_err(err.to_string())
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use argus_core::signals::{AnySignal, Signal};
|
use argus::{AnySignal, BooleanSemantics, QuantitativeSemantics, Signal, Trace};
|
||||||
use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};
|
|
||||||
use pyo3::exceptions::PyTypeError;
|
use pyo3::exceptions::PyTypeError;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyDict, PyString};
|
use pyo3::types::{PyDict, PyString};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use argus_core::signals::interpolation::Linear;
|
use argus::signals::interpolation::Linear;
|
||||||
use argus_core::signals::Signal;
|
use argus::signals::Signal;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::PyType;
|
use pyo3::types::PyType;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue