stouputils 1.7.3__tar.gz → 1.8.0__tar.gz

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.
Files changed (139) hide show
  1. {stouputils-1.7.3 → stouputils-1.8.0}/PKG-INFO +1 -1
  2. {stouputils-1.7.3 → stouputils-1.8.0}/pyproject.toml +1 -1
  3. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/__init__.py +1 -2
  4. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/__init__.pyi +1 -0
  5. stouputils-1.8.0/stouputils/_deprecated.py +37 -0
  6. stouputils-1.8.0/stouputils/_deprecated.pyi +12 -0
  7. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/automatic_docs.py +2 -2
  8. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/automatic_docs.pyi +1 -1
  9. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/cd_utils.py +2 -2
  10. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/cd_utils.pyi +1 -1
  11. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/decorators.py +4 -0
  12. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/decorators.pyi +2 -1
  13. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/image.py +7 -4
  14. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/image.pyi +2 -2
  15. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/io.py +18 -18
  16. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/io.pyi +14 -14
  17. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/print.py +34 -10
  18. {stouputils-1.7.3 → stouputils-1.8.0}/.gitignore +0 -0
  19. {stouputils-1.7.3 → stouputils-1.8.0}/LICENSE +0 -0
  20. {stouputils-1.7.3 → stouputils-1.8.0}/README.md +0 -0
  21. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/__main__.py +0 -0
  22. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/all_doctests.py +0 -0
  23. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/all_doctests.pyi +0 -0
  24. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/__init__.py +0 -0
  25. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/__init__.pyi +0 -0
  26. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/__init__.py +0 -0
  27. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/__init__.pyi +0 -0
  28. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/config.py +0 -0
  29. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/config.pyi +0 -0
  30. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/image.py +0 -0
  31. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/image.pyi +0 -0
  32. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/video.py +0 -0
  33. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/applications/upscaler/video.pyi +0 -0
  34. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/archive.py +0 -0
  35. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/archive.pyi +0 -0
  36. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/backup.py +0 -0
  37. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/backup.pyi +0 -0
  38. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/collections.py +0 -0
  39. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/collections.pyi +0 -0
  40. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/__init__.py +0 -0
  41. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/__init__.pyi +0 -0
  42. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/github.py +0 -0
  43. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/github.pyi +0 -0
  44. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/pypi.py +0 -0
  45. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/pypi.pyi +0 -0
  46. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/pyproject.py +0 -0
  47. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/pyproject.pyi +0 -0
  48. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/stubs.py +0 -0
  49. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/continuous_delivery/stubs.pyi +0 -0
  50. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/ctx.py +0 -0
  51. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/ctx.pyi +0 -0
  52. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/config/get.py +0 -0
  53. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/config/set.py +0 -0
  54. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/__init__.py +0 -0
  55. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
  56. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
  57. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
  58. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
  59. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/blur.py +0 -0
  60. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/brightness.py +0 -0
  61. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/canny.py +0 -0
  62. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/clahe.py +0 -0
  63. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/common.py +0 -0
  64. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/contrast.py +0 -0
  65. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
  66. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/denoise.py +0 -0
  67. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
  68. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/invert.py +0 -0
  69. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
  70. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
  71. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/noise.py +0 -0
  72. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/normalize.py +0 -0
  73. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
  74. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/resize.py +0 -0
  75. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/rotation.py +0 -0
  76. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
  77. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
  78. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/shearing.py +0 -0
  79. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/threshold.py +0 -0
  80. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/translation.py +0 -0
  81. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image/zoom.py +0 -0
  82. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
  83. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
  84. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
  85. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/data_processing/technique.py +0 -0
  86. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/__init__.py +0 -0
  87. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/dataset.py +0 -0
  88. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/dataset_loader.py +0 -0
  89. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
  90. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/image_loader.py +0 -0
  91. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/dataset/xy_tuple.py +0 -0
  92. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/metric_dictionnary.py +0 -0
  93. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/metric_utils.py +0 -0
  94. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/mlflow_utils.py +0 -0
  95. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/abstract_model.py +0 -0
  96. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/all.py +0 -0
  97. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/base_keras.py +0 -0
  98. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/all.py +0 -0
  99. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/convnext.py +0 -0
  100. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/densenet.py +0 -0
  101. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/efficientnet.py +0 -0
  102. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/mobilenet.py +0 -0
  103. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/resnet.py +0 -0
  104. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/squeezenet.py +0 -0
  105. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/vgg.py +0 -0
  106. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras/xception.py +0 -0
  107. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
  108. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
  109. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
  110. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
  111. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
  112. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
  113. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
  114. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
  115. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
  116. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/model_interface.py +0 -0
  117. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/models/sandbox.py +0 -0
  118. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/range_tuple.py +0 -0
  119. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/scripts/augment_dataset.py +0 -0
  120. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
  121. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
  122. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/scripts/routine.py +0 -0
  123. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/data_science/utils.py +0 -0
  124. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/__init__.py +0 -0
  125. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/__init__.pyi +0 -0
  126. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/common.py +0 -0
  127. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/common.pyi +0 -0
  128. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/downloader.py +0 -0
  129. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/downloader.pyi +0 -0
  130. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/linux.py +0 -0
  131. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/linux.pyi +0 -0
  132. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/main.py +0 -0
  133. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/main.pyi +0 -0
  134. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/windows.py +0 -0
  135. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/installer/windows.pyi +0 -0
  136. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/parallel.py +0 -0
  137. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/parallel.pyi +0 -0
  138. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/print.pyi +0 -0
  139. {stouputils-1.7.3 → stouputils-1.8.0}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.7.3
3
+ Version: 1.8.0
4
4
  Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
5
5
  Project-URL: Homepage, https://github.com/Stoupy51/stouputils
6
6
  Project-URL: Issues, https://github.com/Stoupy51/stouputils/issues
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "stouputils"
8
- version = "1.7.3"
8
+ version = "1.8.0"
9
9
  description = "Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more."
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"
@@ -20,12 +20,11 @@ Key Features:
20
20
  from importlib.metadata import PackageNotFoundError, version
21
21
 
22
22
  # Imports
23
+ from ._deprecated import *
23
24
  from .all_doctests import *
24
25
  from .archive import *
25
26
  from .backup import *
26
27
  from .collections import *
27
-
28
- # Folders
29
28
  from .continuous_delivery import *
30
29
  from .ctx import *
31
30
  from .decorators import *
@@ -1,3 +1,4 @@
1
+ from ._deprecated import *
1
2
  from .all_doctests import *
2
3
  from .archive import *
3
4
  from .backup import *
@@ -0,0 +1,37 @@
1
+ """ Deprecated functions and classes.
2
+
3
+ This module contains deprecated functions that have been replaced by new implementations
4
+ These functions are retained for backward compatibility and will log deprecation warnings when used.
5
+ """
6
+
7
+ # Imports
8
+ from typing import Any
9
+
10
+ from .decorators import LogLevels, deprecated
11
+ from .io import csv_dump, csv_load, json_dump, json_load
12
+
13
+
14
+ # Deprecated functions
15
+ @deprecated(message="super_csv_dump has been renamed to csv_dump.", version="v1.8.0", error_log=LogLevels.WARNING)
16
+ def super_csv_dump(*args: Any, **kwargs: Any) -> Any:
17
+ """ Deprecated function, use "csv_dump" instead. """
18
+ return csv_dump(*args, **kwargs)
19
+
20
+
21
+ @deprecated(message="super_csv_load has been renamed to csv_load.", version="v1.8.0", error_log=LogLevels.WARNING)
22
+ def super_csv_load(*args: Any, **kwargs: Any) -> Any:
23
+ """ Deprecated function, use "csv_load" instead. """
24
+ return csv_load(*args, **kwargs)
25
+
26
+
27
+ @deprecated(message="super_json_dump has been renamed to json_dump.", version="v1.8.0", error_log=LogLevels.WARNING)
28
+ def super_json_dump(*args: Any, **kwargs: Any) -> Any:
29
+ """ Deprecated function, use "json_dump" instead. """
30
+ return json_dump(*args, **kwargs)
31
+
32
+
33
+ @deprecated(message="super_json_load has been renamed to json_load.", version="v1.8.0", error_log=LogLevels.WARNING)
34
+ def super_json_load(*args: Any, **kwargs: Any) -> Any:
35
+ """ Deprecated function, use "json_load" instead. """
36
+ return json_load(*args, **kwargs)
37
+
@@ -0,0 +1,12 @@
1
+ from .decorators import LogLevels as LogLevels, deprecated as deprecated
2
+ from .io import csv_dump as csv_dump, csv_load as csv_load, json_dump as json_dump, json_load as json_load
3
+ from typing import Any
4
+
5
+ def super_csv_dump(*args: Any, **kwargs: Any) -> Any:
6
+ ''' Deprecated function, use "csv_dump" instead. '''
7
+ def super_csv_load(*args: Any, **kwargs: Any) -> Any:
8
+ ''' Deprecated function, use "csv_load" instead. '''
9
+ def super_json_dump(*args: Any, **kwargs: Any) -> Any:
10
+ ''' Deprecated function, use "json_dump" instead. '''
11
+ def super_json_load(*args: Any, **kwargs: Any) -> Any:
12
+ ''' Deprecated function, use "json_load" instead. '''
@@ -75,7 +75,7 @@ from typing import Any
75
75
 
76
76
  from ..continuous_delivery import version_to_float
77
77
  from ..decorators import LogLevels, handle_error, simple_cache
78
- from ..io import clean_path, super_json_dump, super_open
78
+ from ..io import clean_path, json_dump, super_open
79
79
  from ..print import info
80
80
 
81
81
  # Constants
@@ -214,7 +214,7 @@ html_theme_options: dict[str, Any] = {{
214
214
  "versions": version_list,
215
215
  "current_version": current_version,
216
216
  })
217
- html_context_str: str = super_json_dump(html_context, max_level=1).replace("true", "True").replace("false", "False")
217
+ html_context_str: str = json_dump(html_context, max_level=1).replace("true", "True").replace("false", "False")
218
218
 
219
219
  conf_content += f"""
220
220
  html_context = {html_context_str}
@@ -1,6 +1,6 @@
1
1
  from ..continuous_delivery import version_to_float as version_to_float
2
2
  from ..decorators import LogLevels as LogLevels, handle_error as handle_error, simple_cache as simple_cache
3
- from ..io import clean_path as clean_path, super_json_dump as super_json_dump, super_open as super_open
3
+ from ..io import clean_path as clean_path, json_dump as json_dump, super_open as super_open
4
4
  from ..print import info as info
5
5
  from collections.abc import Callable as Callable
6
6
 
@@ -7,7 +7,7 @@ import os
7
7
  from typing import TYPE_CHECKING, Any
8
8
 
9
9
  from ..decorators import handle_error
10
- from ..io import clean_path, super_json_load
10
+ from ..io import clean_path, json_load
11
11
  from ..print import warning
12
12
 
13
13
  if TYPE_CHECKING:
@@ -59,7 +59,7 @@ def load_credentials(credentials_path: str) -> dict[str, Any]:
59
59
 
60
60
  # Load the file if it's a JSON file
61
61
  if credentials_path.endswith(".json"):
62
- return super_json_load(credentials_path)
62
+ return json_load(credentials_path)
63
63
 
64
64
  # Else, load the file if it's a YAML file
65
65
  elif credentials_path.endswith((".yml", ".yaml")):
@@ -1,6 +1,6 @@
1
1
  import requests
2
2
  from ..decorators import handle_error as handle_error
3
- from ..io import clean_path as clean_path, super_json_load as super_json_load
3
+ from ..io import clean_path as clean_path, json_load as json_load
4
4
  from ..print import warning as warning
5
5
  from typing import Any
6
6
 
@@ -358,6 +358,7 @@ def deprecated(
358
358
  func: Callable[..., Any] | None = None,
359
359
  *,
360
360
  message: str = "",
361
+ version: str = "",
361
362
  error_log: LogLevels = LogLevels.WARNING
362
363
  ) -> Callable[..., Any]:
363
364
  """ Decorator that marks a function as deprecated.
@@ -365,6 +366,7 @@ def deprecated(
365
366
  Args:
366
367
  func (Callable[..., Any] | None): Function to mark as deprecated
367
368
  message (str): Additional message to display with the deprecation warning
369
+ version (str): Version since when the function is deprecated (e.g. "v1.2.0")
368
370
  error_log (LogLevels): Log level for the deprecation warning
369
371
  LogLevels.NONE: None
370
372
  LogLevels.WARNING: Show as warning
@@ -388,6 +390,8 @@ def deprecated(
388
390
  def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> Any:
389
391
  # Build deprecation message
390
392
  msg: str = f"Function '{_get_func_name(func)}()' is deprecated"
393
+ if version:
394
+ msg += f" since {version}"
391
395
  if message:
392
396
  msg += f". {message}"
393
397
 
@@ -147,12 +147,13 @@ def abstract(func: Callable[..., Any] | None = None, *, error_log: LogLevels = .
147
147
  \t\t\t...
148
148
  \t\tNotImplementedError: Function 'method' is abstract and must be implemented by a subclass
149
149
  \t"""
150
- def deprecated(func: Callable[..., Any] | None = None, *, message: str = '', error_log: LogLevels = ...) -> Callable[..., Any]:
150
+ def deprecated(func: Callable[..., Any] | None = None, *, message: str = '', version: str = '', error_log: LogLevels = ...) -> Callable[..., Any]:
151
151
  ''' Decorator that marks a function as deprecated.
152
152
 
153
153
  \tArgs:
154
154
  \t\tfunc (Callable[..., Any] | None): Function to mark as deprecated
155
155
  \t\tmessage (str): Additional message to display with the deprecation warning
156
+ \t\tversion (str): Version since when the function is deprecated (e.g. "v1.2.0")
156
157
  \t\terror_log (LogLevels): Log level for the deprecation warning
157
158
  \t\t\tLogLevels.NONE: None
158
159
  \t\t\tLogLevels.WARNING: Show as warning
@@ -262,7 +262,7 @@ def auto_crop(
262
262
 
263
263
  def numpy_to_gif(
264
264
  path: str,
265
- array: "NDArray[np.number]",
265
+ array: "NDArray[np.integer | np.floating | np.bool_]",
266
266
  duration: int = 100,
267
267
  loop: int = 0,
268
268
  mkdir: bool = True,
@@ -300,9 +300,10 @@ def numpy_to_gif(
300
300
  os.makedirs(os.path.dirname(path), exist_ok=True)
301
301
 
302
302
  # Normalize array if outside [0-255] range to [0-1]
303
+ array = array.astype(np.float32)
303
304
  mini, maxi = np.min(array), np.max(array)
304
305
  if mini < 0 or maxi > 255:
305
- array = ((array.astype(np.float32) - mini) / (maxi - mini + 1e-8))
306
+ array = ((array - mini) / (maxi - mini + 1e-8))
306
307
 
307
308
  # Scale to [0-255] if in [0-1] range
308
309
  mini, maxi = np.min(array), np.max(array)
@@ -328,7 +329,7 @@ def numpy_to_gif(
328
329
 
329
330
  def numpy_to_obj(
330
331
  path: str,
331
- array: "NDArray[np.number]",
332
+ array: "NDArray[np.integer | np.floating | np.bool_]",
332
333
  threshold: float = 0.5,
333
334
  step_size: int = 1,
334
335
  pad_array: bool = True,
@@ -356,6 +357,7 @@ def numpy_to_obj(
356
357
  """
357
358
  # Imports
358
359
  import numpy as np
360
+ from numpy.typing import NDArray
359
361
  from skimage import measure
360
362
 
361
363
  # Assertions
@@ -374,9 +376,10 @@ def numpy_to_obj(
374
376
  threshold = 0.5
375
377
  elif np.issubdtype(array.dtype, np.integer):
376
378
  # For integer arrays, normalize to 0-1 range
379
+ array = array.astype(np.float32)
377
380
  min_val, max_val = np.min(array), np.max(array)
378
381
  if min_val != max_val:
379
- volume = (array.astype(np.float32) - min_val) / (max_val - min_val)
382
+ volume = (array - min_val) / (max_val - min_val)
380
383
 
381
384
  # Pad array with zeros to ensure closed volumes for border cells
382
385
  if pad_array:
@@ -119,7 +119,7 @@ def auto_crop(image: Image.Image | NDArray[np.number], mask: NDArray[np.bool_] |
119
119
  \t>>> cropped_3d.shape # Should crop all 3 dimensions
120
120
  \t(30, 30, 6)
121
121
  \t'''
122
- def numpy_to_gif(path: str, array: NDArray[np.number], duration: int = 100, loop: int = 0, mkdir: bool = True, **kwargs: Any) -> None:
122
+ def numpy_to_gif(path: str, array: NDArray[np.integer | np.floating | np.bool_], duration: int = 100, loop: int = 0, mkdir: bool = True, **kwargs: Any) -> None:
123
123
  ''' Generate a \'.gif\' file from a numpy array for 3D visualization.
124
124
 
125
125
  \tArgs:
@@ -140,7 +140,7 @@ def numpy_to_gif(path: str, array: NDArray[np.number], duration: int = 100, loop
140
140
  \t\t\t> total_duration = 1000 # 1 second
141
141
  \t\t\t> numpy_to_gif("output_1s.gif", array, duration=total_duration // len(array))
142
142
  \t'''
143
- def numpy_to_obj(path: str, array: NDArray[np.number], threshold: float = 0.5, step_size: int = 1, pad_array: bool = True, verbose: int = 0) -> None:
143
+ def numpy_to_obj(path: str, array: NDArray[np.integer | np.floating | np.bool_], threshold: float = 0.5, step_size: int = 1, pad_array: bool = True, verbose: int = 0) -> None:
144
144
  ''' Generate a \'.obj\' file from a numpy array for 3D visualization using marching cubes.
145
145
 
146
146
  \tArgs:
@@ -3,10 +3,10 @@ This module provides utilities for file management.
3
3
 
4
4
  - get_root_path: Get the absolute path of the directory
5
5
  - relative_path: Get the relative path of a file relative to a given directory
6
- - super_json_dump: Writes the provided data to a JSON file with a specified indentation depth.
7
- - super_json_load: Load a JSON file from the given path
8
- - super_csv_dump: Writes data to a CSV file with customizable options
9
- - super_csv_load: Load a CSV file from the given path
6
+ - json_dump: Writes the provided data to a JSON file with a specified indentation depth.
7
+ - json_load: Load a JSON file from the given path
8
+ - csv_dump: Writes data to a CSV file with customizable options
9
+ - csv_load: Load a CSV file from the given path
10
10
  - super_copy: Copy a file (or a folder) from the source to the destination (always create the directory)
11
11
  - super_open: Open a file with the given mode, creating the directory if it doesn't exist (only if writing)
12
12
  - replace_tilde: Replace the "~" by the user's home directory
@@ -79,7 +79,7 @@ def relative_path(file_path: str, relative_to: str = "") -> str:
79
79
  return file_path or "."
80
80
 
81
81
  # JSON dump with indentation for levels
82
- def super_json_dump(
82
+ def json_dump(
83
83
  data: Any,
84
84
  file: IO[Any] | str | None = None,
85
85
  max_level: int | None = 2,
@@ -98,13 +98,13 @@ def super_json_dump(
98
98
  Returns:
99
99
  str: The content of the file in every case
100
100
 
101
- >>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 0)
101
+ >>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 0)
102
102
  '{"a": [[1,2,3]],"b": 2}\n'
103
- >>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 1)
103
+ >>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 1)
104
104
  '{\n\t"a": [[1,2,3]],\n\t"b": 2\n}\n'
105
- >>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 2)
105
+ >>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 2)
106
106
  '{\n\t"a": [\n\t\t[1,2,3]\n\t],\n\t"b": 2\n}\n'
107
- >>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 3)
107
+ >>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 3)
108
108
  '{\n\t"a": [\n\t\t[\n\t\t\t1,\n\t\t\t2,\n\t\t\t3\n\t\t]\n\t],\n\t"b": 2\n}\n'
109
109
  """
110
110
  # Imports
@@ -146,7 +146,7 @@ def super_json_dump(
146
146
  return content
147
147
 
148
148
  # JSON load from file path
149
- def super_json_load(file_path: str) -> Any:
149
+ def json_load(file_path: str) -> Any:
150
150
  """ Load a JSON file from the given path
151
151
 
152
152
  Args:
@@ -159,7 +159,7 @@ def super_json_load(file_path: str) -> Any:
159
159
  return orjson.loads(f.read())
160
160
 
161
161
  # CSV dump to file
162
- def super_csv_dump(
162
+ def csv_dump(
163
163
  data: Any,
164
164
  file: IO[Any] | str | None = None,
165
165
  delimiter: str = ',',
@@ -184,10 +184,10 @@ def super_csv_dump(
184
184
 
185
185
  Examples:
186
186
 
187
- >>> super_csv_dump([["a", "b", "c"], [1, 2, 3], [4, 5, 6]])
187
+ >>> csv_dump([["a", "b", "c"], [1, 2, 3], [4, 5, 6]])
188
188
  'a,b,c\\r\\n1,2,3\\r\\n4,5,6\\r\\n'
189
189
 
190
- >>> super_csv_dump([{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}])
190
+ >>> csv_dump([{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}])
191
191
  'name,age\\r\\nAlice,30\\r\\nBob,25\\r\\n'
192
192
  """
193
193
  if isinstance(data, str | bytes | dict):
@@ -256,7 +256,7 @@ def super_csv_dump(
256
256
  return content
257
257
 
258
258
  # CSV load from file path
259
- def super_csv_load(file_path: str, delimiter: str = ',', has_header: bool = True, as_dict: bool = False, as_dataframe: bool = False, use_polars: bool = False, *args: Any, **kwargs: Any) -> Any:
259
+ def csv_load(file_path: str, delimiter: str = ',', has_header: bool = True, as_dict: bool = False, as_dataframe: bool = False, use_polars: bool = False, *args: Any, **kwargs: Any) -> Any:
260
260
  """ Load a CSV file from the given path
261
261
 
262
262
  Args:
@@ -276,20 +276,20 @@ def super_csv_load(file_path: str, delimiter: str = ',', has_header: bool = True
276
276
  .. code-block:: python
277
277
 
278
278
  > Assuming "test.csv" contains: a,b,c\\n1,2,3\\n4,5,6
279
- > super_csv_load("test.csv")
279
+ > csv_load("test.csv")
280
280
  [['1', '2', '3'], ['4', '5', '6']]
281
281
 
282
- > super_csv_load("test.csv", as_dict=True)
282
+ > csv_load("test.csv", as_dict=True)
283
283
  [{'a': '1', 'b': '2', 'c': '3'}, {'a': '4', 'b': '5', 'c': '6'}]
284
284
 
285
- > super_csv_load("test.csv", as_dataframe=True)
285
+ > csv_load("test.csv", as_dataframe=True)
286
286
  a b c
287
287
  0 1 2 3
288
288
  1 4 5 6
289
289
 
290
290
  .. code-block:: console
291
291
 
292
- > super_csv_load("test.csv", as_dataframe=True, use_polars=True)
292
+ > csv_load("test.csv", as_dataframe=True, use_polars=True)
293
293
  shape: (2, 3)
294
294
  ┌─────┬─────┬─────┐
295
295
  │ a ┆ b ┆ c │
@@ -35,7 +35,7 @@ def relative_path(file_path: str, relative_to: str = '') -> str:
35
35
  \t\t>>> relative_path("D:/some/random/path/stouputils/io.py", "D:\\\\some\\\\")
36
36
  \t\t\'random/path/stouputils/io.py\'
37
37
  \t'''
38
- def super_json_dump(data: Any, file: IO[Any] | str | None = None, max_level: int | None = 2, indent: str | int = '\t', suffix: str = '\n') -> str:
38
+ def json_dump(data: Any, file: IO[Any] | str | None = None, max_level: int | None = 2, indent: str | int = '\t', suffix: str = '\n') -> str:
39
39
  ''' Writes the provided data to a JSON file with a specified indentation depth.
40
40
  \tFor instance, setting max_level to 2 will limit the indentation to 2 levels.
41
41
 
@@ -48,16 +48,16 @@ def super_json_dump(data: Any, file: IO[Any] | str | None = None, max_level: int
48
48
  \tReturns:
49
49
  \t\tstr: The content of the file in every case
50
50
 
51
- \t>>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 0)
51
+ \t>>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 0)
52
52
  \t\'{"a": [[1,2,3]],"b": 2}\\n\'
53
- \t>>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 1)
53
+ \t>>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 1)
54
54
  \t\'{\\n\\t"a": [[1,2,3]],\\n\\t"b": 2\\n}\\n\'
55
- \t>>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 2)
55
+ \t>>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 2)
56
56
  \t\'{\\n\\t"a": [\\n\\t\\t[1,2,3]\\n\\t],\\n\\t"b": 2\\n}\\n\'
57
- \t>>> super_json_dump({"a": [[1,2,3]], "b": 2}, max_level = 3)
57
+ \t>>> json_dump({"a": [[1,2,3]], "b": 2}, max_level = 3)
58
58
  \t\'{\\n\\t"a": [\\n\\t\\t[\\n\\t\\t\\t1,\\n\\t\\t\\t2,\\n\\t\\t\\t3\\n\\t\\t]\\n\\t],\\n\\t"b": 2\\n}\\n\'
59
59
  \t'''
60
- def super_json_load(file_path: str) -> Any:
60
+ def json_load(file_path: str) -> Any:
61
61
  """ Load a JSON file from the given path
62
62
 
63
63
  \tArgs:
@@ -65,7 +65,7 @@ def super_json_load(file_path: str) -> Any:
65
65
  \tReturns:
66
66
  \t\tAny: The content of the JSON file
67
67
  \t"""
68
- def super_csv_dump(data: Any, file: IO[Any] | str | None = None, delimiter: str = ',', has_header: bool = True, index: bool = False, *args: Any, **kwargs: Any) -> str:
68
+ def csv_dump(data: Any, file: IO[Any] | str | None = None, delimiter: str = ',', has_header: bool = True, index: bool = False, *args: Any, **kwargs: Any) -> str:
69
69
  ''' Writes data to a CSV file with customizable options and returns the CSV content as a string.
70
70
 
71
71
  \tArgs:
@@ -82,13 +82,13 @@ def super_csv_dump(data: Any, file: IO[Any] | str | None = None, delimiter: str
82
82
 
83
83
  \tExamples:
84
84
 
85
- \t\t>>> super_csv_dump([["a", "b", "c"], [1, 2, 3], [4, 5, 6]])
85
+ \t\t>>> csv_dump([["a", "b", "c"], [1, 2, 3], [4, 5, 6]])
86
86
  \t\t\'a,b,c\\r\\n1,2,3\\r\\n4,5,6\\r\\n\'
87
87
 
88
- \t\t>>> super_csv_dump([{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}])
88
+ \t\t>>> csv_dump([{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}])
89
89
  \t\t\'name,age\\r\\nAlice,30\\r\\nBob,25\\r\\n\'
90
90
  \t'''
91
- def super_csv_load(file_path: str, delimiter: str = ',', has_header: bool = True, as_dict: bool = False, as_dataframe: bool = False, use_polars: bool = False, *args: Any, **kwargs: Any) -> Any:
91
+ def csv_load(file_path: str, delimiter: str = ',', has_header: bool = True, as_dict: bool = False, as_dataframe: bool = False, use_polars: bool = False, *args: Any, **kwargs: Any) -> Any:
92
92
  ''' Load a CSV file from the given path
93
93
 
94
94
  \tArgs:
@@ -108,20 +108,20 @@ def super_csv_load(file_path: str, delimiter: str = ',', has_header: bool = True
108
108
  \t\t.. code-block:: python
109
109
 
110
110
  \t\t\t> Assuming "test.csv" contains: a,b,c\\n1,2,3\\n4,5,6
111
- \t\t\t> super_csv_load("test.csv")
111
+ \t\t\t> csv_load("test.csv")
112
112
  \t\t\t[[\'1\', \'2\', \'3\'], [\'4\', \'5\', \'6\']]
113
113
 
114
- \t\t\t> super_csv_load("test.csv", as_dict=True)
114
+ \t\t\t> csv_load("test.csv", as_dict=True)
115
115
  \t\t\t[{\'a\': \'1\', \'b\': \'2\', \'c\': \'3\'}, {\'a\': \'4\', \'b\': \'5\', \'c\': \'6\'}]
116
116
 
117
- \t\t\t> super_csv_load("test.csv", as_dataframe=True)
117
+ \t\t\t> csv_load("test.csv", as_dataframe=True)
118
118
  \t\t\t a b c
119
119
  \t\t\t0 1 2 3
120
120
  \t\t\t1 4 5 6
121
121
 
122
122
  \t\t.. code-block:: console
123
123
 
124
- \t\t\t> super_csv_load("test.csv", as_dataframe=True, use_polars=True)
124
+ \t\t\t> csv_load("test.csv", as_dataframe=True, use_polars=True)
125
125
  \t\t\tshape: (2, 3)
126
126
  \t\t\t┌─────┬─────┬─────┐
127
127
  \t\t\t│ a ┆ b ┆ c │
@@ -202,25 +202,38 @@ def whatisit(
202
202
  def _internal(value: Any) -> str:
203
203
  """ Get the string representation of the value, with length or shape instead of length if shape is available """
204
204
 
205
- # Get the length or shape of the value
206
- length: str = ""
205
+ # Build metadata parts list
206
+ metadata_parts: list[str] = []
207
+
208
+ # Get the dtype if available
207
209
  try:
208
- length = f"(length: {len(value)}) "
210
+ metadata_parts.append(f"dtype: {value.dtype}")
209
211
  except (AttributeError, TypeError):
210
212
  pass
213
+
214
+ # Get the shape or length of the value
211
215
  try:
212
- length = f"(shape: {value.shape}) "
216
+ metadata_parts.append(f"shape: {value.shape}")
213
217
  except (AttributeError, TypeError):
214
- pass
218
+ try:
219
+ metadata_parts.append(f"length: {len(value)}")
220
+ except (AttributeError, TypeError):
221
+ pass
215
222
 
216
- # Get the dtype if available
217
- dtype: str = ""
223
+ # Get the min and max if available (Iterable of numbers)
218
224
  try:
219
- dtype = f"(dtype: {value.dtype}) "
220
- except (AttributeError, TypeError):
225
+ if not isinstance(value, str | bytes | bytearray | dict | int | float):
226
+ import numpy as np
227
+ metadata_parts.append(f"min: {np.min(value)}")
228
+ metadata_parts.append(f"max: {np.max(value)}")
229
+ except (Exception):
221
230
  pass
222
231
 
232
+ # Combine metadata into a single parenthesized string
233
+ metadata_str: str = f"({', '.join(metadata_parts)}) " if metadata_parts else ""
234
+
223
235
  # Get the string representation of the value
236
+ value = cast(Any, value)
224
237
  value_str: str = str(value)
225
238
  if len(value_str) > max_length:
226
239
  value_str = value_str[:max_length] + "..."
@@ -228,7 +241,7 @@ def whatisit(
228
241
  value_str = "\n" + value_str # Add a newline before the value if there is a newline in it.
229
242
 
230
243
  # Return the formatted string
231
- return f"{type(value)}, <id {id(value)}>: {dtype}{length}{value_str}"
244
+ return f"{type(value)}, <id {id(value)}>: {metadata_str}{value_str}"
232
245
 
233
246
  # Add the color to the message
234
247
  if "color" not in print_kwargs:
@@ -479,3 +492,14 @@ if __name__ == "__main__":
479
492
  error("Hello", "World", exit=False)
480
493
  whatisit("Hello", "World")
481
494
 
495
+ # Test whatisit with different types
496
+ import numpy as np
497
+ print()
498
+ whatisit(
499
+ 123,
500
+ "Hello World",
501
+ [1, 2, 3, 4, 5],
502
+ np.array([[1, 2, 3], [4, 5, 6]]),
503
+ {"a": 1, "b": 2},
504
+ )
505
+
File without changes
File without changes
File without changes
File without changes