Skip to content

Commit

Permalink
actually remove the explict typing for now since it caused issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 16, 2024
1 parent cd38713 commit f4f370f
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/depiction/spectrum/baseline/tophat_baseline.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Literal

import numpy as np
from numba import njit, types
from numba import njit
from numpy.typing import NDArray

from depiction.persistence.types import GenericReadFile
Expand Down Expand Up @@ -64,12 +65,13 @@ def optimize_window_size(self, read_file: GenericReadFile, n_spectra: int, rng_s
return max(window_sizes)


@njit(
[
"float64[:](float64[:], int64)",
(types.Array(types.float64, 1, "C", readonly=True), types.int64),
]
)
# @njit(
# [
# (types.Array(types.float64, 1, "C", readonly=False), types.int64),
# (types.Array(types.float64, 1, "C", readonly=True), types.int64),
# ]
# )
@njit
def _compute_erosion(x: NDArray[float], element_size: int) -> NDArray[float]:
eroded = np.zeros_like(x)
n = len(x)
Expand All @@ -81,12 +83,13 @@ def _compute_erosion(x: NDArray[float], element_size: int) -> NDArray[float]:
return eroded


@njit(
[
"float64[:](float64[:], int64)",
(types.Array(types.float64, 1, "C", readonly=True), types.int64),
]
)
# @njit(
# [
# (types.Array(types.float64, 1, "C", readonly=False), types.int64),
# (types.Array(types.float64, 1, "C", readonly=True), types.int64),
# ]
# )
@njit
def _compute_dilation(x: NDArray[float], element_size: int) -> NDArray[float]:
dilation = np.zeros_like(x)
n = len(x)
Expand All @@ -98,12 +101,13 @@ def _compute_dilation(x: NDArray[float], element_size: int) -> NDArray[float]:
return dilation


@njit(
[
"float64[:](float64[:], int64)",
(types.Array(types.float64, 1, "C", readonly=True), types.int64),
]
)
# @njit(
# [
# (types.Array(types.float64, 1, "C", readonly=False), types.int64),
# (types.Array(types.float64, 1, "C", readonly=True), types.int64),
# ]
# )
@njit
def _compute_opening(int_arr: NDArray[float], element_size: int) -> NDArray[float]:
eroded = _compute_erosion(int_arr, element_size)
return _compute_dilation(eroded, element_size)
Expand Down

0 comments on commit f4f370f

Please sign in to comment.