Skip to content

Commit 72e012c

Browse files
Clean up imports
1 parent 38a8875 commit 72e012c

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

bletl/core.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
"""Specifies the base types for parsing and representing BioLector CSV files."""
2-
import abc
3-
import enum
4-
import os
5-
import pathlib
6-
import typing
7-
import urllib.error
8-
import urllib.request
9-
import warnings
102
from collections.abc import Iterable
3+
from pathlib import Path
114
from typing import Optional, Sequence, Union
125

13-
import numpy
146
import pandas
157

168
from . import parsing, utils
@@ -20,11 +12,6 @@
2012
BLDParser,
2113
FilterTimeSeries,
2214
IncompatibleFileError,
23-
InvalidLotNumberError,
24-
LotInformationError,
25-
LotInformationMismatch,
26-
LotInformationNotFound,
27-
NoMeasurementData,
2815
)
2916

3017
parsers = {
@@ -33,12 +20,12 @@
3320
}
3421

3522

36-
def get_parser(filepath: Union[str, pathlib.Path]) -> BLDParser:
23+
def get_parser(filepath: Union[str, Path]) -> BLDParser:
3724
"""Analyzes a raw BioLector file and selects an appropiate parser.
3825
3926
Parameters
4027
----------
41-
filepath : str or pathlib.Path
28+
filepath : str or Path
4229
Path pointing to the file of interest.
4330
4431
Returns
@@ -90,7 +77,7 @@ def get_parser(filepath: Union[str, pathlib.Path]) -> BLDParser:
9077

9178

9279
def _parse(
93-
filepath: str,
80+
filepath: Union[str, Path],
9481
drop_incomplete_cycles: bool,
9582
lot_number: Optional[int],
9683
temp: Optional[int],
@@ -105,7 +92,7 @@ def _parse(
10592
10693
Parameters
10794
----------
108-
filepath : str or pathlib.Path
95+
filepath : str or Path
10996
Path pointing to the file of interest.
11097
drop_incomplete_cycles : bool
11198
If `True`, incomplete cycles at the end are discarded.
@@ -160,7 +147,7 @@ def _parse(
160147

161148

162149
def parse(
163-
filepaths: Union[str, Sequence[str]],
150+
filepaths: Union[Union[str, Path], Sequence[Union[str, Path]]],
164151
*,
165152
drop_incomplete_cycles: bool = True,
166153
lot_number: Optional[int] = None,
@@ -176,7 +163,7 @@ def parse(
176163
177164
Parameters
178165
----------
179-
filepaths : str or pathlib.Path or iterable
166+
filepaths : str or Path or iterable
180167
Path pointing to the file(s) of interest.
181168
If an iterable is provided, files are concatenated.
182169
drop_incomplete_cycles : bool

bletl/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import pathlib
66
import re
77
import urllib
8+
import urllib.error
9+
import urllib.request
810
from typing import Optional, Sequence, Tuple
911

1012
import pandas

tests/test_core.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
import numpy
66
import pandas
77
import pytest
8-
from numpy import random
98

109
import bletl
11-
from bletl import core, parsing, utils
10+
from bletl import (
11+
InvalidLotNumberError,
12+
LotInformationMismatch,
13+
NoMeasurementData,
14+
core,
15+
parsing,
16+
utils,
17+
)
1218
from bletl.parsing import bl1, blpro
1319

1420
dir_testfiles = pathlib.Path(pathlib.Path(__file__).absolute().parent, "data")
@@ -302,7 +308,7 @@ def test_get_unified_narrow_data(self):
302308
data.get_unified_narrow_data(source_well="O9000")
303309

304310
def test_NoMeasurements_Warning(self):
305-
with pytest.warns(core.NoMeasurementData):
311+
with pytest.warns(NoMeasurementData):
306312
bletl.parse(file_with_no_measurements)
307313

308314

@@ -369,7 +375,7 @@ def test_fragments_with_cal_data(self):
369375
return
370376

371377
def test_mismatch_warning(self):
372-
with pytest.warns(core.LotInformationMismatch):
378+
with pytest.warns(LotInformationMismatch):
373379
bletl.parse(file_with_lot_info, lot_number=1818, temp=37)
374380
return
375381

@@ -381,7 +387,7 @@ def test_get_calibration_dict(self):
381387
return
382388

383389
def test_invalid_lot_number(self):
384-
with pytest.raises(core.InvalidLotNumberError):
390+
with pytest.raises(InvalidLotNumberError):
385391
bl1.fetch_calibration_data(99, 99)
386392
return
387393

0 commit comments

Comments
 (0)