metatensor-operations 0.2.1__tar.gz → 0.2.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.
- {metatensor-operations-0.2.1/metatensor_operations.egg-info → metatensor_operations-0.2.2}/PKG-INFO +4 -4
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/__init__.py +1 -1
- metatensor-operations-0.2.1/metatensor/operations/checks.py → metatensor_operations-0.2.2/metatensor/operations/_checks.py +3 -32
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/_dispatch.py +242 -12
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/reduce_over_samples.py +2 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2/metatensor_operations.egg-info}/PKG-INFO +4 -4
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/SOURCES.txt +1 -1
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/pyproject.toml +3 -3
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/setup.py +1 -1
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/AUTHORS +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/LICENSE +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/MANIFEST.in +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/README.rst +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/_backend.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/_utils.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/abs.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/add.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/allclose.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/block_from_array.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/detach.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/divide.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/dot.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/drop_blocks.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/empty_like.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/equal.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/equal_metadata.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/join.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/lstsq.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/manipulate_dimension.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/multiply.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/one_hot.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/ones_like.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/pow.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/random_like.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/remove_gradients.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/requires_grad.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/slice.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/solve.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/sort.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/split.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/subtract.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/unique_metadata.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/zeros_like.py +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/dependency_links.txt +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/requires.txt +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/top_level.txt +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/zip-safe +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/n_commits_since_last_tag +0 -0
- {metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/setup.cfg +0 -0
{metatensor-operations-0.2.1/metatensor_operations.egg-info → metatensor_operations-0.2.2}/PKG-INFO
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: metatensor-operations
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Operations to manipulate metatensor data types
|
|
5
5
|
Author: Guillaume Fraux, Davide Tisi, Philip Loche, Joseph W. Abbott, Jigyasa Nigam, Chiheb Ben Mahmoud
|
|
6
6
|
License: BSD-3-Clause
|
|
7
|
-
Project-URL: homepage, https://
|
|
8
|
-
Project-URL: documentation, https://
|
|
7
|
+
Project-URL: homepage, https://docs.metatensor.org/latest/
|
|
8
|
+
Project-URL: documentation, https://docs.metatensor.org/latest/
|
|
9
9
|
Project-URL: repository, https://github.com/lab-cosmo/metatensor
|
|
10
|
-
Project-URL: changelog, https://
|
|
10
|
+
Project-URL: changelog, https://docs.metatensor.org/latest/operations/CHANGELOG.html
|
|
11
11
|
Keywords: machine learning,molecular modeling
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/__init__.py
RENAMED
|
@@ -4,7 +4,7 @@ __version__ = importlib.metadata.version("metatensor-operations")
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
from ._utils import NotEqualError # noqa
|
|
7
|
-
from .
|
|
7
|
+
from ._checks import checks_enabled, unsafe_disable_checks, unsafe_enable_checks # noqa
|
|
8
8
|
|
|
9
9
|
from .abs import abs # noqa
|
|
10
10
|
from .add import add # noqa
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Metatensor performs `shape` as well as `consistency` checks for the metadata during each
|
|
3
|
-
operation. The check status can be verified with :py:func:`metatensor.checks_enabled()`
|
|
4
|
-
and controlled by :py:class:`metatensor.unsafe_enable_checks()` and
|
|
5
|
-
:py:class:`metatensor.unsafe_disable_checks()`.
|
|
6
|
-
|
|
7
|
-
.. warning::
|
|
8
|
-
Using metatensor without checks is unsafe, can lead to unwanted results, and may
|
|
9
|
-
produce cryptic error messages. Therefore, disabling checks is not recommended and
|
|
10
|
-
should only be used by advanced users! If you see strange results after disabling
|
|
11
|
-
checks, try running the code again with checks enabled.
|
|
12
|
-
|
|
13
|
-
Checks can either be disabled temporarily
|
|
14
|
-
via a compound statements or globally and permanently by calling the speicific function
|
|
15
|
-
directly.
|
|
16
|
-
|
|
17
|
-
The checks can also controlled wit the environment variable
|
|
18
|
-
``METATENSOR_UNSAFE_DISABLE_CHECKS``. To disable checks set
|
|
19
|
-
|
|
20
|
-
.. code-block:: bash
|
|
21
|
-
|
|
22
|
-
export METATENSOR_UNSAFE_DISABLE_CHECKS=1
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Note that :py:class:`metatensor.unsafe_enable_checks()` or
|
|
26
|
-
:py:class:`metatensor.unsafe_disable_checks()` overwrite the defintion of the enviroment
|
|
27
|
-
variable.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
1
|
import os
|
|
31
2
|
|
|
32
3
|
|
|
@@ -48,7 +19,7 @@ def checks_enabled() -> bool:
|
|
|
48
19
|
class _SetChecks:
|
|
49
20
|
"""Private parent class for setting metatensor check control to a certain state.
|
|
50
21
|
|
|
51
|
-
Refer to the docstring of ``
|
|
22
|
+
Refer to the docstring of ``disable_checks`` for more details."""
|
|
52
23
|
|
|
53
24
|
def __init__(self, state):
|
|
54
25
|
global _CHECKS_ENABLED
|
|
@@ -74,7 +45,7 @@ class _SetChecks:
|
|
|
74
45
|
class unsafe_enable_checks(_SetChecks):
|
|
75
46
|
"""Enable metatensor checks.
|
|
76
47
|
|
|
77
|
-
Checks are default enabled. Calling this function
|
|
48
|
+
Checks are default enabled. Calling this function permanently enables all metatensor
|
|
78
49
|
operations checks.
|
|
79
50
|
|
|
80
51
|
>>> import metatensor
|
|
@@ -109,7 +80,7 @@ class unsafe_enable_checks(_SetChecks):
|
|
|
109
80
|
class unsafe_disable_checks(_SetChecks):
|
|
110
81
|
"""Disable metatensor checks.
|
|
111
82
|
|
|
112
|
-
Calling this function
|
|
83
|
+
Calling this function permanently disables all metatensor operations checks.
|
|
113
84
|
|
|
114
85
|
>>> import metatensor
|
|
115
86
|
>>> metatensor.unsafe_disable_checks()
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/_dispatch.py
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import warnings
|
|
3
|
-
from typing import List, Optional, Union
|
|
3
|
+
from typing import List, Optional, Tuple, Union
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
7
|
-
from ._backend import torch_jit_is_scripting
|
|
7
|
+
from ._backend import torch_jit_is_scripting, torch_jit_script
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def parse_version(version):
|
|
@@ -124,13 +124,139 @@ def argsort_labels_values(labels_values, reverse: bool = False):
|
|
|
124
124
|
:return: indices corresponding to the sorted values in ``labels_values``
|
|
125
125
|
"""
|
|
126
126
|
if isinstance(labels_values, TorchTensor):
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
if labels_values.shape[1] == 1:
|
|
128
|
+
# Index is appended at the end to get
|
|
129
|
+
# the indices corresponding to the
|
|
130
|
+
# sorted values. Because we append the indices at
|
|
131
|
+
# the end and since metadata is unique, we do not affect
|
|
132
|
+
# the sorted order. Using `torch.argsort` is not an option
|
|
133
|
+
# because only on Tensors and sorting a Tensor is
|
|
134
|
+
# different than sorting a List(Tuple)
|
|
135
|
+
data = [(int(row[0]), i) for i, row in enumerate(labels_values)]
|
|
136
|
+
return torch.tensor(
|
|
137
|
+
[i[-1] for i in sort_list_2(data, reverse=reverse)],
|
|
138
|
+
dtype=torch.int64,
|
|
139
|
+
device=labels_values.device,
|
|
140
|
+
)
|
|
141
|
+
if labels_values.shape[1] == 2:
|
|
142
|
+
data = [
|
|
143
|
+
(int(row[0]), int(row[1]), i) for i, row in enumerate(labels_values)
|
|
144
|
+
]
|
|
145
|
+
return torch.tensor(
|
|
146
|
+
[i[-1] for i in sort_list_3(data, reverse=reverse)],
|
|
147
|
+
dtype=torch.int64,
|
|
148
|
+
device=labels_values.device,
|
|
149
|
+
)
|
|
150
|
+
if labels_values.shape[1] == 3:
|
|
151
|
+
data = [
|
|
152
|
+
(int(row[0]), int(row[1]), int(row[2]), i)
|
|
153
|
+
for i, row in enumerate(labels_values)
|
|
154
|
+
]
|
|
155
|
+
return torch.tensor(
|
|
156
|
+
[i[-1] for i in sort_list_4(data, reverse=reverse)],
|
|
157
|
+
dtype=torch.int64,
|
|
158
|
+
device=labels_values.device,
|
|
159
|
+
)
|
|
160
|
+
if labels_values.shape[1] == 4:
|
|
161
|
+
data = [
|
|
162
|
+
(int(row[0]), int(row[1]), int(row[2]), int(row[3]), i)
|
|
163
|
+
for i, row in enumerate(labels_values)
|
|
164
|
+
]
|
|
165
|
+
return torch.tensor(
|
|
166
|
+
[i[-1] for i in sort_list_5(data, reverse=reverse)],
|
|
167
|
+
dtype=torch.int64,
|
|
168
|
+
device=labels_values.device,
|
|
169
|
+
)
|
|
170
|
+
if labels_values.shape[1] == 5:
|
|
171
|
+
data = [
|
|
172
|
+
(int(row[0]), int(row[1]), int(row[2]), int(row[3]), int(row[4]), i)
|
|
173
|
+
for i, row in enumerate(labels_values)
|
|
174
|
+
]
|
|
175
|
+
return torch.tensor(
|
|
176
|
+
[i[-1] for i in sort_list_6(data, reverse=reverse)],
|
|
177
|
+
dtype=torch.int64,
|
|
178
|
+
device=labels_values.device,
|
|
179
|
+
)
|
|
180
|
+
if labels_values.shape[1] == 6:
|
|
181
|
+
data = [
|
|
182
|
+
(
|
|
183
|
+
int(row[0]),
|
|
184
|
+
int(row[1]),
|
|
185
|
+
int(row[2]),
|
|
186
|
+
int(row[3]),
|
|
187
|
+
int(row[4]),
|
|
188
|
+
int(row[5]),
|
|
189
|
+
i,
|
|
190
|
+
)
|
|
191
|
+
for i, row in enumerate(labels_values)
|
|
192
|
+
]
|
|
193
|
+
return torch.tensor(
|
|
194
|
+
[i[-1] for i in sort_list_7(data, reverse=reverse)],
|
|
195
|
+
dtype=torch.int64,
|
|
196
|
+
device=labels_values.device,
|
|
197
|
+
)
|
|
198
|
+
if labels_values.shape[1] == 7:
|
|
199
|
+
data = [
|
|
200
|
+
(
|
|
201
|
+
int(row[0]),
|
|
202
|
+
int(row[1]),
|
|
203
|
+
int(row[2]),
|
|
204
|
+
int(row[3]),
|
|
205
|
+
int(row[4]),
|
|
206
|
+
int(row[5]),
|
|
207
|
+
int(row[6]),
|
|
208
|
+
i,
|
|
209
|
+
)
|
|
210
|
+
for i, row in enumerate(labels_values)
|
|
211
|
+
]
|
|
212
|
+
return torch.tensor(
|
|
213
|
+
[i[-1] for i in sort_list_8(data, reverse=reverse)],
|
|
214
|
+
dtype=torch.int64,
|
|
215
|
+
device=labels_values.device,
|
|
216
|
+
)
|
|
217
|
+
if labels_values.shape[1] == 8:
|
|
218
|
+
data = [
|
|
219
|
+
(
|
|
220
|
+
int(row[0]),
|
|
221
|
+
int(row[1]),
|
|
222
|
+
int(row[2]),
|
|
223
|
+
int(row[3]),
|
|
224
|
+
int(row[4]),
|
|
225
|
+
int(row[5]),
|
|
226
|
+
int(row[6]),
|
|
227
|
+
int(row[7]),
|
|
228
|
+
i,
|
|
229
|
+
)
|
|
230
|
+
for i, row in enumerate(labels_values)
|
|
231
|
+
]
|
|
232
|
+
return torch.tensor(
|
|
233
|
+
[i[-1] for i in sort_list_9(data, reverse=reverse)],
|
|
234
|
+
dtype=torch.int64,
|
|
235
|
+
device=labels_values.device,
|
|
236
|
+
)
|
|
237
|
+
if labels_values.shape[1] == 9:
|
|
238
|
+
data = [
|
|
239
|
+
(
|
|
240
|
+
int(row[0]),
|
|
241
|
+
int(row[1]),
|
|
242
|
+
int(row[2]),
|
|
243
|
+
int(row[3]),
|
|
244
|
+
int(row[4]),
|
|
245
|
+
int(row[5]),
|
|
246
|
+
int(row[6]),
|
|
247
|
+
int(row[7]),
|
|
248
|
+
int(row[8]),
|
|
249
|
+
i,
|
|
250
|
+
)
|
|
251
|
+
for i, row in enumerate(labels_values)
|
|
252
|
+
]
|
|
253
|
+
return torch.tensor(
|
|
254
|
+
[i[-1] for i in sort_list_10(data, reverse=reverse)],
|
|
255
|
+
dtype=torch.int64,
|
|
256
|
+
device=labels_values.device,
|
|
257
|
+
)
|
|
258
|
+
else:
|
|
259
|
+
raise Exception("labels_values.shape[1]> 9 is not supported")
|
|
134
260
|
elif isinstance(labels_values, np.ndarray):
|
|
135
261
|
# Index is appended at the end to get the indices corresponding to the
|
|
136
262
|
# sorted values. Because we append the indices at the end and since metadata
|
|
@@ -518,12 +644,15 @@ def sign(array):
|
|
|
518
644
|
"""
|
|
519
645
|
Returns an indication of the sign of the elements in the array.
|
|
520
646
|
|
|
521
|
-
It is equivalent of np.sign(array) and torch.
|
|
647
|
+
It is equivalent of np.sign(array) (as defined in v2.0) and torch.sgn(tensor)
|
|
522
648
|
"""
|
|
523
649
|
if isinstance(array, TorchTensor):
|
|
524
|
-
return torch.
|
|
650
|
+
return torch.sgn(array)
|
|
525
651
|
elif isinstance(array, np.ndarray):
|
|
526
|
-
|
|
652
|
+
if np.issubdtype(array.dtype, np.complexfloating):
|
|
653
|
+
return array / np.abs(array)
|
|
654
|
+
else:
|
|
655
|
+
return np.sign(array)
|
|
527
656
|
else:
|
|
528
657
|
raise TypeError(UNKNOWN_ARRAY_TYPE)
|
|
529
658
|
|
|
@@ -753,3 +882,104 @@ def zeros_like(array, shape: Optional[List[int]] = None, requires_grad: bool = F
|
|
|
753
882
|
return np.zeros_like(array, shape=shape, subok=False)
|
|
754
883
|
else:
|
|
755
884
|
raise TypeError(UNKNOWN_ARRAY_TYPE)
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
@torch_jit_script
|
|
888
|
+
def sort_list_2(
|
|
889
|
+
data: List[Tuple[int, int]], reverse: bool = False
|
|
890
|
+
) -> List[Tuple[int, int]]:
|
|
891
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
892
|
+
if reverse:
|
|
893
|
+
return list(sorted(data))[::-1]
|
|
894
|
+
else:
|
|
895
|
+
return list(sorted(data))
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
@torch_jit_script
|
|
899
|
+
def sort_list_3(
|
|
900
|
+
data: List[Tuple[int, int, int]], reverse: bool = False
|
|
901
|
+
) -> List[Tuple[int, int, int]]:
|
|
902
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
903
|
+
if reverse:
|
|
904
|
+
return list(sorted(data))[::-1]
|
|
905
|
+
else:
|
|
906
|
+
return list(sorted(data))
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
@torch_jit_script
|
|
910
|
+
def sort_list_4(
|
|
911
|
+
data: List[Tuple[int, int, int, int]], reverse: bool = False
|
|
912
|
+
) -> List[Tuple[int, int, int, int]]:
|
|
913
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
914
|
+
if reverse:
|
|
915
|
+
return list(sorted(data))[::-1]
|
|
916
|
+
else:
|
|
917
|
+
return list(sorted(data))
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
@torch_jit_script
|
|
921
|
+
def sort_list_5(
|
|
922
|
+
data: List[Tuple[int, int, int, int, int]], reverse: bool = False
|
|
923
|
+
) -> List[Tuple[int, int, int, int, int]]:
|
|
924
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
925
|
+
if reverse:
|
|
926
|
+
return list(sorted(data))[::-1]
|
|
927
|
+
else:
|
|
928
|
+
return list(sorted(data))
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
@torch_jit_script
|
|
932
|
+
def sort_list_6(
|
|
933
|
+
data: List[Tuple[int, int, int, int, int, int]], reverse: bool = False
|
|
934
|
+
) -> List[Tuple[int, int, int, int, int, int]]:
|
|
935
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
936
|
+
if reverse:
|
|
937
|
+
return list(sorted(data))[::-1]
|
|
938
|
+
else:
|
|
939
|
+
return list(sorted(data))
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
@torch_jit_script
|
|
943
|
+
def sort_list_7(
|
|
944
|
+
data: List[Tuple[int, int, int, int, int, int, int]], reverse: bool = False
|
|
945
|
+
) -> List[Tuple[int, int, int, int, int, int, int]]:
|
|
946
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
947
|
+
if reverse:
|
|
948
|
+
return list(sorted(data))[::-1]
|
|
949
|
+
else:
|
|
950
|
+
return list(sorted(data))
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
@torch_jit_script
|
|
954
|
+
def sort_list_8(
|
|
955
|
+
data: List[Tuple[int, int, int, int, int, int, int, int]], reverse: bool = False
|
|
956
|
+
) -> List[Tuple[int, int, int, int, int, int, int, int]]:
|
|
957
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
958
|
+
if reverse:
|
|
959
|
+
return list(sorted(data))[::-1]
|
|
960
|
+
else:
|
|
961
|
+
return list(sorted(data))
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
@torch_jit_script
|
|
965
|
+
def sort_list_9(
|
|
966
|
+
data: List[Tuple[int, int, int, int, int, int, int, int, int]],
|
|
967
|
+
reverse: bool = False,
|
|
968
|
+
) -> List[Tuple[int, int, int, int, int, int, int, int, int]]:
|
|
969
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
970
|
+
if reverse:
|
|
971
|
+
return list(sorted(data))[::-1]
|
|
972
|
+
else:
|
|
973
|
+
return list(sorted(data))
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
@torch_jit_script
|
|
977
|
+
def sort_list_10(
|
|
978
|
+
data: List[Tuple[int, int, int, int, int, int, int, int, int, int]],
|
|
979
|
+
reverse: bool = False,
|
|
980
|
+
) -> List[Tuple[int, int, int, int, int, int, int, int, int, int]]:
|
|
981
|
+
# Using the `reverse` flag of sorted does not work with TorchScript
|
|
982
|
+
if reverse:
|
|
983
|
+
return list(sorted(data))[::-1]
|
|
984
|
+
else:
|
|
985
|
+
return list(sorted(data))
|
|
@@ -153,6 +153,7 @@ def _reduce_over_samples_block(
|
|
|
153
153
|
new_samples, index = _dispatch.unique_with_inverse(
|
|
154
154
|
block_samples.values[:, sample_selected], axis=0
|
|
155
155
|
)
|
|
156
|
+
index = index.reshape(-1)
|
|
156
157
|
|
|
157
158
|
block_values = block.values
|
|
158
159
|
other_shape = block_values.shape[1:]
|
|
@@ -246,6 +247,7 @@ def _reduce_over_samples_block(
|
|
|
246
247
|
new_gradient_samples, index_gradient = _dispatch.unique_with_inverse(
|
|
247
248
|
samples[:, :], axis=0
|
|
248
249
|
)
|
|
250
|
+
index_gradient = index_gradient.reshape(-1)
|
|
249
251
|
|
|
250
252
|
gradient_values = gradient.values
|
|
251
253
|
other_shape = gradient_values.shape[1:]
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2/metatensor_operations.egg-info}/PKG-INFO
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: metatensor-operations
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Operations to manipulate metatensor data types
|
|
5
5
|
Author: Guillaume Fraux, Davide Tisi, Philip Loche, Joseph W. Abbott, Jigyasa Nigam, Chiheb Ben Mahmoud
|
|
6
6
|
License: BSD-3-Clause
|
|
7
|
-
Project-URL: homepage, https://
|
|
8
|
-
Project-URL: documentation, https://
|
|
7
|
+
Project-URL: homepage, https://docs.metatensor.org/latest/
|
|
8
|
+
Project-URL: documentation, https://docs.metatensor.org/latest/
|
|
9
9
|
Project-URL: repository, https://github.com/lab-cosmo/metatensor
|
|
10
|
-
Project-URL: changelog, https://
|
|
10
|
+
Project-URL: changelog, https://docs.metatensor.org/latest/operations/CHANGELOG.html
|
|
11
11
|
Keywords: machine learning,molecular modeling
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -7,13 +7,13 @@ pyproject.toml
|
|
|
7
7
|
setup.py
|
|
8
8
|
metatensor/operations/__init__.py
|
|
9
9
|
metatensor/operations/_backend.py
|
|
10
|
+
metatensor/operations/_checks.py
|
|
10
11
|
metatensor/operations/_dispatch.py
|
|
11
12
|
metatensor/operations/_utils.py
|
|
12
13
|
metatensor/operations/abs.py
|
|
13
14
|
metatensor/operations/add.py
|
|
14
15
|
metatensor/operations/allclose.py
|
|
15
16
|
metatensor/operations/block_from_array.py
|
|
16
|
-
metatensor/operations/checks.py
|
|
17
17
|
metatensor/operations/detach.py
|
|
18
18
|
metatensor/operations/divide.py
|
|
19
19
|
metatensor/operations/dot.py
|
|
@@ -26,10 +26,10 @@ classifiers = [
|
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
29
|
-
homepage = "https://
|
|
30
|
-
documentation = "https://
|
|
29
|
+
homepage = "https://docs.metatensor.org/latest/"
|
|
30
|
+
documentation = "https://docs.metatensor.org/latest/"
|
|
31
31
|
repository = "https://github.com/lab-cosmo/metatensor"
|
|
32
|
-
changelog = "https://
|
|
32
|
+
changelog = "https://docs.metatensor.org/latest/operations/CHANGELOG.html"
|
|
33
33
|
|
|
34
34
|
### ======================================================================== ###
|
|
35
35
|
[build-system]
|
|
@@ -12,7 +12,7 @@ from setuptools.command.sdist import sdist
|
|
|
12
12
|
ROOT = os.path.realpath(os.path.dirname(__file__))
|
|
13
13
|
METATENSOR_CORE = os.path.realpath(os.path.join(ROOT, "..", "metatensor-core"))
|
|
14
14
|
|
|
15
|
-
METATENSOR_OPERATIONS_VERSION = "0.2.
|
|
15
|
+
METATENSOR_OPERATIONS_VERSION = "0.2.2"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class bdist_egg_disabled(bdist_egg):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/_backend.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/allclose.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/drop_blocks.py
RENAMED
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/empty_like.py
RENAMED
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/equal_metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/multiply.py
RENAMED
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/one_hot.py
RENAMED
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/ones_like.py
RENAMED
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/random_like.py
RENAMED
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/requires_grad.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/subtract.py
RENAMED
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/unique_metadata.py
RENAMED
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor/operations/zeros_like.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor-operations-0.2.1 → metatensor_operations-0.2.2}/metatensor_operations.egg-info/zip-safe
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|