feat(py): expose quantitative semantics
This commit is contained in:
parent
bfb59c1008
commit
9f674bd385
1 changed files with 7 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use argus_core::signals::{AnySignal, Signal};
|
||||
use argus_semantics::{BooleanSemantics, Semantics, Trace};
|
||||
use argus_semantics::{BooleanSemantics, QuantitativeSemantics, Semantics, Trace};
|
||||
use pyo3::exceptions::PyTypeError;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::{PyDict, PyString};
|
||||
|
|
@ -87,10 +87,16 @@ fn eval_bool_semantics(expr: &PyBoolExpr, trace: &PyTrace) -> PyResult<Py<BoolSi
|
|||
let sig = BooleanSemantics::eval(&expr.0, trace, ()).map_err(PyArgusError::from)?;
|
||||
Python::with_gil(|py| Py::new(py, (BoolSignal::from(sig), BoolSignal::super_type())))
|
||||
}
|
||||
#[pyfunction]
|
||||
fn eval_robust_semantics(expr: &PyBoolExpr, trace: &PyTrace) -> PyResult<Py<FloatSignal>> {
|
||||
let sig = QuantitativeSemantics::eval(&expr.0, trace, ()).map_err(PyArgusError::from)?;
|
||||
Python::with_gil(|py| Py::new(py, (FloatSignal::from(sig), FloatSignal::super_type())))
|
||||
}
|
||||
|
||||
pub fn init(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<PyTrace>()?;
|
||||
m.add_function(wrap_pyfunction!(eval_bool_semantics, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(eval_robust_semantics, m)?)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue