Skip to content

Commit

Permalink
Merge pull request #77 from MolarVerse/hotfix/1.0.7
Browse files Browse the repository at this point in the history
Hotfix/1.0.7
  • Loading branch information
galjos authored May 31, 2024
2 parents 2288a03 + a2e2259 commit dd98ab3
Show file tree
Hide file tree
Showing 7 changed files with 794 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ jobs:
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
echo "previousTag: $name"
echo "previousTag=$name" >> $GITHUB_ENV
echo "::set-output name=previousTag::$name"
- name: Update CHANGELOG
id: changelog
Expand All @@ -97,7 +96,7 @@ jobs:
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes '${{ steps.changelog.outputs.changes }}''
--notes '${{ steps.changelog.outputs.changes }}'
pypi-release-update:
name: >-
Expand Down
5 changes: 4 additions & 1 deletion PQAnalysis/atomic_system/atomic_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def __init__(
self._stress = stress
self._cell = cell

@runtime_type_checking
#TODO: check why dynamic formatting does
# not work here for "AtomicSystem"
#
# @runtime_type_checking
def fit_atomic_system(
self,
system: "AtomicSystem",
Expand Down
35 changes: 16 additions & 19 deletions PQAnalysis/io/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from PQAnalysis import __package_name__

from .exceptions import (
BoxFileFormatError,
FileWritingModeError,
OutputFileFormatError
BoxFileFormatError, FileWritingModeError, OutputFileFormatError
)

logger = logging.getLogger(__package_name__).getChild("OutputFileFormat")
Expand Down Expand Up @@ -87,8 +85,8 @@ def _missing_(cls, values: Any) -> Any: # pylint: disable=arguments-differ
if output_file_format == cls.AUTO and filename is None:
logger.error(
(
"The file format could not be inferred from "
"the file extension because no filename was given."
"The file format could not be inferred from "
"the file extension because no filename was given."
),
exception=OutputFileFormatError
)
Expand Down Expand Up @@ -119,9 +117,7 @@ def file_extensions(cls):
file_extensions[cls.VIRIAL.value] = [".virial", ".virials", ".vir"]
file_extensions[cls.INFO.value] = [".info", ".information"]
file_extensions[cls.INSTANTANEOUS_ENERGY.value] = [
".instant_en",
".instant_energies",
".inst_energy"
".instant_en", ".instant_energies", ".inst_energy"
]

return file_extensions
Expand All @@ -142,36 +138,37 @@ def infer_format_from_extension(cls, file_path: str) -> "OutputFileFormat":
The inferred file format.
"""

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

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

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

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

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

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

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

logger.error(
(
"Could not infer the file format from the file extension of "
f"\"{file_path}\". Possible file formats are: "
f"{cls.__members__.values()}"
"Could not infer the file format from the file extension of "
f"\"{file_path}\". Possible file formats are: "
f"{cls.__members__.values()}"
),
exception=OutputFileFormatError
)

@classmethod
def get_file_extensions(
cls,
file_format: "OutputFileFormat | str"
cls, file_format: "OutputFileFormat | str"
) -> List[str]:
"""
Get the file extensions of the given file format.
Expand Down
38 changes: 19 additions & 19 deletions PQAnalysis/tools/add_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def add_molecule(
"""

_check_topology_args(
topology_file,
topology_file_to_add,
topology_file_output
topology_file, topology_file_to_add, topology_file_output
)

_add_molecule = AddMolecule(
Expand Down Expand Up @@ -179,8 +177,8 @@ def _check_topology_args(
if topology_file_output is not None:
AddMolecule.logger.warning(
(
"The output topology file is specified, but no topology "
"files are given to add. The output topology file will be ignored."
"The output topology file is specified, but no topology "
"files are given to add. The output topology file will be ignored."
)
)

Expand All @@ -201,9 +199,9 @@ def _check_topology_args(
if topology_file_output is None:
AddMolecule.logger.error(
(
"The output topology file must be specified if topology files are "
"given to add. This is a special case where None cannot be treated "
"as stdout as it is already used for the restart file."
"The output topology file must be specified if topology files are "
"given to add. This is a special case where None cannot be treated "
"as stdout as it is already used for the restart file."
),
exception=PQValueError
)
Expand Down Expand Up @@ -309,19 +307,21 @@ def __init__(
self.restart_system = None

self.molecule_file_type = OutputFileFormat(
(molecule_file_type,
self.molecule_file)
(molecule_file_type, self.molecule_file)
)

if (self.molecule_file_type != OutputFileFormat.RESTART and
self.molecule_moldescriptor_file is not None):
if (
self.molecule_file_type != OutputFileFormat.RESTART and
self.molecule_moldescriptor_file is not None
):
self.logger.error(
"A moldescriptor file can only be specified for restart files.",
exception=PQValueError
)

if self.molecule_file_type not in [OutputFileFormat.RESTART,
OutputFileFormat.XYZ]:
if self.molecule_file_type not in [
OutputFileFormat.RESTART, OutputFileFormat.XYZ
]:
self.logger.error(
"The molecule file type must be either RESTART or XYZ.",
exception=PQValueError
Expand Down Expand Up @@ -375,8 +375,8 @@ def extend_topology_file(

self.logger.warning(
(
"Extension of the topology file is only implemented for shake bonds. "
"The extension of general bonded topologies is not implemented yet."
"Extension of the topology file is only implemented for shake bonds. "
"The extension of general bonded topologies is not implemented yet."
)
)

Expand All @@ -386,9 +386,9 @@ def extend_topology_file(
if self.restart_system is None or self.molecule is None:
self.logger.error(
(
"The restart frame and the molecule must be read "
"before extending the topology file. Either call "
"the read_files method or the add_molecules method first."
"The restart frame and the molecule must be read "
"before extending the topology file. Either call "
"the read_files method or the add_molecules method first."
),
exception=PQValueError
)
Expand Down
Loading

0 comments on commit dd98ab3

Please sign in to comment.