Skip to content

Commit 69e33a1

Browse files
committed
fix test warnings
1 parent cc842f3 commit 69e33a1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

slise/plot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,10 @@ def plot_2d(
310310
else:
311311
ax.plot(x_limits, y_limits, "-", color=SLISE_ORANGE, label="Model")
312312
formula = ""
313-
if isinstance(model, float) or len(model) == 1:
314-
formula = f"{float(model):.{decimals}f} * {label_x}"
313+
if isinstance(model, float):
314+
formula = f"{model:.{decimals}f} * {label_x}"
315+
elif len(model.flat) == 1:
316+
formula = f"{model.flat[0]:.{decimals}f} * {label_x}"
315317
elif np.abs(model[0]) > 1e-8:
316318
sign = "-" if model[1] < 0.0 else "+"
317319
formula = f"{model[0]:.{decimals}f} {sign} {abs(model[1]):.{decimals}f} $\\cdot$ {label_x}"

tests/test_optim.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ def test_weights():
250250
regularised_regression(X, Y, 1e-4, 1e-4, weight=w2),
251251
)
252252
assert np.allclose(
253-
regularised_regression(X2, Y2, 1e-4, 1e-4, weight=w1),
254-
regularised_regression(X, Y, 1e-4, 1e-4, weight=w3),
255-
atol=1e-4,
253+
regularised_regression(X2, Y2, 1e-4, 1e-4, weight=w1, max_iterations=300),
254+
regularised_regression(X, Y, 1e-4, 1e-4, weight=w3, max_iterations=300),
256255
)
257256

258257

0 commit comments

Comments
 (0)