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
calc_surface_orientation broadcasting error for 2-D inputs in 0.15.1 (regression vs 0.15.0) #2747
pvlib.tracking.calc_surface_orientation regressed in 0.15.1: passing 2-D arrays for tracker_theta (and broadcasting-compatible 2-D axis_tilt / axis_azimuth, e.g. shape (timestamps, sites)) raises a broadcasting ValueError. The same call works in 0.15.0 and earlier.
The cause is the new _unit_normal helper introduced in #2702, which builds its return value with np.column_stack((x, y, z)). np.column_stack only stacks 1-D inputs into columns; for 2-D inputs of shape (T, N) it concatenates along axis=1, producing a (T, 3*N) array instead of the intended (T, N, 3). The subsequent unit_normal[:, 0] / unit_normal[:, 1] then collapse to shape (T,), and the downstream
Regression introduced in #2702 (milestone v0.15.1). Suggested one-line fix in _unit_normal:
# beforereturnnp.column_stack((x, y, z))
# afterreturnnp.stack((x, y, z), axis=-1)
np.stack(..., axis=-1) preserves the leading dimensions for inputs of any rank and is equivalent to the old behavior for 1-D inputs, so it should be a drop-in replacement.
Hit in production while batch-processing tracker geometry across (timestamps × bays); pinned to pvlib<0.15.1 as a workaround.
@cwhanse / @kandersolar — this looks like fallout from #2702 and would be a nice candidate for the v0.15.2 milestone. I can send a PR with the np.stack(..., axis=-1) fix and a 2-D regression test if it would help.
@ArthurOnnoTerabase absolutely! Reduction to 1d (time) was not intended. Although the previous behavior (T, N) was not tested nor intentional, I'm happy to hear that it worked :)
We'd welcome a PR and additions to the test suite.
The fix turned out to be slightly larger than the one-line column_stack → stack(..., axis=-1) I suggested above. Two additional changes were needed:
unit_normal[:, 0]/[:, 1] → unit_normal[..., 0]/[..., 1] in calc_surface_orientation (ellipsis indexing so it works for arbitrary input rank).
np.atleast_1d(np.asarray(theta)) in _unit_normal to preserve the historical (1, 3) return shape for scalar input — without it the existing test__unit_normal regresses on the scalar case.
All 22 existing test_tracking.py tests still pass. Added a new parametrised regression test (test_calc_surface_orientation_2d) covering shapes (3, 5), (1, 7), (4, 1), and (2, 3, 4), which fails on main with the exact ValueError from the original report.
Activity
arthur-onno-tbe commentedon May 5, 2026
@cwhanse / @kandersolar — this looks like fallout from #2702 and would be a nice candidate for the v0.15.2 milestone. I can send a PR with the
np.stack(..., axis=-1)fix and a 2-D regression test if it would help.cwhanse commentedon May 5, 2026
@ArthurOnnoTerabase absolutely! Reduction to 1d (time) was not intended. Although the previous behavior (T, N) was not tested nor intentional, I'm happy to hear that it worked :)
We'd welcome a PR and additions to the test suite.
Fix calc_surface_orientation broadcasting for >1-D tracker_theta
arthur-onno-tbe commentedon May 5, 2026
Submitted #2749 for this.
The fix turned out to be slightly larger than the one-line
column_stack → stack(..., axis=-1)I suggested above. Two additional changes were needed:unit_normal[:, 0]/[:, 1]→unit_normal[..., 0]/[..., 1]incalc_surface_orientation(ellipsis indexing so it works for arbitrary input rank).np.atleast_1d(np.asarray(theta))in_unit_normalto preserve the historical(1, 3)return shape for scalar input — without it the existingtest__unit_normalregresses on the scalar case.All 22 existing
test_tracking.pytests still pass. Added a new parametrised regression test (test_calc_surface_orientation_2d) covering shapes(3, 5),(1, 7),(4, 1), and(2, 3, 4), which fails onmainwith the exactValueErrorfrom the original report.Fix calc_surface_orientation broadcasting for >1-D tracker_theta (pvl…