Skip to content

Commit 2859ebe

Browse files
committed
breaking: make empty a property
1 parent 792d158 commit 2859ebe

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

linopy/expressions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ def size(self) -> int:
13471347
"""
13481348
return self.vars.size
13491349

1350+
@property
13501351
def empty(self) -> bool:
13511352
"""
13521353
Get whether the linear expression is empty.

linopy/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import logging
1010
import os
1111
import re
12-
from collections.abc import Mapping, Sequence
12+
from collections.abc import Callable, Mapping, Sequence
1313
from pathlib import Path
1414
from tempfile import NamedTemporaryFile, gettempdir
15-
from typing import Any, Callable
15+
from typing import Any
1616

1717
import numpy as np
1818
import pandas as pd
@@ -705,7 +705,7 @@ def add_objective(
705705
The objective function assigned to the model.
706706
"""
707707
if not overwrite:
708-
assert self.objective.expression.empty(), (
708+
assert self.objective.expression.empty, (
709709
"Objective already defined."
710710
" Set `overwrite` to True to force overwriting."
711711
)

test/test_linear_expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ def test_linear_expression_loc(x: Variable, y: Variable) -> None:
541541

542542
def test_linear_expression_empty(v: Variable) -> None:
543543
expr = 7 * v
544-
assert not expr.empty()
545-
assert expr.loc[[]].empty()
544+
assert not expr.empty
545+
assert expr.loc[[]].empty
546546

547547

548548
def test_linear_expression_isnull(v: Variable) -> None:

0 commit comments

Comments
 (0)