Skip to content

Commit 4d258b0

Browse files
committed
adding comments to comparison_plot function
1 parent 148f559 commit 4d258b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/sparkle/platform/latex.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ def comparison_plot(
4141
x_values = data_frame[data_frame.columns[0]].to_numpy(dtype=float)
4242
y_values = data_frame[data_frame.columns[1]].to_numpy(dtype=float)
4343
valid_mask = ~(np.isnan(x_values) | np.isnan(y_values))
44+
45+
# Filter out NaN values
4446
x_values = x_values[valid_mask]
4547
y_values = y_values[valid_mask]
4648

47-
# Determine if data is log scale, linregress tells us how linear the data is.
4849
# Guard against degenerate data (single point or no variance) to avoid SciPy warnings.
4950
if (
5051
x_values.size >= 2
5152
and y_values.size >= 2
5253
and np.ptp(x_values) > 0
5354
and np.ptp(y_values) > 0
5455
):
55-
linregress = stats.linregress(x_values, y_values)
56+
linregress = stats.linregress(x_values, y_values) # Perform linear regression
57+
58+
# Determine if log scale is appropriate based on correlation by checking r-value and p-value
5659
log_scale = not (linregress.rvalue > 0.65 and linregress.pvalue < 0.05)
5760
else:
5861
log_scale = False

0 commit comments

Comments
 (0)