metatensor-operations 0.3.2__tar.gz → 0.3.3__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.
Files changed (56) hide show
  1. {metatensor_operations-0.3.2/metatensor_operations.egg-info → metatensor_operations-0.3.3}/PKG-INFO +5 -5
  2. metatensor_operations-0.3.3/git_version_info +2 -0
  3. metatensor_operations-0.3.3/metatensor/operations/__init__.py +75 -0
  4. metatensor_operations-0.3.2/metatensor/operations/abs.py → metatensor_operations-0.3.3/metatensor/operations/_abs.py +1 -6
  5. metatensor_operations-0.3.2/metatensor/operations/add.py → metatensor_operations-0.3.3/metatensor/operations/_add.py +3 -3
  6. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor/operations/_backend.py +20 -22
  7. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor/operations/_dispatch.py +2 -32
  8. metatensor_operations-0.3.2/metatensor/operations/divide.py → metatensor_operations-0.3.3/metatensor/operations/_divide.py +6 -9
  9. metatensor_operations-0.3.2/metatensor/operations/drop_blocks.py → metatensor_operations-0.3.3/metatensor/operations/_drop_blocks.py +3 -3
  10. metatensor_operations-0.3.2/metatensor/operations/equal_metadata.py → metatensor_operations-0.3.3/metatensor/operations/_equal_metadata.py +5 -9
  11. metatensor_operations-0.3.2/metatensor/operations/filter_blocks.py → metatensor_operations-0.3.3/metatensor/operations/_filter_blocks.py +4 -7
  12. metatensor_operations-0.3.2/metatensor/operations/join.py → metatensor_operations-0.3.3/metatensor/operations/_join.py +3 -3
  13. metatensor_operations-0.3.2/metatensor/operations/manipulate_dimension.py → metatensor_operations-0.3.3/metatensor/operations/_manipulate_dimension.py +0 -18
  14. metatensor_operations-0.3.2/metatensor/operations/multiply.py → metatensor_operations-0.3.3/metatensor/operations/_multiply.py +5 -8
  15. metatensor_operations-0.3.2/metatensor/operations/one_hot.py → metatensor_operations-0.3.3/metatensor/operations/_one_hot.py +1 -3
  16. metatensor_operations-0.3.2/metatensor/operations/pow.py → metatensor_operations-0.3.3/metatensor/operations/_pow.py +5 -6
  17. metatensor_operations-0.3.2/metatensor/operations/reduce_over_samples.py → metatensor_operations-0.3.3/metatensor/operations/_reduce_over_samples.py +29 -70
  18. metatensor_operations-0.3.2/metatensor/operations/slice.py → metatensor_operations-0.3.3/metatensor/operations/_slice.py +7 -7
  19. metatensor_operations-0.3.2/metatensor/operations/sort.py → metatensor_operations-0.3.3/metatensor/operations/_sort.py +2 -4
  20. metatensor_operations-0.3.2/metatensor/operations/split.py → metatensor_operations-0.3.3/metatensor/operations/_split.py +4 -4
  21. metatensor_operations-0.3.2/metatensor/operations/subtract.py → metatensor_operations-0.3.3/metatensor/operations/_subtract.py +5 -5
  22. metatensor_operations-0.3.2/metatensor/operations/unique_metadata.py → metatensor_operations-0.3.3/metatensor/operations/_unique_metadata.py +3 -7
  23. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3/metatensor_operations.egg-info}/PKG-INFO +5 -5
  24. metatensor_operations-0.3.3/metatensor_operations.egg-info/SOURCES.txt +50 -0
  25. metatensor_operations-0.3.3/metatensor_operations.egg-info/requires.txt +1 -0
  26. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/pyproject.toml +2 -3
  27. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/setup.py +2 -2
  28. metatensor_operations-0.3.2/git_version_info +0 -2
  29. metatensor_operations-0.3.2/metatensor/operations/__init__.py +0 -72
  30. metatensor_operations-0.3.2/metatensor_operations.egg-info/SOURCES.txt +0 -50
  31. metatensor_operations-0.3.2/metatensor_operations.egg-info/requires.txt +0 -1
  32. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/AUTHORS +0 -0
  33. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/LICENSE +0 -0
  34. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/MANIFEST.in +0 -0
  35. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/README.rst +0 -0
  36. /metatensor_operations-0.3.2/metatensor/operations/allclose.py → /metatensor_operations-0.3.3/metatensor/operations/_allclose.py +0 -0
  37. /metatensor_operations-0.3.2/metatensor/operations/block_from_array.py → /metatensor_operations-0.3.3/metatensor/operations/_block_from_array.py +0 -0
  38. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor/operations/_checks.py +0 -0
  39. /metatensor_operations-0.3.2/metatensor/operations/detach.py → /metatensor_operations-0.3.3/metatensor/operations/_detach.py +0 -0
  40. /metatensor_operations-0.3.2/metatensor/operations/dot.py → /metatensor_operations-0.3.3/metatensor/operations/_dot.py +0 -0
  41. /metatensor_operations-0.3.2/metatensor/operations/empty_like.py → /metatensor_operations-0.3.3/metatensor/operations/_empty_like.py +0 -0
  42. /metatensor_operations-0.3.2/metatensor/operations/equal.py → /metatensor_operations-0.3.3/metatensor/operations/_equal.py +0 -0
  43. /metatensor_operations-0.3.2/metatensor/operations/is_contiguous.py → /metatensor_operations-0.3.3/metatensor/operations/_is_contiguous.py +0 -0
  44. /metatensor_operations-0.3.2/metatensor/operations/lstsq.py → /metatensor_operations-0.3.3/metatensor/operations/_lstsq.py +0 -0
  45. /metatensor_operations-0.3.2/metatensor/operations/make_contiguous.py → /metatensor_operations-0.3.3/metatensor/operations/_make_contiguous.py +0 -0
  46. /metatensor_operations-0.3.2/metatensor/operations/ones_like.py → /metatensor_operations-0.3.3/metatensor/operations/_ones_like.py +0 -0
  47. /metatensor_operations-0.3.2/metatensor/operations/random_like.py → /metatensor_operations-0.3.3/metatensor/operations/_random_like.py +0 -0
  48. /metatensor_operations-0.3.2/metatensor/operations/remove_gradients.py → /metatensor_operations-0.3.3/metatensor/operations/_remove_gradients.py +0 -0
  49. /metatensor_operations-0.3.2/metatensor/operations/requires_grad.py → /metatensor_operations-0.3.3/metatensor/operations/_requires_grad.py +0 -0
  50. /metatensor_operations-0.3.2/metatensor/operations/solve.py → /metatensor_operations-0.3.3/metatensor/operations/_solve.py +0 -0
  51. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor/operations/_utils.py +0 -0
  52. /metatensor_operations-0.3.2/metatensor/operations/zeros_like.py → /metatensor_operations-0.3.3/metatensor/operations/_zeros_like.py +0 -0
  53. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor_operations.egg-info/dependency_links.txt +0 -0
  54. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor_operations.egg-info/top_level.txt +0 -0
  55. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/metatensor_operations.egg-info/zip-safe +0 -0
  56. {metatensor_operations-0.3.2 → metatensor_operations-0.3.3}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: metatensor-operations
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Operations to manipulate metatensor data types
5
5
  Author: Guillaume Fraux, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
6
- License: BSD-3-Clause
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: homepage, https://docs.metatensor.org/latest/
8
8
  Project-URL: documentation, https://docs.metatensor.org/latest/
9
9
  Project-URL: repository, https://github.com/metatensor/metatensor
@@ -11,7 +11,6 @@ Project-URL: changelog, https://docs.metatensor.org/latest/operations/CHANGELOG.
11
11
  Keywords: machine learning,molecular modeling
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Science/Research
14
- Classifier: License :: OSI Approved :: BSD License
15
14
  Classifier: Operating System :: POSIX
16
15
  Classifier: Operating System :: MacOS :: MacOS X
17
16
  Classifier: Operating System :: Microsoft :: Windows
@@ -27,8 +26,9 @@ Requires-Python: >=3.9
27
26
  Description-Content-Type: text/x-rst
28
27
  License-File: LICENSE
29
28
  License-File: AUTHORS
30
- Requires-Dist: metatensor-core<0.2.0,>=0.1.10
29
+ Requires-Dist: metatensor-core<0.2.0,>=0.1.13
31
30
  Dynamic: author
31
+ Dynamic: license-file
32
32
  Dynamic: requires-dist
33
33
 
34
34
  metatensor-operations
@@ -0,0 +1,2 @@
1
+ 0
2
+ git.e07dfb1
@@ -0,0 +1,75 @@
1
+ import importlib.metadata
2
+
3
+
4
+ __version__ = importlib.metadata.version("metatensor-operations")
5
+
6
+
7
+ from ._abs import abs # noqa: F401
8
+ from ._add import add # noqa: F401
9
+ from ._allclose import ( # noqa: F401
10
+ allclose,
11
+ allclose_block,
12
+ allclose_block_raise,
13
+ allclose_raise,
14
+ )
15
+ from ._block_from_array import block_from_array # noqa: F401
16
+ from ._checks import ( # noqa: F401
17
+ checks_enabled,
18
+ unsafe_disable_checks,
19
+ unsafe_enable_checks,
20
+ )
21
+ from ._detach import detach, detach_block # noqa: F401
22
+ from ._divide import divide # noqa: F401
23
+ from ._dot import dot # noqa: F401
24
+ from ._drop_blocks import drop_blocks # noqa: F401
25
+ from ._empty_like import empty_like, empty_like_block # noqa: F401
26
+ from ._equal import equal, equal_block, equal_block_raise, equal_raise # noqa: F401
27
+ from ._equal_metadata import ( # noqa: F401
28
+ equal_metadata,
29
+ equal_metadata_block,
30
+ equal_metadata_block_raise,
31
+ equal_metadata_raise,
32
+ )
33
+ from ._filter_blocks import filter_blocks # noqa: F401
34
+ from ._is_contiguous import ( # noqa: F401
35
+ is_contiguous,
36
+ is_contiguous_block,
37
+ )
38
+ from ._join import join # noqa: F401
39
+ from ._lstsq import lstsq # noqa: F401
40
+ from ._make_contiguous import ( # noqa: F401
41
+ make_contiguous,
42
+ make_contiguous_block,
43
+ )
44
+ from ._manipulate_dimension import ( # noqa: F401
45
+ append_dimension,
46
+ insert_dimension,
47
+ permute_dimensions,
48
+ remove_dimension,
49
+ rename_dimension,
50
+ )
51
+ from ._multiply import multiply # noqa: F401
52
+ from ._one_hot import one_hot # noqa: F401
53
+ from ._ones_like import ones_like, ones_like_block # noqa: F401
54
+ from ._pow import pow # noqa: F401
55
+ from ._random_like import random_uniform_like, random_uniform_like_block # noqa: F401
56
+ from ._reduce_over_samples import ( # noqa: F401
57
+ mean_over_samples,
58
+ mean_over_samples_block,
59
+ std_over_samples,
60
+ std_over_samples_block,
61
+ sum_over_samples,
62
+ sum_over_samples_block,
63
+ var_over_samples,
64
+ var_over_samples_block,
65
+ )
66
+ from ._remove_gradients import remove_gradients, remove_gradients_block # noqa: F401
67
+ from ._requires_grad import requires_grad, requires_grad_block # noqa: F401
68
+ from ._slice import slice, slice_block # noqa: F401
69
+ from ._solve import solve # noqa: F401
70
+ from ._sort import sort, sort_block # noqa: F401
71
+ from ._split import split, split_block # noqa: F401
72
+ from ._subtract import subtract # noqa: F401
73
+ from ._unique_metadata import unique_metadata, unique_metadata_block # noqa: F401
74
+ from ._utils import NotEqualError # noqa: F401
75
+ from ._zeros_like import zeros_like, zeros_like_block # noqa: F401
@@ -1,8 +1,3 @@
1
- """
2
- Module to find the absolute values of a :py:class:`TensorMap`, returning a new
3
- :py:class:`TensorMap`.
4
- """
5
-
6
1
  from typing import List
7
2
 
8
3
  from . import _dispatch
@@ -40,7 +35,7 @@ def _abs_block(block: TensorBlock) -> TensorBlock:
40
35
  # The sign_values have the same dimensions as that of the block.values.
41
36
  # Reshape the sign_values to allow multiplication with gradient.values
42
37
  new_grad = gradient.values[:] * sign_values[
43
- _dispatch.to_index_array(gradient.samples.column("sample"))
38
+ gradient.samples.column("sample")
44
39
  ].reshape([-1] + [1] * diff_components + _shape)
45
40
 
46
41
  gradient = TensorBlock(
@@ -3,7 +3,7 @@ from typing import List, Union
3
3
  from ._backend import (
4
4
  TensorBlock,
5
5
  TensorMap,
6
- is_metatensor_class,
6
+ isinstance_metatensor,
7
7
  torch_jit_is_scripting,
8
8
  torch_jit_script,
9
9
  )
@@ -104,14 +104,14 @@ def add(A: TensorMap, B: Union[int, float, TensorMap]) -> TensorMap:
104
104
  """
105
105
 
106
106
  if not torch_jit_is_scripting():
107
- if not is_metatensor_class(A, TensorMap):
107
+ if not isinstance_metatensor(A, "TensorMap"):
108
108
  raise TypeError(f"`A` must be a metatensor TensorMap, not {type(A)}")
109
109
 
110
110
  blocks: List[TensorBlock] = []
111
111
  if torch_jit_is_scripting():
112
112
  is_tensor_map = isinstance(B, TensorMap)
113
113
  else:
114
- is_tensor_map = is_metatensor_class(B, TensorMap)
114
+ is_tensor_map = isinstance_metatensor(B, "TensorMap")
115
115
 
116
116
  if isinstance(B, (float, int)):
117
117
  B = float(B)
@@ -68,27 +68,25 @@ def _version_at_least(version, expected):
68
68
  return version >= expected
69
69
 
70
70
 
71
- def is_metatensor_class(value, typ):
72
- assert typ in (Labels, TensorBlock, TensorMap)
73
-
74
- if isinstance(value, typ):
75
- return True
71
+ def isinstance_metatensor(value, typename):
72
+ assert typename in ("Labels", "TensorBlock", "TensorMap")
73
+
74
+ if _HAS_TORCH and isinstance(value, torch.ScriptObject):
75
+ is_metatensor_torch_class = "metatensor" in str(value._type())
76
+ if is_metatensor_torch_class:
77
+ warnings.warn(
78
+ "Trying to use operations from metatensor with objects from "
79
+ "metatensor-torch, you should use the operation from "
80
+ "`metatensor.torch` as well, e.g. `metatensor.torch.add(...)` "
81
+ "instead of `metatensor.add(...)`",
82
+ stacklevel=2,
83
+ )
84
+
85
+ if typename == "Labels":
86
+ return isinstance(value, Labels)
87
+ elif typename == "TensorBlock":
88
+ return isinstance(value, TensorBlock)
89
+ elif typename == "TensorMap":
90
+ return isinstance(value, TensorMap)
76
91
  else:
77
- if _HAS_TORCH and isinstance(value, torch.ScriptObject):
78
- if _version_at_least(torch.__version__, "2.1.0"):
79
- # _type() is only working for torch >= 2.1
80
- is_metatensor_torch_class = "metatensor" in str(value._type())
81
- else:
82
- # we don't know, it's fine
83
- is_metatensor_torch_class = False
84
-
85
- if is_metatensor_torch_class:
86
- warnings.warn(
87
- "Trying to use operations from metatensor with objects from "
88
- "metatensor-torch, you should use the operation from "
89
- "`metatensor.torch` as well, e.g. `metatensor.torch.add(...)` "
90
- "instead of `metatensor.add(...)`",
91
- stacklevel=2,
92
- )
93
-
94
92
  return False
@@ -21,7 +21,6 @@ try:
21
21
 
22
22
  torch_dtype = torch.dtype
23
23
  torch_device = torch.device
24
- torch_version = parse_version(torch.__version__)
25
24
 
26
25
  except ImportError:
27
26
 
@@ -34,8 +33,6 @@ except ImportError:
34
33
  class torch_device:
35
34
  pass
36
35
 
37
- torch_version = (0, 0, 0)
38
-
39
36
 
40
37
  UNKNOWN_ARRAY_TYPE = (
41
38
  "unknown array type, only numpy arrays and torch tensors are supported"
@@ -490,7 +487,7 @@ def index_add(output_array, input_array, index):
490
487
  output_array.index_add_(0, torch.tensor(index),input_array)
491
488
 
492
489
  """
493
- index = to_index_array(index)
490
+ _index_array_checks(index)
494
491
  if isinstance(input_array, TorchTensor):
495
492
  if not isinstance(index, TorchTensor):
496
493
  index = torch.tensor(index).to(device=input_array.device)
@@ -860,7 +857,7 @@ def to(
860
857
  raise TypeError(UNKNOWN_ARRAY_TYPE)
861
858
 
862
859
 
863
- def _to_index_array_checks(array):
860
+ def _index_array_checks(array):
864
861
  if len(array.shape) != 1:
865
862
  raise ValueError("Index arrays must be 1D")
866
863
 
@@ -874,33 +871,6 @@ def _to_index_array_checks(array):
874
871
  raise TypeError(UNKNOWN_ARRAY_TYPE)
875
872
 
876
873
 
877
- if torch_version >= (2, 0, 0):
878
-
879
- def to_index_array(array):
880
- """
881
- Returns an array that is suitable for indexing a dimension of
882
- a different array.
883
- """
884
- _to_index_array_checks(array)
885
- return array
886
-
887
- else:
888
-
889
- def to_index_array(array):
890
- """
891
- Returns an array that is suitable for indexing a dimension of
892
- a different array, converting torch data to long/64-bit integers
893
- """
894
- _to_index_array_checks(array)
895
-
896
- if isinstance(array, TorchTensor):
897
- return array.to(torch.long)
898
- elif isinstance(array, np.ndarray):
899
- return array
900
- else:
901
- raise TypeError(UNKNOWN_ARRAY_TYPE)
902
-
903
-
904
874
  def unique(array, axis: Optional[int] = None):
905
875
  """Find the unique elements of an array."""
906
876
  if isinstance(array, TorchTensor):
@@ -1,10 +1,9 @@
1
1
  from typing import List, Union
2
2
 
3
- from . import _dispatch
4
3
  from ._backend import (
5
4
  TensorBlock,
6
5
  TensorMap,
7
- is_metatensor_class,
6
+ isinstance_metatensor,
8
7
  torch_jit_is_scripting,
9
8
  torch_jit_script,
10
9
  )
@@ -75,16 +74,14 @@ def _divide_block_block(block_1: TensorBlock, block_2: TensorBlock) -> TensorBlo
75
74
 
76
75
  gradient_samples_to_values_samples_1 = gradient_1.samples.column("sample")
77
76
  gradient_samples_to_values_samples_2 = gradient_2.samples.column("sample")
78
- gradient_values = -block_1.values[
79
- _dispatch.to_index_array(gradient_samples_to_values_samples_1)
80
- ].reshape(
77
+ gradient_values = -block_1.values[gradient_samples_to_values_samples_1].reshape(
81
78
  [-1] + [1] * diff_components + _shape
82
79
  ) * gradient_2.values / block_2.values[
83
- _dispatch.to_index_array(gradient_samples_to_values_samples_2)
80
+ gradient_samples_to_values_samples_2
84
81
  ].reshape(
85
82
  [-1] + [1] * diff_components + _shape
86
83
  ) ** 2 + gradient_1.values / block_2.values[
87
- _dispatch.to_index_array(gradient_samples_to_values_samples_2)
84
+ gradient_samples_to_values_samples_2
88
85
  ].reshape([-1] + [1] * diff_components + _shape)
89
86
 
90
87
  result_block.add_gradient(
@@ -103,7 +100,7 @@ def _divide_block_block(block_1: TensorBlock, block_2: TensorBlock) -> TensorBlo
103
100
  @torch_jit_script
104
101
  def divide(A: TensorMap, B: Union[float, int, TensorMap]) -> TensorMap:
105
102
  if not torch_jit_is_scripting():
106
- if not is_metatensor_class(A, TensorMap):
103
+ if not isinstance_metatensor(A, "TensorMap"):
107
104
  raise TypeError(f"`A` must be a metatensor TensorMap, not {type(A)}")
108
105
 
109
106
  r"""Return a new :class:`TensorMap` with the values being the element-wise
@@ -136,7 +133,7 @@ def divide(A: TensorMap, B: Union[float, int, TensorMap]) -> TensorMap:
136
133
  if torch_jit_is_scripting():
137
134
  is_tensor_map = isinstance(B, TensorMap)
138
135
  else:
139
- is_tensor_map = is_metatensor_class(B, TensorMap)
136
+ is_tensor_map = isinstance_metatensor(B, "TensorMap")
140
137
 
141
138
  if isinstance(B, (float, int)):
142
139
  B = float(B)
@@ -5,7 +5,7 @@ from ._backend import (
5
5
  Labels,
6
6
  TensorBlock,
7
7
  TensorMap,
8
- is_metatensor_class,
8
+ isinstance_metatensor,
9
9
  torch_jit_is_scripting,
10
10
  torch_jit_script,
11
11
  )
@@ -29,12 +29,12 @@ def drop_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) -> TensorMa
29
29
  """
30
30
  # Check arg types
31
31
  if not torch_jit_is_scripting():
32
- if not is_metatensor_class(tensor, TensorMap):
32
+ if not isinstance_metatensor(tensor, "TensorMap"):
33
33
  raise TypeError(
34
34
  f"`tensor` must be a metatensor TensorMap, not {type(tensor)}"
35
35
  )
36
36
 
37
- if not is_metatensor_class(keys, Labels):
37
+ if not isinstance_metatensor(keys, "Labels"):
38
38
  raise TypeError(f"`keys` must be a metatensor Labels, not {type(keys)}")
39
39
 
40
40
  if not isinstance(copy, bool):
@@ -1,13 +1,9 @@
1
- """
2
- Module for checking equivalence in metadata between 2 TensorMaps
3
- """
4
-
5
1
  from typing import List, Union
6
2
 
7
3
  from ._backend import (
8
4
  TensorBlock,
9
5
  TensorMap,
10
- is_metatensor_class,
6
+ isinstance_metatensor,
11
7
  torch_jit_is_scripting,
12
8
  torch_jit_script,
13
9
  )
@@ -25,9 +21,9 @@ def _equal_metadata_impl(
25
21
  check: Union[List[str], str] = "all",
26
22
  ) -> str:
27
23
  if not torch_jit_is_scripting():
28
- if not is_metatensor_class(tensor_1, TensorMap):
24
+ if not isinstance_metatensor(tensor_1, "TensorMap"):
29
25
  return f"`tensor_1` must be a metatensor TensorMap, not {type(tensor_1)}"
30
- if not is_metatensor_class(tensor_2, TensorMap):
26
+ if not isinstance_metatensor(tensor_2, "TensorMap"):
31
27
  return f"`tensor_2` must be a metatensor TensorMap, not {type(tensor_2)}"
32
28
 
33
29
  message = _check_same_keys_impl(tensor_1, tensor_2, "equal_metadata_raise")
@@ -48,9 +44,9 @@ def _equal_metadata_block_impl(
48
44
  check: Union[List[str], str] = "all",
49
45
  ) -> str:
50
46
  if not torch_jit_is_scripting():
51
- if not is_metatensor_class(block_1, TensorBlock):
47
+ if not isinstance_metatensor(block_1, "TensorBlock"):
52
48
  return f"`block_1` must be a metatensor TensorBlock, not {type(block_1)}"
53
- if not is_metatensor_class(block_2, TensorBlock):
49
+ if not isinstance_metatensor(block_2, "TensorBlock"):
54
50
  return f"`block_2` must be a metatensor TensorBlock, not {type(block_2)}"
55
51
 
56
52
  check_blocks_message = _check_blocks_impl(
@@ -5,7 +5,7 @@ from ._backend import (
5
5
  Labels,
6
6
  TensorBlock,
7
7
  TensorMap,
8
- is_metatensor_class,
8
+ isinstance_metatensor,
9
9
  torch_jit_is_scripting,
10
10
  torch_jit_script,
11
11
  )
@@ -29,12 +29,12 @@ def filter_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) -> Tensor
29
29
  """
30
30
  # Check arg types
31
31
  if not torch_jit_is_scripting():
32
- if not is_metatensor_class(tensor, TensorMap):
32
+ if not isinstance_metatensor(tensor, "TensorMap"):
33
33
  raise TypeError(
34
34
  f"`tensor` must be a metatensor TensorMap, not {type(tensor)}"
35
35
  )
36
36
 
37
- if not is_metatensor_class(keys, Labels):
37
+ if not isinstance_metatensor(keys, "Labels"):
38
38
  raise TypeError(f"`keys` must be a metatensor Labels, not {type(keys)}")
39
39
 
40
40
  if not isinstance(copy, bool):
@@ -46,10 +46,7 @@ def filter_blocks(tensor: TensorMap, keys: Labels, copy: bool = False) -> Tensor
46
46
  # Create the new TensorMap
47
47
  new_blocks: List[TensorBlock] = []
48
48
  new_keys_values = []
49
- for i in range(len(tensor_keys)):
50
- if i not in to_keep_indices:
51
- continue
52
-
49
+ for i in to_keep_indices:
53
50
  new_keys_values.append(tensor_keys.entry(i).values)
54
51
  block = tensor[i]
55
52
 
@@ -5,12 +5,12 @@ from ._backend import (
5
5
  Labels,
6
6
  TensorBlock,
7
7
  TensorMap,
8
- is_metatensor_class,
8
+ isinstance_metatensor,
9
9
  torch_jit_is_scripting,
10
10
  torch_jit_script,
11
11
  )
12
+ from ._manipulate_dimension import remove_dimension
12
13
  from ._utils import _check_same_keys_raise
13
- from .manipulate_dimension import remove_dimension
14
14
 
15
15
 
16
16
  def _disjoint_tensor_labels(tensors: List[TensorMap], axis: str) -> bool:
@@ -353,7 +353,7 @@ def join(
353
353
  raise TypeError(f"`tensor` must be a list or a tuple, not {type(tensors)}")
354
354
 
355
355
  for tensor in tensors:
356
- if not is_metatensor_class(tensor, TensorMap):
356
+ if not isinstance_metatensor(tensor, "TensorMap"):
357
357
  raise TypeError(
358
358
  "`tensors` elements must be metatensor TensorMap, "
359
359
  f"not {type(tensor)}"
@@ -1,21 +1,3 @@
1
- """
2
- Manipulating TensorMap dimensions
3
- =================================
4
-
5
- Functions for manipulating dimensions of an :py:class:`metatensor.TensorMap` (i.e.
6
- changing the columns of the :py:class:`metatensor.Labels` within).
7
-
8
- .. autofunction:: metatensor.append_dimension
9
-
10
- .. autofunction:: metatensor.insert_dimension
11
-
12
- .. autofunction:: metatensor.permute_dimensions
13
-
14
- .. autofunction:: metatensor.remove_dimension
15
-
16
- .. autofunction:: metatensor.rename_dimension
17
- """
18
-
19
1
  from typing import List, Union
20
2
 
21
3
  from . import _dispatch
@@ -1,10 +1,9 @@
1
1
  from typing import List, Union
2
2
 
3
- from . import _dispatch
4
3
  from ._backend import (
5
4
  TensorBlock,
6
5
  TensorMap,
7
- is_metatensor_class,
6
+ isinstance_metatensor,
8
7
  torch_jit_is_scripting,
9
8
  torch_jit_script,
10
9
  )
@@ -75,12 +74,10 @@ def _multiply_block_block(block_1: TensorBlock, block_2: TensorBlock) -> TensorB
75
74
 
76
75
  gradient_samples_to_values_samples_1 = gradient_1.samples.column("sample")
77
76
  gradient_samples_to_values_samples_2 = gradient_2.samples.column("sample")
78
- gradient_values = block_1.values[
79
- _dispatch.to_index_array(gradient_samples_to_values_samples_1)
80
- ].reshape(
77
+ gradient_values = block_1.values[gradient_samples_to_values_samples_1].reshape(
81
78
  [-1] + [1] * diff_components + _shape
82
79
  ) * gradient_2.values + gradient_1.values * block_2.values[
83
- _dispatch.to_index_array(gradient_samples_to_values_samples_2)
80
+ gradient_samples_to_values_samples_2
84
81
  ].reshape([-1] + [1] * diff_components + _shape)
85
82
 
86
83
  result_block.add_gradient(
@@ -124,14 +121,14 @@ def multiply(A: TensorMap, B: Union[float, int, TensorMap]) -> TensorMap:
124
121
  :return: New :py:class:`TensorMap` with the same metadata as ``A``.
125
122
  """
126
123
  if not torch_jit_is_scripting():
127
- if not is_metatensor_class(A, TensorMap):
124
+ if not isinstance_metatensor(A, "TensorMap"):
128
125
  raise TypeError(f"`A` must be a metatensor TensorMap, not {type(A)}")
129
126
 
130
127
  blocks: List[TensorBlock] = []
131
128
  if torch_jit_is_scripting():
132
129
  is_tensor_map = isinstance(B, TensorMap)
133
130
  else:
134
- is_tensor_map = is_metatensor_class(B, TensorMap)
131
+ is_tensor_map = isinstance_metatensor(B, "TensorMap")
135
132
 
136
133
  if isinstance(B, (float, int)):
137
134
  B = float(B)
@@ -72,7 +72,5 @@ def one_hot(labels: Labels, dimension: Labels):
72
72
  )
73
73
  indices[i] = position
74
74
 
75
- one_hot_array = _dispatch.eye_like(dimension.values, len(dimension))[
76
- _dispatch.to_index_array(indices)
77
- ]
75
+ one_hot_array = _dispatch.eye_like(dimension.values, len(dimension))[indices]
78
76
  return one_hot_array
@@ -1,10 +1,9 @@
1
1
  from typing import List, Union
2
2
 
3
- from . import _dispatch
4
3
  from ._backend import (
5
4
  TensorBlock,
6
5
  TensorMap,
7
- is_metatensor_class,
6
+ isinstance_metatensor,
8
7
  torch_jit_is_scripting,
9
8
  torch_jit_script,
10
9
  )
@@ -38,9 +37,9 @@ def _pow_block_constant(block: TensorBlock, constant: float) -> TensorBlock:
38
37
  values_grad = (
39
38
  constant
40
39
  * gradient_values
41
- * block.values[
42
- _dispatch.to_index_array(gradient_samples_to_values_samples)
43
- ].reshape([-1] + [1] * diff_components + _shape)
40
+ * block.values[gradient_samples_to_values_samples].reshape(
41
+ [-1] + [1] * diff_components + _shape
42
+ )
44
43
  ** (constant - 1)
45
44
  )
46
45
 
@@ -77,7 +76,7 @@ def pow(A: TensorMap, B: Union[float, int]) -> TensorMap:
77
76
  :return: New :py:class:`TensorMap` with the same metadata as ``A``.
78
77
  """
79
78
  if not torch_jit_is_scripting():
80
- if not is_metatensor_class(A, TensorMap):
79
+ if not isinstance_metatensor(A, "TensorMap"):
81
80
  raise TypeError(f"`A` must be a metatensor TensorMap, not {type(A)}")
82
81
 
83
82
  if not isinstance(B, (float, int)):
@@ -1,45 +1,3 @@
1
- """
2
- Reduction over samples
3
- ======================
4
-
5
- These functions allow to reduce over the sample indices of a :py:class:`TensorMap` or
6
- :py:class:`TensorBlock` objects, generating a new :py:class:`TensorMap` or
7
- :py:class:`TensorBlock` in which the values sharing the same indices for the indicated
8
- ``sample_names`` have been combined in a single entry. The functions differ by the type
9
- of reduction operation, but otherwise operate in the same way. The reduction operation
10
- loops over the samples in each block/map, and combines all those that only differ by the
11
- values of the indices associated with the names listed in the ``sample_names`` argument.
12
- One way to see these operations is that the sample indices describe the non-zero entries
13
- in a *sparse* array, and the reduction acts much like :func:`numpy.sum`, where
14
- ``sample_names`` plays the same role as the ``axis`` argument. Whenever gradients are
15
- present, the reduction is performed also on the gradients.
16
-
17
- See also :py:func:`metatensor.sum_over_samples_block` and
18
- :py:func:`metatensor.sum_over_samples` for a detailed discussion with examples.
19
-
20
- TensorMap operations
21
- --------------------
22
-
23
- .. autofunction:: metatensor.sum_over_samples
24
-
25
- .. autofunction:: metatensor.mean_over_samples
26
-
27
- .. autofunction:: metatensor.var_over_samples
28
-
29
- .. autofunction:: metatensor.std_over_samples
30
-
31
- TensorBlock operations
32
- ----------------------
33
-
34
- .. autofunction:: metatensor.sum_over_samples_block
35
-
36
- .. autofunction:: metatensor.mean_over_samples_block
37
-
38
- .. autofunction:: metatensor.var_over_samples_block
39
-
40
- .. autofunction:: metatensor.std_over_samples_block
41
- """
42
-
43
1
  from typing import List, Optional, Union
44
2
 
45
3
  import numpy as np
@@ -98,7 +56,7 @@ def _reduce_over_samples_block(
98
56
 
99
57
  assert reduction in ["sum", "mean", "var", "std"]
100
58
  # get the indices of the selected sample
101
- sample_selected = [
59
+ remaining_sample_columns = [
102
60
  block_samples.names.index(sample) for sample in remaining_sample_names
103
61
  ]
104
62
 
@@ -151,48 +109,52 @@ def _reduce_over_samples_block(
151
109
  )
152
110
  else:
153
111
  new_samples, index = _dispatch.unique_with_inverse(
154
- block_samples.values[:, sample_selected], axis=0
112
+ block_samples.values[:, remaining_sample_columns], axis=0
155
113
  )
156
114
  index = index.reshape(-1)
157
115
 
158
116
  block_values = block.values
159
117
  other_shape = block_values.shape[1:]
160
- values_result = _dispatch.zeros_like(
118
+ values_sum = _dispatch.zeros_like(
161
119
  block_values, shape=(new_samples.shape[0],) + other_shape
162
120
  )
163
121
 
164
122
  _dispatch.index_add(
165
- values_result,
123
+ values_sum,
166
124
  block_values,
167
125
  index,
168
126
  )
169
127
 
170
- # define values_mean for torchscript (won't be used unless there are gradients)
171
- values_mean = _dispatch.empty_like(values_result, [0])
128
+ # pre-declare variables that we'll need to use outside of the if block below
129
+ values_mean = _dispatch.empty_like(values_sum, [0])
130
+ values_result = _dispatch.empty_like(values_sum, [0])
172
131
 
173
132
  if reduction == "mean" or reduction == "std" or reduction == "var":
174
- bincount = _dispatch.make_like(_dispatch.bincount(index), values_result)
175
- values_result = values_result / bincount.reshape(
176
- (-1,) + (1,) * len(other_shape)
177
- )
133
+ bincount = _dispatch.make_like(_dispatch.bincount(index), values_sum)
134
+ bincount = bincount.reshape((-1,) + (1,) * len(other_shape))
135
+ values_mean = values_sum / bincount
136
+
178
137
  if reduction == "std" or reduction == "var":
179
- values_result2 = _dispatch.zeros_like(
138
+ values_var = _dispatch.zeros_like(
180
139
  block_values, shape=(new_samples.shape[0],) + other_shape
181
140
  )
141
+
182
142
  _dispatch.index_add(
183
- values_result2,
184
- block_values**2,
143
+ values_var,
144
+ (block_values - values_mean[index]) ** 2,
185
145
  index,
186
146
  )
187
- values_result2 = values_result2 / bincount.reshape(
188
- (-1,) + (1,) * len(other_shape)
189
- )
190
- # I need the mean values in the derivatives
191
- if len(block.gradients_list()) > 0:
192
- values_mean = _dispatch.copy(values_result)
193
- values_result = values_result2 - values_result**2
147
+ values_var = values_var / bincount
148
+
194
149
  if reduction == "std":
195
- values_result = _dispatch.sqrt(values_result)
150
+ values_result = _dispatch.sqrt(values_var)
151
+ elif reduction == "var":
152
+ values_result = values_var
153
+
154
+ elif reduction == "mean":
155
+ values_result = values_mean
156
+ elif reduction == "sum":
157
+ values_result = values_sum
196
158
 
197
159
  # check if the reduce operation reduce all the samples
198
160
  if len(remaining_sample_names) == 0:
@@ -242,7 +204,7 @@ def _reduce_over_samples_block(
242
204
 
243
205
  # change the first columns of the samples array with the mapping
244
206
  # between samples and gradient.samples
245
- samples[:, 0] = index[_dispatch.to_index_array(samples[:, 0])]
207
+ samples[:, 0] = index[samples[:, 0]]
246
208
 
247
209
  new_gradient_samples, index_gradient = _dispatch.unique_with_inverse(
248
210
  samples[:, :], axis=0
@@ -259,9 +221,8 @@ def _reduce_over_samples_block(
259
221
 
260
222
  if reduction == "mean" or reduction == "var" or reduction == "std":
261
223
  bincount = _dispatch.bincount(index_gradient)
262
- gradient_values_result = gradient_values_result / bincount.reshape(
263
- (-1,) + (1,) * len(other_shape)
264
- )
224
+ bincount = bincount.reshape((-1,) + (1,) * len(other_shape))
225
+ gradient_values_result = gradient_values_result / bincount
265
226
  if reduction == "std" or reduction == "var":
266
227
  values_times_gradient_values = _dispatch.zeros_like(gradient_values)
267
228
 
@@ -281,9 +242,7 @@ def _reduce_over_samples_block(
281
242
  index_gradient,
282
243
  )
283
244
 
284
- values_grad_result = values_grad_result / bincount.reshape(
285
- (-1,) + (1,) * len(other_shape)
286
- )
245
+ values_grad_result = values_grad_result / bincount
287
246
  if reduction == "var":
288
247
  for i, s in enumerate(new_gradient_samples):
289
248
  gradient_values_result[i] = (
@@ -6,7 +6,7 @@ from ._backend import (
6
6
  LabelsValues,
7
7
  TensorBlock,
8
8
  TensorMap,
9
- is_metatensor_class,
9
+ isinstance_metatensor,
10
10
  torch_jit_is_scripting,
11
11
  torch_jit_script,
12
12
  )
@@ -26,7 +26,7 @@ def _slice_block(
26
26
  else:
27
27
  if not torch_jit_is_scripting():
28
28
  # This should already have been checked
29
- assert is_metatensor_class(selection, Labels)
29
+ assert isinstance_metatensor(selection, "Labels")
30
30
 
31
31
  if axis == "samples":
32
32
  selected = block.samples.select(selection)
@@ -75,7 +75,7 @@ def _slice_block(
75
75
  sample_column = sample_column.copy()
76
76
 
77
77
  # Create a samples filter for the Gradient TensorBlock
78
- grad_samples_mask = mask[_dispatch.to_index_array(sample_column)]
78
+ grad_samples_mask = mask[sample_column]
79
79
 
80
80
  new_grad_samples_values = _dispatch.mask(
81
81
  gradient.samples.values, 0, grad_samples_mask
@@ -85,7 +85,7 @@ def _slice_block(
85
85
  # update the "sample" column of the gradient samples
86
86
  # to refer to the new samples
87
87
  new_grad_samples_values[:, 0] = sample_map[
88
- _dispatch.to_index_array(new_grad_samples_values[:, 0])
88
+ new_grad_samples_values[:, 0]
89
89
  ]
90
90
 
91
91
  new_grad_samples = Labels(
@@ -168,7 +168,7 @@ def _check_slice_args(
168
168
  raise ValueError("`selection` must be a 1-D array of integers")
169
169
  elif not isinstance(selection, list):
170
170
  if not torch_jit_is_scripting():
171
- if not is_metatensor_class(selection, Labels):
171
+ if not isinstance_metatensor(selection, "Labels"):
172
172
  raise TypeError(
173
173
  "`selection` must be metatensor Labels, an array "
174
174
  + f"or List[int], not {type(selection)}"
@@ -223,7 +223,7 @@ def slice(tensor: TensorMap, axis: str, selection: Labels) -> TensorMap:
223
223
  """
224
224
  # Check input args
225
225
  if not torch_jit_is_scripting():
226
- if not is_metatensor_class(tensor, TensorMap):
226
+ if not isinstance_metatensor(tensor, "TensorMap"):
227
227
  raise TypeError(
228
228
  f"`tensor` must be a metatensor TensorMap, not {type(tensor)}"
229
229
  )
@@ -266,7 +266,7 @@ def slice_block(
266
266
  :return new_block: a :py:class:`TensorBlock` that corresponds to the sliced input.
267
267
  """
268
268
  if not torch_jit_is_scripting():
269
- if not is_metatensor_class(block, TensorBlock):
269
+ if not isinstance_metatensor(block, "TensorBlock"):
270
270
  raise TypeError(
271
271
  f"`block` must be a metatensor TensorBlock, not {type(block)}"
272
272
  )
@@ -9,7 +9,7 @@ from ._backend import (
9
9
  torch_jit_is_scripting,
10
10
  torch_jit_script,
11
11
  )
12
- from .zeros_like import zeros_like_block
12
+ from ._zeros_like import zeros_like_block
13
13
 
14
14
 
15
15
  def _sort_single_gradient_block(
@@ -55,9 +55,7 @@ def _sort_single_gradient_block(
55
55
  # adapt sample column in gradient samples to the one of the sorted values of
56
56
  # the gradient_block the gradient is attached to
57
57
  sample_values = _dispatch.copy(sample_values)
58
- sample_values[:, 0] = sorted_idx_inverse[
59
- _dispatch.to_index_array(sample_values[:, 0])
60
- ]
58
+ sample_values[:, 0] = sorted_idx_inverse[sample_values[:, 0]]
61
59
 
62
60
  # sort the samples in gradient regularly moving the rows considering all columns
63
61
  sorted_idx = _dispatch.argsort_labels_values(sample_values, reverse=descending)
@@ -3,11 +3,11 @@ from typing import Dict, List
3
3
  from ._backend import (
4
4
  TensorBlock,
5
5
  TensorMap,
6
- is_metatensor_class,
6
+ isinstance_metatensor,
7
7
  torch_jit_is_scripting,
8
8
  torch_jit_script,
9
9
  )
10
- from .slice import SliceSelection, _check_slice_args, _slice_block
10
+ from ._slice import SliceSelection, _check_slice_args, _slice_block
11
11
 
12
12
 
13
13
  def _split_block(
@@ -144,7 +144,7 @@ def split(
144
144
  """
145
145
  # Check input args
146
146
  if not torch_jit_is_scripting():
147
- if not is_metatensor_class(tensor, TensorMap):
147
+ if not isinstance_metatensor(tensor, "TensorMap"):
148
148
  raise TypeError(
149
149
  f"`tensor` must be a metatensor TensorMap, not {type(tensor)}"
150
150
  )
@@ -253,7 +253,7 @@ def split_block(
253
253
  """
254
254
  # Check input args
255
255
  if not torch_jit_is_scripting():
256
- if not is_metatensor_class(block, TensorBlock):
256
+ if not isinstance_metatensor(block, "TensorBlock"):
257
257
  raise TypeError(
258
258
  f"`block` must be a metatensor TensorBlock, not {type(block)}"
259
259
  )
@@ -1,13 +1,13 @@
1
1
  from typing import Union
2
2
 
3
+ from ._add import add
3
4
  from ._backend import (
4
5
  TensorMap,
5
- is_metatensor_class,
6
+ isinstance_metatensor,
6
7
  torch_jit_is_scripting,
7
8
  torch_jit_script,
8
9
  )
9
- from .add import add
10
- from .multiply import multiply
10
+ from ._multiply import multiply
11
11
 
12
12
 
13
13
  @torch_jit_script
@@ -37,13 +37,13 @@ def subtract(A: TensorMap, B: Union[float, int, TensorMap]) -> TensorMap:
37
37
  :return: New :py:class:`TensorMap` with the same metadata as ``A``.
38
38
  """
39
39
  if not torch_jit_is_scripting():
40
- if not is_metatensor_class(A, TensorMap):
40
+ if not isinstance_metatensor(A, "TensorMap"):
41
41
  raise TypeError(f"`A` must be a metatensor TensorMap, not {type(A)}")
42
42
 
43
43
  if torch_jit_is_scripting():
44
44
  is_tensor_map = isinstance(B, TensorMap)
45
45
  else:
46
- is_tensor_map = is_metatensor_class(B, TensorMap)
46
+ is_tensor_map = isinstance_metatensor(B, "TensorMap")
47
47
 
48
48
  if isinstance(B, (float, int)):
49
49
  B = -float(B)
@@ -1,7 +1,3 @@
1
- """
2
- Module for finding unique metadata for TensorMaps and TensorBlocks
3
- """
4
-
5
1
  from typing import List, Optional, Tuple, Union
6
2
 
7
3
  from . import _dispatch
@@ -9,7 +5,7 @@ from ._backend import (
9
5
  Labels,
10
6
  TensorBlock,
11
7
  TensorMap,
12
- is_metatensor_class,
8
+ isinstance_metatensor,
13
9
  torch_jit_is_scripting,
14
10
  torch_jit_script,
15
11
  )
@@ -164,7 +160,7 @@ def unique_metadata(
164
160
  """
165
161
  # Parse input args
166
162
  if not torch_jit_is_scripting():
167
- if not is_metatensor_class(tensor, TensorMap):
163
+ if not isinstance_metatensor(tensor, "TensorMap"):
168
164
  raise TypeError(
169
165
  f"`tensor` must be a metatensor TensorMap, not {type(tensor)}"
170
166
  )
@@ -224,7 +220,7 @@ def unique_metadata_block(
224
220
  """
225
221
  # Parse input args
226
222
  if not torch_jit_is_scripting():
227
- if not is_metatensor_class(block, TensorBlock):
223
+ if not isinstance_metatensor(block, "TensorBlock"):
228
224
  raise TypeError(
229
225
  f"`block` must be a metatensor TensorBlock, not {type(block)}"
230
226
  )
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: metatensor-operations
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Operations to manipulate metatensor data types
5
5
  Author: Guillaume Fraux, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
6
- License: BSD-3-Clause
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: homepage, https://docs.metatensor.org/latest/
8
8
  Project-URL: documentation, https://docs.metatensor.org/latest/
9
9
  Project-URL: repository, https://github.com/metatensor/metatensor
@@ -11,7 +11,6 @@ Project-URL: changelog, https://docs.metatensor.org/latest/operations/CHANGELOG.
11
11
  Keywords: machine learning,molecular modeling
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Science/Research
14
- Classifier: License :: OSI Approved :: BSD License
15
14
  Classifier: Operating System :: POSIX
16
15
  Classifier: Operating System :: MacOS :: MacOS X
17
16
  Classifier: Operating System :: Microsoft :: Windows
@@ -27,8 +26,9 @@ Requires-Python: >=3.9
27
26
  Description-Content-Type: text/x-rst
28
27
  License-File: LICENSE
29
28
  License-File: AUTHORS
30
- Requires-Dist: metatensor-core<0.2.0,>=0.1.10
29
+ Requires-Dist: metatensor-core<0.2.0,>=0.1.13
31
30
  Dynamic: author
31
+ Dynamic: license-file
32
32
  Dynamic: requires-dist
33
33
 
34
34
  metatensor-operations
@@ -0,0 +1,50 @@
1
+ AUTHORS
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.rst
5
+ git_version_info
6
+ pyproject.toml
7
+ setup.py
8
+ metatensor/operations/__init__.py
9
+ metatensor/operations/_abs.py
10
+ metatensor/operations/_add.py
11
+ metatensor/operations/_allclose.py
12
+ metatensor/operations/_backend.py
13
+ metatensor/operations/_block_from_array.py
14
+ metatensor/operations/_checks.py
15
+ metatensor/operations/_detach.py
16
+ metatensor/operations/_dispatch.py
17
+ metatensor/operations/_divide.py
18
+ metatensor/operations/_dot.py
19
+ metatensor/operations/_drop_blocks.py
20
+ metatensor/operations/_empty_like.py
21
+ metatensor/operations/_equal.py
22
+ metatensor/operations/_equal_metadata.py
23
+ metatensor/operations/_filter_blocks.py
24
+ metatensor/operations/_is_contiguous.py
25
+ metatensor/operations/_join.py
26
+ metatensor/operations/_lstsq.py
27
+ metatensor/operations/_make_contiguous.py
28
+ metatensor/operations/_manipulate_dimension.py
29
+ metatensor/operations/_multiply.py
30
+ metatensor/operations/_one_hot.py
31
+ metatensor/operations/_ones_like.py
32
+ metatensor/operations/_pow.py
33
+ metatensor/operations/_random_like.py
34
+ metatensor/operations/_reduce_over_samples.py
35
+ metatensor/operations/_remove_gradients.py
36
+ metatensor/operations/_requires_grad.py
37
+ metatensor/operations/_slice.py
38
+ metatensor/operations/_solve.py
39
+ metatensor/operations/_sort.py
40
+ metatensor/operations/_split.py
41
+ metatensor/operations/_subtract.py
42
+ metatensor/operations/_unique_metadata.py
43
+ metatensor/operations/_utils.py
44
+ metatensor/operations/_zeros_like.py
45
+ metatensor_operations.egg-info/PKG-INFO
46
+ metatensor_operations.egg-info/SOURCES.txt
47
+ metatensor_operations.egg-info/dependency_links.txt
48
+ metatensor_operations.egg-info/requires.txt
49
+ metatensor_operations.egg-info/top_level.txt
50
+ metatensor_operations.egg-info/zip-safe
@@ -0,0 +1 @@
1
+ metatensor-core<0.2.0,>=0.1.13
@@ -4,14 +4,13 @@ dynamic = ["version", "authors", "dependencies"]
4
4
  requires-python = ">=3.9"
5
5
 
6
6
  readme = "README.rst"
7
- license = {text = "BSD-3-Clause"}
7
+ license = "BSD-3-Clause"
8
8
  description = "Operations to manipulate metatensor data types"
9
9
 
10
10
  keywords = ["machine learning", "molecular modeling"]
11
11
  classifiers = [
12
12
  "Development Status :: 4 - Beta",
13
13
  "Intended Audience :: Science/Research",
14
- "License :: OSI Approved :: BSD License",
15
14
  "Operating System :: POSIX",
16
15
  "Operating System :: MacOS :: MacOS X",
17
16
  "Operating System :: Microsoft :: Windows",
@@ -34,7 +33,7 @@ changelog = "https://docs.metatensor.org/latest/operations/CHANGELOG.html"
34
33
  ### ======================================================================== ###
35
34
  [build-system]
36
35
  requires = [
37
- "setuptools >=75",
36
+ "setuptools >=77",
38
37
  "packaging >=23",
39
38
  ]
40
39
  build-backend = "setuptools.build_meta"
@@ -11,7 +11,7 @@ from setuptools.command.sdist import sdist
11
11
  ROOT = os.path.realpath(os.path.dirname(__file__))
12
12
  METATENSOR_CORE = os.path.realpath(os.path.join(ROOT, "..", "metatensor_core"))
13
13
 
14
- METATENSOR_OPERATIONS_VERSION = "0.3.2"
14
+ METATENSOR_OPERATIONS_VERSION = "0.3.3"
15
15
 
16
16
 
17
17
  class bdist_egg_disabled(bdist_egg):
@@ -136,7 +136,7 @@ if __name__ == "__main__":
136
136
  install_requires.append(f"metatensor-core @ file://{METATENSOR_CORE}")
137
137
  else:
138
138
  # we are building from a sdist/installing from a wheel
139
- install_requires.append("metatensor-core >=0.1.10,<0.2.0")
139
+ install_requires.append("metatensor-core >=0.1.13,<0.2.0")
140
140
 
141
141
  setup(
142
142
  version=create_version_number(METATENSOR_OPERATIONS_VERSION),
@@ -1,2 +0,0 @@
1
- 0
2
- git.81a27ac
@@ -1,72 +0,0 @@
1
- import importlib.metadata
2
-
3
-
4
- __version__ = importlib.metadata.version("metatensor-operations")
5
-
6
-
7
- from ._utils import NotEqualError # noqa
8
- from ._checks import checks_enabled, unsafe_disable_checks, unsafe_enable_checks # noqa
9
-
10
- from .abs import abs # noqa
11
- from .add import add # noqa
12
- from .allclose import ( # noqa
13
- allclose,
14
- allclose_block,
15
- allclose_block_raise,
16
- allclose_raise,
17
- )
18
- from .block_from_array import block_from_array # noqa
19
- from .detach import detach, detach_block # noqa
20
- from .divide import divide # noqa
21
- from .dot import dot # noqa
22
- from .drop_blocks import drop_blocks # noqa
23
- from .empty_like import empty_like, empty_like_block # noqa
24
- from .equal import equal, equal_block, equal_block_raise, equal_raise # noqa
25
- from .equal_metadata import ( # noqa
26
- equal_metadata,
27
- equal_metadata_block,
28
- equal_metadata_raise,
29
- equal_metadata_block_raise,
30
- )
31
- from .filter_blocks import filter_blocks # noqa
32
- from .is_contiguous import ( # noqa: F401
33
- is_contiguous,
34
- is_contiguous_block,
35
- )
36
- from .join import join # noqa
37
- from .lstsq import lstsq # noqa
38
- from .make_contiguous import ( # noqa: F401
39
- make_contiguous,
40
- make_contiguous_block,
41
- )
42
- from .manipulate_dimension import ( # noqa
43
- append_dimension,
44
- insert_dimension,
45
- permute_dimensions,
46
- remove_dimension,
47
- rename_dimension,
48
- )
49
- from .multiply import multiply # noqa
50
- from .one_hot import one_hot # noqa
51
- from .ones_like import ones_like, ones_like_block # noqa
52
- from .random_like import random_uniform_like, random_uniform_like_block # noqa
53
- from .pow import pow # noqa
54
- from .reduce_over_samples import ( # noqa
55
- mean_over_samples,
56
- mean_over_samples_block,
57
- std_over_samples,
58
- std_over_samples_block,
59
- sum_over_samples,
60
- sum_over_samples_block,
61
- var_over_samples,
62
- var_over_samples_block,
63
- )
64
- from .remove_gradients import remove_gradients, remove_gradients_block # noqa
65
- from .requires_grad import requires_grad, requires_grad_block # noqa
66
- from .slice import slice, slice_block # noqa
67
- from .solve import solve # noqa
68
- from .sort import sort, sort_block # noqa
69
- from .split import split, split_block # noqa
70
- from .subtract import subtract # noqa
71
- from .unique_metadata import unique_metadata, unique_metadata_block # noqa
72
- from .zeros_like import zeros_like, zeros_like_block # noqa
@@ -1,50 +0,0 @@
1
- AUTHORS
2
- LICENSE
3
- MANIFEST.in
4
- README.rst
5
- git_version_info
6
- pyproject.toml
7
- setup.py
8
- metatensor/operations/__init__.py
9
- metatensor/operations/_backend.py
10
- metatensor/operations/_checks.py
11
- metatensor/operations/_dispatch.py
12
- metatensor/operations/_utils.py
13
- metatensor/operations/abs.py
14
- metatensor/operations/add.py
15
- metatensor/operations/allclose.py
16
- metatensor/operations/block_from_array.py
17
- metatensor/operations/detach.py
18
- metatensor/operations/divide.py
19
- metatensor/operations/dot.py
20
- metatensor/operations/drop_blocks.py
21
- metatensor/operations/empty_like.py
22
- metatensor/operations/equal.py
23
- metatensor/operations/equal_metadata.py
24
- metatensor/operations/filter_blocks.py
25
- metatensor/operations/is_contiguous.py
26
- metatensor/operations/join.py
27
- metatensor/operations/lstsq.py
28
- metatensor/operations/make_contiguous.py
29
- metatensor/operations/manipulate_dimension.py
30
- metatensor/operations/multiply.py
31
- metatensor/operations/one_hot.py
32
- metatensor/operations/ones_like.py
33
- metatensor/operations/pow.py
34
- metatensor/operations/random_like.py
35
- metatensor/operations/reduce_over_samples.py
36
- metatensor/operations/remove_gradients.py
37
- metatensor/operations/requires_grad.py
38
- metatensor/operations/slice.py
39
- metatensor/operations/solve.py
40
- metatensor/operations/sort.py
41
- metatensor/operations/split.py
42
- metatensor/operations/subtract.py
43
- metatensor/operations/unique_metadata.py
44
- metatensor/operations/zeros_like.py
45
- metatensor_operations.egg-info/PKG-INFO
46
- metatensor_operations.egg-info/SOURCES.txt
47
- metatensor_operations.egg-info/dependency_links.txt
48
- metatensor_operations.egg-info/requires.txt
49
- metatensor_operations.egg-info/top_level.txt
50
- metatensor_operations.egg-info/zip-safe
@@ -1 +0,0 @@
1
- metatensor-core<0.2.0,>=0.1.10