Skip to content

Commit 7b39673

Browse files
committed
remove _shape_of_max_size, np.broadcast_shapes handles this
1 parent bc6646b commit 7b39673

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

pvlib/pvsystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ def v_from_i(current, photocurrent, saturation_current, resistance_series,
26622662
V = _singlediode.bishop88_v_from_i(*args, method=method.lower())
26632663
if all(map(np.isscalar, args)):
26642664
return V
2665-
shape = _singlediode._shape_of_max_size(*args)
2665+
shape = np.broadcast_shapes(*map(np.shape, args))
26662666
return np.broadcast_to(V, shape)
26672667

26682668

@@ -2744,7 +2744,7 @@ def i_from_v(voltage, photocurrent, saturation_current, resistance_series,
27442744
current = _singlediode.bishop88_i_from_v(*args, method=method.lower())
27452745
if all(map(np.isscalar, args)):
27462746
return current
2747-
shape = _singlediode._shape_of_max_size(*args)
2747+
shape = np.broadcast_shapes(*map(np.shape, args))
27482748
return np.broadcast_to(current, shape)
27492749

27502750

pvlib/singlediode.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,6 @@ def fmpp(x, *a):
596596
return bishop88(vd, *args)
597597

598598

599-
def _shape_of_max_size(*args):
600-
return max(((np.size(a), np.shape(a)) for a in args),
601-
key=lambda t: t[0])[1]
602-
603-
604599
def _prepare_newton_inputs(x0, args, method_kwargs):
605600
"""
606601
Make inputs compatible with Scipy's newton by:
@@ -625,7 +620,7 @@ def _prepare_newton_inputs(x0, args, method_kwargs):
625620
"""
626621
if not (np.isscalar(x0) and all(map(np.isscalar, args))):
627622
args = tuple(map(np.asarray, args))
628-
x0 = np.broadcast_to(x0, _shape_of_max_size(x0, *args))
623+
x0 = np.broadcast_to(x0, np.broadcast_shapes(*map(np.shape, args)))
629624

630625
# set abs tolerance and maxiter from method_kwargs if not provided
631626
# apply defaults, but giving priority to user-specified values

0 commit comments

Comments
 (0)