-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
modified: tests/models/test_vit.py modified: tests/nn/modules/test_linearactivation.py modified: tests/structs/test_localtransformer.py modified: tests/structs/test_transformer.py modified: zeta/nn/modules/test_dense_connect.py
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
Check warning Code scanning / Pylint (reported by Codacy) Missing module docstring Warning
Missing module docstring
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing module docstring Warning
Missing module docstring
|
||
import shutil | ||
import sys | ||
|
||
|
||
def delete_pycache(directory): | ||
Check warning Code scanning / Pylint (reported by Codacy) Missing function docstring Warning
Missing function docstring
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing function or method docstring Warning
Missing function or method docstring
Check notice Code scanning / Pylintpython3 (reported by Codacy) Redefining name 'directory' from outer scope (line 17) Note
Redefining name 'directory' from outer scope (line 17)
|
||
for root, dirs, files in os.walk(directory): | ||
Check warning Code scanning / Prospector (reported by Codacy) Unused variable 'files' (unused-variable) Warning
Unused variable 'files' (unused-variable)
Check notice Code scanning / Pylintpython3 (reported by Codacy) Unused variable 'files' Note
Unused variable 'files'
|
||
if "__pycache__" in dirs: | ||
shutil.rmtree(os.path.join(root, "__pycache__")) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python delete_pycache.py <directory>") | ||
sys.exit(1) | ||
|
||
directory = sys.argv[1] | ||
Check warning Code scanning / Pylint (reported by Codacy) Constant name "directory" doesn't conform to UPPER_CASE naming style Warning
Constant name "directory" doesn't conform to UPPER_CASE naming style
|
||
delete_pycache(directory) | ||
print(f"__pycache__ directories deleted in {directory}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,36 @@ | ||
import torch | ||
import torch.nn as nn | ||
import unittest | ||
|
||
import pytest | ||
from zeta.nn.modules.dense_connect import DenseBlock | ||
|
||
|
||
class DenseBlockTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.submodule = nn.Linear(10, 5) | ||
self.dense_block = DenseBlock(self.submodule) | ||
@pytest.fixture | ||
def dense_block(): | ||
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing function or method docstring Warning test
Missing function or method docstring
Check warning Code scanning / Pylint (reported by Codacy) Missing function docstring Warning test
Missing function docstring
|
||
submodule = nn.Linear(10, 5) | ||
return DenseBlock(submodule) | ||
|
||
|
||
def test_forward(self): | ||
x = torch.randn(32, 10) | ||
output = self.dense_block(x) | ||
def test_forward(dense_block): | ||
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing function or method docstring Warning test
Missing function or method docstring
Check warning Code scanning / Pylint (reported by Codacy) Missing function docstring Warning test
Missing function docstring
Check notice Code scanning / Pylintpython3 (reported by Codacy) Redefining name 'dense_block' from outer scope (line 8) Note test
Redefining name 'dense_block' from outer scope (line 8)
|
||
x = torch.randn(32, 10) | ||
Check warning Code scanning / Pylint (reported by Codacy) Variable name "x" doesn't conform to snake_case naming style Warning test
Variable name "x" doesn't conform to snake_case naming style
|
||
output = dense_block(x) | ||
|
||
self.assertEqual(output.shape, (32, 15)) # Check output shape | ||
self.assertTrue( | ||
torch.allclose(output[:, :10], x) | ||
) # Check if input is preserved | ||
self.assertTrue( | ||
torch.allclose(output[:, 10:], self.submodule(x)) | ||
) # Check submodule output | ||
assert output.shape == (32, 15) # Check output shape | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
assert torch.allclose(output[:, :10], x) # Check if input is preserved | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
assert torch.allclose( | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
output[:, 10:], dense_block.submodule(x) | ||
) # Check submodule output | ||
|
||
def test_initialization(self): | ||
self.assertEqual( | ||
self.dense_block.submodule, self.submodule | ||
) # Check submodule assignment | ||
|
||
def test_docstrings(self): | ||
self.assertIsNotNone( | ||
DenseBlock.__init__.__doc__ | ||
) # Check if __init__ has a docstring | ||
self.assertIsNotNone( | ||
DenseBlock.forward.__doc__ | ||
) # Check if forward has a docstring | ||
def test_initialization(dense_block): | ||
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing function or method docstring Warning test
Missing function or method docstring
Check warning Code scanning / Pylint (reported by Codacy) Missing function docstring Warning test
Missing function docstring
Check notice Code scanning / Pylintpython3 (reported by Codacy) Redefining name 'dense_block' from outer scope (line 8) Note test
Redefining name 'dense_block' from outer scope (line 8)
|
||
assert isinstance(dense_block.submodule, nn.Linear) # Check submodule type | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
assert dense_block.submodule.in_features == 10 # Check input features | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
assert dense_block.submodule.out_features == 5 # Check output features | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
def test_docstrings(): | ||
Check warning Code scanning / Pylintpython3 (reported by Codacy) Missing function or method docstring Warning test
Missing function or method docstring
Check warning Code scanning / Pylint (reported by Codacy) Missing function docstring Warning test
Missing function docstring
|
||
assert ( | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
DenseBlock.__init__.__doc__ is not None | ||
) # Check if __init__ has a docstring | ||
assert ( | ||
Check notice Code scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check warning Code scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||
DenseBlock.forward.__doc__ is not None | ||
) # Check if forward has a docstring |