relib 1.1.1__tar.gz → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: relib
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  Project-URL: Repository, https://github.com/Reddan/relib.git
5
5
  Author: Hampus Hallman
6
6
  License: Copyright 2023 Hampus Hallman
@@ -10,7 +10,4 @@ License: Copyright 2023 Hampus Hallman
10
10
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
11
 
12
12
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- License-File: LICENSE
14
13
  Requires-Python: >=3.12
15
- Requires-Dist: numpy
16
- Requires-Dist: termcolor
@@ -1,11 +1,8 @@
1
1
  [project]
2
2
  name = "relib"
3
- version = "1.1.1"
3
+ version = "1.2.0"
4
4
  requires-python = ">=3.12"
5
- dependencies = [
6
- "numpy",
7
- "termcolor",
8
- ]
5
+ dependencies = []
9
6
  authors = [
10
7
  {name = "Hampus Hallman"}
11
8
  ]
@@ -1,4 +1,5 @@
1
1
  from .utils import (
2
+ clear_console,
2
3
  non_none,
3
4
  list_split,
4
5
  drop_none,
@@ -30,6 +31,5 @@ from .utils import (
30
31
  StrFilter,
31
32
  str_filterer,
32
33
  )
33
- from .raypipe import raypipe
34
34
  from .hashing import hash
35
35
  from .measure_duration import measure_duration
@@ -237,7 +237,7 @@ class NumpyHasher(Hasher):
237
237
  Hasher.save(self, obj)
238
238
 
239
239
 
240
- def hash(obj, hash_name='md5', coerce_mmap=False):
240
+ def hash(obj, hash_name='md5', coerce_mmap=False) -> str:
241
241
  """ Quick calculation of a hash to identify uniquely Python objects
242
242
  containing numpy arrays.
243
243
  Parameters
@@ -1,5 +1,4 @@
1
1
  from time import time
2
- from termcolor import colored
3
2
 
4
3
  active_mds = []
5
4
 
@@ -16,5 +15,5 @@ class measure_duration:
16
15
  depth = len(active_mds) - 1
17
16
  indent = ('──' * depth) + (' ' * (depth > 0))
18
17
  text = '{}: {} seconds'.format(self.name, duration)
19
- print(colored(indent + text, attrs=['dark']))
18
+ print(indent + text)
20
19
  active_mds.remove(self)
@@ -1,8 +1,7 @@
1
- from typing import TypeVar, Iterable, Callable, Any, cast, overload
2
- from itertools import chain
3
- import numpy as np
4
1
  import os
5
2
  import re
3
+ from typing import TypeVar, Iterable, Callable, Any, cast, overload
4
+ from itertools import chain
6
5
 
7
6
  T = TypeVar('T')
8
7
  U = TypeVar('U')
@@ -183,14 +182,16 @@ def num_partitions(values: Iterable[T], num_parts: int) -> list[list[T]]:
183
182
  return [values[i * part_size:(i + 1) * part_size] for i in range(num_parts)]
184
183
 
185
184
  def _cat_tile(cats, n_tile):
185
+ import numpy as np
186
186
  return cats[np.tile(np.arange(len(cats)), n_tile)]
187
187
 
188
188
  def df_from_array(
189
- value_cols: dict[str, np.ndarray],
189
+ value_cols: dict[str, Any],
190
190
  dim_labels: list[tuple[str, list[str | int | float]]],
191
191
  indexed=False,
192
192
  ):
193
193
  import pandas as pd
194
+ import numpy as np
194
195
  dim_sizes = np.array([len(labels) for _, labels in dim_labels])
195
196
  assert all(array.shape == tuple(dim_sizes) for array in value_cols.values())
196
197
  array_offsets = [
relib-1.2.0/uv.lock ADDED
@@ -0,0 +1,7 @@
1
+ version = 1
2
+ requires-python = ">=3.12"
3
+
4
+ [[package]]
5
+ name = "relib"
6
+ version = "1.2.0"
7
+ source = { editable = "." }
@@ -1,60 +0,0 @@
1
- import numpy as np
2
-
3
- class Raypipe():
4
- def __init__(self, handlers=[]):
5
- self.handlers = handlers
6
-
7
- def __add_to_pipeline(self, handler_type, fn, kwargs={}):
8
- handler = (handler_type, fn, kwargs)
9
- return Raypipe(self.handlers + [handler])
10
-
11
- def map(self, fn):
12
- return self.__add_to_pipeline('map', fn)
13
-
14
- def flatten(self):
15
- return self.__add_to_pipeline('flatten', None)
16
-
17
- def flat_map(self, fn):
18
- return self.map(fn).flatten()
19
-
20
- def filter(self, fn):
21
- return self.__add_to_pipeline('filter', fn)
22
-
23
- def sort(self, fn=None, reverse=False):
24
- return self.__add_to_pipeline('sort', fn, dict(reverse=reverse))
25
-
26
- def distinct(self):
27
- return self.__add_to_pipeline('distinct', None)
28
-
29
- def sort_distinct(self, fn=None, reverse=False):
30
- return self.distinct().sort(fn, reverse=reverse)
31
-
32
- def do(self, fn):
33
- return self.__add_to_pipeline('do', fn)
34
-
35
- def shuffle(self, random_state=42):
36
- return self.__add_to_pipeline('shuffle', None, dict(random_state=random_state))
37
-
38
- def to_numpy(self):
39
- return self.__add_to_pipeline('do', np.array)
40
-
41
- def compute(self, values):
42
- for handler_type, handler_fn, handler_kwargs in self.handlers:
43
- if handler_type == 'map':
44
- values = [handler_fn(val) for val in values]
45
- elif handler_type == 'flatten':
46
- values = [item for sublist in values for item in sublist]
47
- elif handler_type == 'filter':
48
- values = [val for val in values if handler_fn(val)]
49
- elif handler_type == 'sort':
50
- values.sort(key=handler_fn, reverse=handler_kwargs['reverse'])
51
- elif handler_type == 'distinct':
52
- values = list(set(values))
53
- elif handler_type == 'do':
54
- values = handler_fn(values)
55
- elif handler_type == 'shuffle':
56
- from sklearn.utils import shuffle
57
- values = shuffle(values, random_state=handler_kwargs['random_state'])
58
- return values
59
-
60
- raypipe = Raypipe()
relib-1.1.1/uv.lock DELETED
@@ -1,62 +0,0 @@
1
- version = 1
2
- requires-python = ">=3.12"
3
-
4
- [[package]]
5
- name = "numpy"
6
- version = "2.1.0"
7
- source = { registry = "https://pypi.org/simple" }
8
- sdist = { url = "https://files.pythonhosted.org/packages/54/a4/f8188c4f3e07f7737683588210c073478abcb542048cf4ab6fedad0b458a/numpy-2.1.0.tar.gz", hash = "sha256:7dc90da0081f7e1da49ec4e398ede6a8e9cc4f5ebe5f9e06b443ed889ee9aaa2", size = 18868922 }
9
- wheels = [
10
- { url = "https://files.pythonhosted.org/packages/eb/f5/a06a231cbeea4aff841ff744a12e4bf4d4407f2c753d13ce4563aa126c90/numpy-2.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:fe76d75b345dc045acdbc006adcb197cc680754afd6c259de60d358d60c93736", size = 20882951 },
11
- { url = "https://files.pythonhosted.org/packages/70/1d/4ad38e3a1840f72c29595c06b103ecd9119f260e897ff7e88a74adb0ca14/numpy-2.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f358ea9e47eb3c2d6eba121ab512dfff38a88db719c38d1e67349af210bc7529", size = 13491878 },
12
- { url = "https://files.pythonhosted.org/packages/b4/3b/569055d01ed80634d6be6ceef8fb28eb0866e4f98c2d97667dcf9fae3e22/numpy-2.1.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:dd94ce596bda40a9618324547cfaaf6650b1a24f5390350142499aa4e34e53d1", size = 5087346 },
13
- { url = "https://files.pythonhosted.org/packages/24/37/212dd6fbd298c467b80d4d6217b2bc902b520e96a967b59f72603bf1142f/numpy-2.1.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:b47c551c6724960479cefd7353656498b86e7232429e3a41ab83be4da1b109e8", size = 6618269 },
14
- { url = "https://files.pythonhosted.org/packages/33/4d/435c143c06e16c8bfccbfd9af252b0a8ac7897e0c0e36e539d75a75e91b4/numpy-2.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0756a179afa766ad7cb6f036de622e8a8f16ffdd55aa31f296c870b5679d745", size = 13695244 },
15
- { url = "https://files.pythonhosted.org/packages/48/3e/bf807eb050abc23adc556f34fcf931ca2d67ad8dfc9c17fcd9332c01347f/numpy-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24003ba8ff22ea29a8c306e61d316ac74111cebf942afbf692df65509a05f111", size = 16040181 },
16
- { url = "https://files.pythonhosted.org/packages/cd/a9/40dc96b5d43076836d82d1e84a3a4a6a4c2925a53ec0b7f31271434ff02c/numpy-2.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:b34fa5e3b5d6dc7e0a4243fa0f81367027cb6f4a7215a17852979634b5544ee0", size = 16407920 },
17
- { url = "https://files.pythonhosted.org/packages/cc/77/39e44cf0a6eb0f93b18ffb00f1964b2c471b1df5605aee486c221b06a8e4/numpy-2.1.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c4f982715e65036c34897eb598d64aef15150c447be2cfc6643ec7a11af06574", size = 14170943 },
18
- { url = "https://files.pythonhosted.org/packages/54/02/f0a3c2ec1622dc4346bd126e2578948c7192b3838c893a3d215738fb367b/numpy-2.1.0-cp312-cp312-win32.whl", hash = "sha256:c4cd94dfefbefec3f8b544f61286584292d740e6e9d4677769bc76b8f41deb02", size = 6235947 },
19
- { url = "https://files.pythonhosted.org/packages/8c/bf/d9d214a9dff020ad1663f1536f45d34e052e4c7f630c46cd363e785e3231/numpy-2.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0cdef204199278f5c461a0bed6ed2e052998276e6d8ab2963d5b5c39a0500bc", size = 12566546 },
20
- { url = "https://files.pythonhosted.org/packages/c3/16/6b536e1b67624178e3631a3fa60c9c1b5ee7cda2fa9492c4f2de01bfcb06/numpy-2.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8ab81ccd753859ab89e67199b9da62c543850f819993761c1e94a75a814ed667", size = 20833354 },
21
- { url = "https://files.pythonhosted.org/packages/52/87/130e95aa8a6383fc3de4fdaf7adc629289b79b88548fb6e35e9d924697d7/numpy-2.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:442596f01913656d579309edcd179a2a2f9977d9a14ff41d042475280fc7f34e", size = 13506169 },
22
- { url = "https://files.pythonhosted.org/packages/d9/c2/0fcf68c67681f9ad9d76156b4606f60b48748ead76d4ba19b90aecd4b626/numpy-2.1.0-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:848c6b5cad9898e4b9ef251b6f934fa34630371f2e916261070a4eb9092ffd33", size = 5072908 },
23
- { url = "https://files.pythonhosted.org/packages/72/40/e21bbbfae665ef5fa1dfd7eae1c5dc93ba9d3b36e39d2d38789dd8c22d56/numpy-2.1.0-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:54c6a63e9d81efe64bfb7bcb0ec64332a87d0b87575f6009c8ba67ea6374770b", size = 6604906 },
24
- { url = "https://files.pythonhosted.org/packages/0e/ce/848967516bf8dd4f769886a883a4852dbc62e9b63b1137d2b9900f595222/numpy-2.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:652e92fc409e278abdd61e9505649e3938f6d04ce7ef1953f2ec598a50e7c195", size = 13690864 },
25
- { url = "https://files.pythonhosted.org/packages/15/72/2cebe04758e1123f625ed3221cb3c48602175ad619dd9b47de69689b4656/numpy-2.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ab32eb9170bf8ffcbb14f11613f4a0b108d3ffee0832457c5d4808233ba8977", size = 16036272 },
26
- { url = "https://files.pythonhosted.org/packages/a7/b7/ae34ced7864b551e0ea01ce4e7acbe7ddf5946afb623dea39760b19bc8b0/numpy-2.1.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:8fb49a0ba4d8f41198ae2d52118b050fd34dace4b8f3fb0ee34e23eb4ae775b1", size = 16408978 },
27
- { url = "https://files.pythonhosted.org/packages/4d/22/c9d696b87c5ce25e857d7745fe4f090373a2daf8c26f5e15b32b5db7bff7/numpy-2.1.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:44e44973262dc3ae79e9063a1284a73e09d01b894b534a769732ccd46c28cc62", size = 14168398 },
28
- { url = "https://files.pythonhosted.org/packages/9e/8b/63f74dccf86d4832d593bdbe06544f4a0a1b7e18e86e0db1e8231bf47c49/numpy-2.1.0-cp313-cp313-win32.whl", hash = "sha256:ab83adc099ec62e044b1fbb3a05499fa1e99f6d53a1dde102b2d85eff66ed324", size = 6232743 },
29
- { url = "https://files.pythonhosted.org/packages/23/4b/e30a3132478c69df3e3e587fa87dcbf2660455daec92d8d52e7028a92554/numpy-2.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:de844aaa4815b78f6023832590d77da0e3b6805c644c33ce94a1e449f16d6ab5", size = 12560212 },
30
- { url = "https://files.pythonhosted.org/packages/5a/1b/40e881a3a272c4861de1e43a3e7ee1559988dd12187463726d3b395a8874/numpy-2.1.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:343e3e152bf5a087511cd325e3b7ecfd5b92d369e80e74c12cd87826e263ec06", size = 20840821 },
31
- { url = "https://files.pythonhosted.org/packages/d0/8e/5b7c08f9238f6cc18037f6fd92f83feaa8c19e9decb6bd075cad81f71fae/numpy-2.1.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:f07fa2f15dabe91259828ce7d71b5ca9e2eb7c8c26baa822c825ce43552f4883", size = 13500478 },
32
- { url = "https://files.pythonhosted.org/packages/65/32/bf9df25ef50761fcb3e089c745d2e195b35cc6506d032f12bb5cc28f6c43/numpy-2.1.0-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:5474dad8c86ee9ba9bb776f4b99ef2d41b3b8f4e0d199d4f7304728ed34d0300", size = 5095825 },
33
- { url = "https://files.pythonhosted.org/packages/50/34/d18c95bc5981ea3bb8e6f896aad12159a37dcc67b22cd9464fe3899612f7/numpy-2.1.0-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1f817c71683fd1bb5cff1529a1d085a57f02ccd2ebc5cd2c566f9a01118e3b7d", size = 6611470 },
34
- { url = "https://files.pythonhosted.org/packages/b4/4f/27d56e9f6222419951bfeef54bc0a71dc40c0ebeb248e1aa85655da6fa11/numpy-2.1.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a3336fbfa0d38d3deacd3fe7f3d07e13597f29c13abf4d15c3b6dc2291cbbdd", size = 13647061 },
35
- { url = "https://files.pythonhosted.org/packages/f9/e0/ae6e12a157c4ab415b380d0f3596cb9090a0c4acf48cd8cd7bc6d6b93d24/numpy-2.1.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a894c51fd8c4e834f00ac742abad73fc485df1062f1b875661a3c1e1fb1c2f6", size = 16006479 },
36
- { url = "https://files.pythonhosted.org/packages/ab/da/b746668c7303bd73af262208abbfa8b1c86be12e9eccb0d3021ed8a58873/numpy-2.1.0-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:9156ca1f79fc4acc226696e95bfcc2b486f165a6a59ebe22b2c1f82ab190384a", size = 16383064 },
37
- { url = "https://files.pythonhosted.org/packages/f4/51/c0dcadea0c281be5db32b29f7b977b17bdb53b7dbfcbc3b4f49288de8696/numpy-2.1.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:624884b572dff8ca8f60fab591413f077471de64e376b17d291b19f56504b2bb", size = 14135556 },
38
- ]
39
-
40
- [[package]]
41
- name = "relib"
42
- version = "1.1.0"
43
- source = { editable = "." }
44
- dependencies = [
45
- { name = "numpy" },
46
- { name = "termcolor" },
47
- ]
48
-
49
- [package.metadata]
50
- requires-dist = [
51
- { name = "numpy", specifier = ">=2.1.0" },
52
- { name = "termcolor", specifier = ">=2.4.0" },
53
- ]
54
-
55
- [[package]]
56
- name = "termcolor"
57
- version = "2.4.0"
58
- source = { registry = "https://pypi.org/simple" }
59
- sdist = { url = "https://files.pythonhosted.org/packages/10/56/d7d66a84f96d804155f6ff2873d065368b25a07222a6fd51c4f24ef6d764/termcolor-2.4.0.tar.gz", hash = "sha256:aab9e56047c8ac41ed798fa36d892a37aca6b3e9159f3e0c24bc64a9b3ac7b7a", size = 12664 }
60
- wheels = [
61
- { url = "https://files.pythonhosted.org/packages/d9/5f/8c716e47b3a50cbd7c146f45881e11d9414def768b7cd9c5e6650ec2a80a/termcolor-2.4.0-py3-none-any.whl", hash = "sha256:9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63", size = 7719 },
62
- ]
File without changes
File without changes
File without changes