QTable equality broken with numpy 1.23
See original GitHub issueDescription
When updating from numpy 1.22 to numpy 1.23, trying to test for equality with an empty and non-empty table rasies an error
Expected behavior
False
to be printed without error. With numpy 1.22
this is the output:
/Users/dstansby/mambaforge/envs/sunpy/lib/python3.10/site-packages/astropy/table/table.py:3474: FutureWarning: elementwise == comparison failed and returning scalar instead; this will raise an error or perform elementwise comparison in the future.
result = self.as_array() == other
False
Actual behavior
With numpy 1.23
:
Traceback (most recent call last):
File "/Users/dstansby/github/sunpy/test.py", line 6, in <module>
print(t1 == t2)
File "/Users/dstansby/mambaforge/envs/sunpy/lib/python3.10/site-packages/astropy/table/table.py", line 3426, in __eq__
return self._rows_equal(other)
File "/Users/dstansby/mambaforge/envs/sunpy/lib/python3.10/site-packages/astropy/table/table.py", line 3474, in _rows_equal
result = self.as_array() == other
TypeError: Cannot compare structured arrays unless they have a common dtype. I.e. `np.result_type(arr1, arr2)` must be defined.
Steps to Reproduce
from astropy.table import QTable
import numpy as np
t1 = QTable([np.array([], dtype=float)], names=('a'))
t2 = QTable([np.array([1], dtype=float)], names=('b'))
print(t1 == t2)
System Details
macOS-12.4-arm64-arm-64bit Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:42:03) [Clang 12.0.1 ] Numpy 1.23.0 pyerfa 2.0.0.1 astropy 5.1 Scipy 1.8.1 Matplotlib 3.5.2
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
numpy.repeat — NumPy v1.24 Manual
The axis along which to repeat values. By default, use the flattened input array, and return a flat output array. Returns: repeated_arrayndarray.
Read more >Full Changelog — SunPy 4.1.0 documentation
4.1.0 (2022-11-11): Breaking Changes: Updated the sample data file, ... This (now fixed) error is only present when using numpy version >= 1.23....
Read more >taurus Documentation - Read the Docs
Taurus is a free, open source, multi-platform pure Python module for creating and supporting ... 1.23: Qt designer widget creation dialog.
Read more >astroquery Documentation
Astroquery works with Python 2.7 and 3.4 or later. ... Properties of z ~ 3-6 Lyman break galaxies. ... 1.23. 0.723. 0.04. 0.937...
Read more >LxMLS - Lab Guide
required Python libraries and download the LXMLS code base. ... Prints a variable, with line break (useful for lists). (n)ext line.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed, it is the
try
part that goes from being cheap to being essentially free, so it pays to put the common path inside atry/except
and have all the costs born by the uncommon path (or error).Yes, if the
except
path is taken (exception gets raised) that is expensive, but thetry
is cheap.