Skip to content

Commit adb6281

Browse files
allow zero values in the measures but skipping nan values
1 parent 3cbf701 commit adb6281

4 files changed

Lines changed: 526 additions & 9 deletions

File tree

src/allotropy/parsers/moldev_softmax_pro/softmax_pro_data_creator.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ def _get_data_cube(
7878
)
7979
],
8080
dimensions=[data_element.elapsed_time],
81-
measures=[data_element.kinetic_measures],
81+
measures=[
82+
[
83+
value if value is not None else NEGATIVE_ZERO
84+
for value in data_element.kinetic_measures
85+
]
86+
],
8287
)
8388

8489

@@ -87,7 +92,7 @@ def _get_spectrum_data_cube(
8792
) -> DataCube | None:
8893
wavelengths = [data_element.wavelength for data_element in data_elements]
8994
values = [data_element.value for data_element in data_elements]
90-
if NEGATIVE_ZERO in values:
95+
if None in values:
9196
# Ignore the wells completely from the ASM if there is an nan value
9297
return None
9398

@@ -106,7 +111,7 @@ def _get_spectrum_data_cube(
106111
)
107112
],
108113
dimensions=[wavelengths],
109-
measures=[values],
114+
measures=[[value if value is not None else NEGATIVE_ZERO for value in values]],
110115
)
111116

112117

@@ -173,17 +178,29 @@ def _create_measurements(plate_block: PlateBlock, position: str) -> list[Measure
173178
type_=measurement_type,
174179
identifier=data_element.uuid,
175180
absorbance=(
176-
data_element.value
181+
(
182+
data_element.value
183+
if data_element.value is not None
184+
else NEGATIVE_ZERO
185+
)
177186
if measurement_type == MeasurementType.ULTRAVIOLET_ABSORBANCE
178187
else None
179188
),
180189
fluorescence=(
181-
data_element.value
190+
(
191+
data_element.value
192+
if data_element.value is not None
193+
else NEGATIVE_ZERO
194+
)
182195
if measurement_type == MeasurementType.FLUORESCENCE
183196
else None
184197
),
185198
luminescence=(
186-
data_element.value
199+
(
200+
data_element.value
201+
if data_element.value is not None
202+
else NEGATIVE_ZERO
203+
)
187204
if measurement_type == MeasurementType.LUMINESCENCE
188205
else None
189206
),

src/allotropy/parsers/moldev_softmax_pro/softmax_pro_structure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class DataElement:
373373
temperature: float | None
374374
wavelength: float
375375
position: str
376-
value: float
376+
value: float | None
377377
error_document: list[ErrorDocument]
378378
custom_info: dict[str, str] = field(default_factory=dict)
379379
elapsed_time: list[float] = field(default_factory=list)
@@ -422,7 +422,7 @@ def create(
422422
temperature=temperature,
423423
wavelength=wavelength,
424424
position=str(position),
425-
value=NEGATIVE_ZERO if value is None else value,
425+
value=value,
426426
error_document=(
427427
[ErrorDocument(str(raw_value), header.read_mode)]
428428
if value is None
@@ -702,7 +702,7 @@ def create(
702702
temperature=temperature,
703703
wavelength=wavelength,
704704
position=str(position),
705-
value=NEGATIVE_ZERO if value is None else value,
705+
value=value,
706706
error_document=error_document,
707707
)
708708

src/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from allotropy.parser_factory import Vendor
2+
from allotropy.testing.utils import from_file
3+
4+
file_name = "partial_plate_with_empty_values.txt"
5+
6+
test_filepath = f"../tests/parsers/moldev_softmax_pro/testdata/{file_name}"
7+
test_output_file = f"{test_filepath.replace('txt', 'json')}"
8+
allotrope_dict = from_file(test_filepath, Vendor.MOLDEV_SOFTMAX_PRO)
9+
10+
# print(json.dumps(allotrope_dict, indent=4, ensure_ascii=False))
11+
# with open(test_output_file, "w", encoding="utf-8") as output_file:
12+
# output_file.write(json.dumps(allotrope_dict, indent=4, ensure_ascii=False))

0 commit comments

Comments
 (0)