chore: fixes tests
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
|
||||
from dataclasses import dataclass, fields
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
class DiceConfig(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the Dice configuration.
|
||||
"""
|
||||
|
||||
ljname: str
|
||||
outname: str
|
||||
dens: float
|
||||
nmol: List[int]
|
||||
nstep: List[int]
|
||||
|
||||
upbuf = 360
|
||||
combrule = "*"
|
||||
isave: int = 1000
|
||||
press: float = 1.0
|
||||
temp: float = 300.0
|
||||
progname: str = "dice"
|
||||
randominit: str = "first"
|
||||
|
||||
def __post_init__(self):
|
||||
if not isinstance(self.ljname, str):
|
||||
raise ValueError("Error: 'ljname' keyword not specified in config file")
|
||||
|
||||
if not isinstance(self.outname, str):
|
||||
raise ValueError("Error: 'outname' keyword not specified in config file")
|
||||
|
||||
if not isinstance(self.dens, float):
|
||||
raise ValueError("Error: 'dens' keyword not specified in config file")
|
||||
|
||||
if not isinstance(self.nmol, list):
|
||||
raise ValueError(
|
||||
"Error: 'nmol' keyword not defined appropriately in config file"
|
||||
)
|
||||
|
||||
if not isinstance(self.nstep, list) or len(self.nstep) not in (2, 3):
|
||||
raise ValueError(
|
||||
"Error: 'nstep' keyword not defined appropriately in config file"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, params: dict):
|
||||
params = {f.name: params[f.name] for f in fields(cls) if f.name in params}
|
||||
|
||||
return cls(**params)
|
||||
@@ -1,30 +0,0 @@
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
|
||||
from dataclasses import dataclass, fields
|
||||
|
||||
|
||||
@dataclass
|
||||
class GaussianDTO(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the Gaussian configuration.
|
||||
"""
|
||||
|
||||
level: str
|
||||
qmprog: str
|
||||
|
||||
chgmult = [0, 1]
|
||||
pop: str = "chelpg"
|
||||
chg_tol: float = 0.01
|
||||
keywords: str = None
|
||||
|
||||
def __post_init__(self):
|
||||
if self.qmprog not in ("g03", "g09", "g16"):
|
||||
raise ValueError("Error: invalid qmprog value.")
|
||||
if self.level is None:
|
||||
raise ValueError("Error: 'level' keyword not specified in config file.")
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, params: dict):
|
||||
params = {f.name: params[f.name] for f in fields(cls) if f.name in params}
|
||||
|
||||
return cls(**params)
|
||||
@@ -1,46 +0,0 @@
|
||||
from diceplayer.shared.config.dice_config import DiceConfig
|
||||
from diceplayer.shared.config.gaussian_config import GaussianDTO
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
|
||||
from dataclasses import dataclass, fields
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlayerConfig(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the player configuration.
|
||||
"""
|
||||
|
||||
opt: bool
|
||||
maxcyc: int
|
||||
nprocs: int
|
||||
ncores: int
|
||||
|
||||
dice: DiceConfig
|
||||
gaussian: GaussianDTO
|
||||
|
||||
mem: int = None
|
||||
switchcyc: int = 3
|
||||
qmprog: str = "g16"
|
||||
altsteps: int = 20000
|
||||
geoms_file = "geoms.xyz"
|
||||
simulation_dir = "simfiles"
|
||||
|
||||
def __post_init__(self):
|
||||
MIN_STEP = 20000
|
||||
# altsteps value is always the nearest multiple of 1000
|
||||
self.altsteps = round(max(MIN_STEP, self.altsteps) / 1000) * 1000
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, params: dict):
|
||||
if params["dice"] is None:
|
||||
raise ValueError("Error: 'dice' keyword not specified in config file.")
|
||||
params["dice"] = DiceConfig.from_dict(params["dice"])
|
||||
|
||||
if params["gaussian"] is None:
|
||||
raise ValueError("Error: 'gaussian' keyword not specified in config file.")
|
||||
params["gaussian"] = GaussianDTO.from_dict(params["gaussian"])
|
||||
|
||||
params = {f.name: params[f.name] for f in fields(cls) if f.name in params}
|
||||
|
||||
return cls(**params)
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from diceplayer.shared.config.player_config import PlayerConfig
|
||||
from diceplayer.config.player_config import PlayerConfig
|
||||
from diceplayer.shared.environment.system import System
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from diceplayer import logger
|
||||
from diceplayer.shared.config.player_config import PlayerConfig
|
||||
from diceplayer.config.player_config import PlayerConfig
|
||||
from diceplayer.shared.environment.system import System
|
||||
from diceplayer.shared.interface import Interface
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from diceplayer import logger
|
||||
from diceplayer.shared.config.player_config import PlayerConfig
|
||||
from diceplayer.config.player_config import PlayerConfig
|
||||
from diceplayer.shared.environment.atom import Atom
|
||||
from diceplayer.shared.environment.molecule import Molecule
|
||||
from diceplayer.shared.environment.system import System
|
||||
|
||||
Reference in New Issue
Block a user