Skip to content

Commit c4ff70b

Browse files
authored
6799 do not compare types (#6801)
Fixes #6799. Fixes #6800 Do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder.
1 parent 5feb353 commit c4ff70b

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ jobs:
6464

6565
- name: Build
6666
run: |
67+
rm -rf /opt/hostedtoolcache/{node,go,Ruby,Java*}
68+
ls -al /opt/hostedtoolcache
69+
rm -rf /usr/share/dotnet/
6770
python -m pip install -U pip wheel
6871
python -m pip install -r requirements-dev.txt
6972
BUILD_MONAI=1 ./runtests.sh --build

tests/test_selfattention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_access_attn_matrix(self):
6262
# be not able to access the matrix
6363
no_matrix_acess_blk = SABlock(hidden_size=hidden_size, num_heads=num_heads, dropout_rate=dropout_rate)
6464
no_matrix_acess_blk(torch.randn(input_shape))
65-
assert type(no_matrix_acess_blk.att_mat) == torch.Tensor
65+
assert isinstance(no_matrix_acess_blk.att_mat, torch.Tensor)
6666
# no of elements is zero
6767
assert no_matrix_acess_blk.att_mat.nelement() == 0
6868

tests/test_transformerblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_access_attn_matrix(self):
6666
hidden_size=hidden_size, mlp_dim=mlp_dim, num_heads=num_heads, dropout_rate=dropout_rate
6767
)
6868
no_matrix_acess_blk(torch.randn(input_shape))
69-
assert type(no_matrix_acess_blk.attn.att_mat) == torch.Tensor
69+
assert isinstance(no_matrix_acess_blk.attn.att_mat, torch.Tensor)
7070
# no of elements is zero
7171
assert no_matrix_acess_blk.attn.att_mat.nelement() == 0
7272

tests/test_vit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_access_attn_matrix(self):
160160
# no data in the matrix
161161
no_matrix_acess_blk = ViT(in_channels=in_channels, img_size=img_size, patch_size=patch_size)
162162
no_matrix_acess_blk(torch.randn(in_shape))
163-
assert type(no_matrix_acess_blk.blocks[0].attn.att_mat) == torch.Tensor
163+
assert isinstance(no_matrix_acess_blk.blocks[0].attn.att_mat, torch.Tensor)
164164
# no of elements is zero
165165
assert no_matrix_acess_blk.blocks[0].attn.att_mat.nelement() == 0
166166

0 commit comments

Comments
 (0)