Skip to content

Commit 42af64e

Browse files
gmgunterGitHub Enterprise
authored andcommitted
Fixes for Python 3.7 (#972)
* Remove use of position-only parameter syntax * Remove usage of `typing.Literal` (both require Python 3.8)
1 parent 21df93e commit 42af64e

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

python/packages/isce3/unwrap/snaphu.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@
33
import pathlib
44
import tempfile
55
from dataclasses import dataclass
6-
from typing import Literal, Optional, Union
6+
from typing import Optional, Union
77

88
import isce3
99
import numpy as np
1010
from pybind_isce3.unwrap import _snaphu_unwrap
1111

1212

13-
TransmitMode = Literal["pingpong", "repeat_pass", "single_antenna_transmit"]
14-
TransmitMode.__doc__ = """Radar transmit mode
15-
16-
'pingpong' and 'repeat_pass' modes indicate that both antennas both
17-
transmitted and received. Both modes have the same effect in the algorithm.
18-
19-
'single_antenna_transmit' indicates that a single antenna was used to
20-
transmit while both antennas received. In this mode, the baseline is
21-
effectively halved.
22-
"""
23-
24-
2513
@dataclass(frozen=True)
2614
class TopoCostParams:
2715
r"""Configuration parameters for SNAPHU "topo" cost mode
@@ -159,7 +147,7 @@ class TopoCostParams:
159147
range_res: float
160148
az_res: float
161149
wavelength: float
162-
transmit_mode: TransmitMode
150+
transmit_mode: str
163151
altitude: float
164152
earth_radius: float = 6_378_000.0
165153
kds: float = 0.02
@@ -656,7 +644,7 @@ def tostring(self):
656644

657645

658646
@contextlib.contextmanager
659-
def scratch_directory(d: Optional[os.PathLike] = None, /) -> pathlib.Path:
647+
def scratch_directory(d: Optional[os.PathLike] = None) -> pathlib.Path:
660648
"""Context manager that creates a (possibly temporary) filesystem directory
661649
662650
If the input is a path-like object, a directory will be created at the
@@ -772,9 +760,6 @@ def from_flat_file(
772760
raster.data[i0:i1] = mmap[i0:i1]
773761

774762

775-
CostMode = Literal["topo", "defo", "smooth", "p-norm"]
776-
CostMode.__doc__ = """SNAPHU cost mode options"""
777-
778763
CostParams = Union[
779764
TopoCostParams, DefoCostParams, SmoothCostParams, PNormCostParams,
780765
]
@@ -787,7 +772,7 @@ def unwrap(
787772
igram: isce3.io.gdal.Raster,
788773
corr: isce3.io.gdal.Raster,
789774
nlooks: float,
790-
cost: CostMode = "smooth",
775+
cost: str = "smooth",
791776
cost_params: Optional[CostParams] = None,
792777
pwr: Optional[isce3.io.gdal.Raster] = None,
793778
mask: Optional[isce3.io.gdal.Raster] = None,

tests/python/packages/isce3/unwrap/snaphu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def next_power_of_two(n):
131131
return z[:length, :width]
132132

133133

134-
def jaccard_similarity(a, b, /):
134+
def jaccard_similarity(a, b):
135135
"""Compute the Jaccard similarity coefficient (intersect-over-union) of two
136136
boolean arrays.
137137

0 commit comments

Comments
 (0)