Skip to content

Commit

Permalink
fixed mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhoyt committed Sep 4, 2024
1 parent 8afec33 commit f2cf2c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 9 additions & 3 deletions imap_processing/lo/l0/data_classes/star_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@


@dataclass
class StarSensor(LoBase):
# Temporarily ignoring this mypy error: Class cannot subclass "LoBase" (has type "Any")
# This data class will soon be removed and LoBase will
# no longer be used by the time star sensor is integrated into the
# L1A processing pipeline
class StarSensor(LoBase): # type: ignore
"""
L1A Star Sensor data class.
Expand Down Expand Up @@ -90,7 +94,9 @@ def _decompress_data(self) -> None:
extracted_integer = int(binary_string.next_bits(bit_length), 2)
# The Star Sensor packet uses a 12 to 8 bit compression
decompressed_integer = decompress_int(
extracted_integer, Decompress.DECOMPRESS8TO12, DECOMPRESSION_TABLES
[extracted_integer], Decompress.DECOMPRESS8TO12, DECOMPRESSION_TABLES
)
data_list.append(decompressed_integer)
# TODO: Need to update this to work with decompress_int outputting
# a list of ints. Remove function from loop during refactor
data_list.append(decompressed_integer[0])
self.DATA = np.array(data_list)
6 changes: 3 additions & 3 deletions imap_processing/lo/l0/lo_science.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def decompress(

# parse the binary and convert to integers
raw_ints = [
int(bin_str[i: i + bits_per_index], 2)
int(bin_str[i : i + bits_per_index], 2)
for i in range(section_start, section_start + section_length, bits_per_index)
]

#decompress raw integers
decompressed_ints = decompress_int(
# decompress raw integers
decompressed_ints: list[int] = decompress_int(
raw_ints,
decompress,
DECOMPRESSION_TABLES,
Expand Down
9 changes: 4 additions & 5 deletions imap_processing/lo/l0/utils/bit_decompression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from enum import Enum
from pathlib import Path
from typing import Any

import numpy as np

Expand All @@ -28,7 +27,7 @@ class Decompress(Enum):

def decompress_int(
compressed_values: list, decompression: Decompress, decompression_lookup: dict
) -> Any:
) -> list[int]:
# No idea what the correct type is for the return. Mypy says it is Any
"""
Will decompress a data field using a specified bit conversion.
Expand All @@ -44,7 +43,7 @@ def decompress_int(
Returns
-------
decompressed : list
decompressed : list[int]
The decompressed integer.
"""
valid_decompression = [
Expand All @@ -59,5 +58,5 @@ def decompress_int(
+ "Decompress.DECOMPRESS8TO12"
)
data = decompression_lookup[decompression]

return data[compressed_values, 1]
decompressed: list[int] = data[compressed_values, 1]
return decompressed

0 comments on commit f2cf2c2

Please sign in to comment.