Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
97gamjak committed May 31, 2024
2 parents c9de6d6 + f0e99c1 commit ed46715
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
18 changes: 5 additions & 13 deletions PQAnalysis/atomic_system/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
from decorator import decorator

from .exceptions import (
AtomicSystemPositionsError,
AtomicSystemMassError,
AtomicSystemError
AtomicSystemPositionsError, AtomicSystemMassError, AtomicSystemError
)


Expand Down Expand Up @@ -54,17 +52,12 @@ def check_atom_number_setters(func, self, arg_to_set: Any) -> None:
AtomicSystemError
If the number of atoms is not equal the number of positions.
"""
print("test")
print(func.__name__, file=sys.stderr)
print(self.logger)
print(arg_to_set)
if self.n_atoms != np.shape(arg_to_set)[0]:
print("test")
self.logger.error(
(
"The number of atoms in the AtomicSystem object have "
"to be equal to the number of atoms in the new array "
"in order to set the property."
"The number of atoms in the AtomicSystem object have "
"to be equal to the number of atoms in the new array "
"in order to set the property."
),
exception=AtomicSystemError
)
Expand Down Expand Up @@ -129,8 +122,7 @@ def check_atoms_has_mass(func, *args, **kwargs):

if not all(atom.mass is not None for atom in self.atoms):
self.logger.error(
AtomicSystemMassError.message,
exception=AtomicSystemMassError
AtomicSystemMassError.message, exception=AtomicSystemMassError
)

return func(*args, **kwargs)
3 changes: 0 additions & 3 deletions PQAnalysis/core/cell/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@ def init_from_box_matrix(cls, box_matrix: Np3x3NumberArray) -> "Cell":
) / (y * z)
)

print(alpha, beta, gamma)
print(np.rad2deg(alpha), np.rad2deg(beta), np.rad2deg(gamma))

return cls(
x, y, z, np.rad2deg(alpha), np.rad2deg(beta), np.rad2deg(gamma)
)
Expand Down
2 changes: 0 additions & 2 deletions PQAnalysis/io/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ def infer_format_from_extension(cls, file_path: str) -> "OutputFileFormat":

file_extension = "." + file_path.split(".")[-1]

print(file_extension)

if file_extension in cls.file_extensions()[cls.XYZ.value]:
return cls.XYZ

Expand Down
26 changes: 11 additions & 15 deletions PQAnalysis/io/input_file_reader/pq/pq_input_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,28 @@ def continue_input_file(self, n: PositiveInt):
if key in self.dictionary.keys():

new_filename = self.dictionary[key][0].replace(
self.actual_n,
new_actual_n
self.actual_n, new_actual_n
)

new_raw_input_file = new_raw_input_file.replace(
self.dictionary[key][0],
new_filename
self.dictionary[key][0], new_filename
)

# replace digit strings in output files
for key in self.start_file_keys:
if key in self.dictionary.keys():

new_filename = self.dictionary[key][0].replace(
self.start_n,
new_start_n
self.start_n, new_start_n
)

new_raw_input_file = new_raw_input_file.replace(
self.dictionary[key][0],
new_filename
self.dictionary[key][0], new_filename
)

# create new input file and write new_raw_input_file to it
new_filename = self.filename.replace(
self.input_file_n,
new_input_file_n
self.input_file_n, new_input_file_n
)

with open(new_filename, "w", encoding="utf-8") as file:
Expand Down Expand Up @@ -191,8 +186,10 @@ def _parse_start_n(self) -> str:

if self.is_rpmd_start_file_defined:
# add "." to match also files without extension
if (_n := _get_digit_string_from_filename(self.rpmd_start_file +
'.')) != n:
if (
_n :=
_get_digit_string_from_filename(self.rpmd_start_file + '.')
) != n:
self.logger.error(
f"N from start_file ({n}) and rpmd_start_file ({_n}) do not match.",
exception=PQValueError
Expand Down Expand Up @@ -226,7 +223,6 @@ def _parse_actual_n(self) -> str:
)

if _n != n and n is not None:
print(_n, n, key)
self.logger.error(
"Actual n in output files is not consistent.",
exception=PQValueError
Expand Down Expand Up @@ -324,8 +320,8 @@ def _get_digit_string_from_filename(filename: str) -> str:
if (regex := re.search(r"\d+.", filename)) is None:
PQInputFileReader.logger.error(
(
f"Filename {filename} does not contain a number to be "
"continued from. It has to be of the form \"...<number>.<extension>\"."
f"Filename {filename} does not contain a number to be "
"continued from. It has to be of the form \"...<number>.<extension>\"."
),
exception=PQValueError
)
Expand Down

0 comments on commit ed46715

Please sign in to comment.