machinevision-toolbox-python 2.2.0__py3-none-any.whl → 2.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,20 @@ import numpy as np
8
8
 
9
9
  from machinevisiontoolbox.mvtb_types import Dtype
10
10
 
11
+ #: Short-name aliases for dtype strings accepted throughout the Toolbox
12
+ #: (e.g. Image(..., dtype='float'), VideoFile(..., dtype='float')).
13
+ #: NumPy's own np.dtype('float') resolves to float64, not float32 -- these
14
+ #: aliases exist specifically so 'float'/'int' mean the Toolbox's own
15
+ #: default single-precision/8-bit types, not NumPy's C-double/C-long
16
+ #: defaults. Single source of truth: resolve any dtype string through this
17
+ #: table (dtype_alias.get(dtype, dtype)) before passing it to np.dtype().
18
+ DTYPE_ALIASES: dict[str, str] = {
19
+ "int": "uint8",
20
+ "float": "float32",
21
+ "double": "float64",
22
+ "half": "float16",
23
+ }
24
+
11
25
 
12
26
  def int_image(
13
27
  image: np.ndarray, intclass: Dtype = "uint8", maxintval: int | None = None
@@ -391,7 +391,8 @@ def main():
391
391
  code = [
392
392
  f"%matplotlib{' '+args.backend if args.backend is not None else ''}",
393
393
  "import matplotlib.pyplot as plt",
394
- "_precision = %precision %.3g;",
394
+ "_prec = get_ipython().run_line_magic('precision', '%.3g'); "
395
+ "print(f'Default numeric formatting: {_prec}')",
395
396
  ]
396
397
  if args.base:
397
398
  code.append("from machinevisiontoolbox.base import *")