make_params_key#

lumopt2.utils.common.make_params_key(params: ndarray | None) bytes | None#

Build a canonical hashable cache key from a parameter array.

Wrapping np.ascontiguousarray(..., dtype=np.float64).tobytes() in a helper guarantees that every cache (single-entry or multi-entry, in Optimization or Project) hashes the same parameter vector to the same key, regardless of whether the caller passes a list, a non-contiguous view, or a different float dtype.

Parameters:
paramsnp.ndarray or None

Parameter values to hash. None is passed through to allow the caller to record “no parameters cached”.

Returns:
bytes or None

The contiguous float64 byte representation of params, or None when params is None.