Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ad6f510
Revert setting legacy print mode
mhvk Oct 29, 2023
069a765
Remove without_legacy_printoptions test fixture
mhvk May 28, 2024
d48a303
Adjust simple table to not use numpy scalars for object with dict
mhvk Jul 3, 2023
bc344ac
Small coordinates fixes
mhvk Aug 10, 2023
ddc5274
Small stats fixups
mhvk Aug 10, 2023
3d17038
Table touchups
mhvk Aug 10, 2023
5f41e98
Time touchups
mhvk Aug 10, 2023
b13dff1
Timeseries touchups
mhvk Aug 10, 2023
8c04a87
Units touchup
mhvk Aug 10, 2023
6dfce2f
Cosmology docs updates
mhvk Aug 10, 2023
f640d82
Coordinates doc updates
mhvk Aug 10, 2023
9eefca7
Modeling doc updates
mhvk Aug 11, 2023
8396a02
NDData docs update
mhvk Aug 11, 2023
a8382a8
Stats doc updates
mhvk Aug 11, 2023
34be9db
Table doc updates
mhvk Aug 11, 2023
af77428
Time doc updates
mhvk Aug 11, 2023
b2248f0
Timeseries doc updates
mhvk Aug 11, 2023
d83f24b
Units doc updates
mhvk Aug 11, 2023
94009a8
Utils doc updates
mhvk Aug 11, 2023
921a01e
Visualization doc updates
mhvk Aug 11, 2023
2f457c0
WCS doc updates
mhvk Aug 11, 2023
9e8a440
known issues doc updates
mhvk Aug 11, 2023
5f98371
Make all of io.fits docs compatible with numpy 2.0
mhvk Oct 30, 2023
4681342
Mark .rst and some py files with docstrings as numpy>=2.0 for doctests
mhvk Oct 30, 2023
a723956
Require numpy>=2.0.0rc1, so tests run on release candidate
mhvk May 28, 2024
4b78dd6
Ensure bottleneck result types are consistent with numpy
mhvk May 28, 2024
24c6c60
Temporarily use -predeps on one of the regular CI runs
mhvk May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ jobs:
envs: |
# NOTE: this coverage test is needed for tests and code that
# run only with minimal dependencies.
# 2024-05-30: added predeps to ensure new PRs do not break numpy 2.0
# docs. Fine to remove once numpy 2.0 is released (if problematic).
- name: Python 3.12 with minimal dependencies and full coverage
linux: py312-test-cov
linux: py312-test-cov-predeps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is okay for a few weeks. It is good to have doctest in coverage.

coverage: codecov

- name: Python 3.11 in Parallel with all optional dependencies
Expand Down
16 changes: 0 additions & 16 deletions astropy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
PYTEST_HEADER_MODULES = {}
TESTED_VERSIONS = {}

import numpy as np
import pytest

from astropy import __version__
from astropy.utils.compat.numpycompat import NUMPY_LT_2_0

if not NUMPY_LT_2_0:
np.set_printoptions(legacy="1.25")

# This is needed to silence a warning from matplotlib caused by
# PyInstaller's matplotlib runtime hook. This can be removed once the
Expand Down Expand Up @@ -67,17 +62,6 @@ def fast_thread_switching():
sys.setswitchinterval(old)


@pytest.fixture
def without_legacy_printoptions():
# this can be removed when/after removing the call to np.set_printoptions
# at the top level
# reverting https://github.com/astropy/astropy/pull/15096
legacy_val = np.get_printoptions()["legacy"]
np.set_printoptions(legacy=False)
yield
np.set_printoptions(legacy=legacy_val)


def pytest_configure(config):
from astropy.utils.iers import conf as iers_conf

Expand Down
12 changes: 6 additions & 6 deletions astropy/coordinates/baseframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,13 +1766,13 @@ def position_angle(self, other: BaseCoordinateFrame | SkyCoord) -> Angle:
>>> from astropy.coordinates import ICRS, SkyCoord
>>> c1 = SkyCoord(0*u.deg, 0*u.deg)
>>> c2 = ICRS(1*u.deg, 0*u.deg)
>>> c1.position_angle(c2).degree
90.0
>>> c2.position_angle(c1).degree
270.0
>>> c1.position_angle(c2).to(u.deg)
<Angle 90. deg>
>>> c2.position_angle(c1).to(u.deg)
<Angle 270. deg>
>>> c3 = SkyCoord(1*u.deg, 1*u.deg)
>>> c1.position_angle(c3).degree # doctest: +FLOAT_CMP
44.995636455344844
>>> c1.position_angle(c3).to(u.deg) # doctest: +FLOAT_CMP
<Angle 44.995636455344844 deg>
"""
return position_angle(*self._prepare_unit_sphere_coords(other, "ignore"))

Expand Down
1 change: 0 additions & 1 deletion astropy/coordinates/tests/test_sky_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ def test_repr():
assert repr(sc_default) == "<SkyCoord (ICRS): (ra, dec) in deg\n (0., 1.)>"


@pytest.mark.usefixtures("without_legacy_printoptions")
def test_repr_altaz():
sc2 = SkyCoord(1 * u.deg, 1 * u.deg, frame="icrs", distance=1 * u.kpc)

Expand Down
1 change: 0 additions & 1 deletion astropy/io/fits/tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ def test_partially_identical_files1(self):
assert "a: 2\n b: 3" in report
assert "No differences found between common HDUs" in report

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_partially_identical_files2(self):
"""
Test files that have some identical HDUs but one different HDU.
Expand Down
3 changes: 0 additions & 3 deletions astropy/io/fits/tests/test_fitsdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def test_onediff(self):
numdiff = fitsdiff.main([tmp_a, tmp_b])
assert numdiff == 1

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_manydiff(self, capsys):
a = np.arange(100).reshape(10, 10)
hdu_a = PrimaryHDU(data=a)
Expand Down Expand Up @@ -95,7 +94,6 @@ def test_manydiff(self, capsys):
" 100 different pixels found (100.00% different).",
]

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_outputfile(self):
a = np.arange(100).reshape(10, 10)
hdu_a = PrimaryHDU(data=a)
Expand Down Expand Up @@ -148,7 +146,6 @@ def test_rtol(self):
numdiff = fitsdiff.main(["-r", "1e-1", tmp_a, tmp_b])
assert numdiff == 0

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_rtol_diff(self, capsys):
a = np.arange(100, dtype=float).reshape(10, 10)
hdu_a = PrimaryHDU(data=a)
Expand Down
1 change: 0 additions & 1 deletion astropy/io/misc/tests/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
np.complex128(1.0 - 2**-52 + 1j * (1.0 - 2**-52)),
],
)
@pytest.mark.usefixtures("without_legacy_printoptions")
def test_numpy_types(c):
cy = load(dump(c))
assert c == cy
Expand Down
2 changes: 0 additions & 2 deletions astropy/io/votable/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def test_float_mask_permissive():
assert c.parse("null", config=config) == (c.null, True)


@pytest.mark.usefixtures("without_legacy_printoptions")
def test_double_array():
config = {"verify": "exception", "version_1_3_or_later": True}
field = tree.Field(None, name="c", datatype="double", arraysize="3", config=config)
Expand Down Expand Up @@ -278,7 +277,6 @@ def test_integer_overflow():
c.parse("-2208988800", config=config)


@pytest.mark.usefixtures("without_legacy_printoptions")
def test_float_default_precision():
config = {"verify": "exception"}

Expand Down
8 changes: 0 additions & 8 deletions astropy/io/votable/tests/test_vo.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,20 @@ def _test_regression(tmp_path, _python_based=False, binary_mode=1):


@pytest.mark.xfail("legacy_float_repr")
@pytest.mark.usefixtures("without_legacy_printoptions")
def test_regression(tmp_path):
# W39: Bit values can not be masked
with pytest.warns(W39), np.errstate(over="ignore"):
_test_regression(tmp_path, False)


@pytest.mark.xfail("legacy_float_repr")
@pytest.mark.usefixtures("without_legacy_printoptions")
def test_regression_python_based_parser(tmp_path):
# W39: Bit values can not be masked
with pytest.warns(W39), np.errstate(over="ignore"):
_test_regression(tmp_path, True)


@pytest.mark.xfail("legacy_float_repr")
@pytest.mark.usefixtures("without_legacy_printoptions")
def test_regression_binary2(tmp_path):
# W39: Bit values can not be masked
with pytest.warns(W39), np.errstate(over="ignore"):
Expand Down Expand Up @@ -267,7 +264,6 @@ def test_iter_coosys(self):
pytest.param(["c1", "string_test", "c2"], ["c1", "c2"], id="list-only-missing"),
],
)
@pytest.mark.usefixtures("without_legacy_printoptions")
def test_select_missing_columns_error_message(columns, expected_missing):
# see https://github.com/astropy/astropy/pull/15956
filename = get_pkg_data_filename("data/regression.xml")
Expand Down Expand Up @@ -461,7 +457,6 @@ def test_long(self):
)
assert_array_equal(self.mask["long"], [False, True, False, False, True])

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_double(self):
assert issubclass(self.array["double"].dtype.type, np.float64)
assert_array_equal(
Expand Down Expand Up @@ -642,7 +637,6 @@ def test_nulls_array(self):
],
)

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_double_array(self):
assert issubclass(self.array["doublearray"].dtype.type, np.object_)
assert len(self.array["doublearray"][0]) == 0
Expand Down Expand Up @@ -698,7 +692,6 @@ def test_get_info_by_id(self):
info = self.votable.get_info_by_id("ErrorInfo")
assert info.value == "One might expect to find some INFO here, too..."

@pytest.mark.usefixtures("without_legacy_printoptions")
def test_repr(self):
assert "3 tables" in repr(self.votable)
assert (
Expand Down Expand Up @@ -877,7 +870,6 @@ def test_too_many_columns():
parse(get_pkg_data_filename("data/too_many_columns.xml.gz"))


@pytest.mark.usefixtures("without_legacy_printoptions")
def test_build_from_scratch(tmp_path):
# Create a new VOTable file...
votable = tree.VOTableFile()
Expand Down
8 changes: 4 additions & 4 deletions astropy/stats/info_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def bayesian_info_criterion(log_likelihood, n_params, n_samples):
>>> bic_g = bayesian_info_criterion(lnL_g, n_params_g, n_samples)
>>> bic_t = bayesian_info_criterion(lnL_t, n_params_t, n_samples)
>>> bic_g - bic_t # doctest: +FLOAT_CMP
2.1948298140119391
np.float64(2.1948298140119391)

Therefore, there exist a moderate evidence that the increasing in
likelihood for t-Student model is due to the larger number of parameters.
Expand Down Expand Up @@ -385,11 +385,11 @@ def akaike_info_criterion_lsq(ssr, n_params, n_samples):
>>> ssr_g2 = np.sum((g2_fit(x) - y)**2.0)
>>> ssr_g1 = np.sum((g1_fit(x) - y)**2.0)
>>> akaike_info_criterion_lsq(ssr_g3, 9, x.shape[0]) # doctest: +FLOAT_CMP
-634.5257517810961
np.float64(-634.5257517810961)
>>> akaike_info_criterion_lsq(ssr_g2, 6, x.shape[0]) # doctest: +FLOAT_CMP
-662.83834510232043
np.float64(-662.83834510232043)
>>> akaike_info_criterion_lsq(ssr_g1, 3, x.shape[0]) # doctest: +FLOAT_CMP
-647.47312032659499
np.float64(-647.47312032659499)

Hence, from the AIC values, we would prefer to choose the model g2_fit.
However, we can considerably support the model g3_fit, since the
Expand Down
6 changes: 3 additions & 3 deletions astropy/stats/jackknife.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ def jackknife_stats(data, statistic, confidence_level=0.95):
>>> estimate, bias, stderr, conf_interval = jackknife_stats(
... data, test_statistic, 0.95)
>>> estimate
4.5
np.float64(4.5)
>>> bias
0.0
np.float64(0.0)
Comment thread
mhvk marked this conversation as resolved.
Resolved
>>> stderr # doctest: +FLOAT_CMP
0.95742710775633832
np.float64(0.95742710775633832)
>>> conf_interval
array([2.62347735, 6.37652265])

Expand Down
Loading