Skip to content
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

Issue 282 use pint to check and convert units #283

Merged
merged 15 commits into from Dec 27, 2021

Conversation

Flix6x
Copy link
Contributor

@Flix6x Flix6x commented Dec 22, 2021

This PR mostly contains behind the screens work as a base for future user functionality (i.e. auto-converting data to desired units when POSTing and GETting data). I did already hook up unit conversion to our dev endpoint for posting sensor data.

I also left a todo to possibly move a list of preferred units to a config setting, but we can also leave that in the code for now. @nhoening what would you prefer?

…urrencies, and simplifying units according to preference; also add tests

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x self-assigned this Dec 22, 2021
@Flix6x Flix6x linked an issue Dec 22, 2021 that may be closed by this pull request
3 tasks
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x marked this pull request as ready for review December 23, 2021 10:22
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x requested a review from nhoening December 23, 2021 10:31
Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool!

flexmeasures/api/dev/tests/utils.py Outdated Show resolved Hide resolved
flexmeasures/utils/unit_utils.py Outdated Show resolved Hide resolved
flexmeasures/utils/unit_utils.py Outdated Show resolved Hide resolved
@nhoening
Copy link
Contributor

I'd leave preferred units in the code for now, as I don't see how users need to care. Both determine_stock_unit and determine_flow_unit (only places this gets touched) don't seem to be used yet in code?

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x
Copy link
Contributor Author

Flix6x commented Dec 27, 2021

Both determine_stock_unit and determine_flow_unit [...] don't seem to be used yet in code?

Correct, not in FlexMeasures, but I had moved it here from one of our plugins. With the introduction of pint, I intend to factor these functions out of that plugin first, and then remove them here.

@Flix6x Flix6x merged commit dc9ecfa into project-9 Dec 27, 2021
@Flix6x Flix6x deleted the Issue-282_Use_pint_to_check_and_convert_units branch December 27, 2021 12:52
@Flix6x Flix6x added this to the 0.8.0 milestone Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use pint to check and convert units
2 participants