Skip to content

Undocumented use of magic numbers #2

Description

@research-police

We patrolled your repo and found the following:
There are multiple instances of undocumented use of magic numbers, like:

mind = mind[:, torch.Tensor([6, 8, 1, 11, 2, 10, 0, 7, 9, 4, 5, 3]).long(), :, :, :]

(we get the intended logic, however it seems arbitrary, error prone and significantly limits comprehensibility)

for ii,i in enumerate((1,7,8,14,18,20,21,28,1,2,3,4,5,6,7,8,9,10,1,2,3,5,6,8,9,11,12,14,17,19)):

as well as
for ii,i in enumerate((1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,7,8,14,18,20,21,28)):

(those numbers look like case IDs, but the overall selection and ordering is unclear/undocumented. Again this is error prone and limits comprehensibility)

keypts_fix = torch.stack((corrfield[:,2+0]/207*2-1,corrfield[:,1+0]/191*2-1,corrfield[:,0+0]/191*2-1),1).cuda()
keypts_mov = torch.stack((corrfield[:,2+3]/207*2-1,corrfield[:,1+3]/191*2-1,corrfield[:,0+3]/191*2-1),1).cuda()
if((ii>=8)&(ii<18)):
keypts_mov = torch.stack((corrfield[:,2+0]/207*2-1,corrfield[:,1+0]/191*2-1,corrfield[:,0+0]/191*2-1),1).cuda()
keypts_fix = torch.stack((corrfield[:,2+3]/207*2-1,corrfield[:,1+3]/191*2-1,corrfield[:,0+3]/191*2-1),1).cuda()

(we figure that the numbers 207, 191, are somehow correlated to the image shape and are used to transform the displacement field to the range of [-1, +1]. Furthermore, please explain the addition operations like 2+0, 2+3)

if(mean_mask<1.97):

This is obviously an undocumented magic number and requires explanation

idx_test_all = torch.tensor([[0,1,15,16],[2,3,10,11],[4,5,17,18],[6,7,12,13],[8,9,14,19]])

Those numbers are (based on the variable naming) test case indices, however why is the tensor multi-dimensional (shape: (5, 4))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions