Skip to content

Commit

Permalink
pylint: improved score - now threshold again at old value of 9.75
Browse files Browse the repository at this point in the history
  • Loading branch information
97gamjak committed Jun 11, 2024
1 parent 93f92de commit 978644e
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 29 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ jobs:
python .github/scripts/parse_pylint.py pylint_output.txt | tee comment.txt
fi
#check if the first line of comment.txt rates higher than 9.75 with following format
#Your code has been rated at 9.86/10 (previous run: 7.63/10, +2.22)
- name: Check if pylint score is higher than 9.75
id: check_pylint_score
run: |
head -n3 comment.txt | tail -n 1
head -n3 comment.txt | tail -n 1 | awk '{print $7}'
head -n3 comment.txt | tail -n 1 | awk '{print $7}' | cut -d '/' -f 1
score=$(head -n3 comment.txt | tail -n 1 | awk '{print $7}' | cut -d '/' -f 1)
if (( $(echo "$score > 9.5" | bc -l) )); then
echo "Pylint score is higher than 9.5 and is $score"
if (( $(echo "$score > 9.75" | bc -l) )); then
echo "Pylint score is higher than 9.75 and is $score"
else
echo "Pylint score is lower than 9.5 and is $score"
echo "Pylint score is lower than 9.75 and is $score"
exit 1
fi
shell: bash
Expand Down
1 change: 0 additions & 1 deletion PQAnalysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# BEARTYPE SETUP #
##################

# TODO: change the default level to "RELEASE" after all changes are implemented
__beartype_default_level__ = "RELEASE"
__beartype_level__ = os.getenv(
"PQANALYSIS_BEARTYPE_LEVEL", __beartype_default_level__
Expand Down
1 change: 0 additions & 1 deletion PQAnalysis/atomic_system/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
of atoms is equal to the number of positions.
"""

import sys
import numpy as np

from beartype.typing import Any
Expand Down
4 changes: 2 additions & 2 deletions PQAnalysis/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def distance(
pos1: Np1DNumberArray | Np2DNumberArray,
pos2: Np1DNumberArray | Np2DNumberArray,
cell: _cell.Cell = _cell.Cell(),
**kwargs
**kwargs # pylint: disable=unused-argument
) -> PositiveReal | Np1DNumberArray | Np2DNumberArray:
"""
Returns the distances between all combinations of two position arrays.
Expand Down Expand Up @@ -66,7 +66,7 @@ def distance(
cell : Cell, optional
The unit cell of the system. Default is Cell().
**kwargs
Arbitrary keyword arguments.
Additional keyword arguments.
Returns
-------
Expand Down
1 change: 1 addition & 0 deletions PQAnalysis/io/gen_file/gen_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def _read_header(self,
"""
n_atoms, periodicity = header[0].split()
n_atoms = int(n_atoms)
is_periodic = False # Default value

if periodicity.lower() == "c":
is_periodic = False
Expand Down
3 changes: 3 additions & 0 deletions PQAnalysis/io/input_file_reader/input_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def parse(self) -> "InputDictionary":
InputDictionary: InputDictionary
The parsed input file dictionary.
"""

grammar_file = None # to avoid linter warning

if self.input_format == InputFileFormat.PQANALYSIS:
grammar_file = "inputGrammar.lark"
elif self.input_format in [InputFileFormat.PQ, InputFileFormat.QMCFC]:
Expand Down
2 changes: 0 additions & 2 deletions PQAnalysis/io/input_file_reader/pq/output_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
A module containing a Mixin class for output files of a PQ input file.
"""

from PQAnalysis.exceptions import PQKeyError



class _OutputFileMixin:
Expand Down
18 changes: 12 additions & 6 deletions PQAnalysis/io/nep/nep_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ def write_from_files(

self.is_validation = False

file_to_write = None # to avoid linting warning

if j in train_indices:
self.n_train_frames += 1
file_to_write = self.train_file
Expand All @@ -339,7 +341,11 @@ def write_from_files(
)

self.write_from_atomic_system(
system, file_to_write, use_forces, use_stress, use_virial
system,
file_to_write,
use_forces,
use_stress,
use_virial,
)

if self.is_validation:
Expand Down Expand Up @@ -437,12 +443,16 @@ def _setup_frame_splitting_for_training(
exception=NEPError
)

n_train = 0.0
n_validation = 0.0
n_test = 0.0

if total_ratios is not None:
ratios = total_ratios.split(":")
if len(ratios) == 2:
n_train = float(ratios[0])
n_test = float(ratios[1])
n_validation = 0
n_validation = 0.0
elif len(ratios) == 3:
n_train = float(ratios[0])
n_test = float(ratios[1])
Expand All @@ -456,10 +466,6 @@ def _setup_frame_splitting_for_training(
),
exception=NEPError
)
else:
n_train = 0.0
n_validation = 0.0
n_test = 0.0

sum_frames = n_train + n_test + n_validation

Expand Down
30 changes: 30 additions & 0 deletions PQAnalysis/io/topology_file/topology_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ def _parse_bonds(self, block: List[str]) -> List[Bond]:

line, comment = self._get_data_line_comment(line)

index = None # to avoid linter warning
target_index = None # to avoid linter warning
bond_type = None # to avoid linter warning
is_linker = None # to avoid linter warning

if len(line.split()) == 4:
index, target_index, bond_type, _ = line.split()
is_linker = True
Expand Down Expand Up @@ -263,6 +268,12 @@ def _parse_angles(self, block: List[str]) -> List[Angle]:

line, comment = self._get_data_line_comment(line)

index1 = None # to avoid linter warning
index2 = None # to avoid linter warning
index3 = None # to avoid linter warning
angle_type = None # to avoid linter warning
is_linker = None # to avoid linter warning

if len(line.split()) == 5:
index1, index2, index3, angle_type, _ = line.split()
is_linker = True
Expand Down Expand Up @@ -318,6 +329,13 @@ def _parse_dihedrals(self, block: List[str]) -> List[Dihedral]:

line, comment = self._get_data_line_comment(line)

index1 = None # to avoid linter warning
index2 = None # to avoid linter warning
index3 = None # to avoid linter warning
index4 = None # to avoid linter warning
dihedral_type = None # to avoid linter warning
is_linker = None # to avoid linter warning

if len(line.split()) == 6:
index1, index2, index3, index4, dihedral_type, _ = line.split()
is_linker = True
Expand Down Expand Up @@ -374,6 +392,13 @@ def _parse_impropers(self, block: List[str]) -> List[Dihedral]:

line, comment = self._get_data_line_comment(line)

index1 = None # to avoid linter warning
index2 = None # to avoid linter warning
index3 = None # to avoid linter warning
index4 = None # to avoid linter warning
dihedral_type = None # to avoid linter warning
is_linker = None # to avoid linter warning

if len(line.split()) == 6:
index1, index2, index3, index4, dihedral_type, _ = line.split()
is_linker = True
Expand Down Expand Up @@ -431,6 +456,11 @@ def _parse_shake(self, block: List[str]) -> List[Bond]:

line, comment = self._get_data_line_comment(line)

index = None # to avoid linter warning
target_index = None # to avoid linter warning
distance = None # to avoid linter warning
is_linker = None # to avoid linter warning

if len(line.split()) == 4:
index, target_index, distance, _ = line.split()
is_linker = True
Expand Down
5 changes: 4 additions & 1 deletion PQAnalysis/io/traj_file/frame_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from PQAnalysis import __package_name__

from .exceptions import FrameReaderError
from .process_lines import process_lines_with_atoms
from .process_lines import process_lines_with_atoms # pylint: disable=import-error



Expand Down Expand Up @@ -316,6 +316,9 @@ def _read_header_line(self, header_line: str) -> Tuple[int, Cell]:
If the header line is not valid. Either it contains too many or too few values.
"""

n_atoms = 0 # default value
cell = None # default value

header_line = header_line.split()

if len(header_line) == 4:
Expand Down
10 changes: 0 additions & 10 deletions PQAnalysis/io/traj_file/setup.py

This file was deleted.

0 comments on commit 978644e

Please sign in to comment.