@@ -188,6 +188,11 @@ def __init__(
188
188
self .y_normalized = self .transform_y (
189
189
self .y_normalized , self .direction , self .curve
190
190
)
191
+
192
+ self .x_normalized = self .transform_x (
193
+ self .x_normalized , self .direction , self .curve
194
+ )
195
+ # normalized difference curve
191
196
# normalized difference curve
192
197
self .y_difference = self .y_normalized - self .x_normalized
193
198
self .x_difference = self .x_normalized .copy ()
@@ -228,16 +233,22 @@ def __normalize(a: Iterable[float]) -> Iterable[float]:
228
233
def transform_y (y : Iterable [float ], direction : str , curve : str ) -> float :
229
234
"""transform y to concave, increasing based on given direction and curve"""
230
235
# convert elbows to knees
231
- if direction == "decreasing" :
232
- if curve == "concave" :
233
- y = np .flip (y )
234
- elif curve == "convex" :
235
- y = y .max () - y
236
- elif direction == "increasing" and curve == "convex" :
237
- y = np .flip (y .max () - y )
236
+ if curve == "convex" :
237
+ y = y .max () - y
238
238
239
239
return y
240
240
241
+ @staticmethod
242
+ def transform_x (x : Iterable [float ], direction : str , curve : str ) -> float :
243
+ """transform x to concave, increasing based on given direction and curve"""
244
+ # convert elbows to knees
245
+ if direction == "decreasing" and curve == "concave" :
246
+ x = x .max - x
247
+ elif direction == "increasing" and curve == "convex" :
248
+ x = x .max - x
249
+
250
+ return x
251
+
241
252
def find_knee (self ,):
242
253
"""This function is called when KneeLocator is instantiated. It identifies the knee value and sets the instance attributes."""
243
254
if not self .maxima_indices .size :
0 commit comments