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
self.prior_range= [aifnot((a==-1) or (a==None)) elseNone
foraindeepcopy(array[1:3])]
However, this means that, contrary to statements in the parameter files, -1.0 can no longer be used as a prior bound! The reason it worked before was that, in CPython, the integers -5 to 256 are pre-allocated, so every integer in this range are in fact the exact same object. MontePython was relying on this to ensure that only -1 was set to None, and not -1.0.
A few comments are in order:
The idea that -1 can be used to signal "no bound" is crazy, and should never have been implemented. None (which also works) is appropriate.
The fact that all -1's are the same object is not guaranteed by the Python specification, so it should not be relied upon.
While the original implementation would still work, it will emit a syntax warning since Python 3.8, so it is not a viable solution. My preferred solution would be to remove the "feature" that -1 may signal unbounded parameters. However, the following change should reestablish the intended behaviour:
self.prior_range= [aifnot((a==-1andtype(a) ==int) or (a==None)) elseNoneforaindeepcopy(array[1:3])]
Let me know if you want a PR for this!
Cheers,
Thomas
The text was updated successfully, but these errors were encountered:
Thank you for noticing and reporting this. I've never liked that option either, it doesn't make sense. We should stop promoting it. But for the sake of people who just keep doing what they've been doing something like your fix could be a good idea, or maybe returning a warning or error if we see they have passed -1. I'm also worried about cases where people actually want a prior bound at -1 and might not think to make it a float, so returning a statement like "Noticed prior bound of -1 in param file. If no prior bound is intended please pass None, if an actual prior bound of -1.0 is intended please pass a float." What do you think? Or we can ignore the problem and go with your suggestion, which seems workable.
Hi there
The commit c692dee substituted the identity comparison operator
is
for the equality comparison operator==
:montepython_public/montepython/prior.py
Lines 56 to 57 in 4f010ad
However, this means that, contrary to statements in the parameter files, -1.0 can no longer be used as a prior bound! The reason it worked before was that, in CPython, the integers -5 to 256 are pre-allocated, so every integer in this range are in fact the exact same object. MontePython was relying on this to ensure that only -1 was set to None, and not -1.0.
A few comments are in order:
While the original implementation would still work, it will emit a syntax warning since Python 3.8, so it is not a viable solution. My preferred solution would be to remove the "feature" that -1 may signal unbounded parameters. However, the following change should reestablish the intended behaviour:
Let me know if you want a PR for this!
Cheers,
Thomas
The text was updated successfully, but these errors were encountered: