-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
bugSomething isn't workingSomething isn't working
Description
🪲
- I have checked that this issue has not already been reported.
Bug summary
Trying to load a Grid from a matfile with a single zone causes a dimensional mismatch error.
Code for reproduction
A minimum code snippet required to reproduce the bug. Please make sure to minimize the
number of dependencies required.
>>> from powersimdata import Grid
>>> grid = Grid(source=PATH_TO_MATFILE, interconnect="ERCOT")
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python39\lib\site-packages\powersimdata\input\grid.py", line 57, in __init__
data = FromREISE(source)
File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 25, in __init__
super().__init__()
File "C:\Python39\lib\site-packages\powersimdata\input\abstract_grid.py", line 34, in __init__
self._build_network()
File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 132, in _build_network
self._read_network()
File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 102, in _read_network
zone = pd.DataFrame(mpc.zone, columns=["zone_id", "zone_name"])
File "C:\Python39\lib\site-packages\pandas\core\frame.py", line 672, in __init__
mgr = ndarray_to_mgr(
File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 324, in ndarray_to_mgr
_check_values_indices_shape_match(values, index, columns)
File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 393, in _check_values_indices_shape_match
raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (2, 1), indices imply (2, 2)If we look at the matfile itself:
>>> from scipy.io import loadmat
>>> mpc = loadmat(PATH_TO_MATFILE, squeeze_me=True, struct_as_record=False)
>>> mpc["mdi"].mpc.zone
array([47, 'ERCOT'], dtype=object)We can reproduce the same error with pandas and dummy data:
>>> import pandas as pd
>>> pd.DataFrame([1, 2], columns=[3, 4])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python39\lib\site-packages\pandas\core\frame.py", line 711, in __init__
mgr = ndarray_to_mgr(
File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 324, in ndarray_to_mgr
_check_values_indices_shape_match(values, index, columns)
File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 393, in _check_values_indices_shape_match
raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (2, 1), indices imply (2, 2)Passing engine="REISE.jl" to the Grid constructor doesn't solve the problem.
Environment
Please specify your platform and versions of the relevant libraries you are using:
- Operating system: Windows
- PowerSimData revision:
8357023827885b936fb1aef758a09e82fdc93004 - Python version: 3.9.6
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working