-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Description
The method __eq__ of pytmatrix.psd.BinnedPSD( ) fails with an AttributeError: 'bool' object has no attribute 'all()' if bin_edges is provided as list:
return len(self.bin_edges) == len(other.bin_edges) and \
(self.bin_edges == other.bin_edges).all() and \
(self.bin_psd == other.bin_psd).all()Cause
If self.bin_edges and other.bin_edges are NumPy arrays, self.bin_edges == other.bin_edges returns an array of booleans, where .all() is valid.
However, if they are Python lists, self.bin_edges == other.bin_edges directly returns a single bool, which does not have an .all() method.
Suggested Fix
Replace the element-wise comparisons with np.array_equal(), which ensures a single boolean output regardless of input type:
return len(self.bin_edges) == len(other.bin_edges) and \
np.array_equal(self.bin_edges, other.bin_edges) and \
np.array_equal(self.bin_psd, other.bin_psd)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels