From 3ad49aaaf497c6daadb9b66f295f58a315476e01 Mon Sep 17 00:00:00 2001 From: Marten van Kerkwijk Date: Sun, 27 May 2018 13:15:16 -0400 Subject: MAINT: clean up assert_array_compare a bit further. This brought to light two bugs in tests, which are fixed here, viz., that a sample ndarray subclass that tested propagation of an added parameter was incomplete, in that in propagating the parameter in __array_wrap__ it assumed it was there on self, but that assumption could be broken when a view of self was taken (as is done by x[~flagged] in the test routine), since there was no __array_finalize__ defined. The other subclass bug counted, incorrectly, on only needing to provide one type of comparison, the __lt__ being explicitly tested. But flags are compared with __eq__ and those flags will have the same subclass. --- numpy/lib/tests/test_ufunclike.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/lib/tests/test_ufunclike.py') diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py index ad006fe17..5604b3744 100644 --- a/numpy/lib/tests/test_ufunclike.py +++ b/numpy/lib/tests/test_ufunclike.py @@ -55,6 +55,10 @@ class TestUfunclike(object): obj.metadata = self.metadata return obj + def __array_finalize__(self, obj): + self.metadata = getattr(obj, 'metadata', None) + return self + a = nx.array([1.1, -1.1]) m = MyArray(a, metadata='foo') f = ufl.fix(m) -- cgit v1.2.1