bluer-objects 6.307.1__py3-none-any.whl → 6.309.1__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.

Potentially problematic release.


This version of bluer-objects might be problematic. Click here for more details.

bluer_objects/__init__.py CHANGED
@@ -4,7 +4,7 @@ ICON = "🌀"
4
4
 
5
5
  DESCRIPTION = f"{ICON} Object management in Bash."
6
6
 
7
- VERSION = "6.307.1"
7
+ VERSION = "6.309.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
@@ -0,0 +1,107 @@
1
+ from typing import List
2
+ import numpy as np
3
+
4
+ from blueness import module
5
+ from bluer_options import string
6
+
7
+ from bluer_objects import NAME
8
+ from bluer_objects.logger import logger
9
+
10
+ NAME = module.name(__file__, NAME)
11
+
12
+
13
+ def stitch_images(
14
+ list_of_images: List[np.ndarray],
15
+ cols: int = -1,
16
+ rows: int = -1,
17
+ log: bool = False,
18
+ ) -> np.ndarray:
19
+ if not list_of_images:
20
+ return np.zeros((1, 1, 3), dtype=np.uint8)
21
+
22
+ list_of_images = list_of_images.copy()
23
+
24
+ if rows == -1:
25
+ rows = int(np.floor(np.sqrt(len(list_of_images))))
26
+ cols = -1
27
+
28
+ if cols == -1:
29
+ cols = int(np.ceil(len(list_of_images) / rows))
30
+
31
+ if log:
32
+ logger.info(
33
+ "{}.stitch_images[{}x{}]({}): {}".format(
34
+ NAME,
35
+ rows,
36
+ cols,
37
+ len(list_of_images),
38
+ ", ".join(
39
+ [string.pretty_shape_of_matrix(image) for image in list_of_images]
40
+ ),
41
+ )
42
+ )
43
+
44
+ for image in list_of_images:
45
+ if len(image.shape) == 2:
46
+ image = np.stack([image, image, image], axis=2)
47
+
48
+ if rows == 1:
49
+ output = np.zeros(
50
+ (
51
+ max([image.shape[0] for image in list_of_images]),
52
+ sum([image.shape[1] for image in list_of_images]),
53
+ 3,
54
+ ),
55
+ dtype=np.uint8,
56
+ )
57
+ x: int = 0
58
+ for image in list_of_images:
59
+ x_new = x + image.shape[1]
60
+
61
+ output[
62
+ : image.shape[0],
63
+ x:x_new,
64
+ :,
65
+ ] = image
66
+
67
+ x = x_new
68
+
69
+ return output
70
+
71
+ if cols == 1:
72
+ output = np.zeros(
73
+ (
74
+ sum([image.shape[0] for image in list_of_images]),
75
+ max([image.shape[1] for image in list_of_images]),
76
+ 3,
77
+ ),
78
+ dtype=np.uint8,
79
+ )
80
+ y: int = 0
81
+ for image in list_of_images:
82
+ y_new = y + image.shape[0]
83
+
84
+ output[
85
+ y:y_new,
86
+ : image.shape[1],
87
+ :,
88
+ ] = image
89
+
90
+ y = y_new
91
+
92
+ return output
93
+
94
+ return stitch_images(
95
+ list_of_images=[
96
+ stitch_images(
97
+ list_of_images[row * cols : (row + 1) * cols],
98
+ cols=cols,
99
+ rows=1,
100
+ log=log,
101
+ )
102
+ for row in range(rows)
103
+ ],
104
+ cols=1,
105
+ rows=rows,
106
+ log=log,
107
+ )
@@ -0,0 +1,47 @@
1
+ import pytest
2
+ import numpy as np
3
+ import random
4
+
5
+ from bluer_objects.logger.stitch import stitch_images
6
+
7
+
8
+ @pytest.mark.parametrize(
9
+ ["count"],
10
+ [[count] for count in range(10)],
11
+ )
12
+ @pytest.mark.parametrize(
13
+ ["cols"],
14
+ [[cols] for cols in [-1, 1, 3]],
15
+ )
16
+ @pytest.mark.parametrize(
17
+ ["rows"],
18
+ [[rows] for rows in [-1, 1, 3]],
19
+ )
20
+ def test_logger_stitch_images(
21
+ count: int,
22
+ cols: int,
23
+ rows: int,
24
+ ):
25
+ rng = np.random.default_rng()
26
+
27
+ list_of_images = list_of_images = [
28
+ rng.integers(
29
+ 0,
30
+ 256,
31
+ (
32
+ random.randint(1, 512),
33
+ random.randint(1, 512),
34
+ random.choice([1, 3]),
35
+ ),
36
+ dtype=np.uint8,
37
+ )
38
+ for _ in range(count)
39
+ ]
40
+
41
+ image = stitch_images(
42
+ list_of_images,
43
+ cols=cols,
44
+ rows=rows,
45
+ log=True,
46
+ )
47
+ assert isinstance(image, np.ndarray)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluer_objects
3
- Version: 6.307.1
3
+ Version: 6.309.1
4
4
  Summary: 🌀 Object management in Bash.
5
5
  Home-page: https://github.com/kamangir/bluer-objects
6
6
  Author: Arash Abadpour (Kamangir)
@@ -65,6 +65,6 @@ pip install bluer-objects
65
65
 
66
66
  [![pylint](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/bluer-objects.svg)](https://pypi.org/project/bluer-objects/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/bluer-objects)](https://pypistats.org/packages/bluer-objects)
67
67
 
68
- built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.307.1`](https://github.com/kamangir/bluer-objects).
68
+ built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.309.1`](https://github.com/kamangir/bluer-objects).
69
69
 
70
70
  built by 🌀 [`blueness-3.118.1`](https://github.com/kamangir/blueness).
@@ -1,4 +1,4 @@
1
- bluer_objects/__init__.py,sha256=DAAKM8pXjLmId4HPAcI_MN9WADPvh0YGTnmbihhtdew,315
1
+ bluer_objects/__init__.py,sha256=oIlM2xeIepu5cmzABGmAKpSHdhD0sO8jRADh8g-v9fg,315
2
2
  bluer_objects/__main__.py,sha256=Yqfov833_hJuRne19WrGhT5DWAPtdffpoMxeSXS7EGw,359
3
3
  bluer_objects/config.env,sha256=ReX0OSH_dK2tdD4-zAlp-427BB57yw8uDTS6tLYN4K0,270
4
4
  bluer_objects/env.py,sha256=ecwldUVsamxAjOI0a6PmbZPcyhdUZgzJ-nhAPh0CJRo,2085
@@ -117,6 +117,7 @@ bluer_objects/host/functions.py,sha256=ADups78hYZDAnC6FlIICQ48WkFd4sPnRMWA0D6X-F
117
117
  bluer_objects/logger/__init__.py,sha256=2aGNbx-qBXU3IlX9BDqtrFfN25lO_uarEg22cE3-3dU,102
118
118
  bluer_objects/logger/image.py,sha256=wHpE6jCqKGmcjXU61vCMKbBeir7DAxH6nKx5kb_1Vv0,2617
119
119
  bluer_objects/logger/matrix.py,sha256=cPKQIhd347MH_9LaB-Ym7Mix1pqampG9MIgkeh08KA4,5757
120
+ bluer_objects/logger/stitch.py,sha256=qFWQAxNyfOn7k5celRYIUPqaI-ZqDWKQ5ud1VyaIwM4,2515
120
121
  bluer_objects/metadata/__init__.py,sha256=nRFzLb9zMQiVqESThflFFThVOnzC7Aq1ks9_K1OaOg4,311
121
122
  bluer_objects/metadata/__main__.py,sha256=UAZBsf3AMUo-OHIgg4gS5_OowDOIO2T_zjismL3AfkI,2272
122
123
  bluer_objects/metadata/enums.py,sha256=aMlAZckl_IjPZcGZhpJa7mb9MTDQ-gWuaQtJJQeHlho,759
@@ -164,6 +165,7 @@ bluer_objects/tests/test_graphics_text.py,sha256=_jLZVuAcQQYlKpATeQCBpPMa8UhKQ__
164
165
  bluer_objects/tests/test_log_image_grid.py,sha256=qjSRMwY5jnJd9S3XZ3FDeoIsSJ9aFJ3yDhth1sV0A5g,737
165
166
  bluer_objects/tests/test_logger.py,sha256=DdkZqj8YOErKf6T-SWEPtU21LGfQf_O3GKrCn3H0Ujs,88
166
167
  bluer_objects/tests/test_logger_matrix.py,sha256=qedidEDGusMWQM04kgk3mt74yFm4iU3jIyjE4gRi_FQ,1703
168
+ bluer_objects/tests/test_logger_stitch_images.py,sha256=GW_EPbByNbAhwCJ3LwVXjwe4sTx6jcE0SXVvM8kL_LY,929
167
169
  bluer_objects/tests/test_markdown.py,sha256=KtCWKIDs4U1M3qAGFMYhzVpdGiDV2VU8z7dCaU3s3Ec,217
168
170
  bluer_objects/tests/test_metadata.py,sha256=Qy-Zp5yFrHmZ5tjujuLNcvI2YEyzNuAFXgy0L7sJOJ0,4389
169
171
  bluer_objects/tests/test_metadata_flatten.py,sha256=edBaX0CF7Yte4jMSIMBM04FY6Umo3BpfSXXStqpx8IM,2760
@@ -182,8 +184,8 @@ bluer_objects/tests/test_web_is_accessible.py,sha256=2Y20NAEDMblg0MKnhnqcfw3XVKE
182
184
  bluer_objects/web/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
183
185
  bluer_objects/web/__main__.py,sha256=xf2Ob54FI8JEokfGhFmiyOBdD9nBactwqmZvsKsdioU,624
184
186
  bluer_objects/web/functions.py,sha256=KNufAFOc6N3BYf83lN2rUpKUdsnzb2anWyp9koFRVUo,172
185
- bluer_objects-6.307.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
186
- bluer_objects-6.307.1.dist-info/METADATA,sha256=6NQ4_-Uw1Mle1qoWyXTtgL0z97OyEbspFm3yqiwc_Ck,3780
187
- bluer_objects-6.307.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
188
- bluer_objects-6.307.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
189
- bluer_objects-6.307.1.dist-info/RECORD,,
187
+ bluer_objects-6.309.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
188
+ bluer_objects-6.309.1.dist-info/METADATA,sha256=hVrsasnK8GnBDs7cnu-z7FFrbqhezumfoHJUy0F6j7A,3780
189
+ bluer_objects-6.309.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
190
+ bluer_objects-6.309.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
191
+ bluer_objects-6.309.1.dist-info/RECORD,,