Skip to content

Commit

Permalink
Get rid of yaml.
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Aug 29, 2024
1 parent 2242312 commit 2ba6441
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
9 changes: 2 additions & 7 deletions ppafm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np
import pydantic
import toml
import yaml

from . import cpp_utils

Expand Down Expand Up @@ -89,8 +88,6 @@ def from_file(cls, file_path: typing.Union[str, Path] = Path("params.ini")):
if suffix == ".ini":
lines = file.readlines()
object.load_ini(lines)
elif suffix == ".yaml":
object.apply_options(yaml.safe_load(file))
elif suffix == ".toml":
object.apply_options(toml.load(file))
else:
Expand All @@ -105,15 +102,13 @@ def apply_options(self, obj):
if hasattr(self, key) and value is not None:
setattr(self, key, value)

def dump_parameters(self, file_path: typing.Union[str, Path] = Path("params.ini")):
def dump_parameters(self, file_path: typing.Union[str, Path] = Path("params.toml")):
"""Save parameters to a file."""
file_path = Path(file_path)
suffix = file_path.suffix
try:
with open(file_path, "w") as file:
if suffix == ".yaml":
yaml.dump(self.model_dump(), file, default_flow_style=False, indent=4)
elif suffix == ".toml":
if suffix == ".toml":
toml.dump(self.model_dump(), file)
else:
raise ValueError(f"Unsupported file extension: {suffix}")
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies = [
"matplotlib",
"numpy",
"pydantic",
"pyyaml",
"toml",
]

Expand Down

0 comments on commit 2ba6441

Please sign in to comment.