Skip to content

Commit

Permalink
Clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelosthege committed Oct 11, 2024
1 parent 38a8875 commit 72e012c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
27 changes: 7 additions & 20 deletions bletl/core.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
"""Specifies the base types for parsing and representing BioLector CSV files."""
import abc
import enum
import os
import pathlib
import typing
import urllib.error
import urllib.request
import warnings
from collections.abc import Iterable
from pathlib import Path
from typing import Optional, Sequence, Union

import numpy
import pandas

from . import parsing, utils
Expand All @@ -20,11 +12,6 @@
BLDParser,
FilterTimeSeries,
IncompatibleFileError,
InvalidLotNumberError,
LotInformationError,
LotInformationMismatch,
LotInformationNotFound,
NoMeasurementData,
)

parsers = {
Expand All @@ -33,12 +20,12 @@
}


def get_parser(filepath: Union[str, pathlib.Path]) -> BLDParser:
def get_parser(filepath: Union[str, Path]) -> BLDParser:
"""Analyzes a raw BioLector file and selects an appropiate parser.
Parameters
----------
filepath : str or pathlib.Path
filepath : str or Path
Path pointing to the file of interest.
Returns
Expand Down Expand Up @@ -90,7 +77,7 @@ def get_parser(filepath: Union[str, pathlib.Path]) -> BLDParser:


def _parse(
filepath: str,
filepath: Union[str, Path],
drop_incomplete_cycles: bool,
lot_number: Optional[int],
temp: Optional[int],
Expand All @@ -105,7 +92,7 @@ def _parse(
Parameters
----------
filepath : str or pathlib.Path
filepath : str or Path
Path pointing to the file of interest.
drop_incomplete_cycles : bool
If `True`, incomplete cycles at the end are discarded.
Expand Down Expand Up @@ -160,7 +147,7 @@ def _parse(


def parse(
filepaths: Union[str, Sequence[str]],
filepaths: Union[Union[str, Path], Sequence[Union[str, Path]]],
*,
drop_incomplete_cycles: bool = True,
lot_number: Optional[int] = None,
Expand All @@ -176,7 +163,7 @@ def parse(
Parameters
----------
filepaths : str or pathlib.Path or iterable
filepaths : str or Path or iterable
Path pointing to the file(s) of interest.
If an iterable is provided, files are concatenated.
drop_incomplete_cycles : bool
Expand Down
2 changes: 2 additions & 0 deletions bletl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import pathlib
import re
import urllib
import urllib.error
import urllib.request
from typing import Optional, Sequence, Tuple

import pandas
Expand Down
16 changes: 11 additions & 5 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
import numpy
import pandas
import pytest
from numpy import random

import bletl
from bletl import core, parsing, utils
from bletl import (
InvalidLotNumberError,
LotInformationMismatch,
NoMeasurementData,
core,
parsing,
utils,
)
from bletl.parsing import bl1, blpro

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

def test_NoMeasurements_Warning(self):
with pytest.warns(core.NoMeasurementData):
with pytest.warns(NoMeasurementData):
bletl.parse(file_with_no_measurements)


Expand Down Expand Up @@ -369,7 +375,7 @@ def test_fragments_with_cal_data(self):
return

def test_mismatch_warning(self):
with pytest.warns(core.LotInformationMismatch):
with pytest.warns(LotInformationMismatch):
bletl.parse(file_with_lot_info, lot_number=1818, temp=37)
return

Expand All @@ -381,7 +387,7 @@ def test_get_calibration_dict(self):
return

def test_invalid_lot_number(self):
with pytest.raises(core.InvalidLotNumberError):
with pytest.raises(InvalidLotNumberError):
bl1.fetch_calibration_data(99, 99)
return

Expand Down

0 comments on commit 72e012c

Please sign in to comment.