import numpy as np from pytfd_compat.helpers import legacy_hop, subset, zeropad_center def test_subset_zero_padding(): x = np.array([1, 2, 3, 4]) np.testing.assert_array_equal(subset(x, center=0, length=4), np.array([0, 0, 1, 2])) np.testing.assert_array_equal(subset(x, center=3, length=4), np.array([2, 3, 4, 0])) def test_subset_circular_padding(): x = np.array([1, 2, 3, 4]) np.testing.assert_array_equal(subset(x, center=0, length=4, padding="circular"), np.array([3, 4, 1, 2])) def test_zeropad_center_even_padding(): x = np.array([1.0, 2.0, 3.0]) np.testing.assert_array_equal(zeropad_center(x, 7), np.array([0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 0.0])) def test_legacy_hop_matches_dense_default(): assert legacy_hop(16, None) == 1 assert legacy_hop(16, 4) == 4