Permit entry of non-finite values into float SpinBox#1422
Permit entry of non-finite values into float SpinBox#1422j9ac9k merged 6 commits intopyqtgraph:masterfrom
Conversation
Bounds are enforced against inf and -inf inputs, but not for nan.
|
Looks like a python2 issue: Any reason not to use the |
Just a habit of preferring standard library functions when operating on single values. Sometimes the numpy alternatives are much slower when operating on single values. Also, numpy hadn't been imported in this module yet and I didn't want to make it harder to reuse this code without it. |
|
Truth be told I too have the habit for using the math module for single values, I made that suggestion not knowing there was a good py2/3 compatible function. |
| SI_PREFIX_EXPONENTS['u'] = -6 | ||
|
|
||
| FLOAT_REGEX = re.compile(r'(?P<number>[+-]?((\d+(\.\d*)?)|(\d*\.\d+))([eE][+-]?\d+)?)\s*((?P<siPrefix>[u' + SI_PREFIXES + r']?)(?P<suffix>\w.*))?$') | ||
| FLOAT_REGEX = re.compile(r'(?P<number>[+-]?((((\d+(\.\d*)?)|(\d*\.\d+))([eE][+-]?\d+)?)|((?i)(nan)|(inf))))\s*((?P<siPrefix>[u' + SI_PREFIXES + r']?)(?P<suffix>\w.*))?$') |
There was a problem hiding this comment.
Just adding a comment here, you don't need to update the PR (unless you want to) but we should really make use of re.verbose for these more complex regexes.
|
Thanks for the PR @lidstrom83 this looks good to me, merging. |
Bounds are enforced for
infand-inf, butnanignores them. Attempting to step any of these values doesn't do anything.A previously existing bug is also fixed where the text is not updated properly when out-of-bounds data is entered.