Skip to content

Commit

Permalink
Merge pull request 21cmfast#355 from 21cmfast/pre-commit-ci-update-co…
Browse files Browse the repository at this point in the history
…nfig

[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
steven-murray authored Feb 19, 2024
2 parents 2cf3c88 + 0250e8f commit ef480dc
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- flake8-print

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.2.0
hooks:
- id: black

Expand All @@ -51,7 +51,7 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py36-plus]
1 change: 1 addition & 0 deletions build_cffi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Build the C code with CFFI."""

import os
from cffi import FFI

Expand Down
1 change: 1 addition & 0 deletions devel/estimated_mem_usage_plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple example script for plotting estimated memory usage."""

import matplotlib.pyplot as plt
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion devel/prepare_gh_logs_for_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Useful for preparing it to be diff'ed against another log to check where things went wrong.
"""


import sys

fname = sys.argv[1]
Expand Down
1 change: 1 addition & 0 deletions devel/prepare_log_for_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Run over output of logging to prepare for diffing."""

import sys

fname = sys.argv[1]
Expand Down
1 change: 1 addition & 0 deletions devel/simulate_mcmc_memory_leak.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple script to simulate an MCMC-like routine to check for memory leaks."""

import numpy as np
import os
import psutil
Expand Down
1 change: 1 addition & 0 deletions devel/simulate_mcmc_memory_leak_lightcone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple script to simulate an MCMC-like routine to check for memory leaks."""

import numpy as np
import os
import psutil
Expand Down
1 change: 1 addition & 0 deletions joss-paper/make-example-plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Run the example in the JOSS paper and make plots."""

import matplotlib.pyplot as plt

import py21cmfast as p21c
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The py21cmfast package."""

try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/_cfg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Open and read the configuration file."""

from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Significantly, adds a new formatter which prepends the PID of the logging process to
any output. This is helpful when running multiple threads in MPI.
"""

import logging
import sys
from multiprocessing import current_process
Expand Down
35 changes: 21 additions & 14 deletions src/py21cmfast/_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities that help with wrapping various C structures."""

import glob
import h5py
import logging
Expand Down Expand Up @@ -1289,17 +1290,21 @@ def _seedless_repr(self):
self._name
+ "("
+ "; ".join(
repr(v)
if isinstance(v, StructWithDefaults)
else (
v.filtered_repr(self._filter_params)
if isinstance(v, StructInstanceWrapper)
else k.lstrip("_")
+ ":"
+ (
float_to_string_precision(v, config["cache_param_sigfigs"])
if isinstance(v, (float, np.float32))
else repr(v)
(
repr(v)
if isinstance(v, StructWithDefaults)
else (
v.filtered_repr(self._filter_params)
if isinstance(v, StructInstanceWrapper)
else k.lstrip("_")
+ ":"
+ (
float_to_string_precision(
v, config["cache_param_sigfigs"]
)
if isinstance(v, (float, np.float32))
else repr(v)
)
)
)
for k, v in [
Expand All @@ -1320,9 +1325,11 @@ def __str__(self):
self._name
+ "("
+ ";\n\t".join(
repr(v)
if isinstance(v, StructWithDefaults)
else k.lstrip("_") + ":" + repr(v)
(
repr(v)
if isinstance(v, StructWithDefaults)
else k.lstrip("_") + ":" + repr(v)
)
for k, v in [(k, getattr(self, k)) for k in self._inputs]
)
) + ")"
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/cache_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A set of tools for reading/writing/querying the in-built cache."""

import glob
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module that contains the command line app."""

import builtins
import click
import inspect
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:class:`GlobalParams`, which is a simple class providing read/write access to a number of parameters
used throughout the computation which are very rarely varied.
"""

from __future__ import annotations

import contextlib
Expand Down
7 changes: 4 additions & 3 deletions src/py21cmfast/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
as output objects from the various functions contained here. Only the data
within the objects should be accessed.
"""

from __future__ import annotations

import h5py
Expand Down Expand Up @@ -1096,9 +1097,9 @@ def _read_particular(cls, fname):
with h5py.File(fname, "r") as fl:
for output_class in _ut.OutputStruct._implementations():
if output_class.__name__ in fl:
kwargs[
_ut.camel_to_snake(output_class.__name__)
] = output_class.from_file(fname)
kwargs[_ut.camel_to_snake(output_class.__name__)] = (
output_class.from_file(fname)
)

return kwargs

Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/plotting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple plotting functions for 21cmFAST objects."""

from __future__ import annotations

import matplotlib.pyplot as plt
Expand Down
13 changes: 7 additions & 6 deletions src/py21cmfast/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
>>> lightcone = p21.run_lightcone(redshift=z2, max_redshift=z2, z_step_factor=1.03)
"""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -563,9 +564,7 @@ def compute_luminosity_function(
return None, None, None

else:
mturnovers = (
np.zeros(len(redshifts), dtype="float32") + 10**astro_params.M_TURN
)
mturnovers = np.zeros(len(redshifts), dtype="float32") + 10**astro_params.M_TURN
component = 1

if component == 0:
Expand Down Expand Up @@ -1895,9 +1894,11 @@ def spin_temperature(
flag_options=flag_options,
random_seed=random_seed,
prev_spin_redshift=prev_z,
perturbed_field_redshift=perturbed_field.redshift
if (perturbed_field is not None and perturbed_field.is_computed)
else redshift,
perturbed_field_redshift=(
perturbed_field.redshift
if (perturbed_field is not None and perturbed_field.is_computed)
else redshift
),
)

# Construct FFTW wisdoms. Only if required
Expand Down
1 change: 1 addition & 0 deletions src/py21cmfast/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A modification of the basic YAML and astropy.io.misc.yaml to be able to load/dump
objects with astropy quantities in them.
"""

import yaml
from astropy.io.misc import yaml as ayaml

Expand Down
1 change: 1 addition & 0 deletions tests/produce_integration_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
and then numerical noise gets relatively more important, and can make the comparison
fail at the tens-of-percent level.
"""

import click
import glob
import h5py
Expand Down
1 change: 1 addition & 0 deletions tests/test_initial_conditions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Various tests of the initial_conditions() function and InitialConditions class.
"""

import pytest

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
a reasonable test: they should be of reduced data such as power spectra or global xHI
measurements, and they should be generated with small simulations.
"""

import pytest

import h5py
Expand Down
1 change: 1 addition & 0 deletions tests/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
correctness of simulations,
but whether different parameter options work/don't work as intended.
"""

import pytest

import h5py
Expand Down

0 comments on commit ef480dc

Please sign in to comment.