Skip to content
Draft
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ _version.py
.DS_Store
.envrc
.hypothesis
.mypy_cache
.pytest_cache
.vscode
*.aux
Expand Down
25 changes: 8 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,6 @@ run = {branch = true, parallel = true, source = [
"sleplet",
]}

[tool.mypy]
disallow_subclassing_any = false
disallow_untyped_decorators = false
enable_error_code = [
"ignore-without-code",
"redundant-expr",
"truthy-bool",
]
explicit_package_bases = true
ignore_missing_imports = true
plugins = [
"pydantic.mypy",
]
strict = true
warn_return_any = false
warn_unreachable = true

[tool.pytest.ini_options]
addopts = [
"--color=yes",
Expand Down Expand Up @@ -191,3 +174,11 @@ write_to = "src/sleplet/_version.py"
[tool.tomlsort]
overrides."project.classifiers".inline_arrays = false
overrides."tool.ruff.lint.isort.section-order".inline_arrays = false

[tool.ty]
rules.invalid-argument-type = "ignore"
rules.unresolved-attribute = "ignore"
src.include = [
"src",
"tests",
]
2 changes: 1 addition & 1 deletion src/sleplet/_convolution_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def sifting_convolution(
if len(g_coefficient.shape) < len(f_coefficient.shape)
else g_coefficient
)
return (f_coefficient.T[:n] * g_reshape.conj().T[:n]).T # type: ignore[return-value]
return (f_coefficient.T[:n] * g_reshape.conj().T[:n]).T # ty: ignore[invalid-return-type]
4 changes: 2 additions & 2 deletions src/sleplet/_data/setup_pooch.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def find_on_pooch_then_local(filename: str) -> os.PathLike[str] | None:
Returns:
The sought after file or nothing if not found
"""
if filename in _POOCH.registry: # type: ignore[union-attr]
if filename in _POOCH.registry:
msg = f"Found {filename} at https://doi.org/{_ZENODO_DATA_DOI}"
_logger.info(msg)
return _POOCH.fetch(filename, progressbar=True) # type: ignore[union-attr]
return _POOCH.fetch(filename, progressbar=True)

if (platformdirs.user_data_path() / filename).exists():
msg = f"Found {filename} at {platformdirs.user_data_path() / filename}"
Expand Down
4 changes: 2 additions & 2 deletions src/sleplet/_mesh_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ def mesh_eigendecomposition(

def read_mesh(
mesh_config: dict[str, float | int | str],
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.int_]]:
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.int_]]: # ty: ignore[invalid-return-type]
"""Read in the given mesh."""
vertices, faces = igl.read_triangle_mesh(
_data_path / f"meshes_polygons_{mesh_config['FILENAME']}",
)
return igl.upsample(vertices, faces, number_of_subdivs=mesh_config["UPSAMPLE"])
return igl.upsample(vertices, faces, number_of_subdivs=mesh_config["UPSAMPLE"]) # ty: ignore[invalid-return-type]


def _mesh_laplacian(
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/_scripts/plotting_on_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _translation_helper(
"z": z,
"arrowcolor": _ANNOTATION_COLOUR,
} | _ARROW_STYLE
return coefficients, filename, annotation
return coefficients, filename, annotation # ty: ignore[invalid-return-type]


def _convolution_helper(
Expand Down
12 changes: 6 additions & 6 deletions src/sleplet/functions/slepian.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def __post_init__(self: typing_extensions.Self) -> None:

def _create_name(self: typing_extensions.Self) -> str:
order = (
f"_m{self.slepian.order[self.rank]}"
f"_m{self.slepian.order[self.rank]}" # ty: ignore[non-subscriptable]
if hasattr(self.slepian, "order")
else ""
)
return (
(
f"{self.slepian.name}{order}_rank{self.rank}"
f"_lam{self.slepian.eigenvalues[self.rank]:e}"
f"{self.slepian.name}{order}_rank{self.rank}" # ty: ignore[possibly-missing-attribute]
f"_lam{self.slepian.eigenvalues[self.rank]:e}" # ty: ignore[possibly-missing-attribute]
)
.replace(".", "-")
.replace("+", "")
Expand All @@ -45,14 +45,14 @@ def _create_coefficients(
self: typing_extensions.Self,
) -> npt.NDArray[np.complex128 | np.float64]:
msg = (
f"Shannon number: {self.slepian.N}\n"
f"Eigenvalue {self.rank}: {self.slepian.eigenvalues[self.rank]:e}"
f"Shannon number: {self.slepian.N}\n" # ty: ignore[possibly-missing-attribute]
f"Eigenvalue {self.rank}: {self.slepian.eigenvalues[self.rank]:e}" # ty: ignore[possibly-missing-attribute]
)
_logger.info(msg)
return sleplet.slepian_methods.slepian_forward(
self.L,
self.slepian,
flm=self.slepian.eigenvectors[self.rank],
flm=self.slepian.eigenvectors[self.rank], # ty: ignore[possibly-missing-attribute]
)

def _set_reality(self: typing_extensions.Self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/sleplet/functions/slepian_dirac_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _create_coefficients(
def _create_name(self: typing_extensions.Self) -> str:
return (
f"{sleplet._string_methods._convert_camel_case_to_snake_case(self.__class__.__name__)}"
f"_{self.slepian.region._name_ending}"
f"_{self.slepian.region._name_ending}" # ty: ignore[possibly-missing-attribute]
)

def _set_reality(self: typing_extensions.Self) -> bool:
Expand All @@ -64,7 +64,7 @@ def _compute_angles(self: typing_extensions.Self) -> None:
Method=sleplet._vars.SAMPLING_SCHEME,
)
sp = ssht.inverse(
self.slepian.eigenvectors[0],
self.slepian.eigenvectors[0], # ty: ignore[possibly-missing-attribute]
self.L,
Method=sleplet._vars.SAMPLING_SCHEME,
)
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/functions/slepian_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _create_coefficients(
def _create_name(self: typing_extensions.Self) -> str:
return (
f"{sleplet._string_methods._convert_camel_case_to_snake_case(self.__class__.__name__)}"
f"_{self.slepian.region._name_ending}"
f"_{self.slepian.region._name_ending}" # ty: ignore[possibly-missing-attribute]
)

def _set_reality(self: typing_extensions.Self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/sleplet/functions/slepian_wavelet_coefficients_africa.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def _create_wavelet_coefficients(
wavelet_coefficients = sleplet.wavelet_methods.slepian_wavelet_forward(
sa.coefficients,
wavelets,
self.slepian.N,
self.slepian.N, # ty: ignore[possibly-missing-attribute]
)
return wavelets, wavelet_coefficients
return wavelets, wavelet_coefficients # ty: ignore[invalid-return-type]

@pydantic.field_validator("j")
def _check_j(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def _create_wavelet_coefficients(
wavelet_coefficients = sleplet.wavelet_methods.slepian_wavelet_forward(
sa.coefficients,
wavelets,
self.slepian.N,
self.slepian.N, # ty: ignore[possibly-missing-attribute]
)
return wavelets, wavelet_coefficients
return wavelets, wavelet_coefficients # ty: ignore[invalid-return-type]

@pydantic.field_validator("j")
def _check_j(
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/functions/slepian_wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _create_coefficients(
def _create_name(self: typing_extensions.Self) -> str:
return (
f"{sleplet._string_methods._convert_camel_case_to_snake_case(self.__class__.__name__)}"
f"_{self.slepian.region._name_ending}"
f"_{self.slepian.region._name_ending}" # ty: ignore[possibly-missing-attribute]
f"{sleplet._string_methods.filename_args(self.B, 'B')}"
f"{sleplet._string_methods.filename_args(self.j_min, 'jmin')}"
f"{sleplet._string_methods.wavelet_ending(self.j_min, self.j)}"
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/meshes/_mesh_slepian_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _validate_rank(self: typing_extensions.Self, rank: int) -> None:
if rank < 0:
msg = "rank cannot be negative"
raise ValueError(msg)
if rank >= self.mesh_slepian.mesh.number_basis_functions:
if rank >= self.mesh_slepian.mesh.number_basis_functions: # ty: ignore[unsupported-operator]
msg = (
"rank should be less than "
f"{self.mesh_slepian.mesh.number_basis_functions}"
Expand Down
4 changes: 2 additions & 2 deletions src/sleplet/meshes/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def __post_init__(self: typing_extensions.Self) -> None:
y_centre=mesh_config["CENTRE_Y"] if self.zoom else 0,
z_centre=mesh_config["CENTRE_Z"] if self.zoom else 0,
)
self._colourbar_pos = (
self._colourbar_pos = ( # ty: ignore[invalid-assignment]
mesh_config["REGION_COLOURBAR_POS"]
if self.zoom
else mesh_config["DEFAULT_COLOURBAR_POS"]
)
self.vertices, self.faces = sleplet._mesh_methods.read_mesh(mesh_config)
self.vertices, self.faces = sleplet._mesh_methods.read_mesh(mesh_config) # ty: ignore[invalid-assignment]
self.mesh_region = sleplet._mesh_methods.create_mesh_region(
mesh_config,
self.vertices,
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/meshes/mesh_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _create_coefficients(
self: typing_extensions.Self,
) -> npt.NDArray[np.complex128 | np.float64]:
"""Compute field on the vertices of the mesh."""
field = igl.per_vertex_normals(self.mesh.vertices, self.mesh.faces)[:, 1]
field = igl.per_vertex_normals(self.mesh.vertices, self.mesh.faces)[:, 1] # ty: ignore[non-subscriptable]
return sleplet.harmonic_methods.mesh_forward(self.mesh, field)

def _create_name(self: typing_extensions.Self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/meshes/mesh_harmonic_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _add_noise_to_signal(
unnoised_coefficients = self.coefficients.copy()
nlm = sleplet.noise._create_mesh_noise(self.coefficients, self.noise)
snr = sleplet.noise.compute_snr(self.coefficients, nlm, "Harmonic")
self.coefficients = self.coefficients + nlm
self.coefficients = self.coefficients + nlm # ty: ignore[invalid-assignment]
return unnoised_coefficients, snr
return None, None

Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/meshes/mesh_slepian_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _add_noise_to_signal(
self.noise,
)
snr = sleplet.noise.compute_snr(self.coefficients, n_p, "Slepian")
self.coefficients = self.coefficients + n_p
self.coefficients = self.coefficients + n_p # ty: ignore[invalid-assignment]
return unnoised_coefficients, snr
return None, None

Expand Down
6 changes: 3 additions & 3 deletions src/sleplet/meshes/mesh_slepian_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def _create_coefficients(
"""Compute field on the vertices of the mesh."""
msg = (
f"Slepian eigenvalue {self.rank}: "
f"{self.mesh_slepian.slepian_eigenvalues[self.rank]:e}",
f"{self.mesh_slepian.slepian_eigenvalues[self.rank]:e}", # ty: ignore[possibly-missing-attribute]
)
_logger.info(msg)
s_p_i = self.mesh_slepian.slepian_functions[self.rank]
s_p_i = self.mesh_slepian.slepian_functions[self.rank] # ty: ignore[possibly-missing-attribute]
return sleplet.slepian_methods.slepian_mesh_forward(
self.mesh_slepian,
u_i=s_p_i,
Expand All @@ -44,7 +44,7 @@ def _create_name(self: typing_extensions.Self) -> str:
return (
(
f"slepian_{self.mesh.name}_rank{self.rank}_"
f"lam{self.mesh_slepian.slepian_eigenvalues[self.rank]:e}"
f"lam{self.mesh_slepian.slepian_eigenvalues[self.rank]:e}" # ty: ignore[possibly-missing-attribute]
)
.replace(".", "-")
.replace("+", "")
Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/meshes/mesh_slepian_wavelet_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _create_wavelet_coefficients(
wavelet_coefficients = sleplet.wavelet_methods.slepian_wavelet_forward(
smf.coefficients,
wavelets,
self.mesh_slepian.N,
self.mesh_slepian.N, # ty: ignore[possibly-missing-attribute]
)
return wavelets, wavelet_coefficients

Expand Down
2 changes: 1 addition & 1 deletion src/sleplet/slepian/slepian_limit_lat_lon.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _slepian_matrix(
"""
K = np.zeros((L**2, L**2), dtype=np.complex128)

for ell in numba.prange(L):
for ell in numba.prange(L): # ty: ignore[not-iterable]
for p in range(ell + 1):
C1 = np.sqrt((2 * ell + 1) * (2 * p + 1)) / (4 * np.pi)

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

import sleplet
import sleplet._vars

ARRAY_DIM = 10
L = 16
Expand Down
2 changes: 1 addition & 1 deletion tests/test_arrays.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

import sleplet
import sleplet._array_methods


def test_fill_matrix_using_hermitian_relation() -> None:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_bool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np

import sleplet
import sleplet._bool_methods
import sleplet._vars

J = 2
J_MIN = 0
Expand Down
3 changes: 3 additions & 0 deletions tests/test_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import pyssht as ssht

import sleplet
import sleplet._mask_methods
import sleplet._vars
import sleplet.slepian._slepian_decomposition


def test_decompose_all_polar(
Expand Down
1 change: 1 addition & 0 deletions tests/test_harmonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pyssht as ssht

import sleplet
import sleplet._vars

L_LARGE = 128
L_SMALL = 16
Expand Down
2 changes: 1 addition & 1 deletion tests/test_loading_pooch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pathlib

import sleplet
import sleplet._data.setup_pooch


def test_known_file_exists_on_pooch() -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/test_mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

import sleplet
import sleplet._integration_methods


def test_inverse_forward_transform_recovery(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parallel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

import sleplet
import sleplet._parallel_methods

L_LARGE = 128
L_SMALL = 16
Expand Down
6 changes: 3 additions & 3 deletions tests/test_slepian_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def test_synthesis_mesh(
wav_coeffs = sleplet.wavelet_methods.slepian_wavelet_forward(
coefficients,
mesh_slepian_wavelets.wavelets,
mesh_slepian_wavelets.mesh_slepian.N,
mesh_slepian_wavelets.mesh_slepian.N, # ty: ignore[possibly-missing-attribute]
)
f_p = sleplet.wavelet_methods.slepian_wavelet_inverse(
wav_coeffs,
mesh_slepian_wavelets.wavelets,
mesh_slepian_wavelets.mesh_slepian.N,
mesh_slepian_wavelets.mesh_slepian.N, # ty: ignore[possibly-missing-attribute]
)
np.testing.assert_allclose(
np.abs(f_p - coefficients)[: mesh_slepian_wavelets.mesh_slepian.N].mean(),
np.abs(f_p - coefficients)[: mesh_slepian_wavelets.mesh_slepian.N].mean(), # ty: ignore[possibly-missing-attribute]
0,
atol=1e-16,
)
1 change: 1 addition & 0 deletions tests/test_strings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

import sleplet
import sleplet._string_methods

J_MIN = 0
PHI_0 = np.pi / 6
Expand Down
7 changes: 4 additions & 3 deletions tests/test_translation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import hypothesis
import hypothesis.strategies
import numpy as np

import pyssht as ssht

import sleplet
import sleplet._vars

L = 128
THETA_MAX = np.pi / 3
Expand Down Expand Up @@ -53,7 +54,7 @@ def test_slepian_translation_changes_max_polar(
sdd_trans = slepian_dirac_delta_polar_cap.translate(
slepian_dirac_delta_polar_cap._alpha,
beta,
shannon=slepian_dirac_delta_polar_cap.slepian.N,
shannon=slepian_dirac_delta_polar_cap.slepian.N, # ty: ignore[possibly-missing-attribute]
)
field = sleplet.slepian_methods.slepian_inverse(
sdd_trans,
Expand Down Expand Up @@ -86,7 +87,7 @@ def test_slepian_translation_changes_max_lim_lat_lon(
sdd_trans = slepian_dirac_delta_lim_lat_lon.translate(
slepian_dirac_delta_lim_lat_lon._alpha,
beta,
shannon=slepian_dirac_delta_lim_lat_lon.slepian.N,
shannon=slepian_dirac_delta_lim_lat_lon.slepian.N, # ty: ignore[possibly-missing-attribute]
)
field = sleplet.slepian_methods.slepian_inverse(
sdd_trans,
Expand Down
Loading
Loading