Skip to content

Commit

Permalink
Bump ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Feb 15, 2024
1 parent 4705b33 commit fc798de
Show file tree
Hide file tree
Showing 90 changed files with 369 additions and 365 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/paddyroddy/.github
rev: v0.130.0
rev: v0.134.0
hooks:
- id: general-hooks
- id: python-hooks
2 changes: 1 addition & 1 deletion examples/arbitrary/_denoising_slepian_wavelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def denoising_slepian_wavelet(
slepian_wavelets: sleplet.functions.SlepianWavelets,
snr_in: float,
n_sigma: int,
) -> npt.NDArray[np.complex_]:
) -> npt.NDArray[np.complex128]:
"""Denoising demo using Slepian wavelets."""
# compute wavelet coefficients
w = sleplet.wavelet_methods.slepian_wavelet_forward(
Expand Down
2 changes: 1 addition & 1 deletion examples/arbitrary/_slepian_wavelet_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def compute_slepian_wavelet_covariance(
slepian_wavelets: sleplet.functions.SlepianWavelets,
*,
var_signal: float,
) -> npt.NDArray[np.float_]:
) -> npt.NDArray[np.float64]:
"""Compute the theoretical covariance of the wavelet coefficients."""
s_p = sleplet.slepian_methods.compute_s_p_omega(L, slepian_wavelets.slepian)
wavelets_reshape = slepian_wavelets.wavelets[
Expand Down
2 changes: 1 addition & 1 deletion examples/arbitrary/africa/denoising_slepian_africa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))

from _denoising_slepian_wavelet import denoising_slepian_wavelet # noqa: E402
from _denoising_slepian_wavelet import denoising_slepian_wavelet

B = 3
J_MIN = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main() -> None:
)

# plot
f_p = np.zeros(swc.slepian.N, dtype=np.complex_)
f_p = np.zeros(swc.slepian.N, dtype=np.complex128)
for p, coeff in enumerate(swc.wavelet_coefficients):
print(f"plot reconstruction: {p}")
f_p += sleplet.wavelet_methods.slepian_wavelet_inverse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))

from _slepian_wavelet_covariance import compute_slepian_wavelet_covariance # noqa: E402
from _slepian_wavelet_covariance import compute_slepian_wavelet_covariance

B = 3
J_MIN = 2
Expand All @@ -32,7 +32,7 @@ def main() -> None:

# initialise matrix
covar_runs_shape = (RUNS, *covar_theory.shape)
covar_data_runs = np.zeros(covar_runs_shape, dtype=np.complex_)
covar_data_runs = np.zeros(covar_runs_shape, dtype=np.complex128)

# set seed
rng = np.random.default_rng(RANDOM_SEED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _denoising_slepian_function(
noised_signal: sleplet.functions.SlepianSouthAmerica,
snr_in: float,
n_sigma: int,
) -> npt.NDArray[np.complex_]:
) -> npt.NDArray[np.complex128]:
"""Denoising demo using Slepian function."""
# compute Slepian noise
sigma_noise = sleplet.noise.compute_sigma_noise(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))

from _denoising_slepian_wavelet import denoising_slepian_wavelet # noqa: E402
from _denoising_slepian_wavelet import denoising_slepian_wavelet

B = 3
J_MIN = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main() -> None:
)

# plot
f_p = np.zeros(swc.slepian.N, dtype=np.complex_)
f_p = np.zeros(swc.slepian.N, dtype=np.complex128)
for p, coeff in enumerate(swc.wavelet_coefficients):
print(f"plot reconstruction: {p}")
f_p += sleplet.wavelet_methods.slepian_wavelet_inverse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))

from _slepian_wavelet_covariance import compute_slepian_wavelet_covariance # noqa: E402
from _slepian_wavelet_covariance import compute_slepian_wavelet_covariance

B = 3
J_MIN = 2
Expand All @@ -32,7 +32,7 @@ def main() -> None:

# initialise matrix
covar_runs_shape = (RUNS, *covar_theory.shape)
covar_data_runs = np.zeros(covar_runs_shape, dtype=np.complex_)
covar_data_runs = np.zeros(covar_runs_shape, dtype=np.complex128)

# set seed
rng = np.random.default_rng(RANDOM_SEED)
Expand Down
2 changes: 1 addition & 1 deletion examples/mesh/denoising_slepian_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _denoising_mesh_slepian(
mesh_slepian_wavelets: sleplet.meshes.MeshSlepianWavelets,
snr_in: float,
n_sigma: int,
) -> npt.NDArray[np.complex_ | np.float_]:
) -> npt.NDArray[np.complex128 | np.float64]:
"""Denoising demo using Slepian wavelets."""
# compute wavelet coefficients
w = sleplet.wavelet_methods.slepian_wavelet_forward(
Expand Down
2 changes: 1 addition & 1 deletion examples/mesh/produce_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parent))

from denoising_slepian_mesh import main # noqa: E402
from denoising_slepian_mesh import main

MESH_SNR_DICT = {
"cheetah": -8.64,
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/_denoising_axisym.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def denoising_axisym( # noqa: PLR0913
n_sigma: int,
*,
rotate_to_south_america: bool = False,
) -> tuple[npt.NDArray[np.complex_], float | None, float]:
) -> tuple[npt.NDArray[np.complex128], float | None, float]:
"""Reproduce the denoising demo from S2LET paper."""
# compute wavelet coefficients
w = sleplet.wavelet_methods.axisymmetric_wavelet_forward(
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/denoising_axisym_africa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parent))

from _denoising_axisym import denoising_axisym # noqa: E402
from _denoising_axisym import denoising_axisym

B = 2
J_MIN = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/denoising_axisym_earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parent))

from _denoising_axisym import denoising_axisym # noqa: E402
from _denoising_axisym import denoising_axisym

B = 2
J_MIN = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/denoising_axisym_south_america.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

sys.path.append(str(pathlib.Path(__file__).resolve().parent))

from _denoising_axisym import denoising_axisym # noqa: E402
from _denoising_axisym import denoising_axisym

B = 2
J_MIN = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/wavelet_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def main() -> None:
plt.close()


def _ricker(freq: float) -> npt.NDArray[np.float_]:
def _ricker(freq: float) -> npt.NDArray[np.float64]:
"""Create a Ricker wavelet."""
t = np.arange(-LENGTH / 2, (LENGTH - DELTA_T) / 2, DELTA_T)
return (1.0 - 2.0 * (np.pi**2) * (freq**2) * (t**2)) * np.exp(
Expand Down
2 changes: 1 addition & 1 deletion examples/polar_cap/eigenfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def main() -> None:
def _helper(
ax: mpl.axes.Axes,
slepian: sleplet.slepian.SlepianPolarCap,
x: npt.NDArray[np.float_],
x: npt.NDArray[np.float64],
i: int,
rank: int,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion examples/polar_cap/simons_5_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _helper( # noqa: PLR0913
ax: npt.NDArray[typing.Any],
slepian: sleplet.slepian.SlepianPolarCap,
resolution: int,
x: npt.NDArray[np.float_],
x: npt.NDArray[np.float64],
i: int,
order: int,
rank: int,
Expand Down
4 changes: 2 additions & 2 deletions examples/polar_cap/slepian_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def _earth_region_harmonic_coefficients(
L: int,
theta_max: int,
) -> npt.NDArray[np.float_]:
) -> npt.NDArray[np.float64]:
"""Harmonic coefficients of the Earth for the polar cap region."""
region = sleplet.slepian.Region(theta_max=np.deg2rad(theta_max))
earth = sleplet.functions.Earth(L, region=region)
Expand All @@ -26,7 +26,7 @@ def _earth_region_harmonic_coefficients(
def _earth_region_slepian_coefficients(
L: int,
theta_max: int,
) -> npt.NDArray[np.float_]:
) -> npt.NDArray[np.float64]:
"""Compute the Slepian coefficients."""
region = sleplet.slepian.Region(theta_max=np.deg2rad(theta_max))
earth = sleplet.functions.Earth(L, region=region)
Expand Down
12 changes: 6 additions & 6 deletions examples/polar_cap/slepian_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def main() -> None:
def _helper_sphere(
L: int,
region: sleplet.slepian.Region,
f: npt.NDArray[np.complex_],
flm: npt.NDArray[np.complex_ | np.float_],
) -> npt.NDArray[np.float_]:
f: npt.NDArray[np.complex128],
flm: npt.NDArray[np.complex128 | np.float64],
) -> npt.NDArray[np.float64]:
"""Calculate the difference in Slepian coefficients by integration of the sphere."""
slepian = sleplet.slepian_methods.choose_slepian_method(L, region)
output = np.abs(sleplet.slepian_methods.slepian_forward(L, slepian, f=f))
Expand All @@ -65,9 +65,9 @@ def _helper_sphere(
def _helper_region(
L: int,
region: sleplet.slepian.Region,
f: npt.NDArray[np.complex_],
flm: npt.NDArray[np.complex_ | np.float_],
) -> npt.NDArray[np.float_]:
f: npt.NDArray[np.complex128],
flm: npt.NDArray[np.complex128 | np.float64],
) -> npt.NDArray[np.float64]:
"""Calculate the difference in Slepian coefficients by integration of the region."""
slepian = sleplet.slepian_methods.choose_slepian_method(L, region)
output = np.abs(
Expand Down
6 changes: 3 additions & 3 deletions examples/wavelets/axisymmetric_wavelet_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@


def _compute_wavelet_covariance(
wavelets: npt.NDArray[np.complex_],
wavelets: npt.NDArray[np.complex128],
*,
var_signal: float,
) -> npt.NDArray[np.float_]:
) -> npt.NDArray[np.float64]:
"""Compute the theoretical covariance of the wavelet coefficients."""
covar_theory = (np.abs(wavelets) ** 2).sum(axis=1)
return covar_theory * var_signal
Expand Down Expand Up @@ -67,7 +67,7 @@ def axisymmetric_wavelet_covariance(

# initialise matrix
covar_runs_shape = (runs, *covar_theory.shape)
covar_data = np.zeros(covar_runs_shape, dtype=np.complex_)
covar_data = np.zeros(covar_runs_shape, dtype=np.complex128)

# set seed
rng = np.random.default_rng(RANDOM_SEED)
Expand Down
6 changes: 3 additions & 3 deletions src/sleplet/_convolution_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@


def sifting_convolution(
f_coefficient: npt.NDArray[np.complex_ | np.float_],
g_coefficient: npt.NDArray[np.complex_ | np.float_],
f_coefficient: npt.NDArray[np.complex128 | np.float64],
g_coefficient: npt.NDArray[np.complex128 | np.float64],
*,
shannon: int | None = None,
) -> npt.NDArray[np.complex_ | np.float_]:
) -> npt.NDArray[np.complex128 | np.float64]:
"""Compute the sifting convolution between two multipoles."""
n = shannon if shannon is not None else np.newaxis
# change shape if the sizes don't match
Expand Down
4 changes: 2 additions & 2 deletions src/sleplet/_data/create_earth_flm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sleplet._smoothing


def create_flm(L: int, *, smoothing: int | None = None) -> npt.NDArray[np.complex_]:
def create_flm(L: int, *, smoothing: int | None = None) -> npt.NDArray[np.complex128]:
"""Create the flm for the whole Earth."""
# load in data
flm = _load_flm()
Expand All @@ -29,7 +29,7 @@ def create_flm(L: int, *, smoothing: int | None = None) -> npt.NDArray[np.comple
return flm


def _load_flm() -> npt.NDArray[np.complex_]:
def _load_flm() -> npt.NDArray[np.complex128]:
"""Load coefficients from file."""
mat_contents = sio.loadmat(
sleplet._data.setup_pooch.find_on_pooch_then_local(
Expand Down
6 changes: 3 additions & 3 deletions src/sleplet/_data/create_wmap_flm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sleplet._vars


def create_flm(L: int) -> npt.NDArray[np.complex_]:
def create_flm(L: int) -> npt.NDArray[np.complex128]:
"""Create the flm for the whole CMB."""
# load in data
cl = _load_cl()
Expand All @@ -17,7 +17,7 @@ def create_flm(L: int) -> npt.NDArray[np.complex_]:
rng = np.random.default_rng(sleplet._vars.RANDOM_SEED)

# Simulate CMB in harmonic space.
flm = np.zeros(L**2, dtype=np.complex_)
flm = np.zeros(L**2, dtype=np.complex128)
for ell in range(2, L):
sigma = np.sqrt(2 * np.pi / (ell * (ell + 1)) * cl[ell - 2])
ind = ssht.elm2ind(ell, 0)
Expand All @@ -37,7 +37,7 @@ def create_flm(L: int) -> npt.NDArray[np.complex_]:
def _load_cl(
*,
file_ending: str = "_lcdm_pl_model_wmap7baoh0",
) -> npt.NDArray[np.float_]:
) -> npt.NDArray[np.float64]:
"""
Pick coefficients from file options are:
* _lcdm_pl_model_yr1_v1.mat
Expand Down
20 changes: 10 additions & 10 deletions src/sleplet/_integration_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sleplet._vars


def calc_integration_weight(L: int) -> npt.NDArray[np.float_]:
def calc_integration_weight(L: int) -> npt.NDArray[np.float64]:
"""Compute the spherical Jacobian for the integration."""
thetas, phis = ssht.sample_positions(
L,
Expand All @@ -22,28 +22,28 @@ def calc_integration_weight(L: int) -> npt.NDArray[np.float_]:


def integrate_whole_sphere(
weight: npt.NDArray[np.float_],
*functions: npt.NDArray[np.complex_],
weight: npt.NDArray[np.float64],
*functions: npt.NDArray[np.complex128],
) -> complex:
"""Compute the integration for the whole sphere."""
multiplied_inputs = _multiply_args(*functions)
return (multiplied_inputs * weight).sum()


def integrate_region_sphere(
mask: npt.NDArray[np.float_],
weight: npt.NDArray[np.float_],
*functions: npt.NDArray[np.complex_ | np.float_],
mask: npt.NDArray[np.float64],
weight: npt.NDArray[np.float64],
*functions: npt.NDArray[np.complex128 | np.float64],
) -> complex:
"""Compute the integration for a region of the sphere."""
multiplied_inputs = _multiply_args(*functions)
return (multiplied_inputs * weight * mask).sum()


def integrate_whole_mesh(
vertices: npt.NDArray[np.float_], # noqa: ARG001
vertices: npt.NDArray[np.float64], # noqa: ARG001
faces: npt.NDArray[np.int_], # noqa: ARG001
*functions: npt.NDArray[np.complex_ | np.float_],
*functions: npt.NDArray[np.complex128 | np.float64],
) -> float:
"""Compute the integral of functions on the vertices."""
multiplied_inputs = _multiply_args(*functions)
Expand All @@ -52,9 +52,9 @@ def integrate_whole_mesh(

def integrate_region_mesh(
mask: npt.NDArray[np.bool_],
vertices: npt.NDArray[np.float_], # noqa: ARG001
vertices: npt.NDArray[np.float64], # noqa: ARG001
faces: npt.NDArray[np.int_], # noqa: ARG001
*functions: npt.NDArray[np.complex_ | np.float_],
*functions: npt.NDArray[np.complex128 | np.float64],
) -> float:
"""Compute the integral of a region of functions on the vertices."""
multiplied_inputs = _multiply_args(*functions)
Expand Down
Loading

0 comments on commit fc798de

Please sign in to comment.