pylablib.core.gui package¶
Subpackages¶
- pylablib.core.gui.qt package
- Subpackages
- pylablib.core.gui.qt.thread package
- Submodules
- pylablib.core.gui.qt.thread.callsync module
- pylablib.core.gui.qt.thread.controller module
- pylablib.core.gui.qt.thread.mthread module
- pylablib.core.gui.qt.thread.signal_pool module
- pylablib.core.gui.qt.thread.synchronizing module
- pylablib.core.gui.qt.thread.threadprop module
- Module contents
- pylablib.core.gui.qt.widgets package
- pylablib.core.gui.qt.thread package
- Submodules
- pylablib.core.gui.qt.utils module
- pylablib.core.gui.qt.values module
- Module contents
- Subpackages
Submodules¶
pylablib.core.gui.format module¶
-
pylablib.core.gui.format.
parse_float
(s)[source]¶ Parse string as a float, with metric prefixes recognition.
Return tuple
(sign, integer, dot, fractional, exponent, prefix)
, where each entry has structure(begin, end, text)
. ReturnNone
if string is unrecognizable.
-
pylablib.core.gui.format.
pos_to_order
(s, pos)[source]¶ For a given string representation of a float and position in the string, get the decimal order for this position.
Return
None
if string is un-parsable or position is out of range (not in mantissa section of the number).
-
pylablib.core.gui.format.
order_to_pos
(s, order)[source]¶ For a given string representation of float and decimal order, get the position in the string corresponding to this order.
If order is out of range for a given representation, truncates to most/least significant digit position. Return
None
if string is un-parsable.
-
pylablib.core.gui.format.
str_to_float
(s)[source]¶ Return float value of a string, with metric prefixes recognition.
Raise
ValueError
if string is unrecognizable.
-
pylablib.core.gui.format.
is_integer
(n, tolerance=0.0)[source]¶ Check if n is less than tolerance away from the nearest integer.
-
pylablib.core.gui.format.
float_to_str_SI
(n, digits=9, trailing_zeros=False)[source]¶ Represent float using SI metric prefixes.
For orders
>=27
and<-24
use usual scientific notation with order being multiple of 3. Iftrailing_zeros==True
, then digits define precision, rather than number significant digits
-
class
pylablib.core.gui.format.
FloatFormatter
(output_format='auto', digits=9, add_trailing_zeros=True, leading_zeros=0, explicit_sign=False)[source]¶ Bases:
object
Floating point number formatter.
Callable object with takes a number as an argument and returns is string representation.
Parameters: - output_format (str) – can be
"auto"
(use standard Python conversion),"SI"
(use SI prefixes if possible), or"sci"
(scientific “E” notation). - digits (int) – if
trailing_zeros==False
, determines the number of significant digits; otherwise, determines precision (number of digits after decimal point). - add_trailing_zeros (bool) – if
True
, always show fixed number of digits after the decimal point, with zero padding if necessary. - leading_zeros (bool) – determines the minimal size of the integer part (before the decimal point) of the number; pads with zeros if necessary.
- explicit_sign (bool) – if
True
, always add explicit plus sign.
- output_format (str) – can be
-
class
pylablib.core.gui.format.
IntegerFormatter
[source]¶ Bases:
object
Simple integer number formatter.
Callable object with takes a number as an argument and returns is string representation.
For more flexibility (e.g., adding leading zeros) it is possible to use
FloatFormatter
withdigits=0
andadd_trailing_zeros=True
.
-
pylablib.core.gui.format.
as_formatter
(formatter)[source]¶ Turn an object into a formatter.
Can be a callable object (returned as is), a string (
"float"
or"int"
), or a tuple starting with"float"
which contains arguments to theFloatFormatter
.
pylablib.core.gui.limit module¶
-
exception
pylablib.core.gui.limit.
LimitError
(value, lower_limit=None, upper_limit=None)[source]¶ Bases:
ArithmeticError
Error raised when the value is out of limits and can’t be coerced.
-
class
pylablib.core.gui.limit.
NumberLimit
(lower_limit=None, upper_limit=None, action='ignore', value_type=None)[source]¶ Bases:
object
Number limiter, which checks validity of user inputs.
Callable object with takes a number as an argument and either returns its coerced version (or the number itself, if it is within limits), or raises
LimitError
if it should be ignored.Parameters: - lower_limit – lower limit (inclusive), or
None
if there is no limit. - upper_limit – upper limit (inclusive), or
None
if there is no limit. - action (str) – action taken if the number is out of limits; either
"coerce"
(return the closest valid value), or"ignore"
(raiseLimitError
). - value_type (str) – determines value type coercion; can be
None
(do nothing, only check limits),"float"
(cast to float), or"int"
(cast to integer).
- lower_limit – lower limit (inclusive), or
-
pylablib.core.gui.limit.
filter_limiter
(pred)[source]¶ Turn a predicator into a limiter.
Returns a function that raises
LimitError
if the predicate is false.
-
pylablib.core.gui.limit.
as_limiter
(limiter)[source]¶ Turn an object into a limiter.
Can be a callable object (returned as is) or a tuple which is used as a list of arguments to the
NumberLimit
object.