Skip to content

v5.10.3

Choose a tag to compare

@github-actions github-actions released this 28 Aug 03:17
· 3 commits to main since this release

Important

This patch release changes behaviour. mtl5.vector() and mtl5.matrix()
no longer silently convert their input, so code that worked on 5.10.2 can now
raise TypeError.

What changed

vector() and matrix() (and their _copy variants, real and complex) now require the dtype to match a registered one exactly and the array to be C-contiguous. Anything else raises TypeError listing every accepted signature, instead of quietly converting.

You are affected if you pass:

  • a non-contiguous array — a[::2], a column of a 2-D array, a transpose
  • a dtype outside float32, float64, int8, int16, int32, int64, uint8, complex64, complex128 — notably float16, uint16, uint32, uint64

The fix is one call, and it is not merely a workaround — it preserves precision that the old path silently discarded:

mtl5.vector(np.ascontiguousarray(a))   # keeps float64
mtl5.vector(a.astype(np.float64))      # or convert deliberately

Why this was worth breaking

The old behaviour was not a convenience, it was a silent correctness bug. nanobind's converting pass repacks layout and dtype together and takes the first overload that converts — float32. So an ordinary float64 slice was downcast to single precision, while reporting is_view=True and aliasing nothing:

a = np.array([0.1, 1.0, 0.2, 2.0, 0.3, 3.0])  # float64
v = mtl5.vector(a[::2])
# 5.10.2: DenseVector_f32, v.is_view is True, v[0] == 0.10000000149011612
# 5.10.3: TypeError

Anyone slicing a float64 array was losing precision with no diagnostic. mtl5.array.asarray has always rejected these inputs for exactly this reason; the factories simply never got the same treatment.

A note on the version number

This is a behaviour change in a patch release, which is not ideal. mtl5-python's minor component tracks the MTL5 release it is built against, so a change like this has no minor slot available to it. Flagging it here rather than letting the version number carry a message it cannot.


v5.10.3 (2026-08-28)

This release is published under the MIT License.

Bug Fixes

  • factories: Reject conversion in vector() and matrix() (#92, 7df54bd)

Continuous Integration

  • Pin the build toolchain (cibuildwheel, build, scikit-build-core) (#91, efd98f9)

Detailed Changes: v5.10.2...v5.10.3