Add host-only Python bindings crate multicalc-py - #330
Conversation
f32bd34 to
3adada4
Compare
|
will look at this by this weekend. |
| }); | ||
| match result { | ||
| Ok(output) => S::from_f64(output), | ||
| Err(_) => S::from_f64(f64::NAN), |
There was a problem hiding this comment.
here and in other places, why are we swallowing error and simply returning NAN?
There was a problem hiding this comment.
ScalarFn::eval can't return PyErr, so NaN was used as a sentinel for multicalc's non-finite checks. That dropped the original Python exception. We now stash the first callback error and re-raise it at the pyfunction boundary via .finish().
| use crate::convert::{matrix_from_rows, matrix_to_rows, vector_from_list, vector_to_list}; | ||
| use crate::errors; | ||
|
|
||
| macro_rules! bind_vector { |
There was a problem hiding this comment.
add a getter function so users can inspect contents of the vector. Similar to to_list of the sqaure matrix defined below
There was a problem hiding this comment.
Added to_list() on all vector types, matching the matrix API — returns a plain list[float] of components.
|
|
||
| /// Weight particles with `measurement_model` (two state components to a 2-vector prediction) and a 2-vector measurement. | ||
| fn update(&mut self, measurement_model: Py<PyAny>, measurement: Vec<f64>) -> PyResult<()> { | ||
| let likelihood = GaussianLikelihood::<2>::new(Matrix::<2, 2>::identity()) |
There was a problem hiding this comment.
Good catch — identity() was a placeholder, not an intentional default. GaussianLikelihood needs the measurement-noise covariance, so I added measurement_noise to ParticleFilter2x2.new and use that in update instead.
| }) | ||
| } | ||
|
|
||
| fn len(&self) -> usize { |
There was a problem hiding this comment.
len so we can do len(tree). Here and in other places. Same for repr and version everywhere applicable
There was a problem hiding this comment.
Switched len() to len so len(tree) works. Added len and repr on other sized/value types (vectors, matrices, polynomials, paths, scan geometry), and exposed version on the module alongside version().
08275b8 to
c552b85
Compare
Expose a slice of crate-root multicalc over PyO3/maturin as import multicalc_py. Host f64 only; const-generic sizes are fixed in the type name. Workspace-internal (publish = false), with pytest coverage and crate/type docs.
c552b85 to
a07e94b
Compare
Closes #48
Expose a slice of crate-root multicalc over PyO3/maturin as import multicalc_py. Host f64 only; const-generic sizes are fixed in the type name. Workspace-internal (publish = false), with pytest coverage and crate/type docs.
Checklist
cargo test+cargo clippy --all-targetsclean locallyunwrap/expect/panicon library paths (typed errors instead)