Skip to content

Commit

Permalink
Adjusted test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganyushin, Dmitry committed Jul 3, 2024
1 parent 65d7b7d commit 8449ba5
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions tests/unit/bm3dornl/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,54 +44,29 @@ def test_is_within_threshold():
result = is_within_threshold(ref_patch, cmp_patch_close, threshold)
assert not result, "Failed: Slightly different patches should not be within very small distance of 0.1"


@pytest.mark.skip(reason="Changed function signature")
def test_horizontal_binning():
size_x , size_y = 64, 64
k = 6
# Initial setup: Create a test image
Z = np.random.rand(64, 64)

# Number of binning iterations
k = 3

# Perform the binning
binned_images = horizontal_binning(Z, k)

# Assert we have the correct number of images
assert len(binned_images) == k + 1, "Incorrect number of binned images returned"
Z = np.random.rand(size_y, size_y)

# Assert that each image has the correct dimensions
expected_width = 64
for i, img in enumerate(binned_images):
assert img.shape[0] == 64, f"Height of image {i} is incorrect"
assert img.shape[1] == expected_width, f"Width of image {i} is incorrect"
expected_width = size_x
for i in range(k):
# Perform the binning
expected_width = (expected_width + 1) // 2 # Calculate the next expected width


@pytest.mark.skip(reason="Changed function signature")
def test_horizontal_binning_k_zero():
Z = np.random.rand(64, 64)
binned_images = horizontal_binning(Z, 0)
assert len(binned_images) == 1 and np.array_equal(
binned_images[0], Z
), "Binning with k=0 should return only the original image"


@pytest.mark.skip(reason="Changed function signature")
def test_horizontal_binning_large_k():
Z = np.random.rand(64, 64)
binned_images = horizontal_binning(Z, 6)
assert len(binned_images) == 7, "Incorrect number of images for large k"
assert binned_images[-1].shape[1] == 1, "Final image width should be 1 for large k"

binned_image = horizontal_binning(Z, fac=2)
assert binned_image.shape[0] == 64, f"Height of image {i} is incorrect"
assert binned_image.shape[1] == expected_width, f"Width of image {i} is incorrect"
Z = binned_image

@pytest.mark.parametrize(
"original_width, target_width", [(32, 64), (64, 128), (128, 256)]
)
@pytest.mark.skip(reason="Changed function signature")
def test_horizontal_debinning_scaling(original_width, target_width):
original_image = np.random.rand(64, original_width)
target_shape = (64, target_width)
debinned_image = horizontal_debinning(original_image, np.empty(target_shape))
debinned_image = horizontal_debinning(original_image, target_width, fac=2, dim=1, n_iter=1)
assert (
debinned_image.shape == target_shape
), f"Failed to scale from {original_width} to {target_width}"
Expand Down

0 comments on commit 8449ba5

Please sign in to comment.