[SyneRBI/SIRF] Updates for mixed data algebra based on __array_priority__. (PR #1373)

0 views
Skip to first unread message

Evgueni Ovtchinnikov

unread,
Feb 10, 2026, 8:39:19 AM (12 days ago) Feb 10
to SyneRBI/SIRF, Subscribed

Changes in this pull request

Replaces quick fix in #1357 with a proper fix employing __array_priority__ feature and adds more mixed algebra tests.

Testing performed

Related issues

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added docstrings/doxygen in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality
  • The code builds and runs on my machine
  • CHANGES.md has been updated with any functionality change

Contribution Notes

Please read and adhere to the contribution guidelines.

Please tick the following:

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in SIRF (the Work) under the terms and conditions of the Apache-2.0 License.

You can view, comment on, or merge this pull request online at:

  https://github.com/SyneRBI/SIRF/pull/1373

Commit Summary

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373@github.com>

Kris Thielemans

unread,
Feb 10, 2026, 9:32:38 AM (12 days ago) Feb 10
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.

As I don't know anything about __array_priority__, I'll leave it to @paskino and @casperdcl to review.

BTW, what happens if the sizes are wrong? Shouldn't we add some check?

This will have to be squash merged (after modifying CHANGES and the user's guide appropriately), due to the somewhat horrible history.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

are we sure we really want to use as_array() for these tests? Obviously, if replacing it with asarray() we'd have to be very careful for any operatoins that modify the object.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3779341422@github.com>

Evgueni Ovtchinnikov

unread,
Feb 11, 2026, 5:11:05 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Subscribed

@evgueni-ovtchinnikov commented on this pull request.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

better safe than sorry IMHO


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3783895926@github.com>

Evgueni Ovtchinnikov

unread,
Feb 11, 2026, 5:12:57 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Subscribed

@evgueni-ovtchinnikov commented on this pull request.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

BTW, what happens if the sizes are wrong?

assert_validities would raise AssertionError


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3783904831@github.com>

Kris Thielemans

unread,
Feb 11, 2026, 5:16:42 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

better safe than sorry IMHO

not necessarily for tests. Probably a good idea to do at least some of the tests with asarray() as well, as the future, it's what is must likely to hit us.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3783924555@github.com>

Evgueni Ovtchinnikov

unread,
Feb 11, 2026, 9:07:15 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Subscribed

@evgueni-ovtchinnikov commented on this pull request.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

Actually, replacing every as_array use with that of asarray is perfectly safe as asarray defaults to copy - to get a view, you need asarray(copy=False) (we probably should keep as_array method in our data container classes for backward compatibility). However, this needs a separate PR I believe, this one just fixes #1357.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3785037085@github.com>

Evgueni Ovtchinnikov

unread,
Feb 11, 2026, 9:46:55 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • 856c7ee added the result type checks for mixed data algebra


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/before/c3aa576cdc4ce9cde60dff1cea1912cc7346b3de/after/856c7ee2505eab4adadce0bd08413033aedc6429@github.com>

Evgueni Ovtchinnikov

unread,
Feb 11, 2026, 11:44:12 AM (11 days ago) Feb 11
to SyneRBI/SIRF, Push

@evgueni-ovtchinnikov pushed 1 commit.

  • 0d8f93f [ci skip] updated User Guide description of data algebra and CHANGES.md


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/before/856c7ee2505eab4adadce0bd08413033aedc6429/after/0d8f93f5e45921362e5c123c4044093021a7fb5c@github.com>

Kris Thielemans

unread,
Feb 11, 2026, 12:25:21 PM (11 days ago) Feb 11
to SyneRBI/SIRF, Subscribed

@KrisThielemans commented on this pull request.


In src/common/Utilities.py:

> @@ -790,24 +790,47 @@ def data_container_algebra_tests(test, x, eps=1e-4):
     t = numpy.linalg.norm(az)
     test.check_if_zero_within_tolerance(s, eps * t)
 
+    z = ay*x
+    az = z.as_array()

asarray defaults to copy

no it doesn't. it defaults to view (if the container supports it).

Whatever, I still feel we need to test with the most used function, even if you know in the end it gives the same results (but at some point, it might not)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <SyneRBI/SIRF/pull/1373/review/3786177918@github.com>

Reply all
Reply to author
Forward
0 new messages