Skip to content

Commit 4ea85ab

Browse files
add release notes (#390)
1 parent 37d720b commit 4ea85ab

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release Notes
44
Upcoming Version
55
----------------
66

7+
* When creating slices for variables and constraints (important for the `solve` function), the slicing is now fixed in case now dimension to slice is available.
78
* Added a pandas priority attribute. With this change, the operation with pandas objects is now prioritizing linopy objects over pandas objects. This is useful when the using linopy objects in arithmetic operations with pandas objects, e.g. `a * x` where `a` is a pandas Series/DataFrame and `x` is a linopy variable.
89
* The method :meth:`model.to_file <linopy.model.Model.to_file>` now includes a progress argument to enable or disable the progress bar while writing.
910

linopy/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ def iterate_slices(
523523

524524
# leading dimension (the dimension with the largest size)
525525
sizes = {dim: ds.sizes[dim] for dim in slice_dims}
526+
if not sizes:
527+
yield ds
528+
return
529+
526530
leading_dim = max(sizes, key=sizes.get) # type: ignore
527531
size_of_leading_dim = ds.sizes[leading_dim]
528532

test/test_common.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,22 @@ def test_iterate_slices_slice_size_none():
522522
assert ds.equals(s)
523523

524524

525-
def test_iterate_slices_invalid_slice_dims():
525+
def test_iterate_slices_empty_slice_dims():
526526
ds = xr.Dataset(
527527
{"var": (("x", "y"), np.random.rand(10, 10))}, # noqa: NPY002
528528
coords={"x": np.arange(10), "y": np.arange(10)},
529529
)
530-
with pytest.raises(ValueError):
531-
list(iterate_slices(ds, slice_size=50, slice_dims=[]))
530+
slices = list(iterate_slices(ds, slice_size=50, slice_dims=[]))
531+
assert len(slices) == 1
532+
for s in slices:
533+
assert ds.equals(s)
534+
532535

536+
def test_iterate_slices_invalid_slice_dims():
537+
ds = xr.Dataset(
538+
{"var": (("x", "y"), np.random.rand(10, 10))}, # noqa: NPY002
539+
coords={"x": np.arange(10), "y": np.arange(10)},
540+
)
533541
with pytest.raises(ValueError):
534542
list(iterate_slices(ds, slice_size=50, slice_dims=["z"]))
535543

0 commit comments

Comments
 (0)