Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 25, 2024
1 parent 4aa6978 commit 4ce1bda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
8 changes: 5 additions & 3 deletions spectrafit/plugins/pkl_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ def save(self, data: Any, fname: Path, export_format: str) -> None:
format=export_format,
)

with pure_fname(fname).with_suffix(".json").open(
"w+", encoding="utf-8"
) as outfile:
with (
pure_fname(fname)
.with_suffix(".json")
.open("w+", encoding="utf-8") as outfile
):
json.dump(data, outfile, indent=4)

def get_type(self, value: Any) -> Union[Dict[str, Any], str]:
Expand Down
22 changes: 15 additions & 7 deletions spectrafit/plugins/rixs_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,23 @@ def save(self, data: Any, fname: Path, export_format: str) -> None:
)

if export_format == "json":
with pure_fname(fname).with_suffix(f".{export_format}").open(
"w",
encoding="utf-8",
) as f:
with (
pure_fname(fname)
.with_suffix(f".{export_format}")
.open(
"w",
encoding="utf-8",
) as f
):
json.dump(self.numpydict2listdict(data), f, indent=4)
elif export_format in {"toml", "lock"}:
with pure_fname(fname).with_suffix(f".{export_format}").open(
"wb",
) as f:
with (
pure_fname(fname)
.with_suffix(f".{export_format}")
.open(
"wb",
) as f
):
tomli_w.dump(self.numpydict2listdict(data), f, multiline_strings=False)
elif export_format == "npy":
np.save(pure_fname(fname).with_suffix(f".{export_format}"), data)
Expand Down

0 comments on commit 4ce1bda

Please sign in to comment.