Adds Formatter to Project
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dacite import from_dict
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
|
||||
@@ -10,6 +11,7 @@ class DiceConfig(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the Dice configuration.
|
||||
"""
|
||||
|
||||
ljname: str
|
||||
outname: str
|
||||
dens: float
|
||||
@@ -22,24 +24,17 @@ class DiceConfig(Dataclass):
|
||||
press: float = 1.0
|
||||
temp: float = 300.0
|
||||
progname: str = "dice"
|
||||
randominit: str = 'first'
|
||||
randominit: str = "first"
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
if not isinstance(self.ljname, str):
|
||||
raise ValueError(
|
||||
"Error: 'ljname' keyword not specified in config file"
|
||||
)
|
||||
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"
|
||||
)
|
||||
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"
|
||||
)
|
||||
raise ValueError("Error: 'dens' keyword not specified in config file")
|
||||
|
||||
if not isinstance(self.nmol, list):
|
||||
raise ValueError(
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dacite import from_dict
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class GaussianDTO(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the Gaussian configuration.
|
||||
"""
|
||||
|
||||
level: str
|
||||
qmprog: str
|
||||
|
||||
chgmult = [0, 1]
|
||||
pop: str = 'chelpg'
|
||||
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."
|
||||
)
|
||||
raise ValueError("Error: invalid qmprog value.")
|
||||
if self.level is None:
|
||||
raise ValueError(
|
||||
"Error: 'level' keyword not specified in config file."
|
||||
)
|
||||
raise ValueError("Error: 'level' keyword not specified in config file.")
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, param: dict):
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from diceplayer.shared.utils.dataclass_protocol import Dataclass
|
||||
from diceplayer.shared.config.gaussian_config import GaussianDTO
|
||||
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 dacite import from_dict
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dacite import from_dict
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -11,6 +12,7 @@ class PlayerConfig(Dataclass):
|
||||
"""
|
||||
Data Transfer Object for the player configuration.
|
||||
"""
|
||||
|
||||
opt: bool
|
||||
maxcyc: int
|
||||
nprocs: int
|
||||
@@ -21,10 +23,10 @@ class PlayerConfig(Dataclass):
|
||||
|
||||
mem: int = None
|
||||
switchcyc: int = 3
|
||||
qmprog: str = 'g16'
|
||||
qmprog: str = "g16"
|
||||
altsteps: int = 20000
|
||||
geoms_file = 'geoms.xyz'
|
||||
simulation_dir = 'simfiles'
|
||||
geoms_file = "geoms.xyz"
|
||||
simulation_dir = "simfiles"
|
||||
|
||||
def __post_init__(self):
|
||||
MIN_STEP = 20000
|
||||
@@ -33,16 +35,12 @@ class PlayerConfig(Dataclass):
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, param: dict):
|
||||
if param['dice'] is None:
|
||||
raise ValueError(
|
||||
"Error: 'dice' keyword not specified in config file."
|
||||
)
|
||||
param['dice'] = DiceConfig.from_dict(param['dice'])
|
||||
if param["dice"] is None:
|
||||
raise ValueError("Error: 'dice' keyword not specified in config file.")
|
||||
param["dice"] = DiceConfig.from_dict(param["dice"])
|
||||
|
||||
if param['gaussian'] is None:
|
||||
raise ValueError(
|
||||
"Error: 'gaussian' keyword not specified in config file."
|
||||
)
|
||||
param['gaussian'] = GaussianDTO.from_dict(param['gaussian'])
|
||||
if param["gaussian"] is None:
|
||||
raise ValueError("Error: 'gaussian' keyword not specified in config file.")
|
||||
param["gaussian"] = GaussianDTO.from_dict(param["gaussian"])
|
||||
|
||||
return from_dict(PlayerConfig, param)
|
||||
|
||||
Reference in New Issue
Block a user