Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Tests for src/pygui/backend/rbf_heatmap.py."""
|
||||
import numpy as np
|
||||
from pygui.backend.rbf_heatmap import interpolate_field, BACKEND
|
||||
|
||||
|
||||
def test_field_shape_and_interpolates_at_sites():
|
||||
xs = np.array([0.0, 10.0, -10.0, 0.0])
|
||||
ys = np.array([10.0, -10.0, -10.0, 0.0])
|
||||
vs = np.array([149.0, 150.0, 148.0, 149.5])
|
||||
field = interpolate_field(xs, ys, vs, width=64, height=64,
|
||||
extent=(-15, 15, -15, 15))
|
||||
assert field.shape == (64, 64)
|
||||
assert np.isfinite(field).all()
|
||||
assert field.min() <= 150.0 and field.max() >= 148.0
|
||||
|
||||
|
||||
def test_round_clip_produces_nans_outside_circle():
|
||||
xs = np.array([0.0, 5.0, -5.0])
|
||||
ys = np.array([5.0, -5.0, 0.0])
|
||||
vs = np.array([149.0, 150.0, 148.0])
|
||||
field = interpolate_field(xs, ys, vs, width=64, height=64,
|
||||
extent=(-15, 15, -15, 15), round_clip=True)
|
||||
assert np.isnan(field).any()
|
||||
# center pixel must be finite
|
||||
assert np.isfinite(field[32, 32])
|
||||
|
||||
|
||||
def test_backend_reported():
|
||||
assert BACKEND in ("cupy", "numpy")
|
||||
Reference in New Issue
Block a user