sensorfusion-tools
Signal-systems utilities for estimation, modeling, and plotting.
Versioning
This library uses calendar-style semantic versions: YYYY.FEATURE.BUGFIX.
YYYY: release year (for long-term timeline tracking)FEATURE: increments for new functionalityBUGFIX: increments for patches and fixes
Framework And Tooling
- Language: Python 3.14+
- Build backend:
uv_build - Package/dependency workflow:
uv - Numerical stack:
numpy,scipy - Plotting:
matplotlib
Testing Framework
- Test runner:
pytest - Property-based testing:
hypothesis - Coverage:
pytest-cov(configured forsrc/sftools)
Run tests:
uv run pytest
Run only sftools tests:
uv run pytest tests/sftools
Code Quality
- Linting:
ruff
Run lint:
uv run ruff check .
CI (GitLab)
The pipeline is defined in .gitlab-ci.yml and includes:
qualitystage:rufflint checksteststage:pytestwith JUnit artifact output
CI uses python:3.14-slim and installs dependencies with:
uv sync --group dev
License
Distributed under the MIT License. See LICENSE for details.
Project Structure
src/
sftools/ # Main signal-system models, estimators, helpers, plotting, shared types
tests/
sftools/ # Pytest suite for src/sftools (one test file per source file)
fixtures/ # Regression test input/output fixtures
For sftools, tests mirror the source layout:
src/sftools/model_obs.py->tests/sftools/test_model.pysrc/sftools/estimator.py->tests/sftools/test_estimator.pysrc/sftools/helper.py->tests/sftools/test_helper.pysrc/sftools/plot.py->tests/sftools/test_plot.py
Shared state/trajectory datatypes are defined in src/sftools/types.py:
GaussianStateParticleStateStateTrajectory(supports probabilistic trajectories viawrite_stateand deterministic trajectories viawrite_mean)
Dimension Conventions
Model calculations use columns for states, observations, and samples:
| Quantity | Shape |
|---|---|
| One state | (n, 1) |
| One observation | (m, 1) |
| State or sample collection | (n, N) |
| Predicted observations for a collection | (m, N) |
| Measurement Jacobian at one state | (m, n) |
| Measurement covariance | (m, m) |
ls, wls, nls, helper.llh, and filter measurement updates require one
observation column. They reject flat, row, and batched observations instead of
reshaping them or allowing accidental NumPy broadcasting. To construct a column
from a flat observation array, explicitly use y[:, None]. A filter update uses
the same observation for every particle, not a separate observation per particle.
GaussianState.x stores a flat (n,) mean; use state.mean() for its (n, 1)
column view. Existing model support for flat state inputs is unchanged.
nls converts its optimization state to and from SciPy's flat-vector convention
internally. Custom model callbacks remain responsible for their output shapes;
the library does not automatically transpose or reshape them to match a model.
sftools.helper.mct accepts vectorized mappings with output shape
(n_outputs, n_samples), or (n_samples,) for scalar outputs.
It requires at least two samples and always returns a matrix covariance,
including shape (1, 1) for a scalar output.
sftools.estimator.ls reports the unweighted estimator's covariance
A @ R @ A.T, where A is the least-squares gain and R is the measurement
covariance. The design matrix must have full column rank. With unequal or
correlated measurement noise, this covariance generally differs from the
covariance reported by sftools.estimator.wls.
Useful StateTrajectory iteration helpers:
for y in trajyields state columns with shape(n, 1)traj.iter_samples(include_cov=True, include_time=True)yields(y, cov, t)tuples when available
Plotting helpers in src/sftools/plot.py use StateTrajectory inputs.
Particle filter helper:
ParticleFilter.init_state_gaussian(mean, cov, n_particles)initializes aParticleStatefrom a Gaussian prior using the filter RNG.
Nonlinear Least-Squares Diagnostics
estimator.nls(model, y, x0) returns a GaussianState as before when the solver
succeeds and its local covariance is available. To inspect the solver, request
the frozen estimator.NLSResult container:
from sftools import estimator
fit = estimator.nls(model, y, x0, return_result=True)
print(fit.optimizer.success, fit.optimizer.message)
print("Weighted residual sum of squares:", 2 * fit.optimizer.cost)
if fit.estimate is not None:
print(fit.estimate.mean(), fit.estimate.P)
fit.optimizer is SciPy's original OptimizeResult, including termination
status and message, optimality, evaluation counts nfev and njev, and
the final candidate x. Its fun contains the whitened residuals
solve(L, y - h(x)), flattened for SciPy, where L @ L.T = R.
Its jac is their Jacobian, -solve(L, H(x)). Twice cost equals both
fun @ fun and the weighted residual sum of squares
(y - h(x)).T @ solve(R, y - h(x)).
Without diagnostics, solver nonconvergence raises RuntimeError with SciPy's
termination message; singular local covariance raises numpy.linalg.LinAlgError.
With return_result=True, either case returns estimate=None while preserving
the optimizer result. Check optimizer.success to distinguish nonconvergence
from unavailable covariance after successful termination. Input errors still
raise normally, and no pseudoinverse is substituted for singular covariance.
The solver remains Levenberg-Marquardt with the supplied analytic Jacobian and measurement covariance. Successful termination does not establish global optimality, identifiability, or confidence-region coverage. Use SciPy directly for bounds, custom residuals, or other optimizer controls.
CRLB Grid Exclusions
helper.crlb(model, region, n_points=..., scalar_fun=...) keeps its existing
interface and returns the position grid and scalar bound array. Undefined or
nonfinite Jacobians, nonfinite information or covariance, and numerically
rank-deficient information produce NaN entries instead of aborting the map.
Rank is checked on the whitened Jacobian using NumPy's default numerical rank
criterion. One RuntimeWarning per call reports the number of excluded points.
If all points are valid, no warning is issued.
Plotting leaves holes at the excluded positions. NaN means that the full
covariance bound is unavailable there, not zero uncertainty. To locate those
positions, use excluded = ~np.isfinite(bound). No pseudoinverse is substituted
for singular information.
The built-in TOA, TDOA, and offset-range models raise ValueError when their
Jacobian is requested at a sensor location, where range is not differentiable;
the CRLB grid helper recognizes this specific domain error and excludes the
point. Range predictions themselves remain defined there. Custom models can
signal undefined derivatives with nonfinite Jacobian entries.
Choose estimator starting points away from sensor locations when an analytic
range Jacobian is required.
Malformed Jacobians, invalid measurement covariance, and ordinary exceptions
from model or scalarization callbacks still raise. Measurement covariance must
be finite, symmetric, and positive definite, and scalar_fun must return a
finite scalar. Exclusion handling is for mathematical grid-point limitations,
not a way to suppress programming errors or establish estimator performance.
Transformation Inspection
helper.sigma_points(state, alpha=..., beta=..., kappa=...) returns a frozen
helper.SigmaPoints container with points, mean_weights, and cov_weights.
It uses the same parameter defaults as helper.ut, which now shares this
construction. For an n-dimensional input, points have shape (n, 2*n+1) and
each weight array has shape (2*n+1,). The first point is the mean, followed by
positive and negative Cholesky-column offsets. Mean and covariance weights are
separate arrays; covariance weights need not sum to one, and weights can be
negative.
To inspect the transformation explicitly:
from sftools import helper
sigma = helper.sigma_points(state, alpha=1, beta=0, kappa=2)
transformed = h(sigma.points)
mean = transformed @ sigma.mean_weights
centered = transformed - mean[:, None]
covariance = (centered * sigma.cov_weights[None, :]) @ centered.T
helper.ut still returns a GaussianState by default, and its existing
return_sigma_points=True option still returns the three-item tuple
(estimate, input_points, output_points). No new UT return option is required.
helper.mct also keeps its ordinary GaussianState return. To retain the samples
used to compute its moments, request the frozen helper.MCTResult container:
fit = helper.mct(state, h, n_samples=1000, rng=rng, return_result=True)
estimate = fit.estimate
input_samples = fit.input_samples
output_samples = fit.output_samples
The arrays have shapes (n_inputs, n_samples) and (n_outputs, n_samples),
including (1, n_samples) for scalar outputs. They are the arrays used in the
original calculation, not a second realization: the option adds no random draws
or callback evaluations. The result retains those arrays in memory for plotting
or inspection. MCT uses the unbiased sample covariance normalization N-1.
Finite sigma-point summaries or finite sample moments do not establish that the transformed distribution has finite population moments or is Gaussian. This is especially important for mappings with singularities such as ratios.
Metadata
Release files for sensorfusion-tools 2026.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sensorfusion_tools-2026.0.2.tar.gz | 21.7 kB | Without provenance | Details for sensorfusion_tools-2026.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sensorfusion_tools-2026.0.2-py3-none-any.whl | Python 3 | none | any | Details for sensorfusion_tools-2026.0.2-py3-none-any.whl |
Total release size: 46.6 kB
Release files / sensorfusion_tools-2026.0.2.tar.gz
| Download URL | sensorfusion_tools-2026.0.2.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf6029c1279baaa1174e82289591126b076be1b5f9dffc114cd9810324168e46
|
|
BLAKE2b-256 checksum How to use checksums |
9a7771d454e8e2bb20b3b9a1bdf2021b3b4abd169f5d465db8b9208c93cd8e55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sensorfusion_tools-2026.0.2-py3-none-any.whl
| Download URL | sensorfusion_tools-2026.0.2-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64d1b857d7ac5b87a558a70a327d9029f373e7a05d27b965064c78315f4dffb8
|
|
BLAKE2b-256 checksum How to use checksums |
b207c9ca3dce0d2cf536398e456b36a4620be92bf20d7e992f823a21b63714ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sensorfusion-tools 2026.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.