You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems very reasonable to iterate over parameter arrays such as
num_threads=np.array([2, 4]) # num_threads[n] is of type numpy.int64forninrange(2):
result[n] =svmbir.recon( ..., num_threads=num_threads[n])
However this results in the somewhat useless warning: UserWarning: Parameter num_threads is not a valid int. Setting to default.
The warning comes from _utils.py:
ifnot (isinstance(num_threads, int) and (num_threads>0)):
warnings.warn(f"Parameter num_threads is not a valid int. Setting to default.")
num_threads=None
Problems with this:
First I thought that UserWarning: Parameter num_threads is not a valid int. Setting to default.
will take my 2 (numpy.int64) and convert it to 2 (int). But instead it will completely disregard the 2 and set it to the number of cores!!!
In my opinion the hard setting to the defaults whenever an input is not precisely what is expected seems very strict and can lead to unexpected behavior.
Whenever a variable get checked it is advised to display the variable and type. Something like warnings.warn(f"Parameter num_threads ({num_threads}, {type(num_threads)}) is not a valid int. Setting to default.")
would give UserWarning: Parameter num_threads (2, <class 'numpy.int64'>) is not a valid int. Setting to default. Now it is so much easier to understand what is wrong.
when num_threads=None this warning is still displayed and then num_threads is again set to None.
In my opinion numpy.int64 should be a perfectly reasonable input. Why not do isinstance(num_threads, (int, np.int64, np.int32))? There may also be more elegant ways of doing this.
The logic in the if clause is not obvious. Can there be more parentheses?
In _utils.py there are more instances like this for other parameters that should be improved.
The text was updated successfully, but these errors were encountered:
Instead of issuing warnings when parameters such as stop_threshold are passed a None value, I would suggest just silently setting those parameters to their default values.
It seems very reasonable to iterate over parameter arrays such as
However this results in the somewhat useless warning:
UserWarning: Parameter num_threads is not a valid int. Setting to default.
The warning comes from
_utils.py
:Problems with this:
UserWarning: Parameter num_threads is not a valid int. Setting to default.
will take my
2 (numpy.int64)
and convert it to2 (int)
. But instead it will completely disregard the2
and set it to the number of cores!!!In my opinion the hard setting to the defaults whenever an input is not precisely what is expected seems very strict and can lead to unexpected behavior.
Whenever a variable get checked it is advised to display the variable and type. Something like
warnings.warn(f"Parameter num_threads ({num_threads}, {type(num_threads)}) is not a valid int. Setting to default.")
would give
UserWarning: Parameter num_threads (2, <class 'numpy.int64'>) is not a valid int. Setting to default.
Now it is so much easier to understand what is wrong.when
num_threads=None
this warning is still displayed and thennum_threads
is again set toNone
.In my opinion
numpy.int64
should be a perfectly reasonable input. Why not doisinstance(num_threads, (int, np.int64, np.int32))
? There may also be more elegant ways of doing this.The logic in the if clause is not obvious. Can there be more parentheses?
In
_utils.py
there are more instances like this for other parameters that should be improved.The text was updated successfully, but these errors were encountered: