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 with GRID_MIN/GRID_MAX in HISTOGRAM action #717
Comments
I note that using GRID_MIN=-pi Works as expected |
@gtribello could it be related to the fact that these conversions do not check the returned bool? |
@GiovanniBussi yes I think if you check the returned bool and put in an error then the problem will be fixed. |
What scares me is the output of this command:
|
In many cases it is used to convert numbers to strings (e.g. for printing) and that's fine. But when it is used for reading an input it could have this problem. |
I confirm (in
to
The result is not affected. This is actually very annoying... Thanks @valsson for pointing this out! |
In the original fix I was making convert() throw exceptions. However, we use a lot failed conversions when reading inputs. Since catching an exception is much more expensive than inspecting a returned bool, this was slowing down a lot some parts of the code In 0ed75e9 I solved the issue by allowing to throw only a few functions. Here I take a radically different approach: a new function (convertNoexcept) can be used like to old one, and returns a bool. The function convert just calls convertNoexcept and, if false, throws. In this manner there is no overhead expected at all with respect to the previous version of the code. In addition, the modifications are less intrusive. It is sufficient to replace convert with convertNoexcept in all the places where the returned bool was checked
By chance, I noticed an issue with
GRID_MIN/GRID_MAX
inHISTOGRAM
action.It is possible to give a random string as a value to
GRID_MIN/GRID_MAX
and the code still runs without an error. Instead, it seems to take 0.0 as the grid value.For example, you can see this in
regtest/analysis/rt-histo
:If you use
HISTOGRAM ...
ARG=x
GRID_MIN=0.0
GRID_MAX=blabla
GRID_BIN=ffa
BANDWIDTH=0.1
LABEL=hA1
... HISTOGRAM
Gives
#! FIELDS x hA1 dhA1_x
#! SET normalisation 1.0000
#! SET min_x 0.0
#! SET max_x blabla
#! SET nbins_x 100
#! SET periodic_x false
0.0000 1.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
0.0000 0.0000 0.0000
I guess it would be better to add a check on either the parsing of GRID_MIN/GRID_MAX that the parameters gives are proper numbers. Or maybe better in the
setBounds
function ingridtools/HistogramOnGrid.cpp
to avoid this problem happening elsewhere.The text was updated successfully, but these errors were encountered: