You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have confirmed this bug exists on the lastest release of Linopy.
I have confirmed this bug exists on the current master branch of Linopy.
Issue Description
If Variables.nvars is accessed, an Exception is raised when the container is empty.
I would expect a return of 0.
This can arise when checking the number of binaries of a Model with no binaries
Reproducible Example
importlinopym=linopy.Model()
m.nvars
Expected Behavior
Expected
Return 0
Currently:
"""Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() File "<input>", line 3, in <module> File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/linopy/model.py", line 826, in nvars return self.variables.nvars File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/linopy/variables.py", line 1300, in nvars return len(self.flat.labels.unique()) File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/linopy/variables.py", line 1424, in flat df = pd.concat([self[k].flat for k in self], ignore_index=True) File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 382, in concat op = _Concatenator( File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 445, in __init__ objs, keys = self._clean_keys_and_objs(objs, keys) File "/Users/felix/Downloads/PythonProject8/.venv/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 507, in _clean_keys_and_objs raise ValueError("No objects to concatenate")ValueError: No objects to concatenate"""
Version Checks (indicate both or one)
I have confirmed this bug exists on the lastest release of Linopy.
I have confirmed this bug exists on the current
master
branch of Linopy.Issue Description
If
Variables.nvars
is accessed, an Exception is raised when the container is empty.I would expect a return of 0.
This can arise when checking the number of binaries of a Model with no binaries
Reproducible Example
Expected Behavior
Expected
Return 0
Currently:
Installed Versions
The text was updated successfully, but these errors were encountered: