Skip to content

Commit

Permalink
Type fixes, got prematurely excited about 3.10 notation
Browse files Browse the repository at this point in the history
  • Loading branch information
league committed Apr 19, 2024
1 parent 076d9fb commit 1c074b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]

[mypy-scipy.fftpack.*]
ignore_missing_imports = True
6 changes: 3 additions & 3 deletions python/bifrost/blocks/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
from bifrost.DataType import DataType

from copy import deepcopy
from typing import Optional
from typing import Optional, Union

from bifrost import telemetry
telemetry.track_module()

class DetectBlock(TransformBlock):
def __init__(self, iring, mode: str, axis: Optional[int|str] = None,
def __init__(self, iring, mode: str, axis: Optional[Union[int,str]] = None,
*args, **kwargs):
super(DetectBlock, self).__init__(iring, *args, **kwargs)
self.specified_axis = axis
Expand Down Expand Up @@ -137,7 +137,7 @@ def on_data(self, ispan, ospan):
bf_map(func, shape=shape, axis_names=inds,
data={'a': ispan.data, 'b': ospan.data})

def detect(iring, mode: str, axis: Optional[int|str] = None, *args, **kwargs):
def detect(iring, mode: str, axis: Optional[Union[int,str]] = None, *args, **kwargs):
"""Apply square-law detection to create polarization products.
Args:
iring (Ring or Block): Input data source.
Expand Down
8 changes: 4 additions & 4 deletions python/bifrost/blocks/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
from copy import deepcopy
import numpy as np

from typing import Any, Dict
from typing import Any, Dict, Union, Tuple

from bifrost import telemetry
telemetry.track_module()

class QuantizeBlock(TransformBlock):
def __init__(self, iring: Ring, dtype: str|np.dtype, scale: float=1.,
def __init__(self, iring: Ring, dtype: Union[str,np.dtype], scale: float=1.,
*args, **kwargs):
super(QuantizeBlock, self).__init__(iring, *args, **kwargs)
self.dtype = dtype
self.scale = scale
def define_valid_input_spaces(self) -> tuple[str]:
def define_valid_input_spaces(self) -> Tuple[str]:
"""Return set of valid spaces (or 'any') for each input"""
return ('any',)
def on_sequence(self, iseq: ReadSequence) -> Dict[str,Any]:
Expand All @@ -65,7 +65,7 @@ def on_data(self, ispan: ReadSpan, ospan: WriteSpan) -> None:
odata = ospan.data
bf_quantize(idata, odata, self.scale)

def quantize(iring: Ring, dtype: str|np.dtype, scale: float=1., *args, **kwargs) -> QuantizeBlock:
def quantize(iring: Ring, dtype: Union[str,np.dtype], scale: float=1., *args, **kwargs) -> QuantizeBlock:
"""Apply a requantization of bit depth for the data.
Args:
Expand Down
8 changes: 4 additions & 4 deletions python/bifrost/blocks/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
from copy import deepcopy
import numpy as np

from typing import Any, Dict
from typing import Any, Dict, Union, Tuple

from bifrost import telemetry
telemetry.track_module()

class UnpackBlock(TransformBlock):
def __init__(self, iring: Ring, dtype: str|np.dtype, align_msb: bool=False,
def __init__(self, iring: Ring, dtype: Union[str,np.dtype], align_msb: bool=False,
*args, **kwargs):
super(UnpackBlock, self).__init__(iring, *args, **kwargs)
self.dtype = dtype
self.align_msb = align_msb
def define_valid_input_spaces(self) -> tuple[str]:
def define_valid_input_spaces(self) -> Tuple[str]:
"""Return set of valid spaces (or 'any') for each input"""
return ('any',)
def on_sequence(self, iseq: ReadSequence) -> Dict[str,Any]:
Expand All @@ -65,7 +65,7 @@ def on_data(self, ispan: ReadSpan, ospan: WriteSpan) -> None:
odata = ospan.data
bf_unpack(idata, odata, self.align_msb)

def unpack(iring: Ring, dtype: str|np.dtype, *args, **kwargs) -> UnpackBlock:
def unpack(iring: Ring, dtype: Union[str,np.dtype], *args, **kwargs) -> UnpackBlock:
"""Unpack data to a larger data type.
Args:
Expand Down

0 comments on commit 1c074b7

Please sign in to comment.