-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and updating version number #81
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ff345ba
Remove dependency, update version
kratman c4bacfd
A few small fixes
kratman 2e7526f
Fix string parsing issue
kratman e161555
Remove problematic delete
kratman 8b23a6c
Merge branch 'main' of github.com:FaradayInstitution/BPX into fix/v0.5.0
kratman 3a69724
Another small fix
kratman 4e8ff09
Cleanup
kratman 5ac8ef2
Experiment
kratman da25bf4
Revert experiment
kratman 052ba69
Test cleanup
kratman d20183d
Experiment
kratman d9ad3ae
Attempt to get the new values
kratman f39c9bc
Revert change
kratman ea46f78
Fix tests
kratman 21e2f36
Update test workflow
kratman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from __future__ import annotations | ||
|
||
import json | ||
from pathlib import Path | ||
|
||
from .schema import BPX | ||
|
||
|
||
|
@@ -26,13 +31,13 @@ def parse_bpx_obj(bpx: dict, v_tol: float = 0.001) -> BPX: | |
return BPX.model_validate(bpx) | ||
|
||
|
||
def parse_bpx_file(filename: str, v_tol: float = 0.001) -> BPX: | ||
def parse_bpx_file(filename: str | Path, v_tol: float = 0.001) -> BPX: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the file name more flexible |
||
""" | ||
A convenience function to parse a bpx file into a BPX model. | ||
|
||
Parameters | ||
---------- | ||
filename: str | ||
filename: str or Path | ||
a filepath to a bpx file | ||
v_tol: float | ||
absolute tolerance in [V] to validate the voltage limits, 1 mV by default | ||
|
@@ -42,18 +47,12 @@ def parse_bpx_file(filename: str, v_tol: float = 0.001) -> BPX: | |
BPX: :class:`bpx.BPX` | ||
a parsed BPX model | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
bpx = "" | ||
if filename.endswith((".yml", ".yaml")): | ||
if str(filename).endswith((".yml", ".yaml")): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the path check |
||
import yaml | ||
|
||
with Path(filename).open(encoding="utf-8") as f: | ||
bpx = yaml.safe_load(f) | ||
else: | ||
import orjson as json | ||
|
||
with Path(filename).open(encoding="utf-8") as f: | ||
bpx = json.loads(f.read()) | ||
|
||
|
@@ -77,7 +76,5 @@ def parse_bpx_str(bpx: str, v_tol: float = 0.001) -> BPX: | |
BPX: | ||
a parsed BPX model | ||
""" | ||
import orjson as json | ||
|
||
bpx = json.loads(bpx) | ||
return parse_bpx_obj(bpx, v_tol) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ dependencies = [ | |
"pydantic >= 2.6", | ||
"pyparsing", | ||
"pyyaml", | ||
"orjson", | ||
] | ||
|
||
[project.urls] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing failures due to cached files not being found. It did not seem necessary