stouputils 1.3.23__tar.gz → 1.4.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.
- {stouputils-1.3.23 → stouputils-1.4.0}/.gitignore +1 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/PKG-INFO +2 -1
- {stouputils-1.3.23 → stouputils-1.4.0}/pyproject.toml +2 -2
- stouputils-1.4.0/stouputils/collections.py +157 -0
- stouputils-1.3.23/stouputils/collections.py +0 -62
- {stouputils-1.3.23 → stouputils-1.4.0}/LICENSE +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/README.md +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/all_doctests.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/automatic_docs.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/upscaler/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/upscaler/config.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/upscaler/image.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/applications/upscaler/video.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/archive.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/backup.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/continuous_delivery/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/continuous_delivery/cd_utils.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/continuous_delivery/github.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/continuous_delivery/pypi.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/continuous_delivery/pyproject.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/ctx.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/config/get.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/config/set.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/blur.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/brightness.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/canny.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/clahe.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/common.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/contrast.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/denoise.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/invert.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/noise.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/normalize.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/resize.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/rotation.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/shearing.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/threshold.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/translation.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/zoom.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/technique.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/dataset.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/dataset_loader.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/image_loader.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/dataset/xy_tuple.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/metric_dictionnary.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/metric_utils.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/mlflow_utils.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/abstract_model.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/all.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/base_keras.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/all.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/convnext.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/densenet.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/efficientnet.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/mobilenet.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/resnet.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/squeezenet.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/vgg.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras/xception.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/model_interface.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/sandbox.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/range_tuple.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/augment_dataset.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/routine.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/utils.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/decorators.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/image.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/__init__.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/common.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/downloader.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/linux.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/main.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/installer/windows.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/io.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/parallel.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/print.py +0 -0
- {stouputils-1.3.23 → stouputils-1.4.0}/stouputils/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.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
|
|
@@ -20,6 +20,7 @@ Requires-Dist: pyyaml>=6.0.0
|
|
|
20
20
|
Requires-Dist: requests>=2.20.0
|
|
21
21
|
Requires-Dist: toml>=0.10.0
|
|
22
22
|
Requires-Dist: tqdm>=4.0.0
|
|
23
|
+
Requires-Dist: zarr>=2.18.3
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
|
|
25
26
|
# 🛠️ Project Badges
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "stouputils"
|
|
8
|
-
version = "1.
|
|
8
|
+
version = "1.4.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"
|
|
@@ -14,7 +14,7 @@ classifiers = [
|
|
|
14
14
|
"License :: OSI Approved :: MIT License",
|
|
15
15
|
"Operating System :: OS Independent",
|
|
16
16
|
]
|
|
17
|
-
dependencies = [ "tqdm>=4.0.0", "requests>=2.20.0", "pyyaml>=6.0.0", "toml>=0.10.0", "pillow>=10.0.0", "numpy", "opencv-python>=4.0.0", "orjson>=3.0.0", "pyfastcopy>=1.0.0", "python-box[all]>=7.0.0",]
|
|
17
|
+
dependencies = [ "tqdm>=4.0.0", "requests>=2.20.0", "pyyaml>=6.0.0", "toml>=0.10.0", "pillow>=10.0.0", "numpy", "opencv-python>=4.0.0", "orjson>=3.0.0", "pyfastcopy>=1.0.0", "python-box[all]>=7.0.0", "zarr>=2.18.3",]
|
|
18
18
|
[[project.authors]]
|
|
19
19
|
name = "Stoupy51"
|
|
20
20
|
email = "stoupy51@gmail.com"
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides utilities for collection manipulation:
|
|
3
|
+
|
|
4
|
+
- unique_list: Remove duplicates from a list while preserving order using object id, hash or str
|
|
5
|
+
- array_to_disk: Easily handle large numpy arrays on disk using zarr for efficient storage and access.
|
|
6
|
+
|
|
7
|
+
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/collections_module.gif
|
|
8
|
+
:alt: stouputils collections examples
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# pyright: reportUnknownMemberType=false
|
|
12
|
+
# Imports
|
|
13
|
+
import atexit
|
|
14
|
+
import os
|
|
15
|
+
import shutil
|
|
16
|
+
import tempfile
|
|
17
|
+
from typing import Any, Literal
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
import zarr # pyright: ignore[reportMissingTypeStubs]
|
|
21
|
+
from numpy.typing import NDArray
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Functions
|
|
25
|
+
def unique_list(list_to_clean: list[Any], method: Literal["id", "hash", "str"] = "str") -> list[Any]:
|
|
26
|
+
""" Remove duplicates from the list while keeping the order using ids (default) or hash or str
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
list_to_clean (list[Any]): The list to clean
|
|
30
|
+
method (Literal["id", "hash", "str"]): The method to use to identify duplicates
|
|
31
|
+
Returns:
|
|
32
|
+
list[Any]: The cleaned list
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
>>> unique_list([1, 2, 3, 2, 1], method="id")
|
|
36
|
+
[1, 2, 3]
|
|
37
|
+
|
|
38
|
+
>>> s1 = {1, 2, 3}
|
|
39
|
+
>>> s2 = {2, 3, 4}
|
|
40
|
+
>>> s3 = {1, 2, 3}
|
|
41
|
+
>>> unique_list([s1, s2, s1, s1, s3, s2, s3], method="id")
|
|
42
|
+
[{1, 2, 3}, {2, 3, 4}, {1, 2, 3}]
|
|
43
|
+
|
|
44
|
+
>>> s1 = {1, 2, 3}
|
|
45
|
+
>>> s2 = {2, 3, 4}
|
|
46
|
+
>>> s3 = {1, 2, 3}
|
|
47
|
+
>>> unique_list([s1, s2, s1, s1, s3, s2, s3], method="str")
|
|
48
|
+
[{1, 2, 3}, {2, 3, 4}]
|
|
49
|
+
"""
|
|
50
|
+
# Initialize the seen ids set and the result list
|
|
51
|
+
seen: set[Any] = set()
|
|
52
|
+
result: list[Any] = []
|
|
53
|
+
|
|
54
|
+
# Iterate over each item in the list
|
|
55
|
+
for item in list_to_clean:
|
|
56
|
+
if method == "id":
|
|
57
|
+
item_identifier = id(item)
|
|
58
|
+
elif method == "hash":
|
|
59
|
+
item_identifier = hash(item)
|
|
60
|
+
elif method == "str":
|
|
61
|
+
item_identifier = str(item)
|
|
62
|
+
else:
|
|
63
|
+
raise ValueError(f"Invalid method: {method}")
|
|
64
|
+
|
|
65
|
+
# If the item id is not in the seen ids set, add it to the seen ids set and append the item to the result list
|
|
66
|
+
if item_identifier not in seen:
|
|
67
|
+
seen.add(item_identifier)
|
|
68
|
+
result.append(item)
|
|
69
|
+
|
|
70
|
+
# Return the cleaned list
|
|
71
|
+
return result
|
|
72
|
+
|
|
73
|
+
def array_to_disk(
|
|
74
|
+
data: NDArray[Any] | zarr.Array,
|
|
75
|
+
delete_input: bool = True,
|
|
76
|
+
more_data: NDArray[Any] | zarr.Array | None = None
|
|
77
|
+
) -> tuple[zarr.Array, str, int]:
|
|
78
|
+
""" Easily handle large numpy arrays on disk using zarr for efficient storage and access.
|
|
79
|
+
|
|
80
|
+
Zarr provides a simpler and more efficient alternative to np.memmap with better compression
|
|
81
|
+
and chunking capabilities.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
data (NDArray | zarr.Array): The data to save/load as a zarr array
|
|
85
|
+
delete_input (bool): Whether to delete the input data after creating the zarr array
|
|
86
|
+
more_data (NDArray | zarr.Array | None): Additional data to append to the zarr array
|
|
87
|
+
Returns:
|
|
88
|
+
tuple[zarr.Array, str, int]: The zarr array, the directory path, and the total size in bytes
|
|
89
|
+
|
|
90
|
+
Examples:
|
|
91
|
+
>>> data = np.random.rand(1000, 1000)
|
|
92
|
+
>>> zarr_array = array_to_disk(data)[0]
|
|
93
|
+
>>> zarr_array.shape
|
|
94
|
+
(1000, 1000)
|
|
95
|
+
|
|
96
|
+
>>> more_data = np.random.rand(500, 1000)
|
|
97
|
+
>>> longer_array, dir_path, total_size = array_to_disk(zarr_array, more_data=more_data)
|
|
98
|
+
"""
|
|
99
|
+
def dir_size(directory: str) -> int:
|
|
100
|
+
return sum(
|
|
101
|
+
os.path.getsize(os.path.join(dirpath, filename))
|
|
102
|
+
for dirpath, _, filenames in os.walk(directory)
|
|
103
|
+
for filename in filenames
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# If data is already a zarr.Array and more_data is present, just append and return
|
|
107
|
+
if isinstance(data, zarr.Array) and more_data is not None:
|
|
108
|
+
original_size: int = data.shape[0]
|
|
109
|
+
new_shape: tuple[int, ...] = (original_size + more_data.shape[0], *data.shape[1:])
|
|
110
|
+
data.resize(new_shape)
|
|
111
|
+
data[original_size:] = more_data[:]
|
|
112
|
+
|
|
113
|
+
# Delete more_data if specified, calculate size, and return
|
|
114
|
+
if delete_input:
|
|
115
|
+
del more_data
|
|
116
|
+
store_path: str = data.store.path if hasattr(data.store, 'path') else str(data.store)
|
|
117
|
+
return data, store_path, dir_size(store_path)
|
|
118
|
+
|
|
119
|
+
# Create a temporary directory to store the zarr array (with compression (auto-chunking for optimal performance))
|
|
120
|
+
temp_dir: str = tempfile.mkdtemp()
|
|
121
|
+
zarr_array: zarr.Array = zarr.open_array(temp_dir, mode="w", shape=data.shape, dtype=data.dtype, chunks=True)
|
|
122
|
+
zarr_array[:] = data[:]
|
|
123
|
+
|
|
124
|
+
# If additional data is provided, resize and append
|
|
125
|
+
if more_data is not None:
|
|
126
|
+
original_size = data.shape[0]
|
|
127
|
+
new_shape = (original_size + more_data.shape[0], *data.shape[1:])
|
|
128
|
+
zarr_array.resize(new_shape)
|
|
129
|
+
zarr_array[original_size:] = more_data[:]
|
|
130
|
+
|
|
131
|
+
# Delete the original data from memory if specified
|
|
132
|
+
if delete_input:
|
|
133
|
+
del data
|
|
134
|
+
if more_data is not None:
|
|
135
|
+
del more_data
|
|
136
|
+
|
|
137
|
+
# Register a cleanup function to delete the zarr directory at exit
|
|
138
|
+
atexit.register(lambda: shutil.rmtree(temp_dir, ignore_errors=True))
|
|
139
|
+
|
|
140
|
+
# Return all
|
|
141
|
+
return zarr_array, temp_dir, dir_size(temp_dir)
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
|
|
145
|
+
# Example usage of array_to_disk (now using zarr)
|
|
146
|
+
print("\nZarr Example:")
|
|
147
|
+
data = np.random.rand(1000, 1000)
|
|
148
|
+
zarr_array, dir_path, total_size = array_to_disk(data, delete_input=True)
|
|
149
|
+
print(f"Zarr array shape: {zarr_array.shape}, directory: {dir_path}, size: {total_size:,} bytes")
|
|
150
|
+
print(f"Compression ratio: {(data.nbytes / total_size):.2f}x")
|
|
151
|
+
|
|
152
|
+
# Make it longer (1000x1000 -> 1500x1000)
|
|
153
|
+
data2 = np.random.rand(500, 1000)
|
|
154
|
+
longer_array, dir_path, total_size = array_to_disk(zarr_array, more_data=data2)
|
|
155
|
+
print(f"\nLonger zarr array shape: {longer_array.shape}, directory: {dir_path}, size: {total_size:,} bytes")
|
|
156
|
+
print(f"Compression ratio: {(1500 * 1000 * 8 / total_size):.2f}x")
|
|
157
|
+
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module provides utilities for collection manipulation:
|
|
3
|
-
|
|
4
|
-
- unique_list: Remove duplicates from a list while preserving order using object id, hash or str
|
|
5
|
-
|
|
6
|
-
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/collections_module.gif
|
|
7
|
-
:alt: stouputils collections examples
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
# Imports
|
|
11
|
-
from typing import Any, Literal
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# Functions
|
|
15
|
-
def unique_list(list_to_clean: list[Any], method: Literal["id", "hash", "str"] = "str") -> list[Any]:
|
|
16
|
-
""" Remove duplicates from the list while keeping the order using ids (default) or hash or str
|
|
17
|
-
|
|
18
|
-
Args:
|
|
19
|
-
list_to_clean (list[Any]): The list to clean
|
|
20
|
-
method (Literal["id", "hash", "str"]): The method to use to identify duplicates
|
|
21
|
-
Returns:
|
|
22
|
-
list[Any]: The cleaned list
|
|
23
|
-
|
|
24
|
-
Examples:
|
|
25
|
-
>>> unique_list([1, 2, 3, 2, 1], method="id")
|
|
26
|
-
[1, 2, 3]
|
|
27
|
-
|
|
28
|
-
>>> s1 = {1, 2, 3}
|
|
29
|
-
>>> s2 = {2, 3, 4}
|
|
30
|
-
>>> s3 = {1, 2, 3}
|
|
31
|
-
>>> unique_list([s1, s2, s1, s1, s3, s2, s3], method="id")
|
|
32
|
-
[{1, 2, 3}, {2, 3, 4}, {1, 2, 3}]
|
|
33
|
-
|
|
34
|
-
>>> s1 = {1, 2, 3}
|
|
35
|
-
>>> s2 = {2, 3, 4}
|
|
36
|
-
>>> s3 = {1, 2, 3}
|
|
37
|
-
>>> unique_list([s1, s2, s1, s1, s3, s2, s3], method="str")
|
|
38
|
-
[{1, 2, 3}, {2, 3, 4}]
|
|
39
|
-
"""
|
|
40
|
-
# Initialize the seen ids set and the result list
|
|
41
|
-
seen: set[Any] = set()
|
|
42
|
-
result: list[Any] = []
|
|
43
|
-
|
|
44
|
-
# Iterate over each item in the list
|
|
45
|
-
for item in list_to_clean:
|
|
46
|
-
if method == "id":
|
|
47
|
-
item_identifier = id(item)
|
|
48
|
-
elif method == "hash":
|
|
49
|
-
item_identifier = hash(item)
|
|
50
|
-
elif method == "str":
|
|
51
|
-
item_identifier = str(item)
|
|
52
|
-
else:
|
|
53
|
-
raise ValueError(f"Invalid method: {method}")
|
|
54
|
-
|
|
55
|
-
# If the item id is not in the seen ids set, add it to the seen ids set and append the item to the result list
|
|
56
|
-
if item_identifier not in seen:
|
|
57
|
-
seen.add(item_identifier)
|
|
58
|
-
result.append(item)
|
|
59
|
-
|
|
60
|
-
# Return the cleaned list
|
|
61
|
-
return result
|
|
62
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/axis_flip.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/blur.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/brightness.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/canny.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/clahe.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/common.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/contrast.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/denoise.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/invert.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/laplacian.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/median_blur.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/noise.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/normalize.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/random_erase.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/resize.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/rotation.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/salt_pepper.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/sharpening.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/shearing.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/threshold.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/translation.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image/zoom.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image_augmentation.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/data_processing/image_preprocess.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/losses/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/models/keras_utils/visualizations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/exhaustive_process.py
RENAMED
|
File without changes
|
{stouputils-1.3.23 → stouputils-1.4.0}/stouputils/data_science/scripts/preprocess_dataset.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|