Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update halos module with main compatability updates. #630

Open
wants to merge 24 commits into
base: module/halos
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
915d48f
tox indexserver is deprecated; use PIP_INDEX_URL and PIP_EXTRA_INDEX_…
rrjbca Mar 31, 2023
0be3a57
BLD: Set numpy latest supported version to 1.25 (#601)
rrjbca Jul 9, 2023
e0ded6d
BLD: Set scipy latest supported version to 1.11 (#602)
rrjbca Jul 10, 2023
7120c11
BLD: Set astropy latest supported version to 5.3 (#603)
rrjbca Jul 10, 2023
752256c
TST: Use conftest from latest astropy package template (#604)
rrjbca Jul 10, 2023
9d7c01f
BLD: Set numpy latest supported version to 1.26 (#607)
rrjbca Sep 22, 2023
dd62ba5
MAINT: Update .readthedocs.yml to latest version in astropy package-t…
rrjbca Nov 18, 2023
8fbe549
Update _astropy_init to latest version in astropy package-template (#…
rrjbca Nov 18, 2023
92a4761
BLD: Set astropy latest supported version to 6.0 (#611)
rrjbca Dec 11, 2023
a11c419
BLD: Upgrade GitHub actions that use deprecated node12 (#612)
rrjbca Dec 11, 2023
cea1836
BLD: Set scipy latest supported version to 1.12 (#613)
rrjbca Feb 6, 2024
eb0efbf
BLD: Set scipy latest supported version to 1.13 (#615)
rrjbca May 28, 2024
ed7ed46
BLD: Set astropy latest supported version to 6.1 (#616)
rrjbca Jun 25, 2024
f0a20fd
BLD: Set scipy oldest supported version to 1.6 (#618)
rrjbca Jun 25, 2024
f4b4bc9
Use scipy.integrate.cumulative_trapezoid (#617)
rrjbca Jun 25, 2024
dbcfff4
BLD: Set python latest supported version to 3.12 (#619)
rrjbca Jun 29, 2024
aa2b367
BLD: Set python oldest supported version to 3.8 (#620)
rrjbca Jun 29, 2024
2b5f39c
BLD: Set scipy latest supported version to 1.14 (#621)
rrjbca Aug 7, 2024
6f3881b
BLD: Set numpy latest supported version to 2.0 (#622)
rrjbca Aug 7, 2024
693edbc
MAINT: numpy.trapz is deprecated; use scipy.integrate.trapezoid (#623)
rrjbca Aug 9, 2024
5814872
MAINT: Upgrade to actions/setup-python@v5 (#624)
rrjbca Aug 9, 2024
5541fe7
BLD: Set numpy oldest supported version to 1.17 (#626)
rrjbca Sep 8, 2024
05444f3
BLD: Set numpy latest supported version to 2.1 (#625)
rrjbca Sep 8, 2024
ee05b5a
CI: Run tests and codestyle on release branches and tags (#627)
rrjbca Sep 8, 2024
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: 6 additions & 2 deletions .github/workflows/codestyle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ on:
branches:
- main
- module/*
- 'v*x'
tags:
- 'v*'
pull_request:
branches:
- main
- module/*
- 'v*x'
jobs:
flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ['3.11']
toxenv: [py311-test, py311-test-dev]
python: ['3.12']
toxenv: [py312-test, py312-test-dev]
release: [main, latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- if: matrix.release != 'main'
name: Checkout Release
run: |
git checkout tags/$(curl -s https://api.github.com/repos/skypyproject/skypy/releases/${{ matrix.release }} | python -c "import sys, json; print(json.load(sys.stdin)['tag_name'])")
- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ on:
branches:
- main
- module/*
- 'v*x'
tags:
- 'v*'
pull_request:
branches:
- main
- module/*
- 'v*x'
jobs:
test:
name: ${{ matrix.name }}
Expand All @@ -19,32 +23,32 @@ jobs:

- name: latest supported versions
os: ubuntu-latest
python: '3.11'
toxenv: py311-test-all-latest-cov
python: '3.12'
toxenv: py312-test-all-latest-cov
toxposargs: --cov-report=xml:${GITHUB_WORKSPACE}/coverage.xml

- name: oldest supported versions
os: ubuntu-latest
python: 3.7
toxenv: py37-test-oldest
python: '3.8'
toxenv: py38-test-oldest

- name: macOS latest supported
os: macos-latest
python: '3.11'
toxenv: py311-test-latest
python: '3.12'
toxenv: py312-test-latest

- name: Windows latest supported
os: windows-latest
python: '3.11'
toxenv: py311-test-latest
python: '3.12'
toxenv: py312-test-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
Expand All @@ -55,4 +59,4 @@ jobs:
tox -e ${{ matrix.toxenv }} ${{ matrix.toxargs }} -- ${{ matrix.toxposargs }}
- if: contains(matrix.toxenv, '-cov')
name: Report Coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
7 changes: 5 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
version: 2

build:
image: latest
os: ubuntu-20.04
tools:
python: '3.8'
apt_packages:
- graphviz

sphinx:
fail_on_warning: true

python:
version: 3.7
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Before your pull request can be merged into the codebase, it will be reviewed by
General Guidelines
^^^^^^^^^^^^^^^^^^

- SkyPy is compatible with Python>=3.7 (see `setup.cfg <https://github.com/skypyproject/skypy/blob/main/setup.cfg>`_). SkyPy *does not* support backwards compatibility with Python 2.x; `six`, `__future__` and `2to3` should not be used.
- SkyPy is compatible with Python>=3.8 (see `setup.cfg <https://github.com/skypyproject/skypy/blob/main/setup.cfg>`_). SkyPy *does not* support backwards compatibility with Python 2.x; `six`, `__future__` and `2to3` should not be used.
- All contributions should follow the `PEP8 Style Guide for Python Code <https://www.python.org/dev/peps/pep-0008/>`_. We recommend using `flake8 <https://flake8.pycqa.org/>`__ to check your code for PEP8 compliance.
- Importing SkyPy should only depend on having `NumPy <https://www.numpy.org>`_, `SciPy <https://www.scipy.org/>`_ and `Astropy <https://www.astropy.org/>`__ installed.
- Code is grouped into submodules based on broad science areas e.g. `galaxies <https://skypy.readthedocs.io/en/stable/galaxies.html>`_. There is also a `utils <https://skypy.readthedocs.io/en/stable/utils/index.html>`_ submodule for general utility functions.
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ can be installed directly from GitHub using a recent version of pip:
Dependencies
------------

SkyPy is compatble with Python versions 3.7 or later on Ubuntu, macOS and
SkyPy is compatble with Python versions 3.8 or later on Ubuntu, macOS and
Windows operating systems. It has the following core dependencies:

- `astropy <https://www.astropy.org/>`__
Expand Down
3 changes: 2 additions & 1 deletion examples/galaxies/plot_schechter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from astropy.units import Quantity
from matplotlib import pyplot as plt
import numpy as np
import scipy.integrate
from skypy.galaxies import schechter_lf

z_range = np.linspace(0.2, 1.0, 100)
Expand Down Expand Up @@ -81,7 +82,7 @@
# SkyPy simulated galaxies
z_mask = np.logical_and(redshift >= z_min, redshift < z_max)
dV_dz = (cosmology.differential_comoving_volume(z) * sky_area).to_value('Mpc3')
dV = np.trapz(dV_dz, z)
dV = scipy.integrate.trapezoid(dV_dz, z)
dM = (np.max(bins)-np.min(bins)) / (np.size(bins)-1)
phi_skypy = np.histogram(magnitude[z_mask], bins=bins)[0] / dV / dM

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ github_project = skypyproject/skypy
[options]
zip_safe = False
packages = find:
python_requires = >=3.7
python_requires = >=3.8
setup_requires = setuptools_scm
install_requires =
astropy>=4
Expand Down
49 changes: 5 additions & 44 deletions skypy/_astropy_init.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import os

__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
__all__ = ['__version__', 'test']

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
# Create the test function for self test
from astropy.tests.runner import TestRunner
test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
47 changes: 18 additions & 29 deletions skypy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# This file is used to configure the behavior of pytest when using the Astropy
# test infrastructure. It needs to live inside the package in order for it to
# get picked up when running the tests inside an interpreter using
# packagename.test
"""Configure Test Suite.

import os
This file is used to configure the behavior of pytest when using the Astropy
test infrastructure. It needs to live inside the package in order for it to
get picked up when running the tests inside an interpreter using
`{{ cookiecutter.module_name }}.test()`.

"""

from astropy.version import version as astropy_version
import os

# For Astropy 3.0 and later, we can use the standalone pytest plugin
if astropy_version < '3.0':
from astropy.tests.pytest_plugins import * # noqa
del pytest_report_header
try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
ASTROPY_HEADER = True
else:
try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
ASTROPY_HEADER = True
except ImportError:
ASTROPY_HEADER = False
except ImportError:
ASTROPY_HEADER = False


def pytest_configure(config):
"""Configure Pytest with Astropy.

Parameters
----------
config : pytest configuration

"""
if ASTROPY_HEADER:

config.option.astropy_header = True
Expand All @@ -34,16 +36,3 @@ def pytest_configure(config):
from . import __version__
packagename = os.path.basename(os.path.dirname(__file__))
TESTED_VERSIONS[packagename] = __version__

# Uncomment the last two lines in this block to treat all DeprecationWarnings as
# exceptions. For Astropy v2.0 or later, there are 2 additional keywords,
# as follow (although default should work for most cases).
# To ignore some packages that produce deprecation warnings on import
# (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and
# 'setuptools'), add:
# modules_to_ignore_on_import=['module_1', 'module_2']
# To ignore some specific deprecation warning messages for Python version
# MAJOR.MINOR or later, add:
# warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']}
# from astropy.tests.helper import enable_deprecations_as_exceptions # noqa
# enable_deprecations_as_exceptions()
2 changes: 1 addition & 1 deletion skypy/galaxies/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def redshifts_from_comoving_density(redshift, density, sky_area, cosmology, nois
dN_dz *= density

# integrate density to get expected number of galaxies
N = np.trapz(dN_dz, redshift)
N = scipy.integrate.trapezoid(dN_dz, redshift)

# Poisson sample galaxy number if requested
if noise:
Expand Down
5 changes: 3 additions & 2 deletions skypy/galaxies/tests/test_redshift.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest
import scipy.integrate
from scipy.stats import kstest


Expand Down Expand Up @@ -38,7 +39,7 @@ def test_schechter_lf_redshift():
density *= (sky_area * cosmo.differential_comoving_volume(z)).to_value('Mpc3')

# integrate total number
n_gal = np.trapz(density, z, axis=-1)
n_gal = scipy.integrate.trapezoid(density, z, axis=-1)

# make sure noise-free sample has right size
assert np.isclose(len(z_gal), n_gal, atol=1.0)
Expand Down Expand Up @@ -85,7 +86,7 @@ def test_schechter_smf_redshift():
density *= (sky_area * cosmo.differential_comoving_volume(z)).to_value('Mpc3')

# integrate total number
n_gal = np.trapz(density, z, axis=-1)
n_gal = scipy.integrate.trapezoid(density, z, axis=-1)

# make sure noise-free sample has right size
assert np.isclose(len(z_gal), n_gal, atol=1.0)
Expand Down
2 changes: 1 addition & 1 deletion skypy/galaxies/tests/test_stellar_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def calc_cdf(m):
mass_min = 10 ** 7
mass_max = 10 ** 13
pdf = calc_pdf(m, alpha, mass_star, mass_min, mass_max)
cdf = scipy.integrate.cumtrapz(pdf, m, initial=0)
cdf = scipy.integrate.cumulative_trapezoid(pdf, m, initial=0)
cdf = cdf / cdf[-1]
return cdf

Expand Down
4 changes: 2 additions & 2 deletions skypy/galaxies/tests/test_velocity_dispersion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from scipy.stats import kstest
from scipy.special import gamma
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid


def test_schechter_vdf():
Expand Down Expand Up @@ -30,7 +30,7 @@ def calc_pdf(vd):

def calc_cdf(m):
pdf = calc_pdf(m)
cdf = cumtrapz(pdf, m, initial=0)
cdf = cumulative_trapezoid(pdf, m, initial=0)
cdf /= cdf[-1]
return cdf

Expand Down
2 changes: 1 addition & 1 deletion skypy/utils/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def logistic_completeness_function(magnitude, magnitude_95, magnitude_50):
is array_like of shape (nb, ) it returns array_like of shape (nb, ).

References
-----------
----------
.. [1] López-Sanjuan, C. et al., `2017A&A…599A..62L`_
.. _2017A&A…599A..62L: https://ui.adsabs.harvard.edu/abs/2017A%26A...599A..62L

Expand Down
Loading
Loading