From dfa4258917493dc88fac0ebc7dc803c30028d758 Mon Sep 17 00:00:00 2001 From: "Karl D. Gordon" Date: Tue, 28 Nov 2023 15:34:37 -0500 Subject: [PATCH 1/3] tox update, removing deprecated, fix URLs --- .github/workflows/tox-tests.yml | 53 +++++++++++++++++---------------- .readthedocs.yml | 18 +++++++++++ README.rst | 6 +--- docs/index.rst | 2 +- megabeast/_astropy_init.py | 52 -------------------------------- readthedocs.yml | 9 ------ tox.ini | 25 ++-------------- 7 files changed, 51 insertions(+), 114 deletions(-) create mode 100644 .readthedocs.yml delete mode 100644 megabeast/_astropy_init.py delete mode 100644 readthedocs.yml diff --git a/.github/workflows/tox-tests.yml b/.github/workflows/tox-tests.yml index de205ff..eb2d3ba 100644 --- a/.github/workflows/tox-tests.yml +++ b/.github/workflows/tox-tests.yml @@ -23,10 +23,13 @@ jobs: # Github actions supports ubuntu, windows, and macos virtual environments: # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners # - os: [ubuntu-latest, macos-latest, windows-latest] + # Only run on ubuntu by default, but can add other os's to the test matrix here. + # For example -- os: [ubuntu-latest, macos-latest, windows-latest] + # windows-latest not possible due to how temp files are used in tests currently + os: [ubuntu-latest, macos-latest] - # Test python 3.7, and 3.8 by default. - python-ver: [7, 8, 9, 10] + # Test python version 3.x + python-ver: [9, 10, 11] # Specify which tox environments to test in this list. # tox-env: [cov, alldeps, devdeps, astropylts] @@ -46,22 +49,22 @@ jobs: tox -e py3${{ matrix.python-ver }}-${{ matrix.tox-env }} # Dev version test - dev_test: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - steps: - - uses: actions/checkout@v1 - - name: Set up python for astropy, numpy dev test - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install base dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox - - name: Test with tox - run: | - tox -e py38-devdeps + # dev_test: + # runs-on: ubuntu-latest + # if: "!contains(github.event.head_commit.message, '[ci skip]')" + # steps: + # - uses: actions/checkout@v1 + # - name: Set up python for astropy, numpy dev test + # uses: actions/setup-python@v1 + # with: + # python-version: 3.8 + # - name: Install base dependencies + # run: | + # python -m pip install --upgrade pip + # python -m pip install tox + # - name: Test with tox + # run: | + # tox -e py38-devdeps # LTS version test lts_test: @@ -72,14 +75,14 @@ jobs: - name: Set up python for astropy lts test uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Install base dependencies run: | python -m pip install --upgrade pip python -m pip install tox - name: Test with tox run: | - tox -e py38-astropylts + tox -e py39-astropylts # Coverage test cov_test: @@ -90,14 +93,14 @@ jobs: - name: Set up python for coverage test uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.11 - name: Install base dependencies run: | python -m pip install --upgrade pip python -m pip install tox - name: Test with tox run: | - tox -e py38-cov + tox -e py311-cov - name: Upload coverage to codecov uses: codecov/codecov-action@v1 with: @@ -120,7 +123,7 @@ jobs: - name: Set up Python to build docs with sphinx uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.11 - name: Install base dependencies run: | python -m pip install --upgrade pip @@ -140,7 +143,7 @@ jobs: - name: Python codestyle check uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.11 - name: Install base dependencies run: | python -m pip install --upgrade pip diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..8b77653 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,18 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.12" + +python: + install: + - method: pip + path: . + extra_requirements: + - docs + - all + +# Don't build any extra formats +formats: [] + diff --git a/README.rst b/README.rst index 0a5fe73..0acf1e7 100644 --- a/README.rst +++ b/README.rst @@ -27,10 +27,6 @@ Build checks/status :target: https://codecov.io/gh/BEAST-Fitting/megabeast :alt: Test Coverage Status -.. image:: https://img.shields.io/lgtm/grade/python/g/BEAST-Fitting/megabeast.svg?logo=lgtm&logoWidth=18 - :target: https://lgtm.com/projects/g/BEAST-Fitting/megabeast/context:python - :alt: LGTM language grade: Python - .. image:: https://api.codacy.com/project/badge/Grade/584c9ed581c6457381d01a4e86e08916 :target: https://www.codacy.com/manual/kgordon/megabeast?utm_source=github.com&utm_medium=referral&utm_content=karllark/megabeast&utm_campaign=Badge_Grade :alt: Codacy Badge @@ -81,5 +77,5 @@ more information. .. _AstroPy: http://www.astropy.org/ .. _contributing: http://docs.astropy.org/en/stable/index.html#contributing -.. _developer: http://docs.astropy.org/en/stable/index.html#developer-documentation +.. _developer: https://docs.astropy.org/en/stable/index_dev.html .. _Astropy Code of Conduct: http://www.astropy.org/about.html#codeofconduct diff --git a/docs/index.rst b/docs/index.rst index 01ddb5e..a012080 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -58,7 +58,7 @@ fixes, code, or documentation (no git or GitHub experience necessary): * `Coding Guidelines `_ -* `Developer Documentation `_ +* `Developer Documentation `_ For the complete list of contributors please see the `megabeast diff --git a/megabeast/_astropy_init.py b/megabeast/_astropy_init.py deleted file mode 100644 index 327db6c..0000000 --- a/megabeast/_astropy_init.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -__all__ = ['__version__'] - -# this indicates whether or not we are in the package's setup.py -try: - _ASTROPY_SETUP_ -except NameError: - import builtins - builtins._ASTROPY_SETUP_ = False - -try: - from .version import version as __version__ -except ImportError: - __version__ = '' - - -if not _ASTROPY_SETUP_: # noqa - import os - from warnings import warn - from astropy.config.configuration import ( - update_default_config, - ConfigurationDefaultMissingError, - ConfigurationDefaultMissingWarning) - - # Create the test function for self test - from astropy.tests.runner import TestRunner - test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) - test.__test__ = False - __all__ += ['test'] - - # add these here so we only need to cleanup the namespace at the end - config_dir = None - - if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False): - config_dir = os.path.dirname(__file__) - config_template = os.path.join(config_dir, __package__ + ".cfg") - if os.path.isfile(config_template): - try: - update_default_config( - __package__, config_dir, version=__version__) - except TypeError as orig_error: - try: - update_default_config(__package__, config_dir) - except ConfigurationDefaultMissingError as e: - wmsg = (e.args[0] - + " Cannot install default profile. If you are " - "importing from source, this is expected.") - warn(ConfigurationDefaultMissingWarning(wmsg)) - del e - except Exception: - raise orig_error diff --git a/readthedocs.yml b/readthedocs.yml deleted file mode 100644 index 8ac7c86..0000000 --- a/readthedocs.yml +++ /dev/null @@ -1,9 +0,0 @@ - -version: 2 - -python: - version: 3.7 - install: - - requirements: docs/requirements.txt - - method: pip - path: . diff --git a/tox.ini b/tox.ini index 918d9ae..d3ff13e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,6 @@ [tox] envlist = - py{37,38,39,310}-test{,-alldeps,-devdeps}{,-cov} - py{37,38,39,310}-test-numpy{118,119,120,121} - py{37,38,39,310}-test-astropy{40,50} + py{39,310,311}-test{,-alldeps}{,-cov} build_docs linkcheck codestyle @@ -10,15 +8,13 @@ requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true -indexserver = - NIGHTLY = https://pypi.anaconda.org/scipy-wheels-nightly/simple [testenv] # Suppress display of matplotlib plots generated during docs build setenv = MPLBACKEND=agg # Pass through the following environment variables which may be needed for the CI -passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TRAVIS +passenv = HOME, WINDIR, LC_ALL, LC_CTYPE, CC, CI, TRAVIS # Run the tests in a temporary directory to make sure that we don't import # this package from the source tree @@ -38,28 +34,13 @@ description = devdeps: with the latest developer version of key dependencies oldestdeps: with the oldest supported version of key dependencies cov: and test coverage - numpy118: with numpy 1.18.* - numpy119: with numpy 1.19.* - numpy120: with numpy 1.20.* - numpy121: with numpy 1.21.* - astropy40: with astropy 4.0.* - astropy50: with astropy 5.0.* astropylts: with the latest astropy LTS (currently v5.0) # The following provides some specific pinnings for key packages deps = - - numpy118: numpy==1.18.* - numpy119: numpy==1.19.* - numpy120: numpy==1.20.* - numpy121: numpy==1.21.* - - astropy40: astropy==4.0.* - astropy50: astropy==5.0.* astropylts: astropy==5.0.* - devdeps: :NIGHTLY:numpy - devdeps: git+https://github.com/astropy/astropy.git#egg=astropy + devdeps: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scipy-wheels-nightly/simple # The following indicates which extras_require from setup.cfg will be installed extras = From 8a9a00a0cb89bf356db527cede61eab3e1c4f6e6 Mon Sep 17 00:00:00 2001 From: "Karl D. Gordon" Date: Tue, 28 Nov 2023 15:37:22 -0500 Subject: [PATCH 2/3] update for deprecation --- megabeast/__init__.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/megabeast/__init__.py b/megabeast/__init__.py index 65b8d0e..3d7d5e3 100644 --- a/megabeast/__init__.py +++ b/megabeast/__init__.py @@ -1,9 +1,6 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst +from importlib.metadata import version as _version, PackageNotFoundError -# Packages may add whatever they like to this file, but -# should keep this content at the top. -# ---------------------------------------------------------------------------- -from ._astropy_init import * # noqa -# ---------------------------------------------------------------------------- - -__all__ = [] +try: + __version__ = _version(__name__) +except PackageNotFoundError: # pragma: no cover + pass From 9a492ca376f77aa97d1287527b89f752b75b35d8 Mon Sep 17 00:00:00 2001 From: "Karl D. Gordon" Date: Tue, 28 Nov 2023 16:14:33 -0500 Subject: [PATCH 3/3] moving old code to old, adding the simpliest of tests --- megabeast/{ => old}/examples/megabeast_input.txt | 0 megabeast/{ => old}/examples/megabeast_wrapper.py | 0 megabeast/{ => old}/simulations/simulate_av.py | 0 megabeast/{ => old}/simulations/simulate_av_plots.py | 2 +- megabeast/tests/basic_test.py | 7 +++++++ megabeast/tools/make_naive_maps.py | 2 +- setup.cfg | 3 ++- 7 files changed, 11 insertions(+), 3 deletions(-) rename megabeast/{ => old}/examples/megabeast_input.txt (100%) rename megabeast/{ => old}/examples/megabeast_wrapper.py (100%) rename megabeast/{ => old}/simulations/simulate_av.py (100%) rename megabeast/{ => old}/simulations/simulate_av_plots.py (99%) create mode 100644 megabeast/tests/basic_test.py diff --git a/megabeast/examples/megabeast_input.txt b/megabeast/old/examples/megabeast_input.txt similarity index 100% rename from megabeast/examples/megabeast_input.txt rename to megabeast/old/examples/megabeast_input.txt diff --git a/megabeast/examples/megabeast_wrapper.py b/megabeast/old/examples/megabeast_wrapper.py similarity index 100% rename from megabeast/examples/megabeast_wrapper.py rename to megabeast/old/examples/megabeast_wrapper.py diff --git a/megabeast/simulations/simulate_av.py b/megabeast/old/simulations/simulate_av.py similarity index 100% rename from megabeast/simulations/simulate_av.py rename to megabeast/old/simulations/simulate_av.py diff --git a/megabeast/simulations/simulate_av_plots.py b/megabeast/old/simulations/simulate_av_plots.py similarity index 99% rename from megabeast/simulations/simulate_av_plots.py rename to megabeast/old/simulations/simulate_av_plots.py index f2280cd..e6e3051 100644 --- a/megabeast/simulations/simulate_av_plots.py +++ b/megabeast/old/simulations/simulate_av_plots.py @@ -5,7 +5,7 @@ from astropy.io import fits from beast.tools.read_beast_data import read_sed_data, read_lnp_data -from beast.physicsmodel.prior_weights_dust import _lognorm, _two_lognorm +from beast.physicsmodel.priormodel_functions import _lognorm, _two_lognorm from megabeast.read_input import read_input diff --git a/megabeast/tests/basic_test.py b/megabeast/tests/basic_test.py new file mode 100644 index 0000000..c5a4689 --- /dev/null +++ b/megabeast/tests/basic_test.py @@ -0,0 +1,7 @@ +from megabeast.mbsettings import mbsettings + + +def test_basic(): + mbparams = mbsettings() + + assert isinstance(mbparams, mbsettings) diff --git a/megabeast/tools/make_naive_maps.py b/megabeast/tools/make_naive_maps.py index 4c0ef53..0bf64e6 100644 --- a/megabeast/tools/make_naive_maps.py +++ b/megabeast/tools/make_naive_maps.py @@ -36,7 +36,7 @@ def create_naive_maps(stats_filename, pix_size=10.0, verbose=False): stat_type = "Exp" # read in the full brick catalog - if type(stats_filename) == str: + if isinstance(stats_filename, str): stats_filename = [stats_filename] cat = Table.read(stats_filename[0]) if len(stats_filename) > 1: diff --git a/setup.cfg b/setup.cfg index 6fdef62..d38bfc1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,7 @@ github_project = BEAST-Fitting/megabeast [options] zip_safe = False packages = find: -python_requires = >=3.6 +python_requires = >=3.9 setup_requires = setuptools_scm install_requires = scipy @@ -55,6 +55,7 @@ omit = megabeast/*/tests/* megabeast/extern/* megabeast/version* + megabeast/old/* */megabeast/_astropy_init* */megabeast/conftest.py */megabeast/*setup_package*