Skip to content

Commit

Permalink
Add tests on 1 and 0 size randoms
Browse files Browse the repository at this point in the history
  • Loading branch information
jranalli committed Oct 9, 2024
1 parent 85d7568 commit 880eb48
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion tests/synthirrad/test_cloudfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class TestFieldGeneration:
# TODO add tests for size 1 and size 0 to guarantee that they produce correct output
def test_random_at_scale_identity(self):
base, interp = cloudfield._random_at_scale((10,10), (10, 10), False)
assert base.shape == (10, 10)
Expand Down Expand Up @@ -37,6 +36,42 @@ def test_random_at_scale_interpolation(self):
# Check that the interpolated values are within the range of the original values
assert interp.min() >= base.min() and interp.max() <= base.max()

def test_random_at_scale_size1(self):
rand_size = (1, 1)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert np.mean(base) == approx(base[0, 0])
assert interp.shape == final_size

def test_random_at_scale_size_partial1(self):
rand_size = (10, 1)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert interp.shape == final_size

rand_size = (1, 10)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert interp.shape == final_size

def test_random_at_scale_size0(self):
rand_size = (0, 0)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert np.mean(base) == approx(base[0, 0])
assert interp.shape == final_size

def test_random_at_scale_size_partial0(self):
rand_size = (10, 0)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert interp.shape == final_size

rand_size = (0, 10)
final_size = (20, 20)
base, interp = cloudfield._random_at_scale(rand_size, final_size)
assert interp.shape == final_size

def test_stack_random_field_with_weights(self):
size = (100, 100)
scales = np.array([1, 2, 3])
Expand Down

0 comments on commit 880eb48

Please sign in to comment.