gridpoints 1.1.1__tar.gz → 1.1.2__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.
- {gridpoints-1.1.1/src/gridpoints.egg-info → gridpoints-1.1.2}/PKG-INFO +1 -1
- {gridpoints-1.1.1 → gridpoints-1.1.2}/pyproject.toml +1 -1
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/__init__.py +1 -1
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/padding.py +22 -14
- {gridpoints-1.1.1 → gridpoints-1.1.2/src/gridpoints.egg-info}/PKG-INFO +1 -1
- {gridpoints-1.1.1 → gridpoints-1.1.2}/LICENSE +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/README.md +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/setup.cfg +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/griddemo/__init__.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/griddemo/quick_demo.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/array_libs.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/diagonal_tricks.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/kdtree.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints/mlg_sort.py +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints.egg-info/SOURCES.txt +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints.egg-info/dependency_links.txt +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints.egg-info/requires.txt +0 -0
- {gridpoints-1.1.1 → gridpoints-1.1.2}/src/gridpoints.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gridpoints"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.2"
|
|
8
8
|
description = "fast multidimensional sorting tool for point clouds using the monotonic lagrangian grid "
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Helper to complete point clouds so that they fit a grid.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .array_libs import arange, astype, empty
|
|
5
|
+
from .array_libs import arange, astype, empty, get_backend
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def pad(X, n_total, value="nan"):
|
|
@@ -26,23 +26,31 @@ def pad(X, n_total, value="nan"):
|
|
|
26
26
|
X_padded : array (n_total, D) or (B, n_total, D)
|
|
27
27
|
"""
|
|
28
28
|
assert value in ("nan", "inf"), f"value must be 'nan' or 'inf', got {value!r}"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
assert max(len(c) for c in
|
|
29
|
+
is_array = hasattr(X, 'ndim')
|
|
30
|
+
ref = X if is_array else X[0]
|
|
31
|
+
assert (X.shape[-2] if is_array else max(len(c) for c in X)) <= n_total, "more points than n_total"
|
|
32
32
|
|
|
33
|
-
ref = clouds[0]
|
|
34
33
|
dtype = str(ref.dtype).replace('torch.', '')
|
|
35
34
|
if 'float' not in dtype: # integers cannot hold nan / inf
|
|
36
35
|
dtype = 'float64'
|
|
37
36
|
D = ref.shape[-1]
|
|
38
|
-
|
|
39
|
-
out[...] = float(value)
|
|
37
|
+
shape = (n_total, D) if is_array and X.ndim == 2 else (len(X), n_total, D)
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
# 1. Prefill with nan, then copy the true points in.
|
|
40
|
+
out = empty(shape, dtype, ref)
|
|
41
|
+
out[...] = float('nan')
|
|
42
|
+
if is_array:
|
|
43
|
+
out[..., :X.shape[-2], :] = astype(X, dtype)
|
|
44
|
+
else:
|
|
45
|
+
for b, cloud in enumerate(X):
|
|
46
|
+
out[b, :len(cloud)] = astype(cloud, dtype)
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
# 2. Turn the nans into +/-inf: point k, coordinate d gets the sign of bit d of k.
|
|
49
|
+
if value == "inf":
|
|
50
|
+
xp, _ = get_backend(out)
|
|
51
|
+
k = arange(n_total, 'int64', ref)[:, None]
|
|
52
|
+
d = arange(D, 'int64', ref)[None, :]
|
|
53
|
+
signs = astype(1 - 2 * ((k // 2 ** (D - 1 - d)) % 2), dtype) # (n_total, D)
|
|
54
|
+
out = xp.where(xp.isnan(out), signs * float('inf'), out)
|
|
55
|
+
|
|
56
|
+
return out
|
|
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
|