-
Notifications
You must be signed in to change notification settings - Fork 100
Add json file input to threshold interpolation #2114
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
base: master
Are you sure you want to change the base?
Add json file input to threshold interpolation #2114
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2114 +/- ##
==========================================
+ Coverage 98.39% 98.46% +0.07%
==========================================
Files 124 139 +15
Lines 12212 13777 +1565
==========================================
+ Hits 12016 13566 +1550
- Misses 196 211 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
brhooper
left a comment
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.
Thanks @maxwhitemet. I've added some suggestions, the mains ones being around changing the format of the json file to simplify the unnecessary "threshold: None" format.
|
Thank you for the review @brhooper. I have implemented all of the suggested changes. |
brhooper
left a comment
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.
Thanks @maxwhitemet, I've added some comments.
| self, | ||
| threshold_values: Optional[List[float]] = None, | ||
| threshold_config: Optional[Dict[str, Union[List[float], str]]] = None, | ||
| threshold_config: Optional[Union[List[float], Dict[str, str]]] = None, |
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.
| threshold_config: Optional[Union[List[float], Dict[str, str]]] = None, | |
| threshold_config: Optional[Union[List[float]], Dict[str, Union[List[float], str]]] = None, |
I can't work out why this was changed, so if I've missed something then please let me know. I think the typing only needed the addition of Union[List[float]], ... though.
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.
Original annotation
The original annotation comes from the threshold.py plugin and suggests dictionary values can be either a list of fuzzy bound floats or a "None" string.
Annotation I suggested
My annotation suggests that if a dictionary is provided, the dictionary's values can only be a "None" string. We don't use fuzzy bounds for threshold interpolation.
I have kept my original change for now. Please let me know if I have misunderstood something
| threshold_values: Optional[Union[float, List[float]]], | ||
| threshold_config: Optional[dict], | ||
| threshold_values: Optional[List[float]] = None, | ||
| threshold_config: Optional[Union[List[float], Dict[str, str]]] = None, |
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.
| threshold_config: Optional[Union[List[float], Dict[str, str]]] = None, | |
| threshold_config: Optional[Union[List[float]], Dict[str, Union[List[float], str]]] = None, |
Same suggestion as above - sorry if I've missed something.
Kat-90
left a comment
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.
Thanks Max.
Your PR description needs fleshing out a bit as you've changed more than just adding a JSON input now.
My tests fail the checksums as well so you might need to update them and repush.
I've left a comment on your test_data PR as well: #2114
|
Looking at your type hints, seems to me that the improvers json input functionality exposes its limited deserialisation capability (internal technical implementation detail) to functions that need to use it. I would expect null to be used within a json to allow built-in deserialisation to a Python None and keys that represent a string of floats or ints to be converted appropriately by improvers deserialisation capability. json containing: These input dictionaries to these functions should be considered dictionaries containing the expected types, not those representing types characterising the spec of json. I would expect the above json to be deserialised appropriately to the following python dictionary: {
1.5: [2.0, 3.0],
2.0: None
}In future, we will want to be removing the clize layer. I don't think it ideal for functions to individually handle/be exposed the deserialisation limitations of improver json loading. This unnecessarily binds the two layers together. Not a blocker for this PR of course, this wasn't due to your changes, I just noticed as your changes drew attention to this issue. Note: the above is conjecture right now, purely from reasoning your type hints, not by looking at improver json input loading capability or testing it. |
…ak anything in pre-written tests
* Changed plugin's functionality when new thresholds have different units such that the output cube's thresholds are converted back to the units of the input cube.
…imension from also modifying the cube's overall units. * Implemeneted new variables in the cli call and created appropriate tests
- More clearly documented ability to supply only a single numeric value for threhsold_values - Added a unit test for when only a single numeric value is provided for threshold_values - Fixed typos
7587361 to
6b6d2bf
Compare
Kat-90
left a comment
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.
When reviewing the suite ticket I noticed there is no redundancy for passing a config file into threshold_values, or a value list into threshold_config. This should probably be handled here or we should change the inputs to just accept "thresholds" for which the format is then handled within the plugin itself and the user doesn't need to choose which they think they should use.
|
In order to maintain a backlog of relevant PRs, we automatically label them as stale after 60 days of inactivity. If this PR is still important to you, then please comment on this PR and the stale label will be removed. Otherwise this PR will be automatically closed in 30 days time. |
|
In order to maintain a backlog of relevant PRs, we automatically label them as stale after 60 days of inactivity. If this PR is still important to you, then please comment on this PR and the stale label will be removed. Otherwise this PR will be automatically closed in 30 days time. |
|
In order to maintain a backlog of relevant PRs, we automatically label them as stale after 60 days of inactivity. If this PR is still important to you, then please comment on this PR and the stale label will be removed. Otherwise this PR will be automatically closed in 30 days time. |
Addresses #866
Description
Testing: