Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RotationWrapper unnecessarily calculates core of block instead of using DataSetBlock.data_unpadded #447

Open
yousefmoazzam opened this issue Sep 13, 2024 · 0 comments
Labels
minor Nice to do but not vital

Comments

@yousefmoazzam
Copy link
Collaborator

As the title says, the following logic is unnecessary and likely can be made tidier by using block.data_unpadded:

# Extract core of block, in case padding slices are present
core_angles_start = 0
core_angles_stop = block.shape_unpadded[0]
if block.is_padded:
core_angles_start = block.padding[0]
core_angles_stop = core_angles_start + block.shape_unpadded[0]
data = block.data[core_angles_start:core_angles_stop, slice_for_cor, :]

Plus, the logic to extract the core out of a padded block is already tested for DataSetBlock.data_unpadded:

def test_get_padded_and_unpadded_data():
padding = (2, 2)
data = np.ones((10, 10, 10), dtype=np.float32)
# set the padding areas to something else
data[: padding[0], :, :] = -1
data[10 - padding[1] :, :, :] = -2
angles = np.linspace(0, math.pi, 30, dtype=np.float32)
block = DataSetBlock(
data=data,
aux_data=AuxiliaryData(angles=angles),
block_start=-2,
chunk_start=8,
slicing_dim=0,
global_shape=(30, 10, 10),
padding=padding,
)
np.testing.assert_array_equal(block.data, data)
unpadded = block.data_unpadded
assert unpadded.shape == (6, 10, 10)
np.testing.assert_array_equal(unpadded, 1.0)

whereas the code extracting the block's core in the rotation wrapper isn't.

@yousefmoazzam yousefmoazzam added the minor Nice to do but not vital label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Nice to do but not vital
Projects
None yet
Development

No branches or pull requests

1 participant