Skip to content

Commit c210aac

Browse files
Fix build warning
1 parent 3be8188 commit c210aac

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,24 @@ def get_edgecolor(self):
770770
def _get_data_scale(X, Y, Z):
771771
"""
772772
Estimate the scale of the 3D data for use in depth shading
773+
774+
Parameters
775+
----------
776+
X, Y, Z : masked arrays
777+
The data to estimate the scale of.
773778
"""
774-
# Account for empty datasets. Assume that X Y and Z have equal lengths
775-
if len(X) == 0:
779+
# Account for empty datasets. Assume that X Y and Z have the same number
780+
# of elements.
781+
if not np.ma.count(X):
776782
return 0
777783

778784
# Estimate the scale using the RSS of the ranges of the dimensions
779-
return np.sqrt(np.ma.ptp(X) ** 2 + np.ma.ptp(Y) ** 2 + np.ma.ptp(Z) ** 2)
785+
# Note that we don't use np.ma.ptp() because we otherwise get a build
786+
# warning about handing empty arrays.
787+
ptp_x = X.max() - X.min()
788+
ptp_y = Y.max() - Y.min()
789+
ptp_z = Z.max() - Z.min()
790+
return np.sqrt(ptp_x ** 2 + ptp_y ** 2 + ptp_z ** 2)
780791

781792

782793
class Path3DCollection(PathCollection):

0 commit comments

Comments
 (0)