source stringclasses 4
values | task_type stringclasses 5
values | instruction stringclasses 5
values | input stringlengths 108 11.9k | output stringlengths 28 12k |
|---|---|---|---|---|
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Add helpers to convert between different types of uncertainties
Currently there no easy way to convert from an arbitrary uncertainty class to a different uncertainty class. This would be useful to be able to pass NDData objects to external libraries/tools which assume, fo... | diff --git a/astropy/nddata/nduncertainty.py b/astropy/nddata/nduncertainty.py
--- a/astropy/nddata/nduncertainty.py
+++ b/astropy/nddata/nduncertainty.py
@@ -395,6 +395,40 @@ def _propagate_multiply(self, other_uncert, result_data, correlation):
def _propagate_divide(self, other_uncert, result_data, correlation):... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Can Table masking be turned off?
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Please be sure to... | diff --git a/astropy/io/fits/connect.py b/astropy/io/fits/connect.py
--- a/astropy/io/fits/connect.py
+++ b/astropy/io/fits/connect.py
@@ -112,7 +112,8 @@ def _decode_mixins(tbl):
def read_table_fits(input, hdu=None, astropy_native=False, memmap=False,
- character_as_bytes=True, unit_parse_stric... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
SkyCoord in Table breaks aggregate on group_by
### Description, actual behaviour, reproduction
When putting a column of `SkyCoord`s in a `Table`, `aggregate` does not work on `group_by().groups`:
```python
from astropy.table import Table
import astropy.units as u
from as... | diff --git a/astropy/table/column.py b/astropy/table/column.py
--- a/astropy/table/column.py
+++ b/astropy/table/column.py
@@ -340,7 +340,9 @@ class ColumnInfo(BaseColumnInfo):
This is required when the object is used as a mixin column within a table,
but can be used as a general way to store meta information... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
The `where` keyword argument of `np.mean` is not supported for `astropy.units.Quantity` instances.
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github... | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -18,6 +18,7 @@
# LOCAL
from astropy import config as _config
+from astropy.utils.compat import NUMPY_LT_1_20, NUMPY_LT_1_22
from astropy.utils.compat.misc import override__dir__
fr... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Modeling's `separability_matrix` does not compute separability correctly for nested CompoundModels
Consider the following model:
```python
from astropy.modeling import models as m
from astropy.modeling.separable import separability_matrix
cm = m.Linear1D(10) & m.Linear1... | diff --git a/astropy/modeling/separable.py b/astropy/modeling/separable.py
--- a/astropy/modeling/separable.py
+++ b/astropy/modeling/separable.py
@@ -242,7 +242,7 @@ def _cstack(left, right):
cright = _coord_matrix(right, 'right', noutp)
else:
cright = np.zeros((noutp, right.shape[1]))
- ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Convert CCDData to ImageHDU
### Description
As far as I can tell, currently there's no way to directly convert a `CCDData` object to an `ImageHDU` object. If we write it to a file using `CCDData.write()` it will always create a file where the first HDU is a `PrimaryHDU` t... | diff --git a/astropy/nddata/ccddata.py b/astropy/nddata/ccddata.py
--- a/astropy/nddata/ccddata.py
+++ b/astropy/nddata/ccddata.py
@@ -270,7 +270,8 @@ def uncertainty(self, value):
self._uncertainty = value
def to_hdu(self, hdu_mask='MASK', hdu_uncertainty='UNCERT',
- hdu_flags=None, w... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Incorrect ignored usage in `ModelBoundingBox`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Plea... | diff --git a/astropy/modeling/bounding_box.py b/astropy/modeling/bounding_box.py
--- a/astropy/modeling/bounding_box.py
+++ b/astropy/modeling/bounding_box.py
@@ -694,6 +694,12 @@ def _validate_dict(self, bounding_box: dict):
for key, value in bounding_box.items():
self[key] = value
+ @proper... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
TimeSeries: misleading exception when required column check fails.
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/C... | diff --git a/astropy/timeseries/core.py b/astropy/timeseries/core.py
--- a/astropy/timeseries/core.py
+++ b/astropy/timeseries/core.py
@@ -55,6 +55,13 @@ class BaseTimeSeries(QTable):
_required_columns_relax = False
def _check_required_columns(self):
+ def as_scalar_or_list_str(obj):
+ if ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Time from astropy.time not precise
Hello,
I encounter difficulties with Time. I'm working on a package to perform photometry and occultation.
For this last case, data need times values accurately estimated. Of course, data coming from different camera will will have di... | diff --git a/astropy/time/core.py b/astropy/time/core.py
--- a/astropy/time/core.py
+++ b/astropy/time/core.py
@@ -655,9 +655,6 @@ def precision(self):
@precision.setter
def precision(self, val):
del self.cache
- if not isinstance(val, int) or val < 0 or val > 9:
- raise ValueError(... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Document reading True/False in ASCII table as bool not str
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUT... | diff --git a/astropy/io/ascii/core.py b/astropy/io/ascii/core.py
--- a/astropy/io/ascii/core.py
+++ b/astropy/io/ascii/core.py
@@ -1016,7 +1016,10 @@ class BaseOutputter:
"""Output table as a dict of column objects keyed on column name. The
table data are stored as plain python lists within the column object... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Register format ``html`` to ``Cosmology.write`` with nice mathjax
Cosmology can now read and write to files.
It would be nice to register with ``Cosmology.write`` a method for exporting a Cosmology to a HTML table.
There are good examples of IO with Cosmology at https://... | diff --git a/astropy/cosmology/io/__init__.py b/astropy/cosmology/io/__init__.py
--- a/astropy/cosmology/io/__init__.py
+++ b/astropy/cosmology/io/__init__.py
@@ -5,4 +5,4 @@
"""
# Import to register with the I/O machinery
-from . import cosmology, ecsv, mapping, model, row, table, yaml
+from . import cosmology, ec... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Add __array_func__ for astropy.time.Time
<!-- This comments are hidden when you submit the pull request,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Pl... | diff --git a/astropy/time/core.py b/astropy/time/core.py
--- a/astropy/time/core.py
+++ b/astropy/time/core.py
@@ -31,6 +31,7 @@
# Import TimeFromEpoch to avoid breaking code that followed the old example of
# making a custom timescale in the documentation.
from .formats import TimeFromEpoch # noqa
+from .time_help... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Angle bug for (d, m, s) tuple input (deprecate dms_to_degrees)
`Angle` does not handle the sign correctly for a `(d, m, s)` tuple input if `d=0`:
```python
>>> from astropy.coordinates import Angle
>>> ang = Angle((-0, -42, -17), unit='deg')
>>> print(ang)
0d42m17s
>>> p... | diff --git a/astropy/coordinates/angle_formats.py b/astropy/coordinates/angle_formats.py
--- a/astropy/coordinates/angle_formats.py
+++ b/astropy/coordinates/angle_formats.py
@@ -27,6 +27,7 @@
IllegalMinuteWarning, IllegalMinuteError,
IllegalSecondWarning, IllegalSecondError)... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Structured column serialization round-trip fails with field name of "name"
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blo... | diff --git a/astropy/table/serialize.py b/astropy/table/serialize.py
--- a/astropy/table/serialize.py
+++ b/astropy/table/serialize.py
@@ -293,14 +293,18 @@ def _construct_mixin_from_obj_attrs_and_info(obj_attrs, info):
# untrusted code by only importing known astropy classes.
cls_full_name = obj_attrs.pop('_... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Consider removing auto-transform of structured column into NdarrayMixin
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/m... | diff --git a/astropy/table/table.py b/astropy/table/table.py
--- a/astropy/table/table.py
+++ b/astropy/table/table.py
@@ -1239,13 +1239,6 @@ def _convert_data_to_col(self, data, copy=True, default_name=None, dtype=None, n
f'{fully_qualified_name} '
'did... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
vstack'ing structured array tables fails with casting error
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBU... | diff --git a/astropy/utils/metadata.py b/astropy/utils/metadata.py
--- a/astropy/utils/metadata.py
+++ b/astropy/utils/metadata.py
@@ -73,7 +73,7 @@ def dtype(arr):
dtype_bytes_or_chars(arr.dtype)]
arr_common = np.array([arr[0] for arr in arrs])
- return arr_common.dtype.str
+ retur... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Masked ``_array2string`` doesn't work on some structured arrays
### Description
The dispatch function ``_array2string `` in ``masked.function_helpers`` doesn't work on arrays with strutcured dtypes.
### Expected behavior
Masked arrays with structured dtypes can be prin... | diff --git a/astropy/utils/masked/function_helpers.py b/astropy/utils/masked/function_helpers.py
--- a/astropy/utils/masked/function_helpers.py
+++ b/astropy/utils/masked/function_helpers.py
@@ -877,13 +877,19 @@ class MaskedFormat:
"""
def __init__(self, format_function):
self.format_function = form... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
[Security] Jquery 3.1.1 is vulnerable to untrusted code execution
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CO... | diff --git a/astropy/table/jsviewer.py b/astropy/table/jsviewer.py
--- a/astropy/table/jsviewer.py
+++ b/astropy/table/jsviewer.py
@@ -15,7 +15,7 @@ class Conf(_config.ConfigNamespace):
"""
jquery_url = _config.ConfigItem(
- 'https://code.jquery.com/jquery-3.1.1.min.js',
+ 'https://code.jquery... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
TST: time/tests/test_precision.py failed in pyinstaller (computed error is different depending on the order of the arguments)
First failing log (2022-03-13): https://github.com/astropy/astropy/runs/5525474634
Last successful log (2022-03-12): https://github.com/astropy/a... | diff --git a/astropy/time/utils.py b/astropy/time/utils.py
--- a/astropy/time/utils.py
+++ b/astropy/time/utils.py
@@ -60,14 +60,16 @@ def day_frac(val1, val2, factor=None, divisor=None):
# get integer fraction
day = np.round(sum12)
- extra, frac = two_sum(sum12, -day)
- frac += extra + err12
- # O... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
rtol for FITSDiff not working as expected.
I have question about the rtol parameter for FITSDiff, when I create a report it appears that the numbers cited as being different are within the given relative tolerance. I couldn't figure out why so I thought this may be a bu... | diff --git a/astropy/io/fits/diff.py b/astropy/io/fits/diff.py
--- a/astropy/io/fits/diff.py
+++ b/astropy/io/fits/diff.py
@@ -1051,7 +1051,8 @@ def _report(self):
index = [x + 1 for x in reversed(index)]
self._writeln(f' Data differs at {index}:')
report_diff_values(values[0], va... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Can't convert a list of Astropy tables to a NumPy array of tables
I recently stumbled upon [a StackOverflow question](https://stackoverflow.com/questions/69414829/convert-a-list-of-astropy-table-in-a-numpy-array-of-astropy-table) where someone likes to convert a list of T... | diff --git a/astropy/table/table.py b/astropy/table/table.py
--- a/astropy/table/table.py
+++ b/astropy/table/table.py
@@ -1070,7 +1070,12 @@ def __array__(self, dtype=None):
supported and will raise a ValueError.
"""
if dtype is not None:
- raise ValueError('Datatype coercion is n... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Comparing Frame with data and SkyCoord with same data raises exception
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/ma... | diff --git a/astropy/coordinates/baseframe.py b/astropy/coordinates/baseframe.py
--- a/astropy/coordinates/baseframe.py
+++ b/astropy/coordinates/baseframe.py
@@ -1650,6 +1650,9 @@ def __eq__(self, value):
This implements strict equality and requires that the frames are
equivalent and that the represe... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Inconsistent behavior of `world_to_pixel` in `SlicedLowLevelWCS`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CO... | diff --git a/astropy/wcs/wcsapi/wrappers/sliced_wcs.py b/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
--- a/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
+++ b/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
@@ -243,6 +243,8 @@ def pixel_to_world_values(self, *pixel_arrays):
return world_arrays
def world_to_pixel_va... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
`Quantity.__ilshift__` throws exception with `dtype=int`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTIN... | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -1088,21 +1088,23 @@ def __ilshift__(self, other):
try:
other = Unit(other, parse_strict='silent')
except UnitTypeError:
- return NotImplemented... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
wcslint crashes on valid WCS
`wcslint` calls an underlying function here:
https://github.com/astropy/astropy/blob/8c0581fc68ca1f970d7f4e6c9ca9f2b9567d7b4c/astropy/wcs/wcs.py#L3430
Looks like all it does is tries to create a `WCS` object with the header and report warnin... | diff --git a/astropy/wcs/wcs.py b/astropy/wcs/wcs.py
--- a/astropy/wcs/wcs.py
+++ b/astropy/wcs/wcs.py
@@ -3528,7 +3528,7 @@ def __repr__(self):
"always", FITSFixedWarning, append=True)
try:
- WCS(hdu.header,
+ WCS(hdu.header, hdulist,
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
`Time` parses fractional days in year-month-day format incorrectly
`Time('2017-08-24.25')` results in `2017-08-24 00:00:00.250`: the fractional days are interpreted as fractional seconds (`2017-08-24 06:00:00` is what I hoped for).
The format `2017-08-24.25` is perhaps n... | diff --git a/astropy/time/formats.py b/astropy/time/formats.py
--- a/astropy/time/formats.py
+++ b/astropy/time/formats.py
@@ -1294,13 +1294,15 @@ def parse_string(self, timestr, subfmts):
try:
idot = timestr.rindex('.')
except Exception:
- fracsec = 0.0
+ timestr_ha... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Add option to input/output column units for fixed width tables
Extend the `io.ascii.FixedWidth` reader to include a keyword arg that will specify that there is a row of unit specifiers after the column name specifiers (or at the top of the header if there are no column na... | diff --git a/astropy/io/ascii/fixedwidth.py b/astropy/io/ascii/fixedwidth.py
--- a/astropy/io/ascii/fixedwidth.py
+++ b/astropy/io/ascii/fixedwidth.py
@@ -92,6 +92,7 @@ def get_cols(self, lines):
List of table lines
"""
+ header_rows = getattr(self, "header_rows", ["name"])
# S... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
float32 representation of pi/2 is rejected by `Latitude`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTIN... | diff --git a/astropy/coordinates/angles.py b/astropy/coordinates/angles.py
--- a/astropy/coordinates/angles.py
+++ b/astropy/coordinates/angles.py
@@ -587,7 +587,7 @@ def _validate_angles(self, angles=None):
if angles.unit is u.deg:
limit = 90
elif angles.unit is u.rad:
- limit... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
float32 representation of pi/2 is rejected by `Latitude`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTIN... | diff --git a/astropy/coordinates/angles.py b/astropy/coordinates/angles.py
--- a/astropy/coordinates/angles.py
+++ b/astropy/coordinates/angles.py
@@ -573,8 +573,8 @@ def _validate_angles(self, angles=None):
# objects, for speed.
if angles is None:
angles = self
- lower = u.degree.... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Creating a mixin column in a new table from columns of another table renames columns in original table.
### Description
Consider the following code, where a subset of columns from another table should be included in a new table with new names, prerably without copying th... | diff --git a/astropy/table/table.py b/astropy/table/table.py
--- a/astropy/table/table.py
+++ b/astropy/table/table.py
@@ -1264,8 +1264,10 @@ def _convert_data_to_col(self, data, copy=True, default_name=None, dtype=None, n
elif data_is_mixin:
# Copy the mixin column attributes if they exist sinc... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Unpickled Angle.to_string fails
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Please be sure to ... | diff --git a/astropy/coordinates/angles.py b/astropy/coordinates/angles.py
--- a/astropy/coordinates/angles.py
+++ b/astropy/coordinates/angles.py
@@ -5,6 +5,7 @@
coordinates in astropy.
"""
+import functools
from collections import namedtuple
import numpy as np
@@ -157,7 +158,7 @@ def _tuple_to_float(angle, un... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Should `Quantity.__array_ufunc__()` return `NotImplemented` instead of raising `ValueError` if the inputs are incompatible?
### Description
I'm trying to implement a duck type of `astropy.units.Quantity`. If you are interested, the project is available [here](https://gith... | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -633,53 +633,70 @@ def __array_ufunc__(self, function, method, *inputs, **kwargs):
Returns
-------
- result : `~astropy.units.Quantity`
+ result : `~ast... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Degrees Celsius should be supported by FITS units
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
... | diff --git a/astropy/units/format/fits.py b/astropy/units/format/fits.py
--- a/astropy/units/format/fits.py
+++ b/astropy/units/format/fits.py
@@ -28,7 +28,12 @@ class Fits(generic.Generic):
def _generate_unit_names():
from astropy import units as u
- names = {}
+ # add some units up-front... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Subclassed SkyCoord gives misleading attribute access message
I'm trying to subclass `SkyCoord`, and add some custom properties. This all seems to be working fine, but when I have a custom property (`prop` below) that tries to access a non-existent attribute (`random_attr... | diff --git a/astropy/coordinates/sky_coordinate.py b/astropy/coordinates/sky_coordinate.py
--- a/astropy/coordinates/sky_coordinate.py
+++ b/astropy/coordinates/sky_coordinate.py
@@ -894,10 +894,8 @@ def __getattr__(self, attr):
if frame_cls is not None and self.frame.is_transformable_to(frame_cls):
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Should calling `np.array_equal()` on `astropy.units.Quantity` instances with incompatible units return `False`?
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
h... | diff --git a/astropy/units/quantity_helper/function_helpers.py b/astropy/units/quantity_helper/function_helpers.py
--- a/astropy/units/quantity_helper/function_helpers.py
+++ b/astropy/units/quantity_helper/function_helpers.py
@@ -40,7 +40,12 @@
import numpy as np
from numpy.lib import recfunctions as rfn
-from ast... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Please support header rows in RestructuredText output
### Description
It would be great if the following would work:
```Python
>>> from astropy.table import QTable
>>> import astropy.units as u
>>> import sys
>>> tbl = QTable({'wave': [350,950]*u.nm, 'response': [0.7, 1... | diff --git a/astropy/io/ascii/rst.py b/astropy/io/ascii/rst.py
--- a/astropy/io/ascii/rst.py
+++ b/astropy/io/ascii/rst.py
@@ -27,7 +27,6 @@ def get_fixedwidth_params(self, line):
class SimpleRSTData(FixedWidthData):
- start_line = 3
end_line = -1
splitter_class = FixedWidthTwoLineDataSplitter
@@ -3... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
The `range` argument to `numpy.histogram`-like functions does not accept instances of `astropy.units.Quantity`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
ht... | diff --git a/astropy/units/quantity_helper/function_helpers.py b/astropy/units/quantity_helper/function_helpers.py
--- a/astropy/units/quantity_helper/function_helpers.py
+++ b/astropy/units/quantity_helper/function_helpers.py
@@ -663,6 +663,12 @@ def _check_bins(bins, unit):
return bins
+def _check_range(... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
When should `info` be linked to a new object?
Mostly for @taldcroft - I noticed that in `Quantity` the way we have set up `__array_finalize__`, `info` is passed on not just for views (where it should be), but also for copies (implicitly in arithmetic operations, etc.). Wh... | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -731,7 +731,9 @@ def _result_as_quantity(self, result, unit, out):
if out is None:
# View the result array as a Quantity with the proper unit.
- return... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
IndexError: tuple index out of range in identify_format (io.registry)
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/mai... | diff --git a/astropy/io/fits/connect.py b/astropy/io/fits/connect.py
--- a/astropy/io/fits/connect.py
+++ b/astropy/io/fits/connect.py
@@ -65,10 +65,9 @@ def is_fits(origin, filepath, fileobj, *args, **kwargs):
fileobj.seek(pos)
return sig == FITS_SIGNATURE
elif filepath is not None:
- if ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
ascii.qdp Table format assumes QDP commands are upper case
### Description
ascii.qdp assumes that commands in a QDP file are upper case, for example, for errors they must be "READ SERR 1 2" whereas QDP itself is not case sensitive and case use "read serr 1 2".
As many ... | diff --git a/astropy/io/ascii/qdp.py b/astropy/io/ascii/qdp.py
--- a/astropy/io/ascii/qdp.py
+++ b/astropy/io/ascii/qdp.py
@@ -68,7 +68,7 @@ def _line_type(line, delimiter=None):
_new_re = rf"NO({sep}NO)+"
_data_re = rf"({_decimal_re}|NO|[-+]?nan)({sep}({_decimal_re}|NO|[-+]?nan))*)"
_type_re = rf"^\s*((... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Add ``atol`` argument to function ``is_O3``
Or at least use the maximum precision of the matrix dtype instead of the arbitrarily chosen 1e-15.
https://github.com/astropy/astropy/blob/3912916dad56920514ba648be400a5f82add041a/astropy/coordinates/matrix_utilities.py#L137-L1... | diff --git a/astropy/coordinates/matrix_utilities.py b/astropy/coordinates/matrix_utilities.py
--- a/astropy/coordinates/matrix_utilities.py
+++ b/astropy/coordinates/matrix_utilities.py
@@ -136,7 +136,7 @@ def angle_axis(matrix):
return Angle(angle, u.radian), -axis / r
-def is_O3(matrix):
+def is_O3(matrix, ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Space between value and unit
Currently, ``Angle.to_string`` doesn't include a space between the value and unit:
```python
In [30]: from astropy.coordinates import Angle
In [31]: a = Angle(3, 'deg')
In [32]: a.to_string(unit='mas')
Out[32]: '1.08e+07mas'
```
I think th... | diff --git a/astropy/coordinates/angles.py b/astropy/coordinates/angles.py
--- a/astropy/coordinates/angles.py
+++ b/astropy/coordinates/angles.py
@@ -314,10 +314,21 @@ def to_string(
)
func = ("{:g}" if precision is None else f"{{0:0.{precision}f}}").format
# Don't add unit b... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Unicode and console unit representations sometimes include an extraneous space
### Description
As noted in #14407, for units typset in `unicode` or `console` format, a space is included in front, unlike for regular units, yet it is sometimes omitted if a unit scale facto... | diff --git a/astropy/units/format/console.py b/astropy/units/format/console.py
--- a/astropy/units/format/console.py
+++ b/astropy/units/format/console.py
@@ -17,7 +17,7 @@ class Console(base.Base):
>>> import astropy.units as u
>>> print(u.Ry.decompose().to_string('console')) # doctest: +FLOAT_CMP
- ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Regarding FITS standard definition for 'Jy/beam'
Astropy unit definition for Jy/beam currently exports it as 'beam-1 Jy'
`from astropy import units as u`
`(u.Jy/u.beam).to_string('FITS')`
'beam-1 Jy'
This is contrary to how most radio astronomy packages define the unit. ... | diff --git a/astropy/modeling/physical_models.py b/astropy/modeling/physical_models.py
--- a/astropy/modeling/physical_models.py
+++ b/astropy/modeling/physical_models.py
@@ -47,7 +47,7 @@ class BlackBody(Fittable1DModel):
>>> from astropy import units as u
>>> bb = models.BlackBody(temperature=5000*u.K)
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
New Quantity warning starting with yesterday's numpy-dev
### Description
Starting today, `photutils` CI tests with `astropy-dev` and `numpy-dev` started failing due a new warning. I've extracted a MWE showing the warning:
```python
import astropy.units as u
import pyte... | diff --git a/astropy/units/quantity_helper/function_helpers.py b/astropy/units/quantity_helper/function_helpers.py
--- a/astropy/units/quantity_helper/function_helpers.py
+++ b/astropy/units/quantity_helper/function_helpers.py
@@ -75,9 +75,10 @@
np.put, np.fill_diagonal, np.tile, np.repeat,
np.split, np.array... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
`io.fits.Card` may use a string representation of floats that is larger than necessary
### Description
In some scenarios, `io.fits.Card` may use a string representation of floats that is larger than necessary, which can force comments to be truncated. Due to this, there ... | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -1298,31 +1298,17 @@ def _format_value(value):
def _format_float(value):
- """Format a floating number to make sure it gets the decimal point."""
- value_str = f"{value:.16G}"
- if... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
`io.fits` creates a corrupt FITS files if a `ImageHDU` contains zero-dimensional data
### Description
`ImageHDU` accepts a ndarray with shape `()` (zero-dimensional) as a data array. This later causes issues when writing to a file because `io.fits` assumes that the data ... | diff --git a/astropy/io/fits/hdu/image.py b/astropy/io/fits/hdu/image.py
--- a/astropy/io/fits/hdu/image.py
+++ b/astropy/io/fits/hdu/image.py
@@ -264,19 +264,16 @@ def data(self, data):
self._data_replaced = True
was_unsigned = False
- if (
- data is not None
- ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
`io.fits.FITSDiff` may sometimes report differences between identical files
### Description
In some scenarios, `io.fits.FITSDiff` may report differences between identical files, even when comparing the same file to itself. This may be caused by improper handling of VLAs ... | diff --git a/astropy/io/fits/diff.py b/astropy/io/fits/diff.py
--- a/astropy/io/fits/diff.py
+++ b/astropy/io/fits/diff.py
@@ -1449,7 +1449,7 @@ def _diff(self):
arrb.dtype, np.floating
):
diffs = where_not_allclose(arra, arrb, rtol=self.rtol, atol=self.atol)
- ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Problem with "decimalyear" applied to MaskedColumn type
### Description
The "decimalyear" type produces odd errors when applied to the MaskedColumn type.
The "jyear" type does not, and appears to behave properly.
### Expected behavior
I would expect "decimalyear" and "... | diff --git a/astropy/time/formats.py b/astropy/time/formats.py
--- a/astropy/time/formats.py
+++ b/astropy/time/formats.py
@@ -121,6 +121,8 @@ class TimeFormat:
----------
val1 : numpy ndarray, list, number, str, or bytes
Values to initialize the time or times. Bytes are decoded as ascii.
+ Q... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Writing a Table to FITS fails if the table contains objects
The following works fine:
``` Python
from astropy.table import Table
Table([{'col1': None}]).write('/tmp/tmp.txt', format='ascii')
```
whereas the following fails:
``` Python
Table([{'col1': None}]).write('/tm... | diff --git a/astropy/io/fits/column.py b/astropy/io/fits/column.py
--- a/astropy/io/fits/column.py
+++ b/astropy/io/fits/column.py
@@ -1528,7 +1528,19 @@ def _init_from_array(self, array):
for idx in range(len(array.dtype)):
cname = array.dtype.names[idx]
ftype = array.dtype.fields[cn... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
TST: np.fix check fails with numpy-dev (TypeError: cannot write to unmasked output)
Started popping up in numpy-dev jobs. @mhvk is investigating.
```
____________________________ TestUfuncLike.test_fix ____________________________
self = <astropy.utils.masked.tests.test... | diff --git a/astropy/utils/masked/core.py b/astropy/utils/masked/core.py
--- a/astropy/utils/masked/core.py
+++ b/astropy/utils/masked/core.py
@@ -671,20 +671,35 @@ def __ne__(self, other):
)
return result.any(axis=-1)
- def _combine_masks(self, masks, out=None):
+ def _combine_masks(self, mas... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Inconsistency in double single-quote ('') management in FITS Card
### Description
The management of single-quotes in FITS cards seem correct, except *sometimes* when dealing with null strings, i.e. double single quotes (`''`), which sometimes are transformed into single ... | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -66,7 +66,7 @@ class Card(_Verify):
# followed by an optional comment
_strg = r"\'(?P<strg>([ -~]+?|\'\'|) *?)\'(?=$|/| )"
_comm_field = r"(?P<comm_field>(?P<sepr>/ *)(?P<comm>(.|... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Make getting a topocentric ITRS position easier
### What is the problem this feature will solve?
Right now, it is not easy to create ITRS coordinates for sources relative to a given location (rather than geocentric), to the level that we have specific instructions on how... | diff --git a/astropy/coordinates/earth.py b/astropy/coordinates/earth.py
--- a/astropy/coordinates/earth.py
+++ b/astropy/coordinates/earth.py
@@ -655,21 +655,26 @@ def to_geocentric(self):
"""Convert to a tuple with X, Y, and Z as quantities."""
return (self.x, self.y, self.z)
- def get_itrs(sel... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Register ``latex`` to ``Cosmology.write``
Cosmology can now read and write to files.
It would be nice to register with ``Cosmology.write`` a method for exporting a Cosmology to a Latex table.
There are good examples of IO with Cosmology at https://github.com/astropy/astr... | diff --git a/astropy/cosmology/io/__init__.py b/astropy/cosmology/io/__init__.py
--- a/astropy/cosmology/io/__init__.py
+++ b/astropy/cosmology/io/__init__.py
@@ -5,4 +5,4 @@
"""
# Import to register with the I/O machinery
-from . import cosmology, ecsv, html, mapping, model, row, table, yaml
+from . import cosmolo... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
BUG: change representation of votable.tree.Table vs table.Table
More often than not it's rather confusing (and annoying) that a VOTable and a Table look exactly the same, but obviously, they don't behave the same way and don't have the same methods available, etc.
I wou... | diff --git a/astropy/io/votable/tree.py b/astropy/io/votable/tree.py
--- a/astropy/io/votable/tree.py
+++ b/astropy/io/votable/tree.py
@@ -2420,7 +2420,10 @@ def __init__(
warn_unknown_attrs("TABLE", extra.keys(), config, pos)
def __repr__(self):
- return repr(self.to_table())
+ s = repr(s... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Add registration label ‘ascii.latex’ to Cosmology IO
### What is the problem this feature will solve?
The Cosmology write methods that leverage Table should have the same `format=` keys. Table has both “latex” and “ascii.latex”, so too should Cosmology.
### Describe th... | diff --git a/astropy/cosmology/io/latex.py b/astropy/cosmology/io/latex.py
--- a/astropy/cosmology/io/latex.py
+++ b/astropy/cosmology/io/latex.py
@@ -48,10 +48,10 @@ def write_latex(
TypeError
If kwarg (optional) 'cls' is not a subclass of `astropy.table.Table`
"""
- # Check that the format is 'l... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
QTable: Group keys don't have a unit
### Description
When grouping a QTable with a column that contains a quantity, the keys only contain a float with a value, but not the full quantity:
```Python
>>> from astropy.table import QTable
>>> import astropy.units as u
>>> tb... | diff --git a/astropy/table/groups.py b/astropy/table/groups.py
--- a/astropy/table/groups.py
+++ b/astropy/table/groups.py
@@ -74,10 +74,15 @@ def _table_group_by(table, keys):
)
)
+ # TODO: don't use represent_mixins_as_columns here, but instead ensure that
+ # keys_sort.argsort(kind="sta... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Error in distance calculations for w0wz Cosmologies
### Description
I believe that the equation used to calculate the de_density_scale in `w0wzcdm.py `is incorrect.
Line 205 has `return zp1 ** (3.0 * (1.0 + self._w0 - self._wz)) * exp(-3.0 * self._wz * z)`
### Expec... | diff --git a/astropy/cosmology/flrw/w0wzcdm.py b/astropy/cosmology/flrw/w0wzcdm.py
--- a/astropy/cosmology/flrw/w0wzcdm.py
+++ b/astropy/cosmology/flrw/w0wzcdm.py
@@ -190,19 +190,25 @@ def de_density_scale(self, z):
The scaling of the energy density of dark energy with redshift.
Returns `float... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
In v5.3, NDDataRef mask propagation fails when one of the operand does not have a mask
### Description
This applies to v5.3.
It looks like when one of the operand does not have a mask, the mask propagation when doing arithmetic, in particular with `handle_mask=np.bitwi... | diff --git a/astropy/nddata/mixins/ndarithmetic.py b/astropy/nddata/mixins/ndarithmetic.py
--- a/astropy/nddata/mixins/ndarithmetic.py
+++ b/astropy/nddata/mixins/ndarithmetic.py
@@ -520,10 +520,10 @@ def _arithmetic_mask(self, operation, operand, handle_mask, axis=None, **kwds):
elif self.mask is None and ope... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Possible bug in io.fits related to D exponents
I came across the following code in ``fitsrec.py``:
```python
# Replace exponent separator in floating point numbers
if 'D' in format:
output_field.replace(encode_ascii('E'), encode_ascii('D'))
``... | diff --git a/astropy/io/fits/fitsrec.py b/astropy/io/fits/fitsrec.py
--- a/astropy/io/fits/fitsrec.py
+++ b/astropy/io/fits/fitsrec.py
@@ -1261,7 +1261,7 @@ def _scale_back_ascii(self, col_idx, input_field, output_field):
# Replace exponent separator in floating point numbers
if 'D' in format:
- ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Context manager for constant versions
For some use cases it would be helpful to have a context manager to set the version set of the constants. E.g., something like
```
with constants_set(astropyconst13):
... code goes here ...
````
Hints:
I am trying to take a sta... | diff --git a/astropy/constants/__init__.py b/astropy/constants/__init__.py
--- a/astropy/constants/__init__.py
+++ b/astropy/constants/__init__.py
@@ -13,8 +13,8 @@
<Quantity 0.510998927603161 MeV>
"""
-
-import itertools
+import inspect
+from contextlib import contextmanager
# Hack to make circular imports ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
InheritDocstrings metaclass doesn't work for properties
Inside the InheritDocstrings metaclass it uses `inspect.isfunction` which returns `False` for properties.
Hints:
This was as implemented back in #2159. I don't see any `inspect.isproperty`. Do you have any suggesti... | diff --git a/astropy/utils/misc.py b/astropy/utils/misc.py
--- a/astropy/utils/misc.py
+++ b/astropy/utils/misc.py
@@ -4,9 +4,6 @@
A "grab bag" of relatively small general-purpose utilities that don't have
a clear module/package to live in.
"""
-
-
-
import abc
import contextlib
import difflib
@@ -27,7 +24,6 @@
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
HDUList.copy() returns a list
Currently ``HDUList.copy()`` returns a list rather than an ``HDUList``:
```python
In [1]: from astropy.io.fits import HDUList
In [2]: hdulist = HDUList()
In [3]: hdulist.copy()
Out[3]: []
In [4]: type(_)
Out[4]: list
```
This is with Pyt... | diff --git a/astropy/io/fits/hdu/hdulist.py b/astropy/io/fits/hdu/hdulist.py
--- a/astropy/io/fits/hdu/hdulist.py
+++ b/astropy/io/fits/hdu/hdulist.py
@@ -510,6 +510,25 @@ def fileinfo(self, index):
return output
+ def __copy__(self):
+ """
+ Return a shallow copy of an HDUList.
+
+ ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
units.quantity_input decorator fails for constructors with type hinted return value -> None
### Summary
I am using the `units.quantity_input` decorator with typing hints for constructors, however when I add the correct return value for the constructor (`None`) then I get ... | diff --git a/astropy/units/decorators.py b/astropy/units/decorators.py
--- a/astropy/units/decorators.py
+++ b/astropy/units/decorators.py
@@ -220,7 +220,7 @@ def wrapper(*func_args, **func_kwargs):
# Call the original function with any equivalencies in force.
with add_enabled_equivalencies(se... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
astropy.time.TimeDelta should support conversion to `datetime.timedelta`
Because of the inheritance `TimeDelta` has a method `to_datetime` which is useless.
It should have a method `to_timedelta` which returns a `datetime.timedelta` object or objects.
Conversion to `np.... | diff --git a/astropy/time/core.py b/astropy/time/core.py
--- a/astropy/time/core.py
+++ b/astropy/time/core.py
@@ -10,7 +10,7 @@
import copy
import operator
-from datetime import datetime
+from datetime import datetime, timedelta
import numpy as np
@@ -1603,7 +1603,7 @@ def __add__(self, other):
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Unit equality comparison with None raises TypeError for UnrecognizedUnit
```
In [12]: x = u.Unit('asdf', parse_strict='silent')
In [13]: x == None # Should be False
---------------------------------------------------------------------------
TypeError ... | diff --git a/astropy/units/core.py b/astropy/units/core.py
--- a/astropy/units/core.py
+++ b/astropy/units/core.py
@@ -728,7 +728,7 @@ def __eq__(self, other):
try:
other = Unit(other, parse_strict='silent')
except (ValueError, UnitsError, TypeError):
- return False
+ ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
minversion failures
The change in PR #7647 causes `minversion` to fail in certain cases, e.g.:
```
>>> from astropy.utils import minversion
>>> minversion('numpy', '1.14dev')
TypeError Traceback (most recent call last)
<ipython-input-1-760e... | diff --git a/astropy/utils/introspection.py b/astropy/utils/introspection.py
--- a/astropy/utils/introspection.py
+++ b/astropy/utils/introspection.py
@@ -4,6 +4,7 @@
import inspect
+import re
import types
import importlib
from distutils.version import LooseVersion
@@ -139,6 +140,14 @@ def minversion(module, ve... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
biweight_location of a constant array returns nan
Currently the robust mean estimator `biweight_location` returns `nan` for an array with zero variance.
eg:
```
>>> astropy.stats.biweight_location(np.ones(4))
nan # Instead of expected value 1
```
This is primarily beca... | diff --git a/astropy/stats/biweight.py b/astropy/stats/biweight.py
--- a/astropy/stats/biweight.py
+++ b/astropy/stats/biweight.py
@@ -102,8 +102,15 @@ def biweight_location(data, c=6.0, M=None, axis=None):
# set up the weighting
mad = median_absolute_deviation(data, axis=axis)
+
+ if axis is None and ma... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Issue when passing empty lists/arrays to WCS transformations
The following should not fail but instead should return empty lists/arrays:
```
In [1]: from astropy.wcs import WCS
In [2]: wcs = WCS('2MASS_h.fits')
In [3]: wcs.wcs_pix2world([], [], 0)
---------------------... | diff --git a/astropy/wcs/wcs.py b/astropy/wcs/wcs.py
--- a/astropy/wcs/wcs.py
+++ b/astropy/wcs/wcs.py
@@ -1212,6 +1212,9 @@ def _array_converter(self, func, sky, *args, ra_dec_order=False):
"""
def _return_list_of_arrays(axes, origin):
+ if any([x.size == 0 for x in axes]):
+ ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Issue when transforming a single scalar coordinate with a 1D WCS
The following example illustrates a bug when dealing with single scalar coordinates in 1D WCSes:
```
In [1]: from astropy.wcs import WCS
In [2]: wcs = WCS(naxis=1)
In [3]: wcs.all_pix2world(29, 0)
-------... | diff --git a/astropy/wcs/wcs.py b/astropy/wcs/wcs.py
--- a/astropy/wcs/wcs.py
+++ b/astropy/wcs/wcs.py
@@ -1256,7 +1256,7 @@ def _return_single_array(xy, origin):
raise TypeError(
"When providing two arguments, they must be "
"(coords[N][{0}], origin)".format(s... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Record data size in the WCS object
It is clear that there are practical reasons to have a record of the original data size in the WCS object. This in the past has been recorded in public attributes `naxis1` and `naxis2` and subsequently in the private `_naxis1` and `_naxi... | diff --git a/astropy/wcs/wcs.py b/astropy/wcs/wcs.py
--- a/astropy/wcs/wcs.py
+++ b/astropy/wcs/wcs.py
@@ -72,6 +72,10 @@
__doctest_skip__ = ['WCS.all_world2pix']
+NAXIS_DEPRECATE_MESSAGE = """
+Private attributes "_naxis1" and "naxis2" have been deprecated since v3.1.
+Instead use the "pixel_shape" property which... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Cosmologies used in equivalencies
The thermodynamic temperature equivalency appears to default to the Planck 2015 cosmology value:
```python
if T_cmb is None:
from ..cosmology import Planck15
T_cmb = Planck15.Tcmb0
```
whereas in the ``with_H0`` equi... | diff --git a/astropy/units/equivalencies.py b/astropy/units/equivalencies.py
--- a/astropy/units/equivalencies.py
+++ b/astropy/units/equivalencies.py
@@ -591,8 +591,9 @@ def thermodynamic_temperature(frequency, T_cmb=None):
frequency : `~astropy.units.Quantity` with spectral units
The observed `spectral`... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
units: 's / m' and 's / m' are not convertible
To paraphrase from https://github.com/PlasmaPy/PlasmaPy/issues/587, exceptions like `astropy.units.core.UnitConversionError: 's / m' and 's / m' are not convertible` (and a few other cases with first, second and third powers ... | diff --git a/astropy/units/core.py b/astropy/units/core.py
--- a/astropy/units/core.py
+++ b/astropy/units/core.py
@@ -2022,8 +2022,10 @@ def __init__(self, scale, bases, powers, decompose=False,
"bases must be sequence of UnitBase instances")
powers = [validate_power(p) for p in p... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Problem with the `littleh` part of unit equivalencies?
In the newly added `littleh` equivalencies: http://docs.astropy.org/en/stable/units/equivalencies.html#unit-equivalencies
We notice that the implementation of `littleh` seems to be wrong, as highlighted in the follo... | diff --git a/astropy/units/equivalencies.py b/astropy/units/equivalencies.py
--- a/astropy/units/equivalencies.py
+++ b/astropy/units/equivalencies.py
@@ -728,6 +728,6 @@ def with_H0(H0=None):
from astropy import cosmology
H0 = cosmology.default_cosmology.get().H0
- h100_val_unit = Unit(H0.to((si... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
ncp_prior referenced before assignment in Bayesian Blocks
There is a bug in the bayesian blocks algorithm of astropy.stats. It's not a big deal so I show you below how to solve it directly.
When I call:
```python
bayesian_blocks(tt, ff, sig, fitness='measures', ncp_prior... | diff --git a/astropy/stats/bayesian_blocks.py b/astropy/stats/bayesian_blocks.py
--- a/astropy/stats/bayesian_blocks.py
+++ b/astropy/stats/bayesian_blocks.py
@@ -289,15 +289,14 @@ def compute_ncp_prior(self, N):
If ``ncp_prior`` is not explicitly defined, compute it from ``gamma``
or ``p0``.
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Adding/subtracting ABmag Quantities loses the "type" of magnitude
The following code raises a `UnitConversionError`, because it appears the math operation lost track of the "type" of magnitude. `fluxMag` and `color` are both `ABmag`, so I would expect their difference to ... | diff --git a/astropy/units/function/core.py b/astropy/units/function/core.py
--- a/astropy/units/function/core.py
+++ b/astropy/units/function/core.py
@@ -6,7 +6,7 @@
import numpy as np
-from astropy.units import (Unit, UnitBase, UnitsError, UnitTypeError,
+from astropy.units import (Unit, UnitBase, UnitsError, Un... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Header.fromstring does not accept Python 3 bytes
According to [the docs](http://docs.astropy.org/en/stable/_modules/astropy/io/fits/header.html#Header.fromstring), the method `Header.fromstring` "...creates an HDU header from a byte string containing the entire header dat... | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -554,6 +554,13 @@ def fromstring(cls, image):
"""
card = cls()
+ if isinstance(image, bytes):
+ # FITS supports only ASCII, but decode as latin1 and just ta... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
Support new clip ufunc
Starting with numpy 1.17, `np.clip` will be based on a `ufunc`, which means we can ensure it works properly with `Quantity`. (Until we do so, we might also get `numpy-dev` failures.)
Hints:
@mhvk , numpy-dev is failing now; e.g. https://travis-ci.... | diff --git a/astropy/units/function/core.py b/astropy/units/function/core.py
--- a/astropy/units/function/core.py
+++ b/astropy/units/function/core.py
@@ -683,3 +683,7 @@ def sum(self, axis=None, dtype=None, out=None, keepdims=False):
def cumsum(self, axis=None, dtype=None, out=None):
return self._wrap_... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
astropy/astropy
Problem Statement:
float16 quantities get upgraded to float64 automatically
When trying to create a `Quantity` from a `np.float16` (not something I actually intended to do, I was experimenting while investigating other issue) it gets upgraded automatically to `np.float64`, which is somethin... | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -215,8 +215,8 @@ class Quantity(np.ndarray, metaclass=InheritDocstrings):
dtype : ~numpy.dtype, optional
The dtype of the resulting Numpy array or scalar that will
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Misleading sqlmigrate "App 'apps.somethings' does not have migrations." error message
Description
This ticket is very similar to https://code.djangoproject.com/ticket/29506
As shown above, validation should be added sqlmigrate.
Hints:
https://github.com/django/django/p... | diff --git a/django/core/management/commands/sqlmigrate.py b/django/core/management/commands/sqlmigrate.py
--- a/django/core/management/commands/sqlmigrate.py
+++ b/django/core/management/commands/sqlmigrate.py
@@ -1,3 +1,4 @@
+from django.apps import apps
from django.core.management.base import BaseCommand, CommandEr... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Make URLValidator reject invalid characters in the username and password
Description
(last modified by Tim Bell)
Since #20003, core.validators.URLValidator accepts URLs with usernames and passwords. RFC 1738 section 3.1 requires "Within the user and password field, ... | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -94,7 +94,7 @@ class URLValidator(RegexValidator):
regex = _lazy_re_compile(
r'^(?:[a-z0-9\.\-\+]*)://' # scheme is validated separately
- r'(?:\S+(?::\S*)?@)?' ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Add an option to django-admin to always colorize output
Description
With Django management commands, it is currently possible disable colors with the --no-colors flag.
What I'd like to have is basically the other side of the coin: a --force-colors flag that instructs Djan... | diff --git a/django/core/management/base.py b/django/core/management/base.py
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -95,7 +95,7 @@ class DjangoHelpFormatter(HelpFormatter):
"""
show_last = {
'--version', '--verbosity', '--traceback', '--settings', '--pythonpath',... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Add validation of related fields and lookups in model Meta.ordering
Description
When the ordering class member in Meta of a model contains a field from a related model, and that field does not exist, django's makemigrations does not throw an error. However, if it is a dir... | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1643,9 +1643,35 @@ def _check_ordering(cls):
# Convert "-field" to "field".
fields = ((f[1:] if f.startswith('-') else f) for f in fields)
- # Skip ordering in th... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
SQLite functions crashes on NULL values
Description
In [14]: TestModel2.objects.annotate(null=models.Value(None, output_field=models.IntegerField())).values(pow=models.F('null') ** models.F('null')).first()
-----------------------------------------------------------------... | diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -569,7 +569,7 @@ def subtract_temporals(self, internal_type, lhs, rhs):
if internal_type == 'DateField':
lhs... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
diffsettings raises misleading exception message if using settings.configure()
Description
If, rather than using the env var DJANGO_SETTINGS_MODULE one uses settings.configure(...), attempting to call diffsettings can fail because it calls settings._setup() unconditionall... | diff --git a/django/core/management/commands/diffsettings.py b/django/core/management/commands/diffsettings.py
--- a/django/core/management/commands/diffsettings.py
+++ b/django/core/management/commands/diffsettings.py
@@ -42,7 +42,8 @@ def handle(self, **options):
from django.conf import settings, Settings, g... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Trunc() should allow passing is_dst resolution to avoid NonExistentTimeError/AmbiguousTimeError
Description
(last modified by Alexander Holmbäck)
When Trunc() truncates to a nonexisting or ambiguous datetime, the exception raised by pytz remains unhandled. The expec... | diff --git a/django/db/models/functions/datetime.py b/django/db/models/functions/datetime.py
--- a/django/db/models/functions/datetime.py
+++ b/django/db/models/functions/datetime.py
@@ -170,8 +170,9 @@ class TruncBase(TimezoneMixin, Transform):
kind = None
tzinfo = None
- def __init__(self, expression, ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Add app_label validation to showmigrations
Description
#29469
#29518
#29506
The app label validation was added to some commands as above tickets.
But showmigrations command doesn't contain it.
So I think the validation should be added to showmigrations command.
Hints:
... | diff --git a/django/core/management/commands/showmigrations.py b/django/core/management/commands/showmigrations.py
--- a/django/core/management/commands/showmigrations.py
+++ b/django/core/management/commands/showmigrations.py
@@ -1,4 +1,7 @@
-from django.core.management.base import BaseCommand, CommandError
+import sy... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Models history doesn't use verbose names
Description
The history for a model object (within the admin section) should show human-readable messages, favoring verbose names over field names. However, this is not currently the case. For example, consider a model with the fol... | diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py
--- a/django/contrib/admin/models.py
+++ b/django/contrib/admin/models.py
@@ -114,7 +114,7 @@ def get_change_message(self):
elif 'changed' in sub_message:
sub_message['changed']['fields'] = get_text_list... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Union queryset with ordering breaks on ordering with derived querysets
Description
(last modified by Sergei Maertens)
May be related to #29692
Simple reproduction (the exact models are not relevant I think):
>>> Dimension.objects.values_list('id', flat=True)
<QueryS... | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -356,7 +356,12 @@ def get_order_by(self):
resolved.set_source_expressions([RawSQL('%d' % (idx + 1), ())])
br... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Using RelatedOnlyFieldListFilter with reverse ManyToMany crashes
Description
(last modified by Tim Graham)
Using RelatedOnlyFieldListFilter with a reverse ManyToMany relation causes this exception:
get_choices() got an unexpected keyword argument 'limit_choices_to'
... | diff --git a/django/db/models/fields/reverse_related.py b/django/db/models/fields/reverse_related.py
--- a/django/db/models/fields/reverse_related.py
+++ b/django/db/models/fields/reverse_related.py
@@ -114,7 +114,10 @@ def __repr__(self):
self.related_model._meta.model_name,
)
- def get_choi... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Allow icontains lookup to accept uuids with or without dashes
Description
We have Django 2.1 project with model admin which includes an UUIDField in list_display and search_fields. The UUID is displayed with dashes on changelist (e.g. "245ba2eb-6852-47be-82be-7dc07327cf9e... | diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -5,7 +5,7 @@
from django.core.exceptions import EmptyResultSet
from django.db.models.expressions import Case, Exists, Func, Value, When
from django.db.models.fields import (
-... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Refactor AutoField logic into a mixin, implement checks and validators.
Description
Currently AutoField inherits from Field and BigAutoField from AutoField. In effect they largely redefine IntegerField and BigIntegerField respectively, but add in the auto field "behaviour... | diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py
--- a/django/db/backends/base/operations.py
+++ b/django/db/backends/base/operations.py
@@ -26,6 +26,9 @@ class BaseDatabaseOperations:
'BigIntegerField': (-9223372036854775808, 9223372036854775807),
'PositiveSm... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Infinite loop in ExceptionReporter.get_traceback_frames()
Description
The following code generates a cause/context cycle (exc_value.__cause__.__context__ is exc_value):
except WrapperException as exc:
raise exc.__cause__
The while exc_value loop then never terminates.
... | diff --git a/django/views/debug.py b/django/views/debug.py
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -397,6 +397,9 @@ def explicit_or_implicit_cause(exc_value):
while exc_value:
exceptions.append(exc_value)
exc_value = explicit_or_implicit_cause(exc_value)
+ ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Raised FieldError's should include the field that caused the error
Description
Currently there are many places in django/db/models/sql/compiler.py that raise a FieldError however frustratingly the field that caused the error is not included.
I'm proposing that, where pos... | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1191,9 +1191,15 @@ def prepare_value(self, field, value):
'can only be used to update, not to insert.' % (value, field)
... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
SQLite (pre 3.25.0) does not support window functions, raises OperationalError
Description
Window functions are supported in SQLite 3.25.0 and newer, but Python 3.6.7 and 3.7.1 only ships with SQLite 3.21.0. Window function syntax is invalid for older versions.
As per the... | diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py
--- a/django/db/backends/base/features.py
+++ b/django/db/backends/base/features.py
@@ -239,6 +239,7 @@ class BaseDatabaseFeatures:
# Does the backend support window expressions (expression OVER (...))?
supports_over_clau... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Query syntax error with condition and distinct combination
Description
A Count annotation containing both a Case condition and a distinct=True param produces a query error on Django 2.2 (whatever the db backend). A space is missing at least (... COUNT(DISTINCTCASE WHEN ..... | diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -68,7 +68,7 @@ def get_group_by_cols(self):
return []
def as_sql(self, compiler, connection, **extra_context):
- extra_context['distinct'] = 'D... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Using database functions with tzinfo=datetime.timezone(datetime.timedelta(...)) results in an incorrect query
Description
I haven’t checked this bug with other databases, but it definitely works improperly with postgres.
Django ORM create incorrect query when I use timezo... | diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -69,9 +69,20 @@ def date_trunc_sql(self, lookup_type, field_name):
else:
return "DATE(%s)" % (field_name)
+ ... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Set default FILE_UPLOAD_PERMISSION to 0o644.
Description
Hello,
As far as I can see, the File Uploads documentation page does not mention any permission issues.
What I would like to see is a warning that in absence of explicitly configured FILE_UPLOAD_PERMISSIONS, the pe... | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -304,7 +304,7 @@ def gettext_noop(s):
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https:/... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Allow FilePathField path to accept a callable.
Description
I have a special case where I want to create a model containing the path to some local files on the server/dev machine. Seeing as the place where these files are stored is different on different machines I have th... | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -1709,7 +1709,7 @@ def get_prep_value(self, value):
def formfield(self, **kwargs):
return super().formfield(**{
- 'path... |
swebench | bug_fixing | Fix the bug described in the repository issue. | Repository:
django/django
Problem Statement:
Deprecate ugettext(), ugettext_lazy(), ugettext_noop(), ungettext(), and ungettext_lazy()
Description
Along the lines of #27753 (Cleanups when no supported version of Django supports Python 2 anymore), the legacy functions in django.utils.translation -- ugettext(), ugette... | diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -2,9 +2,11 @@
Internationalization support.
"""
import re
+import warnings
from contextlib import ContextDecorator
from django.utils.au... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.