lint and mypy fixes

This commit is contained in:
jan 2025-12-30 00:22:29 -08:00
parent 1b2e2070f9
commit a6b6d23cdb
3 changed files with 17 additions and 13 deletions

View File

@ -1,4 +1,4 @@
from .obr import OBRData
from .obr import OBRData as OBRData
__version__ = '0.1'

View File

@ -1,4 +1,4 @@
from typing import IO, Self
from typing import IO
from dataclasses import dataclass
from pathlib import Path
import logging
@ -32,14 +32,14 @@ class OBRData:
"""
Time delay (x-axis) for `te` and `tm` data
"""
tt = numpy.arange(self.tee.size) * self.dt_ns + self.t0half * 2
tt = numpy.arange(self.te.size, dtype=numpy.float64) * self.dt_ns + self.t0half * 2
return tt
@property
def wl_range_nm(self) -> NDArray[numpy.float64]:
freq_range = numpy.asarray([
self.max_freq_GHz - 1 / (2 * self.dt_ns),
welf.max_freq_GHz,
self.max_freq_GHz,
])
return C0 / freq_range
@ -66,7 +66,7 @@ class OBRData:
return scale * ham
@staticmethod
def read(file: str | IO[bytes] | Path) -> Self:
def read(file: str | IO[bytes] | Path) -> 'OBRData':
def fromfile(*args, **kwargs) -> NDArray:
if not isinstance(file, str | Path):
file.seek(0)
@ -77,11 +77,12 @@ class OBRData:
logger.warning(f'Unexpected magic bytes: {magic}')
metadata = fromfile(dtype=numpy.float64, offset=0x0c, count=4)
ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1)
gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1)
ng = fromfile(dtype=numpy.float64, offset=0x2e, count=1)[0]
gain_dB = fromfile(dtype=numpy.int16, offset=0x36, count=1)[0]
dates = fromfile(dtype=numpy.int16, offset=0x46, count=2 * 8)
t0half = fromfile(dtype=numpy.float64, offset=0x96, count=1)
t0half = fromfile(dtype=numpy.float64, offset=0x96, count=1)[0]
freq_windowed = fromfile(dtype=numpy.int8, offset=0xb6, count=1).any()
raw_sweep_rate = fromfile(dtype=numpy.uint8, offset=0xb9, count=2)
arr = fromfile(dtype=numpy.float64, offset=0x800)
max_freq_GHz = metadata[0]
@ -101,11 +102,13 @@ class OBRData:
gain_dB = gain_dB,
max_freq_GHz = max_freq_GHz,
ng_setting = ng,
freq_windowed = freq_windowed,
freq_windowed = bool(freq_windowed),
meas_date = meas_date,
calib_date = calib_date,
_wip_metadata = metadata[1:3],
_raw_sweep_rate = raw_sweep_rate, # TODO translate
)
return result

View File

@ -1,4 +1,4 @@
from typing import IO, Self
from typing import IO
from dataclasses import dataclass
from pathlib import Path
import logging
@ -27,14 +27,14 @@ class OVABINData:
"""
Time delay (x-axis) for `te` and `tm` data
"""
tt = numpy.arange(self.tee.size) * self.dt_ns
tt = numpy.arange(self.te.size, dtype=numpy.float64) * self.dt_ns
return tt
@property
def wl_range_nm(self) -> NDArray[numpy.float64]:
freq_range = numpy.asarray([
self.max_freq_GHz - 1 / (2 * self.dt_ns),
welf.max_freq_GHz,
self.max_freq_GHz,
])
return C0 / freq_range
@ -61,7 +61,7 @@ class OVABINData:
return scale * ham
@staticmethod
def read(file: str | IO[bytes] | Path) -> Self:
def read(file: str | IO[bytes] | Path) -> 'OVABINData':
raise NotImplementedError('Still WIP')
def fromfile(*args, **kwargs) -> NDArray:
if not isinstance(file, str | Path):
@ -96,6 +96,7 @@ class OVABINData:
meas_date = meas_date,
_wip_metadata = metadata[1:],
)
return result
"""