stouputils 1.16.2__tar.gz → 1.16.3__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 (141) hide show
  1. {stouputils-1.16.2 → stouputils-1.16.3}/PKG-INFO +2 -2
  2. {stouputils-1.16.2 → stouputils-1.16.3}/README.md +1 -1
  3. {stouputils-1.16.2 → stouputils-1.16.3}/pyproject.toml +1 -1
  4. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/collections.py +34 -1
  5. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/collections.pyi +21 -1
  6. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/__init__.py +0 -0
  7. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/__init__.pyi +0 -0
  8. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/__main__.py +0 -0
  9. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/_deprecated.py +0 -0
  10. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/_deprecated.pyi +0 -0
  11. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/all_doctests.py +0 -0
  12. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/all_doctests.pyi +0 -0
  13. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/__init__.py +0 -0
  14. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/__init__.pyi +0 -0
  15. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/automatic_docs.py +0 -0
  16. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/automatic_docs.pyi +0 -0
  17. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/__init__.py +0 -0
  18. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/__init__.pyi +0 -0
  19. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/config.py +0 -0
  20. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/config.pyi +0 -0
  21. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/image.py +0 -0
  22. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/image.pyi +0 -0
  23. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/video.py +0 -0
  24. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/applications/upscaler/video.pyi +0 -0
  25. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/archive.py +0 -0
  26. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/archive.pyi +0 -0
  27. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/backup.py +0 -0
  28. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/backup.pyi +0 -0
  29. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/__init__.py +0 -0
  30. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/__init__.pyi +0 -0
  31. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/cd_utils.py +0 -0
  32. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/cd_utils.pyi +0 -0
  33. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/github.py +0 -0
  34. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/github.pyi +0 -0
  35. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/pypi.py +0 -0
  36. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/pypi.pyi +0 -0
  37. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/pyproject.py +0 -0
  38. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/pyproject.pyi +0 -0
  39. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/stubs.py +0 -0
  40. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/continuous_delivery/stubs.pyi +0 -0
  41. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/ctx.py +0 -0
  42. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/ctx.pyi +0 -0
  43. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/config/get.py +0 -0
  44. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/config/set.py +0 -0
  45. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/__init__.py +0 -0
  46. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
  47. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
  48. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
  49. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
  50. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/blur.py +0 -0
  51. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/brightness.py +0 -0
  52. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/canny.py +0 -0
  53. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/clahe.py +0 -0
  54. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/common.py +0 -0
  55. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/contrast.py +0 -0
  56. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
  57. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/denoise.py +0 -0
  58. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
  59. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/invert.py +0 -0
  60. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
  61. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
  62. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/noise.py +0 -0
  63. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/normalize.py +0 -0
  64. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
  65. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/resize.py +0 -0
  66. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/rotation.py +0 -0
  67. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
  68. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
  69. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/shearing.py +0 -0
  70. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/threshold.py +0 -0
  71. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/translation.py +0 -0
  72. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image/zoom.py +0 -0
  73. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
  74. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
  75. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
  76. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/data_processing/technique.py +0 -0
  77. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/__init__.py +0 -0
  78. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/dataset.py +0 -0
  79. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/dataset_loader.py +0 -0
  80. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
  81. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/image_loader.py +0 -0
  82. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/dataset/xy_tuple.py +0 -0
  83. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/metric_dictionnary.py +0 -0
  84. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/metric_utils.py +0 -0
  85. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/mlflow_utils.py +0 -0
  86. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/abstract_model.py +0 -0
  87. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/all.py +0 -0
  88. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/base_keras.py +0 -0
  89. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/all.py +0 -0
  90. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/convnext.py +0 -0
  91. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/densenet.py +0 -0
  92. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/efficientnet.py +0 -0
  93. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/mobilenet.py +0 -0
  94. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/resnet.py +0 -0
  95. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/squeezenet.py +0 -0
  96. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/vgg.py +0 -0
  97. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras/xception.py +0 -0
  98. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
  99. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
  100. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
  101. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
  102. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
  103. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
  104. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
  105. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
  106. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
  107. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/model_interface.py +0 -0
  108. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/models/sandbox.py +0 -0
  109. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/range_tuple.py +0 -0
  110. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/scripts/augment_dataset.py +0 -0
  111. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
  112. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
  113. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/scripts/routine.py +0 -0
  114. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/data_science/utils.py +0 -0
  115. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/decorators.py +0 -0
  116. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/decorators.pyi +0 -0
  117. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/image.py +0 -0
  118. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/image.pyi +0 -0
  119. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/__init__.py +0 -0
  120. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/__init__.pyi +0 -0
  121. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/common.py +0 -0
  122. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/common.pyi +0 -0
  123. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/downloader.py +0 -0
  124. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/downloader.pyi +0 -0
  125. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/linux.py +0 -0
  126. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/linux.pyi +0 -0
  127. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/main.py +0 -0
  128. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/main.pyi +0 -0
  129. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/windows.py +0 -0
  130. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/installer/windows.pyi +0 -0
  131. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/io.py +0 -0
  132. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/io.pyi +0 -0
  133. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/parallel.py +0 -0
  134. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/parallel.pyi +0 -0
  135. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/print.py +0 -0
  136. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/print.pyi +0 -0
  137. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/py.typed +0 -0
  138. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/typing.py +0 -0
  139. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/typing.pyi +0 -0
  140. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/version_pkg.py +0 -0
  141. {stouputils-1.16.2 → stouputils-1.16.3}/stouputils/version_pkg.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: stouputils
3
- Version: 1.16.2
3
+ Version: 1.16.3
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
  Keywords: utilities,tools,helpers,development,python
6
6
  Author: Stoupy51
@@ -93,7 +93,7 @@ Start now by installing the package: `pip install stouputils`.<br>
93
93
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💾 Utilities for file management <span class="paren">(json_dump, json_load, csv_dump, csv_load, read_file, super_copy, super_open, clean_path, ...)</span></span>
94
94
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🔀 Utility functions for parallel processing <span class="paren">(multiprocessing, multithreading, run_in_subprocess)</span></span>
95
95
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Little utilities for image processing <span class="paren">(image_resize, auto_crop, numpy_to_gif, numpy_to_obj)</span></span>
96
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation <span class="paren">(unique_list, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span></span>
96
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation <span class="paren">(unique_list, at_least_n, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span></span>
97
97
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.typing.html">typing.py</a> <span class="comment"># 📝 Utilities for typing enhancements <span class="paren">(IterAny, JsonDict, JsonList, ..., convert_to_serializable)</span></span>
98
98
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Run all doctests for all modules in a given directory <span class="paren">(launch_tests, test_module_with_progress)</span></span>
99
99
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 💾 Utilities for backup management <span class="paren">(delta backup, consolidate)</span></span>
@@ -51,7 +51,7 @@ Start now by installing the package: `pip install stouputils`.<br>
51
51
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💾 Utilities for file management <span class="paren">(json_dump, json_load, csv_dump, csv_load, read_file, super_copy, super_open, clean_path, ...)</span></span>
52
52
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🔀 Utility functions for parallel processing <span class="paren">(multiprocessing, multithreading, run_in_subprocess)</span></span>
53
53
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Little utilities for image processing <span class="paren">(image_resize, auto_crop, numpy_to_gif, numpy_to_obj)</span></span>
54
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation <span class="paren">(unique_list, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span></span>
54
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation <span class="paren">(unique_list, at_least_n, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span></span>
55
55
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.typing.html">typing.py</a> <span class="comment"># 📝 Utilities for typing enhancements <span class="paren">(IterAny, JsonDict, JsonList, ..., convert_to_serializable)</span></span>
56
56
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Run all doctests for all modules in a given directory <span class="paren">(launch_tests, test_module_with_progress)</span></span>
57
57
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 💾 Utilities for backup management <span class="paren">(delta backup, consolidate)</span></span>
@@ -8,7 +8,7 @@ module-root = ""
8
8
 
9
9
  [project]
10
10
  name = "stouputils"
11
- version = "1.16.2"
11
+ version = "1.16.3"
12
12
  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."
13
13
  readme = "README.md"
14
14
  keywords = ["utilities", "tools", "helpers", "development", "python"]
@@ -2,6 +2,7 @@
2
2
  This module provides utilities for collection manipulation:
3
3
 
4
4
  - unique_list: Remove duplicates from a list while preserving order using object id, hash or str
5
+ - at_least_n: Check if at least n elements in an iterable satisfy a given predicate
5
6
  - sort_dict_keys: Sort dictionary keys using a given order list (ascending or descending)
6
7
  - upsert_in_dataframe: Insert or update a row in a Polars DataFrame based on primary keys
7
8
  - array_to_disk: Easily handle large numpy arrays on disk using zarr for efficient storage and access.
@@ -15,7 +16,7 @@ import atexit
15
16
  import os
16
17
  import shutil
17
18
  import tempfile
18
- from collections.abc import Iterable
19
+ from collections.abc import Callable, Iterable
19
20
  from typing import TYPE_CHECKING, Any, Literal, TypeVar
20
21
 
21
22
  # Lazy imports for typing
@@ -77,6 +78,38 @@ def unique_list[T](list_to_clean: Iterable[T], method: Literal["id", "hash", "st
77
78
  # Return the cleaned list
78
79
  return result
79
80
 
81
+
82
+ def at_least_n(iterable: Iterable[T], predicate: Callable[[T], bool], n: int) -> bool:
83
+ """ Return True if at least n elements in iterable satisfy predicate.
84
+ It's like the built-in any() but for at least n matches.
85
+
86
+ Stops iterating as soon as n matches are found (short-circuit evaluation).
87
+
88
+ Args:
89
+ iterable (Iterable[T]): The iterable to check.
90
+ predicate (Callable[[T], bool]): The predicate to apply to items.
91
+ n (int): Minimum number of matches required.
92
+
93
+ Returns:
94
+ bool: True if at least n elements satisfy predicate, otherwise False.
95
+
96
+ Examples:
97
+ >>> at_least_n([1, 2, 3, 4, *[i for i in range(5, int(1e5))]], lambda x: x % 2 == 0, 2)
98
+ True
99
+ >>> at_least_n([1, 3, 5, 7], lambda x: x % 2 == 0, 1)
100
+ False
101
+ """
102
+ if n <= 0:
103
+ return True
104
+ count: int = 0
105
+ for item in iterable:
106
+ if predicate(item):
107
+ count += 1
108
+ if count >= n:
109
+ return True
110
+ return False
111
+
112
+
80
113
  def sort_dict_keys[T](dictionary: dict[T, Any], order: list[T], reverse: bool = False) -> dict[T, Any]:
81
114
  """ Sort dictionary keys using a given order list (reverse optional)
82
115
 
@@ -1,6 +1,6 @@
1
1
  import polars as pl
2
2
  import zarr
3
- from collections.abc import Iterable
3
+ from collections.abc import Callable as Callable, Iterable
4
4
  from numpy.typing import NDArray as NDArray
5
5
  from typing import Any, Literal, TypeVar
6
6
 
@@ -31,6 +31,26 @@ def unique_list[T](list_to_clean: Iterable[T], method: Literal['id', 'hash', 'st
31
31
  \t\t>>> unique_list([s1, s2, s1, s1, s3, s2, s3], method="str")
32
32
  \t\t[{1, 2, 3}, {2, 3, 4}]
33
33
  \t'''
34
+ def at_least_n(iterable: Iterable[T], predicate: Callable[[T], bool], n: int) -> bool:
35
+ """ Return True if at least n elements in iterable satisfy predicate.
36
+ \tIt's like the built-in any() but for at least n matches.
37
+
38
+ \tStops iterating as soon as n matches are found (short-circuit evaluation).
39
+
40
+ \tArgs:
41
+ \t\titerable\t(Iterable[T]):\t\t\tThe iterable to check.
42
+ \t\tpredicate\t(Callable[[T], bool]):\tThe predicate to apply to items.
43
+ \t\tn\t\t\t(int):\t\t\t\t\tMinimum number of matches required.
44
+
45
+ \tReturns:
46
+ \t\tbool: True if at least n elements satisfy predicate, otherwise False.
47
+
48
+ \tExamples:
49
+ \t\t>>> at_least_n([1, 2, 3, 4, *[i for i in range(5, int(1e5))]], lambda x: x % 2 == 0, 2)
50
+ \t\tTrue
51
+ \t\t>>> at_least_n([1, 3, 5, 7], lambda x: x % 2 == 0, 1)
52
+ \t\tFalse
53
+ \t"""
34
54
  def sort_dict_keys[T](dictionary: dict[T, Any], order: list[T], reverse: bool = False) -> dict[T, Any]:
35
55
  ''' Sort dictionary keys using a given order list (reverse optional)
36
56