Skip to content

Commit

Permalink
Merge pull request #239 from neutrinoceros/dep/drop_cp38
Browse files Browse the repository at this point in the history
DEP: drop support for CPython 3.8 and 3.9
  • Loading branch information
neutrinoceros authored Feb 11, 2025
2 parents 3ccae0d + 2f8a71a commit af9b0a1
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- macos-latest
- windows-latest
python-version:
- '3.8'
- '3.10'
- '3.13'

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
with:
# Match minimal supported Python version
# to make sure we're not using unparseable syntax
python-version: '3.8'
python-version: '3.10'

- name: Build
run: |
Expand Down
3 changes: 1 addition & 2 deletions amical/_cli/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from argparse import ArgumentParser
from typing import List, Optional

from amical._cli.commands.calibrate import perform_calibrate
from amical._cli.commands.clean import perform_clean
from amical._cli.commands.extract import perform_extract


def main(argv: Optional[List[str]] = None) -> int:
def main(argv: list[str] | None = None) -> int:
parser = ArgumentParser()

subparsers = parser.add_subparsers(dest="command")
Expand Down
5 changes: 3 additions & 2 deletions amical/_rich_display.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any, List, Sequence
from collections.abc import Sequence
from typing import Any

from astropy.table import Table


def tabulate(rows: Sequence[Any], headers: List[str]) -> Table:
def tabulate(rows: Sequence[Any], headers: list[str]) -> Table:
# a drop-in replacement for tabulate.tabulate
data = {name: [row[i] for row in rows] for i, name in enumerate(headers)}
return Table(data)
9 changes: 4 additions & 5 deletions amical/analysis/easy_candid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import List, Optional, Union

import numpy as np
from rich import print as rprint
Expand All @@ -8,20 +7,20 @@


def candid_grid(
input_data: Union[str, List[str]],
input_data: str | list[str],
step: int = 10,
rmin: float = 20,
rmax: float = 400,
diam: float = 0,
obs: Optional[List[str]] = None,
obs: list[str] | None = None,
extra_error_cp: float = 0,
err_scale: float = 1,
extra_error_v2: float = 0,
instruments=None,
doNotFit=None,
ncore: int = 1,
save: bool = False,
outputfile: Optional[str] = None,
outputfile: str | None = None,
verbose: bool = False,
):
"""This function is an user friendly interface between the users of amical
Expand Down Expand Up @@ -145,7 +144,7 @@ def candid_grid(


def candid_cr_limit(
input_data: Union[str, List[str]],
input_data: str | list[str],
step: int = 10,
rmin: float = 20,
rmax: float = 400,
Expand Down
7 changes: 0 additions & 7 deletions amical/analysis/fitting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import multiprocessing
import os
import sys

import numpy as np
from rich.progress import track
Expand All @@ -10,12 +9,6 @@
from amical.dpfit import leastsqFit
from amical.tools import mas2rad, roundSciDigit

if sys.platform == "darwin":
multiprocessing.set_start_method(
"fork", force=True
) # this fixes loop in python 3.8 on MacOS


err_pts_style = {
"linestyle": "None",
"capsize": 1,
Expand Down
5 changes: 0 additions & 5 deletions amical/externals/candid/candid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

import numpy as np

if sys.platform == "darwin":
multiprocessing.set_start_method(
"fork", force=True
) # this fixes loop in python 3.8 on MacOS

# -- defunct ;(
# from scipy import weave
# from scipy.weave import converters
Expand Down
5 changes: 0 additions & 5 deletions amical/externals/pymask/cp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

import numpy as np

if sys.platform == "darwin":
multiprocessing.set_start_method(
"fork", force=True
) # this fixes loop in python 3.8 on MacOS


"""------------------------------------------------------------------------
cp_tools.py - a collection of functions useful for closure phase analysis
Expand Down
6 changes: 1 addition & 5 deletions amical/get_infos_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
--------------------------------------------------------------------
"""

import importlib.resources as importlib_resources
import sys

import numpy as np
from rich import print as rprint

from amical.tools import mas2rad

if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
import importlib_resources


def get_mask(ins, mask, first=0):
"""Return dictionnary containning saved informations about masks."""
Expand Down
2 changes: 1 addition & 1 deletion amical/mf_pipeline/ami_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def make_mf(
f"channel index `i_wl` must be specified (nlambda = {len(filt)}) and "
"should be strictly identical to the one used for the cleaning step."
)
if isinstance(i_wl, (int, np.integer)):
if isinstance(i_wl, int | np.integer):
filt = [filt[i_wl], 0.001 * filt[i_wl]]
else:
filt = [np.mean(filt[i_wl[0] : i_wl[1]]), filt[i_wl[1]] - filt[i_wl[0]]]
Expand Down
7 changes: 5 additions & 2 deletions amical/oifits.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def save(
if not isinstance(observables, list):
observables = [observables]

if not isinstance(origin, (str, type(None))):
if not isinstance(origin, str | type(None)):
raise TypeError("origin should be a str or None")

l_dic = []
Expand Down Expand Up @@ -1268,7 +1268,10 @@ def show(
ax1.yaxis.set_ticks_position("none")
if diffWl:
handles, labels = ax1.get_legend_handles_labels()
labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0]))
labels, handles = zip(
*sorted(zip(labels, handles, strict=False), key=lambda t: t[0]),
strict=False,
)
ax1.legend(handles, labels, loc="best", fontsize=9)

plt.text(
Expand Down
5 changes: 3 additions & 2 deletions amical/tests/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ def test_clean_data_bmap_3d():

cleaned = clean_data(data, sky=False, apod=False, bad_map=bad_cube)
nobpix_list = [
fix_bad_pixels(img, bad_map=bmap) for img, bmap in zip(data, bad_cube)
fix_bad_pixels(img, bad_map=bmap)
for img, bmap in zip(data, bad_cube, strict=False)
]

assert np.all([cleaned[i] == nobpix_list[i] for i in range(data.shape[0])])
Expand Down Expand Up @@ -476,7 +477,7 @@ def test_clean_data_bmap_3d_add_bad_2d():
cleaned = clean_data(data, sky=False, apod=False, bad_map=bad_cube, add_bad=add_bad)
nobpix_list = [
fix_bad_pixels(img, bad_map=bmap, add_bad=add_bad)
for img, bmap in zip(data, bad_cube)
for img, bmap in zip(data, bad_cube, strict=False)
]

full_bad_cube = bad_cube.copy()
Expand Down
2 changes: 1 addition & 1 deletion amical/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def plot_circle(d, x, y, hole_radius, sz=1, display=True):
im = np.zeros([chipsz, chipsz])
info = [len(im.shape), im.shape[0], im.shape[1], 3, len(im.ravel())]

if isinstance(x, (float, int)):
if isinstance(x, float | int):
n_circ = 1
xx = [x]
yy = [y]
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Astronomy",
"Typing :: Typed",
]
requires-python = ">=3.8"
requires-python = ">=3.10"
dependencies = [
"astropy>=5.0",
"astroquery",
Expand All @@ -33,7 +33,6 @@ dependencies = [
"rich>=13.5.2",
"scipy",
"uncertainties",
"importlib_resources>=1.3; python_version < '3.9'",
]

[project.readme]
Expand Down Expand Up @@ -113,7 +112,7 @@ omit = [
]

[tool.mypy]
python_version = 3.8
python_version = "3.10"
ignore_missing_imports = true
warn_unused_configs = true
warn_unused_ignores = true
Expand Down

0 comments on commit af9b0a1

Please sign in to comment.