Skip to content

fix: avoid dtype comparison for None report metadata - #448

Merged
ev-br merged 1 commit into
data-apis:masterfrom
tomatotomata:codex/mlx-none-dtype-447
Aug 9, 2026
Merged

fix: avoid dtype comparison for None report metadata#448
ev-br merged 1 commit into
data-apis:masterfrom
tomatotomata:codex/mlx-none-dtype-447

Conversation

@tomatotomata

Copy link
Copy Markdown
Contributor

Summary

  • avoid comparing None with array-library dtype objects before looking them up in dtype_to_name
  • add a regression test using an MLX-like dtype whose equality operation rejects None

Closes #447

Validation

  • ARRAY_API_TESTS_MODULE=numpy PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest -q -p pytest_jsonreport.plugin meta_tests/test_reporting.py passed: 1 test
  • ARRAY_API_TESTS_MODULE=numpy PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest -q -p pytest_jsonreport.plugin meta_tests/test_utils.py passed: 30 tests
  • python -m compileall -q reporting.py meta_tests/test_reporting.py passed
  • git diff --check passed

The full suite was not run. The focused commands disable unrelated globally installed pytest plugins and load the repository's JSON-report plugin explicitly.

@ev-br

ev-br commented Aug 9, 2026

Copy link
Copy Markdown
Member

I've to admit this looks a bit overboard. If the problem is that None in dtype_to_name fails with mlx.core, would the following do the trick? cc @aaishwarymishra --- would it fix the problem you were having:

$ git diff
diff --git a/reporting.py b/reporting.py
index 579aa21..0dcf410 100644
--- a/reporting.py
+++ b/reporting.py
@@ -17,6 +17,8 @@ except ImportError:
     raise ImportError("pytest-json-report is required to run the array API tests")
 
 def to_json_serializable(o):
+    if o is None:
+        return o
     if o in dtype_to_name:
         return dtype_to_name[o]
     if isinstance(o, (BuiltinFunctionType, FunctionType, type)):

@ev-br

ev-br commented Aug 9, 2026

Copy link
Copy Markdown
Member

Actually, scratch that. Need some more coffee, sorry. Now that I re-read the function itself, my diff above is the same fix.
LGTM, thanks @tomatotomata

@ev-br
ev-br marked this pull request as ready for review August 9, 2026 11:18
@ev-br
ev-br merged commit b22fba7 into data-apis:master Aug 9, 2026
5 checks passed
@aaishwarymishra

Copy link
Copy Markdown

@ev-br happens to the best of us 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

None dtype comparison not supported in MLX

3 participants