ibpsa / project1-boptest

Building Optimization Performance Tests
Other
102 stars 66 forks source link

Flask truncation of overwrite floats #577

Closed dhblum closed 9 months ago

dhblum commented 10 months ago

When writing overwrite values in /advance, the flask api in restapi.py seems to truncate floats, as they are converted to unicode by default. For example, for a particular timestep when running examples/python/testcase1_scenario.py: Python controller sent: {'oveAct_u': 63.82314159145608, 'oveAct_activate': 1} Flask api sent to testcase.py: {'oveAct_u': u'63.8231415915', 'oveAct_activate': u'1'}

On the surface this is not too much of an issue, but the rest api of boptest-service does not perform this truncation, and testing has revealed this makes a small numeric difference for the example feedback controllers for testcase1 and testcase3, causing unit tests to fail upon syncing boptest-service with the latest master branch.

This issue proposes to fix the Flask api by specifying that the overwrite value arguments in /advance be strictly defined as floats (using type=float option when defining the arguments of the api request here), which then removes any truncation from the api and delivers to testcase.py exactly what is expected.

dhblum commented 10 months ago

Being addressed in #536.

dhblum commented 9 months ago

Closed by https://github.com/ibpsa/project1-boptest/pull/536.