From a12aaaa4f59affb9619e0c2034b4eb3f66e1973b Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Tue, 8 Aug 2023 15:58:40 +0200 Subject: [PATCH] cleaning --- examples/load_from_yaml.py | 10 +++------- hdxms_datasets/__init__.py | 7 ++++++- hdxms_datasets/datasets.py | 4 +++- hdxms_datasets/datavault.py | 2 +- hdxms_datasets/process.py | 5 +---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/load_from_yaml.py b/examples/load_from_yaml.py index 909e25b..ecfeed0 100644 --- a/examples/load_from_yaml.py +++ b/examples/load_from_yaml.py @@ -6,17 +6,13 @@ test_pth = Path("../tests").resolve() data_pth = test_pth / "datasets" -data_id = '20221007_1530_SecA_Krishnamurthy' +data_id = "20221007_1530_SecA_Krishnamurthy" hdx_spec = yaml.safe_load((data_pth / data_id / "hdx_spec.yaml").read_text()) metadata = yaml.safe_load((data_pth / data_id / "metadata.yaml").read_text()) #%% -dataset = HDXDataSet.from_spec( - hdx_spec, - data_dir=data_pth / data_id, - metadata=metadata -) +dataset = HDXDataSet.from_spec(hdx_spec, data_dir=data_pth / data_id, metadata=metadata) -print(dataset.describe()) \ No newline at end of file +print(dataset.describe()) diff --git a/hdxms_datasets/__init__.py b/hdxms_datasets/__init__.py index d998233..cdc14a4 100644 --- a/hdxms_datasets/__init__.py +++ b/hdxms_datasets/__init__.py @@ -4,5 +4,10 @@ from hdxms_datasets.config import cfg from hdxms_datasets.datasets import HDXDataSet, DataFile from hdxms_datasets.datavault import DataVault -from hdxms_datasets.process import convert_temperature, convert_time, filter_peptides, parse_data_files +from hdxms_datasets.process import ( + convert_temperature, + convert_time, + filter_peptides, + parse_data_files, +) from hdxms_datasets.reader import read_dynamx diff --git a/hdxms_datasets/datasets.py b/hdxms_datasets/datasets.py index cf72f65..8d4605a 100644 --- a/hdxms_datasets/datasets.py +++ b/hdxms_datasets/datasets.py @@ -57,7 +57,9 @@ class HDXDataSet(object): _cache: dict[tuple[str, str], pd.DataFrame] = field(init=False, default_factory=dict) @classmethod - def from_spec(cls, hdx_spec: dict, data_dir: Path, data_id = Optional[str], metadata: Optional[dict] = None): + def from_spec( + cls, hdx_spec: dict, data_dir: Path, data_id=Optional[str], metadata: Optional[dict] = None + ): metadata = metadata or {} data_id = data_id or uuid.uuid4().hex data_files = parse_data_files(hdx_spec["data_files"], data_dir) diff --git a/hdxms_datasets/datavault.py b/hdxms_datasets/datavault.py index b7f0693..a24b739 100644 --- a/hdxms_datasets/datavault.py +++ b/hdxms_datasets/datavault.py @@ -146,5 +146,5 @@ def load_dataset(self, data_id: str) -> HDXDataSet: hdx_spec=hdx_spec, data_dir=self.cache_dir / data_id, data_id=data_id, - metadata=dataset_metadata + metadata=dataset_metadata, ) diff --git a/hdxms_datasets/process.py b/hdxms_datasets/process.py index 453ac67..8c173f4 100644 --- a/hdxms_datasets/process.py +++ b/hdxms_datasets/process.py @@ -1,9 +1,8 @@ from __future__ import annotations from pathlib import Path -from typing import Literal, Optional, Union, TypeVar, TYPE_CHECKING +from typing import Literal, Optional, Union, TYPE_CHECKING -import numpy.typing as npt import pandas as pd from hdxms_datasets.config import cfg @@ -15,8 +14,6 @@ TIME_FACTORS = {"s": 1, "m": 60.0, "min": 60.0, "h": 3600, "d": 86400} TEMPERATURE_OFFSETS = {"c": 273.15, "celsius": 273.15, "k": 0.0, "kelvin": 0.0} -A = TypeVar("A", npt.ArrayLike, pd.Series, pd.DataFrame) - def convert_temperature( temperature_dict: dict, target_unit: str = "c"