Give the parameterless math Units a usable SETTINGS type - #230
Merged
Conversation
Anscombe, Abs and Invert declared no SETTINGS -- the source carried
``... # SETTINGS = None``, a comment rather than code. ezmsg's Unit metaclass
therefore substituted a bare ``ez.Settings()``, which the paired transformer
then rejected: its settings type resolves to ``NoneType`` via the ``[None, ...]``
typevar, so ``_unify_settings`` fails its ``isinstance(settings, settings_type)``
assert. The break surfaces at ``create_processor()``, i.e. at ``initialize()``
inside a running pipeline:
AssertionError: Settings must be of type <class 'NoneType'>
``SETTINGS = None`` cannot be written literally -- the metaclass requires an
``ez.Settings`` subclass and raises ``TypeError: issubclass() arg 1 must be a
class`` at class creation -- which is presumably why it was left commented out.
So each transform gets an empty ``ez.Settings`` subclass instead, and the
transformer is parameterized with that rather than ``None``.
abs.py already had a vestigial ``class AbsSettings: pass`` that was neither an
ez.Settings subclass nor referenced anywhere; it becomes the real one.
Adds a sweep over every Unit in ezmsg.sigproc.math asserting its SETTINGS is
accepted by its transformer, and building the processor to exercise the actual
failure path. The sweep runs at call time rather than collection time: importing
the whole math package during collection perturbs import order enough to tip
test_mlx_cache_limit_actually_bounds_the_cache, which is sensitive to
allocation history.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Anscombedeclares noSETTINGS— the source carries... # SETTINGS = None, a comment rather than code. ezmsg's Unit metaclass therefore substitutes a bareez.Settings(). ButAnscombeTransformeris parameterized asBaseTransformer[None, ...], so its settings type resolves toNoneType, and_unify_settingsfails itsisinstance(settings, settings_type)assert:This surfaces at
create_processor()— i.e. atinitialize(), inside a running pipeline.SETTINGS = Nonecannot be written literally: the metaclass requires anez.Settingssubclass and raisesTypeError: issubclass() arg 1 must be a classat class-creation time. That is presumably why it was left as a comment.Scope note
AbsandInverthave the byte-identical defect and fail with the sameAssertionError. They're fixed here too — a patch that repaired one of three identical breakages seemed worse than useless. Happy to split them out if you'd rather keep this to Anscombe.The fix
Each parameterless transform gets an empty
ez.Settingssubclass, and its transformer is parameterized with that instead ofNone:abs.pyalready had a vestigialclass AbsSettings: pass— neither anez.Settingssubclass nor referenced anywhere. It becomes the real one.The only visible behavior change is that
AnscombeTransformer().settingsis nowAnscombeSettings()rather thanNone. All existing call sites construct these transformers with no arguments, so nothing else moves.Test
A sweep over every Unit in
ezmsg.sigproc.math(10 of them) asserting itsSETTINGSis accepted by its paired transformer, and building the processor to exercise the real failure path. Reverting the source fix reproduces exactly:Full suite: 4120 passed, 6 skipped.
Heads-up on an unrelated fragile test
The sweep deliberately runs at call time, not collection time. My first version parametrized over the units, which imported the whole
mathpackage during collection — and that tippedtest_asarray.py::test_mlx_cache_limit_actually_bounds_the_cacheinto failing.That test is order-sensitive on
devtoday, independent of this PR:It asserts
mx.get_cache_memory() <= 32 MB, but MLX's cache limit is a soft target and the observed value sits right at the edge — I measured 17.00 MB and 34.30 MB on identical back-to-back trials in one process. Anything that shifts allocation history flips it. Not touched here, but it's a latent CI flake worth a separate look.