Skip to content

Commit b588063

Browse files
committed
1 parent ef596d9 commit b588063

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

mikeio/dataset/_dataset.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22
from pathlib import Path
3-
import warnings
43
from datetime import datetime
54
from copy import deepcopy
65
from typing import (
@@ -16,6 +15,7 @@
1615
TYPE_CHECKING,
1716
Callable,
1817
)
18+
from warnings import deprecated
1919

2020

2121
import numpy as np
@@ -97,6 +97,22 @@ class Dataset:
9797
9898
"""
9999

100+
@overload
101+
@deprecated(
102+
"Supplying data as a list of numpy arrays is deprecated. Use Dataset.from_numpy instead"
103+
)
104+
def __init__(
105+
self,
106+
data: (Sequence[NDArray[np.floating]]),
107+
time: pd.DatetimeIndex | None = None,
108+
items: Sequence[ItemInfo] | None = None,
109+
geometry: Any = None,
110+
zn: NDArray[np.floating] | None = None,
111+
dims: tuple[str, ...] | None = None,
112+
validate: bool = True,
113+
dt: float = 1.0,
114+
): ...
115+
100116
def __init__(
101117
self,
102118
data: (
@@ -113,10 +129,6 @@ def __init__(
113129
dt: float = 1.0,
114130
):
115131
if not self._is_DataArrays(data):
116-
warnings.warn(
117-
"Supplying data as a list of numpy arrays is deprecated. Use Dataset.from_numpy",
118-
FutureWarning,
119-
)
120132
data = self._create_dataarrays(
121133
data=data,
122134
time=time,

mikeio/generic.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from shutil import copyfile
1212
from collections.abc import Iterable, Sequence
1313
from typing import Callable, Union
14-
import warnings
14+
from warnings import deprecated
1515

1616

1717
import numpy as np
@@ -329,14 +329,13 @@ def _process_dfs_files(
329329

330330

331331
# TODO sum is conflicting with the built-in sum function, which we could haved used above.
332+
@deprecated("Use add instead.")
332333
def sum(
333334
infilename_a: str | pathlib.Path,
334335
infilename_b: str | pathlib.Path,
335336
outfilename: str | pathlib.Path,
336337
) -> None:
337338
"""Sum two dfs files (a+b)."""
338-
# deprecated
339-
warnings.warn(FutureWarning("This function is deprecated. Use add instead."))
340339
_process_dfs_files(infilename_a, infilename_b, outfilename, operator.add)
341340

342341

0 commit comments

Comments
 (0)