Skip to content

Commit d857fd5

Browse files
Fix order and type conversion of fluidics["reservoir"] column (#85)
* Run pre-commit on Python 3.13 * Modify test to show that `fluidics["reservoir"]` was broken * Fix bug in conversion of enum columns The bug was introduced in #67 and released in v1.4.2 (2024-06-18).
1 parent c8c11d3 commit d857fd5

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ jobs:
1212
- uses: actions/checkout@v5
1313
- uses: actions/setup-python@v6
1414
with:
15-
python-version: '3.x'
15+
python-version: '3.13'
1616
- uses: pre-commit/[email protected]

bletl/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def __to_typed_cols__(
3838
dfout[ncol] = None
3939
elif issubclass(typ, enum.Enum):
4040
# Enum types are kept as object-series
41-
dfout[ncol] = pandas.Series([typ(x) for x in dfin[ocol]], name=ncol, dtype=object)
41+
dfout[ncol] = pandas.Series(
42+
[typ(x) for x in dfin[ocol]], index=dfin.index, name=ncol, dtype=object
43+
)
4244
else:
4345
dfout[ncol] = dfin[ocol].astype(typ)
4446
return dfout

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "bletl"
9-
version = "1.6.1"
9+
version = "1.6.2"
1010
description = "Package for parsing and transforming BioLector raw data."
1111
readme = "README.md"
1212
requires-python = ">=3.8"

tests/test_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,5 +683,8 @@ def test_issue_38(self):
683683
def test_fluidics_source(self):
684684
fp = dir_testfiles / "BLPro" / "18-FZJ-Test2--2018-02-07-10-01-11.csv"
685685
bldata = bletl.parse(fp)
686-
assert isinstance(bldata.fluidics["reservoir"][0], bletl.FluidicsSource)
686+
correct_type = numpy.array(
687+
[isinstance(r, bletl.FluidicsSource) for r in bldata.fluidics["reservoir"]]
688+
)
689+
assert all(correct_type), f"{sum(correct_type)/len(correct_type)} % correct"
687690
pass

0 commit comments

Comments
 (0)