Skip to content

Commit

Permalink
origin file added to LSCSample
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Dec 18, 2024
1 parent a331274 commit 873f105
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libra_toolbox/tritium/lsc_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ def get_lum(self) -> List[float]:

class LSCSample:
activity: pint.Quantity
origin_file: str

def __init__(self, activity: pint.Quantity, name: str):
self.activity = activity
self.name = name
# TODO add other attributes available in LSC file
self.background_substracted = False
self.origin_file = None

def __str__(self):
return f"Sample {self.name}"
Expand Down Expand Up @@ -153,7 +155,9 @@ def from_file(file_reader: LSCFileReader, vial_name: str) -> "LSCSample":
if vial_name not in values:
raise ValueError(f"Vial {vial_name} not found in the file reader.")
activity = values[vial_name] * ureg.Bq
return LSCSample(activity, vial_name)
sample = LSCSample(activity, vial_name)
sample.origin_file = file_reader.file_path
return sample


class LIBRASample:
Expand Down
12 changes: 12 additions & 0 deletions test/tritium/test_lsc_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ def test_lscsample_from_file_when_not_found():
ValueError, match="Vial coucoucou not found in the file reader."
):
LSCSample.from_file(file_reader, "coucoucou")


def test_lsc_sample_has_origin_file():
"""Test that the origin file is set when creating a LSCSample from a LSCFileReader"""
filename = Path(__file__).parent / "test_lsc_file_with_labels.csv"

csv_reader = LSCFileReader(filename, labels_column="SMPL_ID")
csv_reader.read_file()

sample = LSCSample.from_file(csv_reader, "1L-IV_2-0-4")

assert sample.origin_file == filename

0 comments on commit 873f105

Please sign in to comment.