Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Drop python 3.7 #64

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
File renamed without changes.
8 changes: 4 additions & 4 deletions .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
# that gives too many false positives due to URL timeouts. We also
# install all dependencies via pip here so we pick up the latest
# releases.
- name: Python 3.7 with dev version of key dependencies
- name: Python 3.8 with dev version of key dependencies
os: ubuntu-latest
python: 3.7
toxenv: py37-test-devdeps
python: 3.8
toxenv: py38-test-devdeps

- name: Documentation link check
os: ubuntu-latest
python: 3.7
python: 3.8
toxenv: linkcheck

- name: Bundling with pyinstaller
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,25 @@ jobs:
matrix:
include:

- name: py3.8 - all deps, remote data | coverage
- name: py3.9 - all deps, remote data | coverage
os: ubuntu-latest
python: 3.8
toxenv: py38-test-alldeps-cov
python: 3.9
toxenv: py39-test-alldeps-cov
toxargs: -v --develop
toxposargs: --durations=50 --remote-data=any # in case it runs long

# NOTE: In the build below we also check that tests do not open and
# leave open any files. This has a performance impact on running the
# tests, hence why it is not enabled by default.
- name: py3.7 - oldest deps
- name: py3.8 - oldest deps
os: ubuntu-16.04
python: 3.7
toxenv: py37-test-oldestdeps
python: 3.8
toxenv: py38-test-oldestdeps

- name: py3.7 - all deps, numpy 1.17 | coverage
- name: py3.8 - all deps, numpy 1.17 | coverage
os: ubuntu-latest
python: 3.7
toxenv: py37-test-alldeps-numpy117-cov-clocale
python: 3.8
toxenv: py38-test-alldeps-numpy117-cov-clocale
# toxposargs: --remote-data=discO

- name: py3.8 - all deps (MacOS X)
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:

matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.7, 3.8]
python: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ repos:
- id: script-must-not-have-extension
- id: shfmt

- repo: https://github.com/mgedmin/check-manifest
rev: "0.46"
hooks:
- id: check-manifest

- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
hooks:
Expand All @@ -68,7 +63,7 @@ repos:
- id: flake8
args: # arguments to configure flake8
# making isort line length compatible with black
- "--max-line-length=88"
- "--max-line-length=100"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"

Expand Down
8 changes: 5 additions & 3 deletions discO/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
# IMPORTS

# keep this content at the top. (sets the __version__)
from ._astropy_init import * # noqa: F401, F403 # isort:skip
from ._astropy_init import __version__ # noqa: F401 # isort:skip
from ._astropy_init import * # noqa: F401, F403 # isort: skip
from ._astropy_init import __version__ # noqa: F401 # isort: skip

# PROJECT-SPECIFIC
from . import setup_package # noqa: F401 # isort: skip

# LOCAL
from . import core, data, plugin
from .config import conf
from .core import * # noqa: F401, F403
Expand Down
7 changes: 4 additions & 3 deletions discO/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@
_ASTROPY_SETUP_ # type: ignore
except NameError:
# BUILT-IN
# STDLIB
import builtins

builtins._ASTROPY_SETUP_ = False

try:
# PROJECT-SPECIFIC
# LOCAL
from .version import version as __version__
except ImportError:
__version__ = ""


if not _ASTROPY_SETUP_: # noqa: F403
# BUILT-IN
# STDLIB
import os
from warnings import warn

Expand Down Expand Up @@ -63,8 +65,7 @@
update_default_config(__package__, config_dir)
except ConfigurationDefaultMissingError as e:
wmsg = (
e.args[0]
+ " Cannot install default profile. If you are "
e.args[0] + " Cannot install default profile. If you are "
"importing from source, this is expected."
)
warn(ConfigurationDefaultMissingWarning(wmsg))
Expand Down
43 changes: 30 additions & 13 deletions discO/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
##############################################################################
# IMPORTS

# BUILT-IN
# STDLIB
import configparser
import importlib
import os

# THIRD PARTY
import pytest

# PROJECT-SPECIFIC
# LOCAL
from .setup_package import HAS_AGAMA, HAS_GALA, HAS_GALPY

try:
# THIRD PARTY
from pytest_astropy_header.display import (
PYTEST_HEADER_MODULES,
TESTED_VERSIONS,
)
from pytest_astropy_header.display import PYTEST_HEADER_MODULES # noqa: F401
from pytest_astropy_header.display import TESTED_VERSIONS

ASTROPY_HEADER = True
except ImportError:
Expand Down Expand Up @@ -57,6 +57,29 @@
SKIP_NO_GALPY = pytest.mark.skipif(not HAS_GALPY, reason="needs galpy")
if not HAS_GALPY:
collect_ignore.append("plugin/galpy/")
else:
# THIRD PARTY
import galpy

importlib.reload(galpy)

# THIRD PARTY
from galpy.util import config as galpy_config

# configuration
galpy_config._APY_LOADED = True
galpy_config.__config__.set("astropy", "astropy-units", "True")
galpy_config.__config__.set("astropy", "astropy-coords", "True")

if ".tmp" in os.getcwd():

# write config and read it
cfilename = os.path.join(os.path.expanduser("~"), ".galpyrc")
galpy_config.write_config(cfilename, galpy_config.__config__)

__config__ = configparser.ConfigParser()
__config__.read(cfilename)
galpy_config.__config__ = __config__


# ------------------------------------------------------
Expand All @@ -74,13 +97,7 @@ def pytest_configure(config):

config.option.astropy_header = True

# Customize the following lines to add/remove entries from the list of
# packages for which version numbers are displayed when running the
# tests.
PYTEST_HEADER_MODULES.pop("Pandas", None)
PYTEST_HEADER_MODULES["scikit-image"] = "skimage"

# PROJECT-SPECIFIC
# LOCAL
from . import __version__

packagename = os.path.basename(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion discO/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# IMPORTS
# flatten structure

# PROJECT-SPECIFIC
# LOCAL
from . import fitter, measurement, pipeline, residual, sample
from .fitter import * # noqa: F401, F403
from .measurement import * # noqa: F401, F403
Expand Down
10 changes: 3 additions & 7 deletions discO/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##############################################################################
# IMPORTS

# BUILT-IN
# STDLIB
import inspect
import typing as T
from abc import ABCMeta, abstractmethod
Expand All @@ -22,7 +22,7 @@
from astropy.utils.decorators import classproperty
from astropy.utils.introspection import resolve_name

# PROJECT-SPECIFIC
# LOCAL
import discO.type_hints as TH

##############################################################################
Expand Down Expand Up @@ -137,11 +137,7 @@ def registry(cls) -> T.Mapping:

# else, filter registry by subclass
return MappingProxyType(
{
k: v
for k, v in cls._registry.items()
if issubclass(v, cls) and v is not cls
},
{k: v for k, v in cls._registry.items() if issubclass(v, cls) and v is not cls},
)

# /def
Expand Down
16 changes: 5 additions & 11 deletions discO/core/fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@
##############################################################################
# IMPORTS

# BUILT-IN
# STDLIB
import abc
import typing as T
from types import MappingProxyType, ModuleType

# THIRD PARTY
import numpy as np

# PROJECT-SPECIFIC
# LOCAL
import discO.type_hints as TH
from .common import CommonBase
from discO.utils.coordinates import (
resolve_framelike,
resolve_representationlike,
)
from discO.utils.coordinates import resolve_framelike, resolve_representationlike
from discO.utils.pbar import get_progress_bar

##############################################################################
Expand Down Expand Up @@ -114,16 +111,13 @@ def __new__(

if key not in cls._registry:
raise ValueError(
"PotentialFitter has no registered fitter for key: "
f"{key}",
"PotentialFitter has no registered fitter for key: " f"{key}",
)

# from registry. Registered in __init_subclass__
kls = cls._registry[key]
kwargs.pop("key", None) # it's already used.
return kls.__new__(
kls, potential_cls=potential_cls, key=None, **kwargs
)
return kls.__new__(kls, potential_cls=potential_cls, key=None, **kwargs)

elif key is not None:
raise ValueError(
Expand Down
34 changes: 9 additions & 25 deletions discO/core/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
##############################################################################
# IMPORTS

# BUILT-IN
# STDLIB
import abc
import copy
import inspect
Expand All @@ -37,15 +37,10 @@
import astropy.units as u
import numpy as np
import scipy.stats
from astropy.coordinates import (
BaseCoordinateFrame,
BaseRepresentation,
SkyCoord,
concatenate,
)
from astropy.coordinates import BaseCoordinateFrame, BaseRepresentation, SkyCoord, concatenate
from astropy.utils.decorators import classproperty

# PROJECT-SPECIFIC
# LOCAL
import discO.type_hints as TH
from .common import CommonBase
from .sample import RandomLike # TODO move to type-hints
Expand Down Expand Up @@ -173,8 +168,7 @@ def __new__(

elif method is not None:
raise ValueError(
f"Can't specify 'method' on {cls},"
" only on MeasurementErrorSampler.",
f"Can't specify 'method' on {cls}," " only on MeasurementErrorSampler.",
)

return super().__new__(cls)
Expand Down Expand Up @@ -398,9 +392,7 @@ def _run_batch(
else: # (Nsamples, Niter)

samples = list(
self._run_iter(
c, c_err=c_err, random=random, progress=progress, **kwargs
),
self._run_iter(c, c_err=c_err, random=random, progress=progress, **kwargs),
)

sample = concatenate(samples).reshape(c.shape)
Expand Down Expand Up @@ -457,9 +449,7 @@ def run(
if not isinstance(random, np.random.RandomState):
random = np.random.RandomState(random)

return run_func(
c, c_err=c_err, random=random, progress=progress, **kwargs
)
return run_func(c, c_err=c_err, random=random, progress=progress, **kwargs)

# /def

Expand Down Expand Up @@ -698,15 +688,12 @@ def __new__(
# a cleaner error than KeyError on the actual registry
if not cls._in_registry(method):
raise ValueError(
"RVS_Continuous has no registered "
f"measurement resampler '{method}'",
"RVS_Continuous has no registered " f"measurement resampler '{method}'",
)

# from registry. Registered in __init_subclass__
# don't pass rvs, b/c not all subclasses take it
return super().__new__(
cls[method], c_err=c_err, method=None, **kwargs
)
return super().__new__(cls[method], c_err=c_err, method=None, **kwargs)

elif method is not None:
raise ValueError(
Expand Down Expand Up @@ -846,10 +833,7 @@ def __call__(

# re-build representation
new_rep = rep.__class__(
**{
n: attr_classes[n](p * unit)
for p, (n, unit) in zip(new_posT, units.items())
}
**{n: attr_classes[n](p * unit) for p, (n, unit) in zip(new_posT, units.items())}
)
# make coordinate
new_cc = self.frame.realize_frame(
Expand Down
4 changes: 2 additions & 2 deletions discO/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
##############################################################################
# IMPORTS

# BUILT-IN
# STDLIB
import typing as T
import weakref

Expand All @@ -21,7 +21,7 @@
import numpy as np
import typing_extensions as TE

# PROJECT-SPECIFIC
# LOCAL
import discO.type_hints as TH
from .fitter import PotentialFitter
from .measurement import CERR_Type, MeasurementErrorSampler
Expand Down
Loading