Skip to content

Commit ce2e80d

Browse files
committed
style: Reformat Code
- Optimize imports - Cleanup code
1 parent 8811cef commit ce2e80d

9 files changed

+25
-18
lines changed

AstToEcoreConverter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ def get_method_def_from_internal_structure(self, method_name, module):
10991099
return current_method[0]
11001100
return None
11011101

1102-
def create_method_signature(self, method_node, name, arguments, return_type = None):
1102+
def create_method_signature(self, method_node, name, arguments, return_type=None):
11031103
"""
11041104
Creates a method signature for a method definition.
11051105
@@ -1134,7 +1134,7 @@ def create_method_signature(self, method_node, name, arguments, return_type = No
11341134

11351135
# Add type for TParameter.type
11361136
parameter_type = self.create_ecore_instance(NodeTypes.CLASS)
1137-
#parameter_type.tName = arg.annotation if arg.annotation else 'None'
1137+
# parameter_type.tName = arg.annotation if arg.annotation else 'None'
11381138
parameter.type = parameter_type
11391139

11401140
method_node.signature = method_signature

EcoreToMatrixConverter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ def convert_subpackages_recursive(self, t_package):
335335
t_package: The package to convert subpackages from.
336336
"""
337337
for t_subpackage in t_package.subpackages:
338-
current_subpackage = self.get_node_in_container(t_subpackage.tName, NodeTypes.PACKAGE.value, t_package.tName,
338+
current_subpackage = self.get_node_in_container(t_subpackage.tName, NodeTypes.PACKAGE.value,
339+
t_package.tName,
339340
NodeTypes.PACKAGE.value)
340341
if current_subpackage is None:
341342
self.node_matrix.append(NodeTypes.PACKAGE.value)

GCN.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
'''defines the architecture of the graph convolutional network'''
66

7+
78
class GCN(torch.nn.Module):
89
def __init__(self, num_node_features, num_classes, hidden_channels):
910
super(GCN, self).__init__()
@@ -33,4 +34,4 @@ def forward(self, x, edge_index, edge_attr, batch=None):
3334
# sigmoid activation function for multi-label
3435
x = f.sigmoid(x)
3536

36-
return x
37+
return x

GraphClasses.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
"""in this file are the defined labels for our dataset, they are not mutually exclusive"""
22
from settings import CONFIG
3+
34
defined_labels = CONFIG['graph']['defined_labels']

NodeFeatures.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ class NodeTypes(Enum):
1717
CLASS = "TClass"
1818
# TMethod
1919
METHOD = "TMethod"
20-
METHOD_SIGNATURE = "TMethodSignature" # missing firstParameter does not need to be implemented.
21-
METHOD_DEFINITION = "TMethodDefinition"# missing "".overloading and "".overloadedBY does not need to be implemented.
20+
METHOD_SIGNATURE = "TMethodSignature" # missing firstParameter does not need to be implemented.
21+
METHOD_DEFINITION = "TMethodDefinition" # missing "".overloading and "".overloadedBY does not need to be implemented.
2222
PARAMETER = "TParameter"
2323
# TField
2424
FIELD = "TField"
25-
FIELD_SIGNATURE = "TFieldSignature" # Todo implement this in AstToEcoreConverter (only missing TFieldSignature.type)
26-
FIELD_DEFINITION = "TFieldDefinition" # missing TFieldDefinition.hidden and "".hiddenBy does not to be implemented
25+
FIELD_SIGNATURE = "TFieldSignature" # Todo implement this in AstToEcoreConverter (only missing TFieldSignature.type)
26+
FIELD_DEFINITION = "TFieldDefinition" # missing TFieldDefinition.hidden and "".hiddenBy does not to be implemented
2727
# TAccess
2828
CALL = "TCall"
2929
READ = "TRead" # Todo implement this in AstToEcoreConverter
3030
WRITE = "TWrite" # Todo implement this in AstToEcoreConverter
3131
READ_WRITE = "TReadWrite" # Todo implement this in AstToEcoreConverter
32-
#TInterface
32+
# TInterface
3333
INTERFACE = "TInterface"
3434
# In Python, there is no formal concept of interfaces as found in some other programming languages like Java or C#.
3535
# However, Python supports a similar concept through the use of abstract base classes (ABCs) and duck typing.
36-
# The return on investment probably is not sufficient to justify the implementation.
36+
# The return on investment probably is not sufficient to justify the implementation.

Pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ def prepare_dataset(repository_directory, output_directory=None, repository_list
239239
global repo_multiprocess, ecore_graph
240240
global node_features, adj_list, edge_attribute
241241

242-
243242
# clone repositories for the dataset
244243
if repository_list is not None:
245244
download_repositories(repository_directory, repository_list)

TorchGPUCheck.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import torch
2+
23
"""
34
This code is a simple Python script that checks if CUDA is available on the system and provides instructions on how to enable it if it's not available.
45
"""
@@ -14,7 +15,10 @@
1415
print("CUDA is not available.")
1516
print("To enable CUDA, follow these steps:")
1617
print("1. **Install NVIDIA Drivers**: Ensure you have the latest NVIDIA drivers installed on your system.")
17-
print("2. **Install CUDA Toolkit**: Download and install the CUDA Toolkit from the official NVIDIA website: https://developer.nvidia.com/cuda-downloads")
18-
print("3. **Verify CUDA Installation**: After installation, verify that CUDA is working correctly by running the `nvidia-smi` command in your terminal/command prompt.")
19-
print("4. **Update PyTorch**: Make sure you're using the latest version of PyTorch. You can update PyTorch using pip: `pip install --upgrade torch`")
20-
print("5. **Restart Your System**: Restart your system to ensure that the changes take effect.")
18+
print(
19+
"2. **Install CUDA Toolkit**: Download and install the CUDA Toolkit from the official NVIDIA website: https://developer.nvidia.com/cuda-downloads")
20+
print(
21+
"3. **Verify CUDA Installation**: After installation, verify that CUDA is working correctly by running the `nvidia-smi` command in your terminal/command prompt.")
22+
print(
23+
"4. **Update PyTorch**: Make sure you're using the latest version of PyTorch. You can update PyTorch using pip: `pip install --upgrade torch`")
24+
print("5. **Restart Your System**: Restart your system to ensure that the changes take effect.")

pep8autoformat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import autopep8
22

3+
34
def format_python_file(path_to_file):
45
try:
56
# Read the current content of the file
@@ -21,4 +22,4 @@ def format_python_file(path_to_file):
2122
if __name__ == "__main__":
2223
# Specify the file path you want to format
2324
file_path = 'AstToEcoreConverter.py'
24-
format_python_file(file_path)
25+
format_python_file(file_path)

train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def train():
3434

3535
num_classes = int(len(defined_labels))
3636

37-
for graph in tqdm(trainloader,desc = "Training"):
37+
for graph in tqdm(trainloader, desc="Training"):
3838

3939
if device == 'cuda':
4040
graph.x = graph.x.to(device)
@@ -67,7 +67,7 @@ def test(loader):
6767
total = 0
6868
num_classes = int(len(defined_labels))
6969

70-
for graph in tqdm(loader,desc = "Testing"):
70+
for graph in tqdm(loader, desc="Testing"):
7171

7272
if device == 'cuda':
7373
graph.x = graph.x.to(device)

0 commit comments

Comments
 (0)