bluer-objects 6.255.1__py3-none-any.whl → 6.258.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.255.1"
7
+ VERSION = "6.258.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
@@ -5,4 +5,5 @@ from bluer_objects.metadata.get import (
5
5
  get_from_object,
6
6
  get_from_path,
7
7
  )
8
+ from bluer_objects.metadata.flatten import flatten
8
9
  from bluer_objects.metadata.post import post, post_to_file, post_to_object, post_to_path
@@ -0,0 +1,27 @@
1
+ from typing import Any
2
+ import numpy as np
3
+
4
+
5
+ def flatten(obj: Any) -> Any:
6
+ if isinstance(obj, dict):
7
+ return {k: flatten(v) for k, v in obj.items()}
8
+
9
+ if isinstance(obj, list):
10
+ return [flatten(x) for x in obj]
11
+
12
+ if isinstance(obj, tuple):
13
+ return tuple(flatten(x) for x in obj)
14
+
15
+ if isinstance(obj, np.ndarray):
16
+ return obj.tolist()
17
+
18
+ if hasattr(obj, "__dict__"):
19
+ return flatten(vars(obj))
20
+
21
+ if isinstance(obj, (int, float, str)):
22
+ return obj
23
+
24
+ try:
25
+ return str(obj)
26
+ except:
27
+ return obj.__class__.__name__
@@ -0,0 +1,109 @@
1
+ import pytest
2
+ import numpy as np
3
+
4
+ from bluer_objects.metadata import flatten
5
+
6
+
7
+ test_objects = [
8
+ np.zeros((4, 5)),
9
+ [np.zeros((4, 5)) for _ in range(5)],
10
+ tuple(np.zeros((4, 5)) for _ in range(5)),
11
+ {"this": np.zeros((4, 5))},
12
+ {"this": 1, "that": 2},
13
+ ]
14
+
15
+ test_flatten_objects = [
16
+ [
17
+ [0.0, 0.0, 0.0, 0.0, 0.0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0, 0.0, 0.0, 0.0],
66
+ ],
67
+ [
68
+ [0.0, 0.0, 0.0, 0.0, 0.0],
69
+ [0.0, 0.0, 0.0, 0.0, 0.0],
70
+ [0.0, 0.0, 0.0, 0.0, 0.0],
71
+ [0.0, 0.0, 0.0, 0.0, 0.0],
72
+ ],
73
+ [
74
+ [0.0, 0.0, 0.0, 0.0, 0.0],
75
+ [0.0, 0.0, 0.0, 0.0, 0.0],
76
+ [0.0, 0.0, 0.0, 0.0, 0.0],
77
+ [0.0, 0.0, 0.0, 0.0, 0.0],
78
+ ],
79
+ [
80
+ [0.0, 0.0, 0.0, 0.0, 0.0],
81
+ [0.0, 0.0, 0.0, 0.0, 0.0],
82
+ [0.0, 0.0, 0.0, 0.0, 0.0],
83
+ [0.0, 0.0, 0.0, 0.0, 0.0],
84
+ ],
85
+ ),
86
+ {
87
+ "this": [
88
+ [0.0, 0.0, 0.0, 0.0, 0.0],
89
+ [0.0, 0.0, 0.0, 0.0, 0.0],
90
+ [0.0, 0.0, 0.0, 0.0, 0.0],
91
+ [0.0, 0.0, 0.0, 0.0, 0.0],
92
+ ]
93
+ },
94
+ {"this": 1, "that": 2},
95
+ ]
96
+
97
+
98
+ @pytest.mark.parametrize(
99
+ ["obj", "flatten_obj"],
100
+ [
101
+ [obj, flatten_obj]
102
+ for obj, flatten_obj in zip(
103
+ test_objects,
104
+ test_flatten_objects,
105
+ )
106
+ ],
107
+ )
108
+ def test_metadata_flatten(obj, flatten_obj):
109
+ assert flatten(obj) == flatten_obj
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluer_objects
3
- Version: 6.255.1
3
+ Version: 6.258.1
4
4
  Summary: 🌀 Object management in Bash.
5
5
  Home-page: https://github.com/kamangir/bluer-objects
6
6
  Author: Arash Abadpour (Kamangir)
@@ -64,6 +64,6 @@ pip install bluer-objects
64
64
 
65
65
  [![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)
66
66
 
67
- built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.255.1`](https://github.com/kamangir/bluer-objects).
67
+ built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.258.1`](https://github.com/kamangir/bluer-objects).
68
68
 
69
69
  built by 🌀 [`blueness-3.118.1`](https://github.com/kamangir/blueness).
@@ -1,4 +1,4 @@
1
- bluer_objects/__init__.py,sha256=Z4iwLgZZkCeP0QTdzqmBxPs8N-mob7qU0OmO_OcQ0TQ,315
1
+ bluer_objects/__init__.py,sha256=Au6HgvlITOtM99WPA3ucZ0fbQjp6y-mZriimwKV4Ic4,315
2
2
  bluer_objects/__main__.py,sha256=Yqfov833_hJuRne19WrGhT5DWAPtdffpoMxeSXS7EGw,359
3
3
  bluer_objects/config.env,sha256=RjcpnbKfRqNyGLRB4z7M_OG9z2pOM032ck__53JqXqo,216
4
4
  bluer_objects/env.py,sha256=iw4QvaImqnavlsHwfkUScNHc7afDEJQKJSsHTtVJE78,2019
@@ -110,9 +110,10 @@ bluer_objects/host/functions.py,sha256=ADups78hYZDAnC6FlIICQ48WkFd4sPnRMWA0D6X-F
110
110
  bluer_objects/logger/__init__.py,sha256=2aGNbx-qBXU3IlX9BDqtrFfN25lO_uarEg22cE3-3dU,102
111
111
  bluer_objects/logger/image.py,sha256=wHpE6jCqKGmcjXU61vCMKbBeir7DAxH6nKx5kb_1Vv0,2617
112
112
  bluer_objects/logger/matrix.py,sha256=cPKQIhd347MH_9LaB-Ym7Mix1pqampG9MIgkeh08KA4,5757
113
- bluer_objects/metadata/__init__.py,sha256=B8cmMOMMO53mTwD2LJUFbSjvangSkpLqhR3oVIBsoBI,260
113
+ bluer_objects/metadata/__init__.py,sha256=nRFzLb9zMQiVqESThflFFThVOnzC7Aq1ks9_K1OaOg4,311
114
114
  bluer_objects/metadata/__main__.py,sha256=UAZBsf3AMUo-OHIgg4gS5_OowDOIO2T_zjismL3AfkI,2272
115
115
  bluer_objects/metadata/enums.py,sha256=aMlAZckl_IjPZcGZhpJa7mb9MTDQ-gWuaQtJJQeHlho,759
116
+ bluer_objects/metadata/flatten.py,sha256=Du_mieFw9WGMAGXw7N7zsVJ_A_aMbCpoYjLCC2U3UlE,589
116
117
  bluer_objects/metadata/get.py,sha256=1eS1O-GghJ7mYCIiwcQRFwyAd1b3CUafmajAwja9HB8,1803
117
118
  bluer_objects/metadata/post.py,sha256=1r0yLmIuEPrKJ_-RfALC5ajpLzmUqEjLYoIQMuI4Jjw,2062
118
119
  bluer_objects/mlflow/__init__.py,sha256=GVPXTclqYAyu-iJoLeHSgTaMeoMpVaczFgU4PavS3QA,523
@@ -156,6 +157,7 @@ bluer_objects/tests/test_logger.py,sha256=DdkZqj8YOErKf6T-SWEPtU21LGfQf_O3GKrCn3
156
157
  bluer_objects/tests/test_logger_matrix.py,sha256=qedidEDGusMWQM04kgk3mt74yFm4iU3jIyjE4gRi_FQ,1703
157
158
  bluer_objects/tests/test_markdown.py,sha256=KtCWKIDs4U1M3qAGFMYhzVpdGiDV2VU8z7dCaU3s3Ec,217
158
159
  bluer_objects/tests/test_metadata.py,sha256=Qy-Zp5yFrHmZ5tjujuLNcvI2YEyzNuAFXgy0L7sJOJ0,4389
160
+ bluer_objects/tests/test_metadata_flatten.py,sha256=edBaX0CF7Yte4jMSIMBM04FY6Umo3BpfSXXStqpx8IM,2760
159
161
  bluer_objects/tests/test_mlflow.py,sha256=Ee6T7r2qT1fvUv2ommC3Wl5Gwz1olURvMvhoaM0779M,1419
160
162
  bluer_objects/tests/test_mlflow_lock.py,sha256=rDNfyWHZu3U88yIIFrPeQPsTneU0GR8n9gSgqpj0q9k,569
161
163
  bluer_objects/tests/test_objects.py,sha256=pqdXvnAJ5WPlHvqqaKrd9-vqktrE9GOVxSgqHs8yK8w,1441
@@ -171,8 +173,8 @@ bluer_objects/tests/test_web_is_accessible.py,sha256=2Y20NAEDMblg0MKnhnqcfw3XVKE
171
173
  bluer_objects/web/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
172
174
  bluer_objects/web/__main__.py,sha256=xf2Ob54FI8JEokfGhFmiyOBdD9nBactwqmZvsKsdioU,624
173
175
  bluer_objects/web/functions.py,sha256=KNufAFOc6N3BYf83lN2rUpKUdsnzb2anWyp9koFRVUo,172
174
- bluer_objects-6.255.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
175
- bluer_objects-6.255.1.dist-info/METADATA,sha256=rB31zp3kzAZbxvQkZ1nmWEPD1F2xi3BDyPlDZAOkx5c,3678
176
- bluer_objects-6.255.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
177
- bluer_objects-6.255.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
178
- bluer_objects-6.255.1.dist-info/RECORD,,
176
+ bluer_objects-6.258.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
177
+ bluer_objects-6.258.1.dist-info/METADATA,sha256=KxtIHUkFtrMEgJQz4bOWbItrFeLBxOGKI8zlhnHb63k,3678
178
+ bluer_objects-6.258.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
+ bluer_objects-6.258.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
180
+ bluer_objects-6.258.1.dist-info/RECORD,,