Skip to content

Commit

Permalink
Merge pull request #224 from braingram/copy_change
Browse files Browse the repository at this point in the history
Update `copy` usage in `Quantity` converter to deal with astropy 6.1 changes
  • Loading branch information
braingram committed Apr 5, 2024
2 parents f7a29ba + ae5c088 commit 80a5845
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Expand Up @@ -39,8 +39,7 @@ jobs:
envs: |
- linux: py39-parallel-cov
- linux: py311-test-devdeps-parallel-cov
- linux: py39-astropylts-parallel-cov
- linux: py39-transformlts-parallel-cov
- linux: py312-test-predeps-parallel-cov
coverage: codecov

asdf-schemas:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,9 @@
0.6.1 (unreleased)
------------------

- update ``copy`` usage in ``Quantity`` converter to
deal with astropy 6.1 changes. [#224]

0.6.0 (2024-03-13)
------------------

Expand Down
8 changes: 7 additions & 1 deletion asdf_astropy/converters/unit/quantity.py
Expand Up @@ -23,8 +23,14 @@ def to_yaml_tree(self, obj, tag, ctx):
return node

def from_yaml_tree(self, node, tag, ctx):
# numpy 2.0 changed behavior for copy where an error is produced
# if False and a copy is required (previously there was no error)
# astropy 6.1 changed Quantity in a similar way
import numpy as np
from astropy.units import Quantity

copy = None if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1" else False

value = node["value"]
dtype = node.get("datatype", None)
if isinstance(value, NDArrayType):
Expand All @@ -33,4 +39,4 @@ def from_yaml_tree(self, node, tag, ctx):
value = value._make_array()
dtype = value.dtype

return Quantity(value, unit=node["unit"], copy=False, dtype=dtype)
return Quantity(value, unit=node["unit"], copy=copy, dtype=dtype)
9 changes: 5 additions & 4 deletions tox.ini
Expand Up @@ -3,29 +3,30 @@ envlist =
py{39,310}-test{,-alldeps}
py38-test-devdeps{,-numpydev}
py38-cov
py38-astropylts
py39-test-oldestdep-parallels-cov
requires =
setuptools >= 30.3.0
pip >= 19.3.1
isolated_build = true


[testenv]
description =
run tests
alldeps: with all optional dependencies
devdeps: with the latest developer version of key dependencies
cov: and test coverage
astropylts: with astropy LTS

setenv =
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scientific-python-nightly-wheels/simple

pip_pre =
predeps: true
!predeps: false

# The following provides some specific pinnings for key packages
deps =
cov: coverage
astropylts: astropy==5.0.*
transformlts: asdf-transform-schemas==0.2.*

devdeps: -rrequirements-dev.txt
oldestdeps: minimum_dependencies
Expand Down

0 comments on commit 80a5845

Please sign in to comment.