Skip to content

Commit

Permalink
fix some type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 28, 2024
1 parent f85bb32 commit eda0f30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/depiction/persistence/imzml/imzml_writer.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

import pyimzml
import pyimzml.ImzMLWriter
from pathlib import Path
from typing import TYPE_CHECKING

from depiction.persistence.imzml.imzml_alignment_tracker import ImzmlAlignmentTracker
from depiction.persistence.imzml.imzml_mode_enum import ImzmlModeEnum
from depiction.persistence.types import GenericWriter

if TYPE_CHECKING:
import numpy as np
from numpy.typing import NDArray


class ImzmlWriter(GenericWriter):
Expand Down Expand Up @@ -65,9 +64,9 @@ def is_aligned(self) -> bool:

def add_spectrum(
self,
mz_arr: np.ndarray,
int_arr: np.ndarray,
coordinates: tuple[int, int] | tuple[int, int, int],
mz_arr: NDArray[float],
int_arr: NDArray[float],
coordinates: tuple[int, int] | tuple[int, int, int] | NDArray[int],
) -> None:
if len(mz_arr) != len(int_arr):
raise ValueError(f"{len(mz_arr)=} and {len(int_arr)=} must be equal.")
Expand Down
4 changes: 2 additions & 2 deletions src/depiction/persistence/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_spectrum(self, i_spectrum: int) -> tuple[NDArray[float], NDArray[float]]
"""Returns the m/z and intensity arrays of the i-th spectrum."""
return self.get_spectrum_mz(i_spectrum=i_spectrum), self.get_spectrum_int(i_spectrum=i_spectrum)

def get_spectrum_with_coords(self, i_spectrum: int) -> tuple[NDArray[float], NDArray[float], NDArray[float]]:
def get_spectrum_with_coords(self, i_spectrum: int) -> tuple[NDArray[float], NDArray[float], NDArray[int]]:
"""Returns the m/z, intensity and v arrays of the i-th spectrum."""
mz_arr = self.get_spectrum_mz(i_spectrum=i_spectrum)
int_arr = self.get_spectrum_int(i_spectrum=i_spectrum)
Expand Down Expand Up @@ -215,7 +215,7 @@ def add_spectrum(
self,
mz_arr: np.ndarray,
int_arr: np.ndarray,
coordinates: tuple[int, int] | tuple[int, int, int],
coordinates: tuple[int, int] | tuple[int, int, int] | NDArray[int],
) -> None: ...

def copy_spectra(
Expand Down

0 comments on commit eda0f30

Please sign in to comment.