Skip to content
Merged
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
2 changes: 1 addition & 1 deletion autoarray/inversion/mesh/mesh_geometry/delaunay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import scipy.spatial
from typing import Tuple

from autonerves import cached_property
Expand Down Expand Up @@ -147,6 +146,7 @@ def neighbors(self) -> Neighbors:
The neighbors of a Voronoi mesh are computed using the `ridge_points` attribute of the scipy `Voronoi`
object, as described in the method `voronoi_neighbors_from`.
"""
import scipy.spatial

delaunay = scipy.spatial.Delaunay(self.mesh_grid_xy)

Expand Down
3 changes: 2 additions & 1 deletion autoarray/operators/coarse_interp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""

import numpy as np
from scipy.sparse import csr_matrix

from autoarray import exc
from autoarray import numba_util
Expand Down Expand Up @@ -242,6 +241,8 @@ def coarse_interp_matrix_from(
A ``scipy.sparse.csr_matrix`` of shape
[n_unmasked_fine_pixels, n_unmasked_coarse_pixels].
"""
from scipy.sparse import csr_matrix

mask_itp_box = np.asarray(mask_itp_box)
if np.count_nonzero(~mask_itp_box) == 0:
raise exc.MeshException(
Expand Down
11 changes: 8 additions & 3 deletions autoarray/operators/derivative_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"""

import numpy as np
from scipy.sparse import csr_matrix

from autoarray import exc
from autoarray import numba_util
Expand Down Expand Up @@ -297,9 +296,11 @@ def derivative_1st_operators_from(mask, pixel_scale: float = 1.0):
-------
The (Hy, Hx) operators as ``scipy.sparse.csr_matrix``.
"""
from scipy.sparse import csr_matrix

mask, diff_types = _diff_types_of_cleaned_mask_from(mask)
rows_hx, cols_hx, data_hx, rows_hy, cols_hy, data_hy = (
derivative_1st_triplets_from(mask, diff_types, dpix=pixel_scale)
rows_hx, cols_hx, data_hx, rows_hy, cols_hy, data_hy = derivative_1st_triplets_from(
mask, diff_types, dpix=pixel_scale
)

n_unmasked = np.count_nonzero(~mask)
Expand Down Expand Up @@ -443,6 +444,8 @@ def derivative_2nd_operators_from(mask, pixel_scale: float = 1.0):
-------
The (Hyy, Hxx) operators as ``scipy.sparse.csr_matrix``.
"""
from scipy.sparse import csr_matrix

mask, diff_types = _diff_types_of_cleaned_mask_from(mask)
rows_hxx, cols_hxx, data_hxx, rows_hyy, cols_hyy, data_hyy = (
derivative_2nd_triplets_from(mask, diff_types, dpix=pixel_scale)
Expand Down Expand Up @@ -574,6 +577,8 @@ def forward_difference_operators_from(
-------
The (Hy, Hx) operators as ``scipy.sparse.csr_matrix``.
"""
from scipy.sparse import csr_matrix

if max_order not in (1, 2, 3, 4):
raise ValueError(f"max_order must be in 1..4, got {max_order}")

Expand Down
Loading