Skip to content

Commit 9719cd1

Browse files
authored
Merge pull request #811 from DHI/deprecated
Use new @deprecated decorator.
2 parents ef596d9 + a86cb8b commit 9719cd1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

mikeio/dataset/_dataset.py

Lines changed: 32 additions & 1 deletion
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,9 @@
1615
TYPE_CHECKING,
1716
Callable,
1817
)
18+
import warnings
19+
from typing_extensions import deprecated
20+
# from warnings import deprecated
1921

2022

2123
import numpy as np
@@ -97,6 +99,35 @@ class Dataset:
9799
98100
"""
99101

102+
@overload
103+
@deprecated(
104+
"Supplying data as a list of numpy arrays is deprecated. Use Dataset.from_numpy instead"
105+
)
106+
def __init__(
107+
self,
108+
data: (Sequence[NDArray[np.floating]]),
109+
time: pd.DatetimeIndex | None = None,
110+
items: Sequence[ItemInfo] | None = None,
111+
geometry: Any = None,
112+
zn: NDArray[np.floating] | None = None,
113+
dims: tuple[str, ...] | None = None,
114+
validate: bool = True,
115+
dt: float = 1.0,
116+
): ...
117+
118+
@overload
119+
def __init__(
120+
self,
121+
data: (Mapping[str, DataArray] | Sequence[DataArray]),
122+
time: pd.DatetimeIndex | None = None,
123+
items: Sequence[ItemInfo] | None = None,
124+
geometry: Any = None,
125+
zn: NDArray[np.floating] | None = None,
126+
dims: tuple[str, ...] | None = None,
127+
validate: bool = True,
128+
dt: float = 1.0,
129+
): ...
130+
100131
def __init__(
101132
self,
102133
data: (

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies = [
3030
"PyYAML",
3131
"tqdm",
3232
"xarray",
33+
"typing-extensions",
3334
]
3435

3536
authors = [

0 commit comments

Comments
 (0)