Skip to content

Commit

Permalink
Remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomodeller committed Sep 9, 2024
1 parent 6f614a3 commit ccd178e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 5 additions & 11 deletions mikeio/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _clone(
outfilename: str | pathlib.Path,
start_time: datetime | None = None,
timestep: float | None = None,
items: Sequence[int | str | DfsDynamicItemInfo] | None = None,
items: Sequence[int | DfsDynamicItemInfo] | None = None,
) -> DfsFile:
"""Clone a dfs file
Expand All @@ -104,7 +104,7 @@ def _clone(
new start time for the new file, by default None
timestep : float, optional
new timestep (in seconds) for the new file, by default None
items : list(int,str,eum.ItemInfo), optional
items : list(int,eum.ItemInfo), optional
list of items for new file, either as a list of
ItemInfo or a list of str/int referring to original file,
default: all items from original file
Expand Down Expand Up @@ -142,9 +142,6 @@ def _clone(
for customBlock in fi.CustomBlocks:
builder.AddCustomBlock(customBlock)

names = [x.Name for x in source.ItemInfo]
item_lookup = {name: i for i, name in enumerate(names)}

if isinstance(items, Iterable) and not isinstance(items, str):
for item in items:
if isinstance(item, ItemInfo):
Expand All @@ -157,11 +154,8 @@ def _clone(
builder.AddDynamicItem(item)
elif isinstance(item, int):
builder.AddDynamicItem(source.ItemInfo[item])
elif isinstance(item, str):
item_no = item_lookup[item]
builder.AddDynamicItem(source.ItemInfo[item_no])

elif isinstance(items, (int, str)) or items is None:
elif isinstance(items, (int)) or items is None:
# must be str/int refering to original file (or None)
item_numbers = _valid_item_numbers(source.ItemInfo, items)
items = [source.ItemInfo[item] for item in item_numbers]
Expand Down Expand Up @@ -507,8 +501,8 @@ def concat(
def extract(
infilename: str | pathlib.Path,
outfilename: str | pathlib.Path,
start: int = 0,
end: int = -1,
start: int | float | str | datetime = 0,
end: int | float | str | datetime = -1,
step: int = 1,
items: Sequence[int | str] | None = None,
) -> None:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def test_sum_dfsu(tmp_path: Path) -> None:
infilename_a = "tests/testdata/HD2D.dfsu"
infilename_b = "tests/testdata/HD2D.dfsu"
fp = tmp_path / "sum.dfsu"
mikeio.generic.sum(infilename_a, infilename_b, fp)

with pytest.warns(FutureWarning):
mikeio.generic.sum(infilename_a, infilename_b, fp)

org = mikeio.read(infilename_a)

Expand Down Expand Up @@ -373,6 +375,9 @@ def test_extract_equidistant(tmp_path: Path) -> None:
with pytest.raises(ValueError):
extract(infile, fp, start=1000)

with pytest.raises(ValueError):
extract(infile, fp, end=1000)


def test_extract_non_equidistant(tmp_path: Path) -> None:
infile = "tests/testdata/da_diagnostic.dfs0"
Expand Down

0 comments on commit ccd178e

Please sign in to comment.