MCPcopy Index your code
hub / github.com/plotly/plotly.py / _replace_zero_coords

Function _replace_zero_coords

plotly/figure_factory/_ternary_contour.py:55–86  ·  view source on GitHub ↗

Replaces zero ternary coordinates with delta and normalize the new triplets (a, b, c). Parameters ---------- ternary_data : ndarray of shape (N, 3) delta : float Small float to regularize logarithm. Notes ----- Implements a method by J. A. Martin-

(ternary_data, delta=0.0005)

Source from the content-addressed store, hash-verified

53
54
55def _replace_zero_coords(ternary_data, delta=0.0005):
56 """
57 Replaces zero ternary coordinates with delta and normalize the new
58 triplets (a, b, c).
59
60 Parameters
61 ----------
62
63 ternary_data : ndarray of shape (N, 3)
64
65 delta : float
66 Small float to regularize logarithm.
67
68 Notes
69 -----
70 Implements a method
71 by J. A. Martin-Fernandez, C. Barcelo-Vidal, V. Pawlowsky-Glahn,
72 Dealing with zeros and missing values in compositional data sets
73 using nonparametric imputation, Mathematical Geology 35 (2003),
74 pp 253-278.
75 """
76 zero_mask = ternary_data == 0
77 is_any_coord_zero = np.any(zero_mask, axis=0)
78
79 unity_complement = 1 - delta * is_any_coord_zero
80 if np.any(unity_complement) < 0:
81 raise ValueError(
82 "The provided value of delta led to negative"
83 "ternary coords.Set a smaller delta"
84 )
85 ternary_data = np.where(zero_mask, delta, unity_complement * ternary_data)
86 return ternary_data
87
88
89def _ilr_transform(barycentric):

Callers 1

_compute_gridFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected