swe-bench/SWE-bench

Error in `astropy__astropy-14539` when using numpy==1.25.2

Closed this issue · 3 comments

Describe the bug

When running the code from the issue that compares FITS files using astropy.io.fits.FITSDiff, an error occurs with numpy==1.25.2 due to an ambiguous array comparison. The problem arises from comparing arrays with multiple elements without using .any() or .all().

This issue does not appear when using numpy==1.24.2.

Steps/Code to Reproduce

pip install numpy==1.25.2
pip install setuptools==68.0.0
pip install extension_helpers
pip install wheel
pip install git+https://github.com/astropy/astropy.git@cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 --no-build-isolation

python -c "from astropy.io import fits; col = fits.Column('a', format='QD', array=[[0], [0, 0]]); hdu = fits.BinTableHDU.from_columns([col]); hdu.writeto('diffbug.fits', overwrite=True); print(fits.FITSDiff('diffbug.fits', 'diffbug.fits').identical); fits.printdiff('diffbug.fits', 'diffbug.fits')"

Expected Results

No error

Actual Results

Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/testbed/astropy/io/fits/diff.py", line 311, in __init__
    super().__init__(a, b)
  File "/testbed/astropy/io/fits/diff.py", line 72, in __init__
    self._diff()
  File "/testbed/astropy/io/fits/diff.py", line 349, in _diff
    hdu_diff = HDUDiff.fromdiff(self, self.a[idx], self.b[idx])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/testbed/astropy/io/fits/diff.py", line 107, in fromdiff
    return cls(a, b, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/testbed/astropy/io/fits/diff.py", line 530, in __init__
    super().__init__(a, b)
  File "/testbed/astropy/io/fits/diff.py", line 72, in __init__
    self._diff()
  File "/testbed/astropy/io/fits/diff.py", line 562, in _diff
    self.diff_data = TableDataDiff.fromdiff(self, self.a.data,
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/testbed/astropy/io/fits/diff.py", line 107, in fromdiff
    return cls(a, b, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/testbed/astropy/io/fits/diff.py", line 1256, in __init__
    super().__init__(a, b)
  File "/testbed/astropy/io/fits/diff.py", line 72, in __init__
    self._diff()
  File "/testbed/astropy/io/fits/diff.py", line 1370, in _diff
    diffs = np.where(arra != arrb)
                     ^^^^^^^^^^^^
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

System Information

No response

Hi @SmartManoj

I just ran evaluation on the gold patch for this instance.

$ python -m swebench.harness.run_evaluation --dataset_name princeton-nlp/SWE-bench --split test --predictions_path gold --run_id check --instance_ids astropy__astropy-14539
/opt/miniconda3/envs/sweb/lib/python3.10/runpy.py:126: RuntimeWarning: 'swebench.harness.run_evaluation' found in sys.modules after import of package 'swebench.harness', but prior to execution of 'swebench.harness.run_evaluation'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
Using gold predictions - ignoring predictions_path
Running 1 unevaluated instances...
Base image sweb.base.x86_64:latest already exists, skipping build.
Base images built successfully.
No environment images need to be built.
Running 1 instances...
  0%|                                                                                                                                                                                                                                      | 0/1 [00:00<?, ?it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [01:44<00:00, 104.31s/it]
All instances run.
Cleaning cached images...
Removed 0 images.
Total instances: 1
Instances submitted: 1
Instances completed: 1
Instances incomplete: 0
Instances resolved: 1
Instances unresolved: 0
Instances with empty patches: 0
Instances with errors: 0
Unstopped containers: 0
Unremoved images: 0
Report written to gold.check.json

It works fine. What machine are you running on? I would recommend running evaluation on Linux x86 machines. We've been building everything with respect to AWS ec2 instances.

Closing this issue for now, but if errors persist (from running the same command on Linux), please feel free to re-open.

What machine are you running on?

WSL


What is the NumPy version used in the above one?

1.25.2 (from this line)

>>> from datasets import load_dataset
>>> data = load_dataset('princeton-nlp/SWE-bench', split='test')
>>> data = {x['instance_id']: x for x in data}
>>> data['astropy__astropy-14539']['version']
'5.1'

The version is 5.1, which maps to the tagged line.