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
{{ message }}
Repository navigation
create_small_multiples crashes when commodities fit in one row (n <= cols) #158
Status: confirmed (local repro on main5d9aa37 and on PR #157 head 2a7596e; pre-existing, not introduced by #157). Priority P2, area: visualization.
PriceVisualizer.create_small_multiples() raises whenever all commodities fit in one row (len(commodities) <= cols, default cols=3), which is the most common call.
Cause (oilpriceapi/visualization.py ~L452-469): when rows == 1, plt.subplots(1, cols) returns a 1-D array, the code wraps it as axes = [axes], then indexes axes[col]. For col=0 that is the whole ndarray; for col>=1 it would be an IndexError. The cols == 1 branch has the same shape problem.
Fix:fig, axes = plt.subplots(rows, cols, ..., squeeze=False) and always index axes[row][col]; drop the two wrapping branches. Add a test for n=1, n=cols, n=cols+1 and cols=1.
Activity