Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class MeasurementGroup:
@dataclass(frozen=True)
class Calibration:
name: str
report: str
time: str
report: str | None = None


@dataclass(frozen=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,39 @@ def _get_plate_well_count(cls, header_data: pd.DataFrame) -> float:
def create_calibration(calibration_data: SeriesData) -> Calibration:
"""Create a CalibrationItem from a calibration line.

Each line should follow the pattern "Last <calibration_name>,<calibration_report> <calibration_time><,,,,"
example: "Last F3DeCAL1 Calibration,Passed 05/17/2023 09:25:11,,,,,,"
Each line should follow one of these patterns:
- "Last <calibration_name>,<calibration_report> <calibration_time><,,,,"
- "Last <calibration_name>,<calibration_time><,,,,"
"""
if len(calibration_data.series.index) < MINIMUM_CALIBRATION_LINE_COLS:
msg = f"Expected at least two columns on the calibration line, got:\n{calibration_data.series}."
raise AllotropeConversionError(msg)

calibration_result = calibration_data.series.iloc[1].split(maxsplit=1)
if len(calibration_result) != EXPECTED_CALIBRATION_RESULT_LEN:
msg = f"Invalid calibration result format, expected to split into two values, got: {calibration_result}."
calibration_info = calibration_data.series.iloc[1].strip()

# Check if the calibration info starts with a known status value
status_values = ["Passed", "Failed", "Calibrated", "Verified"]
first_word = calibration_info.split()[0] if calibration_info.split() else ""

report = None
time = None

if first_word in status_values:
calibration_result = calibration_info.split(maxsplit=1)
if len(calibration_result) == EXPECTED_CALIBRATION_RESULT_LEN:
report = calibration_result[0]
time = calibration_result[1]
elif calibration_info and any(char.isdigit() for char in calibration_info):
Comment thread
nathan-stender marked this conversation as resolved.
time = calibration_info

if not time:
msg = f"Invalid calibration result format, got: ['{calibration_info}']."
raise AllotropeConversionError(msg)

return Calibration(
name=calibration_data.series.iloc[0].replace("Last", "").strip(),
report=calibration_result[0],
time=calibration_result[1],
time=time,
report=report,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_create_calibration_item() -> None:

assert create_calibration(
SeriesData(pd.Series([name, f"{report} {time}"]))
) == Calibration(name, report, time)
) == Calibration(name, time, report)


def test_create_calibration_item_invalid_line_format() -> None:
Expand All @@ -153,7 +153,7 @@ def test_create_calibration_item_invalid_line_format() -> None:

def test_create_calibration_item_invalid_calibration_result() -> None:
bad_result = "bad_result"
error = f"Invalid calibration result format, expected to split into two values, got: ['{bad_result}']"
error = f"Invalid calibration result format, got: ['{bad_result}']"
with pytest.raises(AllotropeConversionError, match=re.escape(error)):
create_calibration(SeriesData(pd.Series(["Last CalReport", bad_result])))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20553,7 +20553,7 @@
"file name": "luminex_xPONENT_NaN_and_not_reported_values.csv",
"UNC path": "tests/parsers/luminex_xponent/testdata/luminex_xPONENT_NaN_and_not_reported_values.csv",
"ASM converter name": "allotropy_luminex_xponent",
"ASM converter version": "0.1.98",
"ASM converter version": "0.1.99",
"software name": "xPONENT",
"software version": "4.3.309.1"
},
Expand All @@ -20564,33 +20564,27 @@
"calibration document": [
{
"calibration name": "F3DeCAL1 Calibration",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
},
{
"calibration name": "F3DCAL2 Calibration",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
},
{
"calibration name": "F3DCAL3 Calibration",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
},
{
"calibration name": "F3DeVER1 Verification",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
},
{
"calibration name": "F3DVER2 Verification",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
},
{
"calibration name": "Fluidics Test",
"calibration time": "2025-07-17T01:00:00+00:00",
"calibration report": "1/1/2025"
"calibration time": "2025-01-01T01:00:00+00:00"
}
]
}
Expand Down
Loading