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)
Description
The method
__eq__of pytmatrix.psd.BinnedPSD( ) fails with an AttributeError: 'bool' object has no attribute 'all()' ifbin_edgesis provided as list:Cause
If
self.bin_edgesandother.bin_edgesare NumPy arrays,self.bin_edges == other.bin_edgesreturns an array of booleans, where.all()is valid.However, if they are Python lists,
self.bin_edges == other.bin_edgesdirectly 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: