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

Make submodules private #28

Merged
merged 1 commit into from
Aug 24, 2023
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
14 changes: 7 additions & 7 deletions src/tophu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .filter import *
from .io import *
from .multilook import *
from .multiscale import *
from .unwrap import *
from .upsample import *
from .util import *
from ._filter import *
from ._io import *
from ._multilook import *
from ._multiscale import *
from ._unwrap import *
from ._upsample import *
from ._util import *

__version__ = "0.1.0"
File renamed without changes.
6 changes: 3 additions & 3 deletions src/tophu/io.py → src/tophu/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import rasterio
from numpy.typing import ArrayLike, DTypeLike

from . import util
from ._util import as_tuple_of_int

__all__ = [
"DatasetReader",
Expand Down Expand Up @@ -154,7 +154,7 @@ def __init__(
object.
"""
filepath = Path(filepath)
shape = util.as_tuple_of_int(shape)
shape = as_tuple_of_int(shape)
dtype = np.dtype(dtype)

# Get array size in bytes.
Expand Down Expand Up @@ -298,7 +298,7 @@ def __init__(
# Create the HDF5 file and dataset if they don't already exist.
# If the dataset already exists, make sure its shape & dtype are as
# specified.
shape = util.as_tuple_of_int(shape)
shape = as_tuple_of_int(shape)
dtype = np.dtype(dtype)
with h5py.File(filepath, "a") as f:
dataset = f.require_dataset(
Expand Down
4 changes: 2 additions & 2 deletions src/tophu/multilook.py → src/tophu/_multilook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import dask.array as da
import numpy as np

from . import util
from ._util import iseven

__all__ = [
"multilook",
Expand Down Expand Up @@ -64,7 +64,7 @@ def multilook(arr: da.Array, nlooks: int | Iterable[int]) -> da.Array:
raise ValueError("number of looks should not exceed array shape")

# Warn if the number of looks along any axis is even-valued.
if any(map(util.iseven, nlooks)):
if any(map(iseven, nlooks)):
warnings.warn(
"one or more components of nlooks is even-valued -- this will result in"
" a phase delay in the multilooked data equivalent to a half-bin shift",
Expand Down
34 changes: 17 additions & 17 deletions src/tophu/multiscale.py → src/tophu/_multiscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import scipy.signal
from numpy.typing import ArrayLike, NDArray

from . import util
from .filter import bandpass_equiripple_filter
from .io import DatasetReader, DatasetWriter
from .multilook import multilook
from .unwrap import UnwrapCallback
from .upsample import upsample_nearest
from . import _util
from ._filter import bandpass_equiripple_filter
from ._io import DatasetReader, DatasetWriter
from ._multilook import multilook
from ._unwrap import UnwrapCallback
from ._upsample import upsample_nearest

__all__ = [
"multiscale_unwrap",
Expand Down Expand Up @@ -325,7 +325,7 @@
coherence_lores_singleblock = to_single_chunk(coherence_lores)

# Unwrap the downsampled data.
unwrapped_lores, conncomp_lores = util.map_blocks(
unwrapped_lores, conncomp_lores = _util.map_blocks(
unwrap_func,
igram_lores_singleblock,
coherence_lores_singleblock,
Expand Down Expand Up @@ -512,7 +512,7 @@
# downsampling was requested. This case is functionally equivalent to just making a
# single call to `unwrap_func()`.
if (igram.numblocks == 1) and (downsample_factor == (1, 1)):
return util.map_blocks( # type: ignore[return-value]
return _util.map_blocks( # type: ignore[return-value]

Check warning on line 515 in src/tophu/_multiscale.py

View check run for this annotation

Codecov / codecov/patch

src/tophu/_multiscale.py#L515

Added line #L515 was not covered by tests
unwrap_func,
igram,
coherence,
Expand All @@ -536,7 +536,7 @@
)

# Unwrap each tile independently.
unwrapped, conncomp = util.map_blocks(
unwrapped, conncomp = _util.map_blocks(
unwrap_func,
igram,
coherence,
Expand Down Expand Up @@ -585,8 +585,8 @@
Shape of a typical tile. The last tile along each axis may be smaller.
"""
# Normalize `shape` and `ntiles` into tuples of ints.
shape = util.as_tuple_of_int(shape)
ntiles = util.as_tuple_of_int(ntiles)
shape = _util.as_tuple_of_int(shape)
ntiles = _util.as_tuple_of_int(ntiles)

# Number of dimensions of the partitioned array.
ndim = len(shape)
Expand All @@ -598,18 +598,18 @@
if any(map(lambda n: n < 1, ntiles)):
raise ValueError("number of tiles must be >= 1")

tiledims = util.ceil_divide(shape, ntiles)
tiledims = _util.ceil_divide(shape, ntiles)

if snap_to is not None:
# Normalize `snap_to` to a tuple of ints.
snap_to = util.as_tuple_of_int(snap_to)
snap_to = _util.as_tuple_of_int(snap_to)

if len(snap_to) != ndim:
if len(snap_to) != ndim: # type: ignore[arg-type]
raise ValueError("size mismatch: shape and snap_to must have same length")
if any(map(lambda s: s < 1, snap_to)):
if any(map(lambda s: s < 1, snap_to)): # type: ignore[arg-type]
raise ValueError("snap_to lengths must be >= 1")

tiledims = util.round_up_to_next_multiple(tiledims, snap_to)
tiledims = _util.round_up_to_next_multiple(tiledims, snap_to)

# Tile dimensions should not exceed the full array dimensions.
tiledims = tuple(np.minimum(tiledims, shape))
Expand Down Expand Up @@ -725,4 +725,4 @@
)

# Store results.
da.store([da_unwrapped, da_conncomp], [unwrapped, conncomp], lock=util.get_lock())
da.store([da_unwrapped, da_conncomp], [unwrapped, conncomp], lock=_util.get_lock())
File renamed without changes.
6 changes: 3 additions & 3 deletions src/tophu/upsample.py → src/tophu/_upsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import scipy.fft
from numpy.typing import ArrayLike, NDArray

from . import util
from ._util import iseven

__all__ = [
"upsample_fft",
Expand Down Expand Up @@ -153,13 +153,13 @@ def negfreqbins(n: int) -> slice:
# Nyquist bin in the padded array.
for axis in axes:
n = data.shape[axis]
if util.iseven(n):
if iseven(n):
s = [slice(None)] * data.ndim
s[axis] = n // 2
Y[tuple(s)] *= 0.5
for axis in axes:
n = data.shape[axis]
if util.iseven(n):
if iseven(n):
s1 = [slice(None)] * data.ndim
s1[axis] = n // 2
s2 = [slice(None)] * data.ndim
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/test_multiscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from numpy.typing import ArrayLike, NDArray

import tophu
from tophu.multiscale import get_tile_dims
from tophu.unwrap import UnwrapCallback
from tophu import UnwrapCallback
from tophu._multiscale import get_tile_dims

from .simulate import simulate_phase_noise, simulate_terrain

Expand Down