Skip to content

Commit

Permalink
Merge pull request #43 from JuBiotech/reservoir-dtype
Browse files Browse the repository at this point in the history
Treat reservoir ID in fluidics as int
  • Loading branch information
bertramgeinitz authored Aug 2, 2023
2 parents 40d0e0a + 103e429 commit 2006f0a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions bletl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
BLData,
BLDParser,
FilterTimeSeries,
FluidicsSource,
IncompatibleFileError,
InvalidLotNumberError,
LotInformationError,
Expand Down
3 changes: 2 additions & 1 deletion bletl/parsing/blpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
BLData,
BLDParser,
FilterTimeSeries,
FluidicsSource,
InvalidLotNumberError,
)

Expand Down Expand Up @@ -346,7 +347,7 @@ def extract_fluidics(dfraw):
("Cycle", "cycle", int),
("Well", "well", int),
("Time", "time", float),
("Reservoir", "reservoir", float),
("Reservoir", "reservoir", FluidicsSource),
("MF_Volume", "mf_volume", float),
("Temp_Ch4", "volume", float),
]
Expand Down
15 changes: 14 additions & 1 deletion bletl/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import enum
import os
import typing
import warnings
from typing import Dict, Optional, Tuple, Union

import numpy
Expand All @@ -19,6 +18,20 @@ class BioLectorModel(enum.Enum):
XT = "blXT"


class FluidicsSource(enum.IntEnum):
"""Number that identifies the source of volume changes."""

ReservoirA = 1

"""Additions from reservoir A."""
ReservoirB = 2

"""Additions from reservoir B."""

Pipetting = -1
"""Additions from pipetting."""


class BLData(dict):
"""Standardized data type for BioLector data."""

Expand Down
6 changes: 5 additions & 1 deletion bletl/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Contains helper functions that do not depend on other modules within this package."""
import datetime
import enum
import pathlib
import re
import urllib
from typing import Optional, Sequence, Tuple, Union
from typing import Optional, Sequence, Tuple

import pandas

Expand Down Expand Up @@ -32,6 +33,9 @@ def __to_typed_cols__(
for ocol, ncol, typ in ocol_ncol_type:
if ocol is None or not ocol in dfin:
dfout[ncol] = None
elif issubclass(typ, enum.Enum):
# Enum types are kept as object-series
dfout[ncol] = dfin[ocol].apply(lambda x: typ(x), convert_dtype=False)
else:
dfout[ncol] = dfin[ocol].astype(typ)
return dfout
Expand Down
6 changes: 6 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,3 +635,9 @@ def test_issue_38(self):
assert bldata.fluidics.loc["E06", "volume"][-1] == 913.16
assert bldata.fluidics.loc["F01", "volume"][-1] == 1202.719
pass

def test_fluidics_source(self):
fp = dir_testfiles / "BLPro" / "18-FZJ-Test2--2018-02-07-10-01-11.csv"
bldata = bletl.parse(fp)
assert isinstance(bldata.fluidics["reservoir"][0], bletl.FluidicsSource)
pass

0 comments on commit 2006f0a

Please sign in to comment.