Skip to content

Commit

Permalink
Bump min Python to 3.11 per SPEC 0 (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson authored Dec 3, 2024
1 parent e43b7fc commit 313bedd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ jobs:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
with:
envs: |
- linux: py310-oldestdeps-cov
- linux: py311-oldestdeps-cov
coverage: codecov
- linux: py310
- linux: py311-cov
coverage: codecov
- linux: py312-withromancal-cov
coverage: codecov
- linux: py313
- macos: py311
- macos: py312
test_upstream:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@d68193b68216da64eafaa618f53c59f5d271c56e # v1.14.0
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
if: (github.repository == 'spacetelescope/roman_datamodels' && (github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Weekly CI')))
with:
envs: |
- macos: py310
- linux: py312-devdeps
- macos: py311
- linux: py313-devdeps
1 change: 1 addition & 0 deletions changes/432.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump min Python version to 3.11 per SPEC 0.
7 changes: 1 addition & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
import importlib
import os
import sys
import tomllib
from distutils.version import LooseVersion
from pathlib import Path

import sphinx

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
name = "roman_datamodels"
description = "data models supporting calibration of the Nancy Grace Roman Space Telescope"
readme = "README.md"
requires-python = ">=3.10"
authors = [{ name = "STScI", email = "help@stsci.edu" }]
requires-python = ">=3.11"
authors = [
{ name = "STScI", email = "help@stsci.edu" },
]
classifiers = [
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Astronomy",
Expand Down Expand Up @@ -32,13 +34,11 @@ test = [
"pytest-doctestplus >=1.2.1",
"pytest-env >= 0.8",
]
aws = ["stsci-aws-utils >= 0.1.2"]
docs = [
"sphinx",
"sphinx-automodapi",
"sphinx-rtd-theme",
"sphinx-astropy",
"tomli; python_version <\"3.11\"",
]

[project.urls]
Expand All @@ -49,7 +49,10 @@ repository = "https://github.com/spacetelescope/roman_datamodels"
roman_datamodels = "roman_datamodels.stnode._integration:get_extensions"

[build-system]
requires = ["setuptools >=61", "setuptools_scm[toml] >=3.4", "wheel"]
requires = [
"setuptools >=61",
"setuptools_scm[toml] >=3.4",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
Expand Down
16 changes: 4 additions & 12 deletions src/roman_datamodels/dqflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,16 @@
the formula `2**bit_number` where `bit_number` is the 0-index bit of interest.
"""

import sys
from enum import unique

# Something with pickling of multiclassed enums was changed in 3.11 + allowing
# us to directly us `np.uint32` as the enum object rather than a python `int`.
if sys.version_info < (3, 11):
from enum import IntEnum
else:
from enum import Enum

import numpy as np
from enum import Enum, unique

class IntEnum(np.uint32, Enum): ...
import numpy as np


# fmt: off
@unique
class pixel(IntEnum):
class pixel(np.uint32, Enum):
"""Pixel-specific data quality flags"""

GOOD = 0 # No bits set, all is good
Expand Down Expand Up @@ -74,7 +66,7 @@ class pixel(IntEnum):


@unique
class group(IntEnum):
class group(np.uint32, Enum):
"""Group-specific data quality flags
Once groups are combined, these flags are equivalent to the pixel-specific flags.
"""
Expand Down
11 changes: 2 additions & 9 deletions tests/test_dqflags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from math import log10

import numpy as np
Expand Down Expand Up @@ -32,10 +31,7 @@ def test_pixel_flags(flag):
assert isinstance(flag, dqflags.pixel)

# Test that the pixel flags are ints
if sys.version_info < (3, 11):
assert isinstance(flag, int)
else:
assert isinstance(flag, np.uint32)
assert isinstance(flag, np.uint32)

# Test that the pixel flags are dict accessible
assert dqflags.pixel[flag.name] is flag
Expand Down Expand Up @@ -83,10 +79,7 @@ def test_group_flags(flag):
assert isinstance(flag, dqflags.group)

# Test that the group flags are ints
if sys.version_info < (3, 11):
assert isinstance(flag, int)
else:
assert isinstance(flag, np.uint32)
assert isinstance(flag, np.uint32)

# Test that the group flags are dict accessible
assert dqflags.group[flag.name] is flag
Expand Down

0 comments on commit 313bedd

Please sign in to comment.