Skip to main content

Crate spectrafit_core

Crate spectrafit_core 

Source
Expand description

spectrafit-core — PyO3 cdylib bindings.

Exposes Python-callable functions:

  • fit(graph_json, data_json, options_json) -> str
  • fit_arrays(graph_json, x, y, sigma, dataset_sizes, n_dims, options_json) -> str
  • fit_arrays_numpy(graph_json, x, y, sigma, dataset_sizes, n_dims, options_json) -> (str, ndarray) — like fit_arrays, but bypasses JSON serialisation of per-point arrays and returns the fitted curve as a NumPy array
  • evaluate(graph_json, params_json, data_json) -> str
  • evaluate_components(graph_json, params_json, data_json) -> str
  • model_type_wire_strings() -> str — returns the canonical wire-format string of every supported model type, in ModelTypeStr declaration order

fit accepts JSON-encoded data (backwards-compatible, MCP-friendly). fit_arrays accepts raw numpy buffers and eliminates JSON serialisation of measurement data — the dominant bottleneck for large datasets. fit_arrays_numpy extends fit_arrays: returns (compact_json, best_fit_ndarray) so the large per-point arrays bypass JSON entirely, cutting 2–3 ms per call. Graph/options remain JSON for reproducibility and language-neutrality. CoreError maps to PyValueError so Python callers receive a descriptive ValueError.