Skip to content

Commit 444d601

Browse files
committed
refactor(pyargus): make pyargus depend only on argus
1 parent db3a63f commit 444d601

File tree

6 files changed

+32
-64
lines changed

6 files changed

+32
-64
lines changed

argus/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
pub mod prelude {
2-
pub use argus_core::prelude::*;
3-
pub use argus_parser::parse_str;
4-
pub use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};
5-
}
1+
pub use argus_core::signals::{AnySignal, Signal};
2+
pub use argus_core::{expr, signals, ArgusResult, Error};
3+
pub use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};

pyargus/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ name = "pyargus"
1212
crate-type = ["cdylib"]
1313

1414
[dependencies]
15-
argus-core = { version = "0.1.0", path = "../argus-core" }
16-
argus-semantics = { version = "0.1.0", path = "../argus-semantics" }
15+
argus = { version = "0.1.0", path = "../argus" }
1716
derive_more = "0.99.17"
1817
log = "0.4.20"
1918
paste = "1.0.14"

pyargus/src/expr.rs

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Duration;
22

3-
use argus_core::prelude::*;
3+
use argus::expr::*;
44
use pyo3::prelude::*;
55
use pyo3::pyclass::CompareOp;
66

@@ -62,7 +62,7 @@ pub struct ConstInt;
6262
impl ConstInt {
6363
#[new]
6464
fn new(val: i64) -> (Self, PyNumExpr) {
65-
(Self, Box::new(NumExpr::IntLit(argus_core::expr::IntLit(val))).into())
65+
(Self, Box::new(NumExpr::IntLit(argus::expr::IntLit(val))).into())
6666
}
6767
}
6868

@@ -79,7 +79,7 @@ pub struct ConstUInt;
7979
impl ConstUInt {
8080
#[new]
8181
fn new(val: u64) -> (Self, PyNumExpr) {
82-
(Self, Box::new(NumExpr::UIntLit(argus_core::expr::UIntLit(val))).into())
82+
(Self, Box::new(NumExpr::UIntLit(argus::expr::UIntLit(val))).into())
8383
}
8484
}
8585

@@ -91,10 +91,7 @@ pub struct ConstFloat;
9191
impl ConstFloat {
9292
#[new]
9393
fn new(val: f64) -> (Self, PyNumExpr) {
94-
(
95-
Self,
96-
Box::new(NumExpr::FloatLit(argus_core::expr::FloatLit(val))).into(),
97-
)
94+
(Self, Box::new(NumExpr::FloatLit(argus::expr::FloatLit(val))).into())
9895
}
9996
}
10097

@@ -106,10 +103,7 @@ pub struct VarInt;
106103
impl VarInt {
107104
#[new]
108105
fn new(name: String) -> (Self, PyNumExpr) {
109-
(
110-
Self,
111-
Box::new(NumExpr::IntVar(argus_core::expr::IntVar { name })).into(),
112-
)
106+
(Self, Box::new(NumExpr::IntVar(argus::expr::IntVar { name })).into())
113107
}
114108
}
115109

@@ -121,10 +115,7 @@ pub struct VarUInt;
121115
impl VarUInt {
122116
#[new]
123117
fn new(name: String) -> (Self, PyNumExpr) {
124-
(
125-
Self,
126-
Box::new(NumExpr::UIntVar(argus_core::expr::UIntVar { name })).into(),
127-
)
118+
(Self, Box::new(NumExpr::UIntVar(argus::expr::UIntVar { name })).into())
128119
}
129120
}
130121

@@ -136,10 +127,7 @@ pub struct VarFloat;
136127
impl VarFloat {
137128
#[new]
138129
fn new(name: String) -> (Self, PyNumExpr) {
139-
(
140-
Self,
141-
Box::new(NumExpr::FloatVar(argus_core::expr::FloatVar { name })).into(),
142-
)
130+
(Self, Box::new(NumExpr::FloatVar(argus::expr::FloatVar { name })).into())
143131
}
144132
}
145133

@@ -152,7 +140,7 @@ impl Negate {
152140
#[new]
153141
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
154142
let arg = arg.0;
155-
(Self, Box::new(NumExpr::Neg(argus_core::expr::Neg { arg })).into())
143+
(Self, Box::new(NumExpr::Neg(argus::expr::Neg { arg })).into())
156144
}
157145
}
158146

@@ -167,7 +155,7 @@ impl Add {
167155
#[new]
168156
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
169157
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
170-
(Self, Box::new(NumExpr::Add(argus_core::expr::Add { args })).into())
158+
(Self, Box::new(NumExpr::Add(argus::expr::Add { args })).into())
171159
}
172160
}
173161

@@ -180,7 +168,7 @@ impl Sub {
180168
fn new(lhs: PyNumExpr, rhs: PyNumExpr) -> (Self, PyNumExpr) {
181169
let lhs = lhs.0;
182170
let rhs = rhs.0;
183-
(Self, Box::new(NumExpr::Sub(argus_core::expr::Sub { lhs, rhs })).into())
171+
(Self, Box::new(NumExpr::Sub(argus::expr::Sub { lhs, rhs })).into())
184172
}
185173
}
186174

@@ -192,7 +180,7 @@ impl Mul {
192180
#[new]
193181
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
194182
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
195-
(Self, Box::new(NumExpr::Mul(argus_core::expr::Mul { args })).into())
183+
(Self, Box::new(NumExpr::Mul(argus::expr::Mul { args })).into())
196184
}
197185
}
198186

@@ -207,7 +195,7 @@ impl Div {
207195
let divisor = divisor.0;
208196
(
209197
Self,
210-
Box::new(NumExpr::Div(argus_core::expr::Div { dividend, divisor })).into(),
198+
Box::new(NumExpr::Div(argus::expr::Div { dividend, divisor })).into(),
211199
)
212200
}
213201
}
@@ -220,7 +208,7 @@ impl Abs {
220208
#[new]
221209
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
222210
let arg = arg.0;
223-
(Self, Box::new(NumExpr::Abs(argus_core::expr::Abs { arg })).into())
211+
(Self, Box::new(NumExpr::Abs(argus::expr::Abs { arg })).into())
224212
}
225213
}
226214

@@ -254,7 +242,7 @@ pub struct ConstBool;
254242
impl ConstBool {
255243
#[new]
256244
fn new(val: bool) -> (Self, PyBoolExpr) {
257-
(Self, Box::new(BoolExpr::BoolLit(argus_core::expr::BoolLit(val))).into())
245+
(Self, Box::new(BoolExpr::BoolLit(argus::expr::BoolLit(val))).into())
258246
}
259247
}
260248

@@ -265,10 +253,7 @@ pub struct VarBool;
265253
impl VarBool {
266254
#[new]
267255
fn new(name: String) -> (Self, PyBoolExpr) {
268-
(
269-
Self,
270-
Box::new(BoolExpr::BoolVar(argus_core::expr::BoolVar { name })).into(),
271-
)
256+
(Self, Box::new(BoolExpr::BoolVar(argus::expr::BoolVar { name })).into())
272257
}
273258
}
274259

@@ -284,10 +269,7 @@ impl Cmp {
284269
let op = op.0;
285270
let lhs = lhs.0;
286271
let rhs = rhs.0;
287-
(
288-
Self,
289-
Box::new(BoolExpr::Cmp(argus_core::expr::Cmp { op, lhs, rhs })).into(),
290-
)
272+
(Self, Box::new(BoolExpr::Cmp(argus::expr::Cmp { op, lhs, rhs })).into())
291273
}
292274
}
293275

@@ -332,7 +314,7 @@ impl Not {
332314
#[new]
333315
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
334316
let arg = arg.0;
335-
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus_core::expr::Not { arg }))))
317+
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus::expr::Not { arg }))))
336318
}
337319
}
338320

@@ -344,10 +326,7 @@ impl And {
344326
#[new]
345327
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
346328
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
347-
(
348-
Self,
349-
PyBoolExpr(Box::new(BoolExpr::And(argus_core::expr::And { args }))),
350-
)
329+
(Self, PyBoolExpr(Box::new(BoolExpr::And(argus::expr::And { args }))))
351330
}
352331
}
353332

@@ -359,7 +338,7 @@ impl Or {
359338
#[new]
360339
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
361340
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
362-
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus_core::expr::Or { args }))))
341+
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus::expr::Or { args }))))
363342
}
364343
}
365344

@@ -371,10 +350,7 @@ impl Next {
371350
#[new]
372351
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
373352
let arg = arg.0;
374-
(
375-
Self,
376-
PyBoolExpr(Box::new(BoolExpr::Next(argus_core::expr::Next { arg }))),
377-
)
353+
(Self, PyBoolExpr(Box::new(BoolExpr::Next(argus::expr::Next { arg }))))
378354
}
379355
}
380356

@@ -395,7 +371,7 @@ impl Always {
395371
};
396372
(
397373
Self,
398-
PyBoolExpr(Box::new(BoolExpr::Always(argus_core::expr::Always { arg, interval }))),
374+
PyBoolExpr(Box::new(BoolExpr::Always(argus::expr::Always { arg, interval }))),
399375
)
400376
}
401377
}
@@ -417,7 +393,7 @@ impl Eventually {
417393
};
418394
(
419395
Self,
420-
PyBoolExpr(Box::new(BoolExpr::Eventually(argus_core::expr::Eventually {
396+
PyBoolExpr(Box::new(BoolExpr::Eventually(argus::expr::Eventually {
421397
arg,
422398
interval,
423399
}))),
@@ -443,11 +419,7 @@ impl Until {
443419
};
444420
(
445421
Self,
446-
PyBoolExpr(Box::new(BoolExpr::Until(argus_core::expr::Until {
447-
lhs,
448-
rhs,
449-
interval,
450-
}))),
422+
PyBoolExpr(Box::new(BoolExpr::Until(argus::expr::Until { lhs, rhs, interval }))),
451423
)
452424
}
453425
}

pyargus/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod expr;
22
mod semantics;
33
mod signals;
44

5-
use argus_core::ArgusError;
5+
use argus::Error as ArgusError;
66
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyTypeError, PyValueError};
77
use pyo3::prelude::*;
88
use pyo3::types::{PyBool, PyFloat, PyInt, PyType};
@@ -12,7 +12,7 @@ struct PyArgusError(ArgusError);
1212

1313
impl From<PyArgusError> for PyErr {
1414
fn from(value: PyArgusError) -> Self {
15-
use argus_core::Error::*;
15+
use argus::Error::*;
1616
match value.0 {
1717
err @ (IncompleteArgs | InvalidOperation | IdentifierRedeclaration | InvalidInterval { reason: _ }) => {
1818
PyValueError::new_err(err.to_string())

pyargus/src/semantics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::collections::HashMap;
22

3-
use argus_core::signals::{AnySignal, Signal};
4-
use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Trace};
3+
use argus::{AnySignal, BooleanSemantics, QuantitativeSemantics, Signal, Trace};
54
use pyo3::exceptions::PyTypeError;
65
use pyo3::prelude::*;
76
use pyo3::types::{PyDict, PyString};

pyargus/src/signals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use argus_core::signals::interpolation::Linear;
2-
use argus_core::signals::Signal;
1+
use argus::signals::interpolation::Linear;
2+
use argus::signals::Signal;
33
use pyo3::prelude::*;
44
use pyo3::types::PyType;
55

0 commit comments

Comments
 (0)