Skip to content

Commit 0931e3f

Browse files
authored
Update project configuration and version to 0.10.2 (#42)
* Update project configuration and version to 0.10.2 - Updated version in `__init__.py` and `pyproject.toml` to 0.10.2. - Added `uv.lock` to `.gitignore`. - Refactored `pyproject.toml` to use the new build system and dependency groups. - Simplified GitHub Actions workflows for testing and release processes by consolidating OS and Python version specifications. * Update Python version constraint in pyproject.toml - Changed the Python version requirement from ">=3.10" to ">=3.10,<3.15" to restrict compatibility to specific versions. * Update peak assignment summary and molecule names in usage notebook - Enhanced the HTML and plain text representations of the peak assignment summary for better readability. - Updated the molecule name for SAH from "Adenosylhomocysteine" to "S-adenosyl-L-homocysteine" for accuracy. - Adjusted the Ado molecule name to "Adenosine" for consistency. - Updated Python version in the notebook metadata from 3.12.11 to 3.13.7. * Add pre-commit configuration for code quality checks * run ruff * fixed configuration
1 parent 4404dd6 commit 0931e3f

File tree

19 files changed

+240
-554
lines changed

19 files changed

+240
-554
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ jobs:
9999
with:
100100
name: python-package-distributions
101101
path: dist/
102-
- name: Sign the dists with Sigstore
103-
uses: sigstore/gh-action-sigstore-python@v3.0.1
104-
with:
105-
inputs: >-
106-
./dist/*.tar.gz
107-
./dist/*.whl
108102
- name: Create GitHub Release
109103
env:
110104
GITHUB_TOKEN: ${{ github.token }}
@@ -113,7 +107,7 @@ jobs:
113107
'${{ github.ref_name }}'
114108
--repo '${{ github.repository }}'
115109
--notes ""
116-
- name: Upload artifact signatures to GitHub Release
110+
- name: Upload distributions to GitHub Release
117111
env:
118112
GITHUB_TOKEN: ${{ github.token }}
119113
run: >-

.github/workflows/run_tests.yaml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,12 @@ on: push
44

55
jobs:
66
build:
7-
8-
runs-on: ${{ matrix.os }}
97
strategy:
108
matrix:
11-
include:
12-
- os: ubuntu-latest
13-
python-version: "3.10"
14-
- os: ubuntu-latest
15-
python-version: "3.11"
16-
- os: ubuntu-latest
17-
python-version: "3.12"
18-
- os: ubuntu-latest
19-
python-version: "3.13"
20-
- os: macos-latest
21-
python-version: "3.10"
22-
- os: macos-latest
23-
python-version: "3.11"
24-
- os: macos-latest
25-
python-version: "3.12"
26-
- os: macos-latest
27-
python-version: "3.13"
28-
- os: windows-latest
29-
python-version: "3.10"
30-
- os: windows-latest
31-
python-version: "3.11"
32-
- os: windows-latest
33-
python-version: "3.12"
9+
os: [ubuntu-latest, macos-latest, windows-latest]
10+
python-version: ["3.10", "3.11", "3.12", "3.13"]
11+
12+
runs-on: ${{ matrix.os }}
3413

3514
steps:
3615
- uses: actions/checkout@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,5 @@ cython_debug/
167167

168168
test.py
169169

170-
.DS_Store
170+
.DS_Store
171+
uv.lock

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: pyright
5+
name: pyright (uv venv)
6+
entry: uv run pyright
7+
language: system
8+
pass_filenames: false
9+
stages: [manual]
10+
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.6.8
13+
hooks:
14+
- id: ruff-format
15+
types_or: [python, pyi, jupyter]
16+
- id: ruff
17+
types_or: [python, pyi, jupyter, toml]
18+
args: [--fix]
19+
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.6.0
22+
hooks:
23+
- id: check-merge-conflict
24+
- id: check-added-large-files
25+
args: ["--maxkb=5000"]

chromhandler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ def __getattr__(name: str) -> Handler:
5555

5656
__all__ = ["Handler", "ChromAnalyzer", "Molecule", "Protein", "to_enzymeml"]
5757

58-
__version__ = "0.10.1"
58+
__version__ = "0.10.2"

chromhandler/enzymeml.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ def add_data(
493493

494494
if calibrator_type == CalibratorType.EXTERNAL:
495495
calibrator = calibrators[measurement_data.species_id]
496-
assert isinstance(calibrator, Calibrator), (
497-
"Calibrator must be of type Calibrator."
498-
)
496+
assert isinstance(
497+
calibrator, Calibrator
498+
), "Calibrator must be of type Calibrator."
499499

500500
if peak is not None:
501501
conc = calibrator.calculate_concentrations(
@@ -515,9 +515,9 @@ def add_data(
515515

516516
elif calibrator_type == CalibratorType.INTERNAL:
517517
calibrator = calibrators[measurement_data.species_id]
518-
assert isinstance(calibrator, InternalStandard), (
519-
"Calibrator must be of type InternalStandard."
520-
)
518+
assert isinstance(
519+
calibrator, InternalStandard
520+
), "Calibrator must be of type InternalStandard."
521521

522522
if peak is not None:
523523
internal_std_peak = next(
@@ -578,9 +578,9 @@ def setup_external_calibrators(
578578
if molecule.standard:
579579
calibrators[molecule.id] = Calibrator.from_standard(molecule.standard)
580580

581-
assert calibrators, (
582-
"No calibrators were created. Please define standards for the molecules."
583-
)
581+
assert (
582+
calibrators
583+
), "No calibrators were created. Please define standards for the molecules."
584584

585585
return calibrators
586586

@@ -669,24 +669,24 @@ def extract_measurement_conditions(
669669
]
670670

671671
assert len(set(phs)) == 1, "All measurements need to have the same pH."
672-
assert len(set(temperatures)) == 1, (
673-
"All measurements need to have the same temperature."
674-
)
675-
assert len(set(time_units)) == 1, (
676-
"All measurements need to have the same time unit."
677-
)
678-
assert len(set(temperature_units)) == 1, (
679-
"All measurements need to have the same temperature unit."
680-
)
672+
assert (
673+
len(set(temperatures)) == 1
674+
), "All measurements need to have the same temperature."
675+
assert (
676+
len(set(time_units)) == 1
677+
), "All measurements need to have the same time unit."
678+
assert (
679+
len(set(temperature_units)) == 1
680+
), "All measurements need to have the same temperature unit."
681681

682682
assert measurements[0].ph is not None, "The pH needs to be defined."
683-
assert measurements[0].temperature is not None, (
684-
"The temperature needs to be defined."
685-
)
683+
assert (
684+
measurements[0].temperature is not None
685+
), "The temperature needs to be defined."
686686
assert measurements[0].data.unit is not None, "The time unit needs to be defined."
687-
assert measurements[0].temperature_unit is not None, (
688-
"The temperature unit needs to be defined."
689-
)
687+
assert (
688+
measurements[0].temperature_unit is not None
689+
), "The temperature unit needs to be defined."
690690

691691
ph = measurements[0].ph
692692
temperature = measurements[0].temperature

chromhandler/handler.py

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77
from typing import Any, Literal, Optional
88

9-
import plotly.graph_objects as go
109
from calipytion.model import Calibration
1110
from calipytion.tools.utility import pubchem_request_molecule_name
1211
from loguru import logger
@@ -165,13 +164,13 @@ def define_molecule(
165164
"""
166165

167166
if conc_unit:
168-
assert init_conc is not None, (
169-
"Initial concentration must be provided if concentration unit is given."
170-
)
167+
assert (
168+
init_conc is not None
169+
), "Initial concentration must be provided if concentration unit is given."
171170
if init_conc:
172-
assert conc_unit, (
173-
"Concentration unit must be provided if initial concentration is given."
174-
)
171+
assert (
172+
conc_unit
173+
), "Concentration unit must be provided if initial concentration is given."
175174

176175
if name is None:
177176
name = pubchem_request_molecule_name(pubchem_cid)
@@ -904,21 +903,6 @@ def get_molecule(self, molecule_id: str) -> Molecule:
904903

905904
raise ValueError(f"Molecule with ID {molecule_id} not found.")
906905

907-
def visualize_all(
908-
self, assigned_only: bool = False, dark_mode: bool = False, show: bool = False
909-
) -> go.Figure:
910-
"""Plots the fitted peaks of the chromatograms in an interactive figure.
911-
912-
Args:
913-
assigned_only (bool, optional): If True, only the peaks that are assigned to a molecule are plotted. Defaults to False.
914-
dark_mode (bool, optional): If True, the figure is displayed in dark mode. Defaults to False.
915-
show (bool, optional): If True, shows the figure. Defaults to False.
916-
917-
Returns:
918-
go.Figure: The plotly figure object.
919-
"""
920-
return visualize.visualize_all(self, assigned_only, dark_mode, show)
921-
922906
def add_standard(
923907
self,
924908
molecule: Molecule,
@@ -932,25 +916,25 @@ def add_standard(
932916
wavelength (float | None, optional): The wavelength of the detector. Defaults to None.
933917
visualize (bool, optional): If True, the standard curve is visualized. Defaults to True.
934918
"""
935-
assert any([molecule in [mol for mol in self.molecules]]), (
936-
"Molecule not found in molecules of handler."
937-
)
919+
assert any(
920+
[molecule in [mol for mol in self.molecules]]
921+
), "Molecule not found in molecules of handler."
938922

939923
# check if all measurements only contain one chromatogram
940924
if all([len(meas.chromatograms) == 1 for meas in self.measurements]):
941925
chroms = [
942926
chrom for meas in self.measurements for chrom in meas.chromatograms
943927
]
944928
else:
945-
assert wavelength is not None, (
946-
"Multiple chromatograms found for each measurment, wavelength needs to be provided."
947-
)
929+
assert (
930+
wavelength is not None
931+
), "Multiple chromatograms found for each measurment, wavelength needs to be provided."
948932

949933
chroms = self._get_chromatograms_by_wavelegnth(wavelength)
950934

951-
assert len(chroms) > 0, (
952-
"No chromatograms found at the specified wavelength."
953-
)
935+
assert (
936+
len(chroms) > 0
937+
), "No chromatograms found at the specified wavelength."
954938

955939
peak_areas = [
956940
peak.area for chrom in chroms for peak in chrom.peaks if peak.molecule_id
@@ -959,13 +943,13 @@ def add_standard(
959943
concs = [meas.data.value for meas in self.measurements]
960944
conc_unit = self.measurements[0].data.unit
961945

962-
assert len(peak_areas) == len(concs), (
963-
f"Number of {molecule.name} peak areas {len(peak_areas)} and concentrations {len(concs)} do not match."
964-
)
946+
assert (
947+
len(peak_areas) == len(concs)
948+
), f"Number of {molecule.name} peak areas {len(peak_areas)} and concentrations {len(concs)} do not match."
965949

966-
assert all(meas.ph == self.measurements[0].ph for meas in self.measurements), (
967-
"All measurements need to have the same pH value."
968-
)
950+
assert all(
951+
meas.ph == self.measurements[0].ph for meas in self.measurements
952+
), "All measurements need to have the same pH value."
969953
ph = self.measurements[0].ph
970954

971955
assert all(
@@ -1030,18 +1014,6 @@ def _update_protein(self, protein: Protein) -> None:
10301014

10311015
self.proteins.append(protein)
10321016

1033-
def visualize_spectra(self, dark_mode: bool = False) -> go.Figure:
1034-
"""
1035-
Plots all chromatograms in the Handler in a single plot.
1036-
1037-
Args:
1038-
dark_mode (bool, optional): If True, the figure is displayed in dark mode. Defaults to False.
1039-
1040-
Returns:
1041-
go.Figure: The plotly figure object.
1042-
"""
1043-
return visualize.visualize_spectra(self, dark_mode)
1044-
10451017
def visualize(
10461018
self,
10471019
n_cols: int = 2,

chromhandler/model.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ def set_attr_term(
179179
AssertionError: If the attribute is not found in the model
180180
"""
181181

182-
assert attr in self.model_fields, (
183-
f"Attribute {attr} not found in {self.__class__.__name__}"
184-
)
182+
assert (
183+
attr in self.model_fields
184+
), f"Attribute {attr} not found in {self.__class__.__name__}"
185185

186186
if prefix:
187187
validate_prefix(term, prefix)
@@ -298,9 +298,9 @@ def set_attr_term(
298298
AssertionError: If the attribute is not found in the model
299299
"""
300300

301-
assert attr in self.model_fields, (
302-
f"Attribute {attr} not found in {self.__class__.__name__}"
303-
)
301+
assert (
302+
attr in self.model_fields
303+
), f"Attribute {attr} not found in {self.__class__.__name__}"
304304

305305
if prefix:
306306
validate_prefix(term, prefix)
@@ -406,9 +406,9 @@ def set_attr_term(
406406
AssertionError: If the attribute is not found in the model
407407
"""
408408

409-
assert attr in self.model_fields, (
410-
f"Attribute {attr} not found in {self.__class__.__name__}"
411-
)
409+
assert (
410+
attr in self.model_fields
411+
), f"Attribute {attr} not found in {self.__class__.__name__}"
412412

413413
if prefix:
414414
validate_prefix(term, prefix)
@@ -549,9 +549,9 @@ def set_attr_term(
549549
AssertionError: If the attribute is not found in the model
550550
"""
551551

552-
assert attr in self.model_fields, (
553-
f"Attribute {attr} not found in {self.__class__.__name__}"
554-
)
552+
assert (
553+
attr in self.model_fields
554+
), f"Attribute {attr} not found in {self.__class__.__name__}"
555555

556556
if prefix:
557557
validate_prefix(term, prefix)

chromhandler/readers/asm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ def _get_file_paths(self) -> None:
4343
# check if directory exists
4444
assert directory.exists(), f"Directory '{self.dirpath}' does not exist."
4545
assert directory.is_dir(), f"'{self.dirpath}' is not a directory."
46-
assert any(directory.rglob("*.json")), (
47-
f"No .json files found in '{self.dirpath}'."
48-
)
46+
assert any(
47+
directory.rglob("*.json")
48+
), f"No .json files found in '{self.dirpath}'."
4949

5050
for file_path in directory.iterdir():
5151
if file_path.name.startswith(".") or not file_path.name.endswith(".json"):
5252
continue
5353

5454
files.append(str(file_path.absolute()))
5555

56-
assert len(files) == len(self.values), (
57-
f"Number of files ({len(files)}) does not match the number of reaction times ({len(self.values)})."
58-
)
56+
assert (
57+
len(files) == len(self.values)
58+
), f"Number of files ({len(files)}) does not match the number of reaction times ({len(self.values)})."
5959

6060
self.file_paths = sorted(files)
6161

0 commit comments

Comments
 (0)