Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install language-pack-fr tzdata
sudo apt-get install language-pack-fr tzdata libopenblas-dev
- name: Install tox
run: python -m pip install --upgrade tox
- name: Run tests
Expand All @@ -120,10 +120,10 @@ jobs:
fail-fast: false
matrix:
include:
- name: (Allowed Failure) Python 3.8 with remote data and dev version of key dependencies
- name: (Allowed Failure) Python 3.11 with remote data and dev version of key dependencies
os: ubuntu-latest
python: 3.8
toxenv: py38-test-devdeps
python: '3.11.0-rc.2'
Comment thread
Cadair marked this conversation as resolved.
Resolved
toxenv: py311-test-devdeps
toxposargs: --remote-data=any

steps:
Expand Down
7 changes: 5 additions & 2 deletions astropy/cosmology/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
# LOCAL
import astropy.cosmology.units as cu
import astropy.units as u
from astropy.cosmology import Cosmology, CosmologyError, FlatCosmologyMixin
from astropy.cosmology import Cosmology, FlatCosmologyMixin
from astropy.cosmology.core import _COSMOLOGY_CLASSES
from astropy.cosmology.parameter import Parameter
from astropy.table import Column, QTable, Table
from astropy.utils.compat import PYTHON_LT_3_11
from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.utils.metadata import MetaData

Expand Down Expand Up @@ -197,7 +198,9 @@ def test_name(self, cosmo):
assert cosmo.name == self.cls_kwargs["name"] # test has expected value

# immutable
with pytest.raises(AttributeError, match="can't set"):
match = ("can't set" if PYTHON_LT_3_11
else f"property 'name' of {cosmo.__class__.__name__!r} object has no setter")
with pytest.raises(AttributeError, match=match):
cosmo.name = None

def test_is_flat(self, cosmo_cls, cosmo):
Expand Down
20 changes: 12 additions & 8 deletions astropy/io/ascii/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,17 +1088,21 @@ def _convert_vals(self, cols):
try:
col.data = converter_func(col.str_vals)
col.type = converter_type
except (TypeError, ValueError) as err:
col.converters.pop(0)
last_err = err
except OverflowError as err:
except (OverflowError, TypeError, ValueError) as err:
# Overflow during conversion (most likely an int that
# doesn't fit in native C long). Put string at the top of
# the converters list for the next while iteration.
warnings.warn(
"OverflowError converting to {} in column {}, reverting to String."
.format(converter_type.__name__, col.name), AstropyWarning)
col.converters.insert(0, convert_numpy(numpy.str))
# With python/cpython#95778 this has been supplemented with a
# "ValueError: Exceeds the limit (4300) for integer string conversion"
# so need to catch that as well.
if isinstance(err, OverflowError) or (isinstance(err, ValueError) and
str(err).startswith('Exceeds the limit')):
warnings.warn(
f'OverflowError converting to {converter_type.__name__} in column '
f'{col.name}, reverting to String.', AstropyWarning)
col.converters.insert(0, convert_numpy(numpy.str))
else:
col.converters.pop(0)
last_err = err


Expand Down
13 changes: 9 additions & 4 deletions astropy/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import sys
import pickle
import inspect
import warnings
import functools

Expand All @@ -15,7 +16,7 @@
from astropy.utils.decorators import deprecated
from astropy.utils.exceptions import (AstropyDeprecationWarning,
AstropyPendingDeprecationWarning)

from astropy.utils.compat import PYTHON_LT_3_11

# For backward-compatibility with affiliated packages
from .runner import TestRunner # pylint: disable=W0611 # noqa
Expand Down Expand Up @@ -409,11 +410,15 @@ def generic_recursive_equality_test(a, b, class_history):
Check if the attributes of a and b are equal. Then,
check if the attributes of the attributes are equal.
"""
dict_a = a.__getstate__() if hasattr(a, '__getstate__') else a.__dict__
if PYTHON_LT_3_11:
dict_a = a.__getstate__() if hasattr(a, '__getstate__') else a.__dict__
else:
# NOTE: The call may need to be adapted if other objects implementing a __getstate__
# with required argument(s) are passed to this function.
dict_a = a.__getstate__(a) if inspect.isclass(a) else a.__getstate__()
dict_b = b.__dict__
for key in dict_a:
assert key in dict_b,\
f"Did not pickle {key}"
assert key in dict_b, f"Did not pickle {key}"

if dict_a[key].__class__.__eq__ is not object.__eq__:
# Only compare if the class defines a proper equality test.
Expand Down
9 changes: 7 additions & 2 deletions astropy/time/tests/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from astropy import units as u
from astropy.utils import iers
from astropy.utils.compat import PYTHON_LT_3_11
from astropy.time import Time
from astropy.table import Table
from astropy.utils.compat.optional_deps import HAS_H5PY
Expand All @@ -15,6 +16,11 @@
atol=2. ** -52 * 24 * 3600) # 20 ps atol
is_masked = np.ma.is_masked

# The first form is expanded to r"can't set attribute '{0}'" in Python 3.10, and replaced
# with the more informative second form as of 3.11 (python/cpython#31311).
no_setter_err = (r"can't set attribute" if PYTHON_LT_3_11
else r"property '{0}' of '{1}' object has no setter")


def test_simple():
t = Time([1, 2, 3], format='cxcsec')
Expand Down Expand Up @@ -47,9 +53,8 @@ def test_scalar_init():

def test_mask_not_writeable():
t = Time('2000:001')
with pytest.raises(AttributeError) as err:
with pytest.raises(AttributeError, match=no_setter_err.format('mask', t.__class__.__name__)):
t.mask = True
assert "can't set attribute" in str(err.value)

t = Time(['2000:001'])
with pytest.raises(ValueError) as err:
Expand Down
5 changes: 4 additions & 1 deletion astropy/utils/compat/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

from astropy.utils.decorators import deprecated

__all__ = ['override__dir__', 'possible_filename']
__all__ = ["override__dir__", "possible_filename",
"PYTHON_LT_3_11"]

PYTHON_LT_3_11 = sys.version_info < (3, 11)


def possible_filename(filename):
Expand Down
1 change: 1 addition & 0 deletions docs/changes/13614.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compatibility with Python 3.11, 3.10.7, 3.9.14, 3.8.14
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{38,39,310,dev}-test{,-image,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy118,-numpy119,-numpy120,-numpy121,-mpl311}{,-cov}{,-clocale}
py{38,39,310,311,dev}-test{,-image,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy118,-numpy119,-numpy120,-numpy121,-mpl311}{,-cov}{,-clocale}
build_docs
linkcheck
codestyle
Expand Down Expand Up @@ -28,6 +28,7 @@ setenv =
!image: MPLFLAGS =
clocale: LC_CTYPE = C.ascii
clocale: LC_ALL = C
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scipy-wheels-nightly/simple

# Run the tests in a temporary directory to make sure that we don't import
# astropy from the source tree
Expand Down Expand Up @@ -87,7 +88,9 @@ deps =
# The devdeps factor is intended to be used to install the latest developer version
# or nightly wheel of key dependencies.
# Do not install asdf-astropy so we can test astropy.io.misc.asdf until we remove it.
devdeps,mpldev: git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib
devdeps: scipy>=0.0.dev0
devdeps: numpy>=0.0.dev0
devdeps,mpldev: matplotlib>=0.0.dev0

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.

@Cadair , this picked up matplotlib 3.6.0rc2 , not a dev version. Is this supposed to happen?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmmm where?

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.

devdeps: git+https://github.com/asdf-format/asdf.git#egg=asdf
devdeps: git+https://github.com/liberfa/pyerfa.git#egg=pyerfa

Expand All @@ -112,8 +115,6 @@ extras =
alldeps: test_all

commands =
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
pip freeze
!cov-!double: pytest --pyargs astropy {toxinidir}/docs {env:MPLFLAGS} {posargs}
cov-!double: pytest --pyargs astropy {toxinidir}/docs {env:MPLFLAGS} --cov astropy --cov-config={toxinidir}/pyproject.toml {posargs}
Expand Down