metatensor-core 0.2.4__tar.gz → 0.2.6__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_core-0.2.4 → metatensor_core-0.2.6}/CMakeLists.txt +1 -1
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/PKG-INFO +1 -1
- metatensor_core-0.2.6/git_version_info +2 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_block.py +1 -1
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_c_lib.py +60 -13
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_html.py +11 -11
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_labels.py +4 -4
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_tensor.py +5 -2
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/io/_block.py +3 -2
- metatensor_core-0.2.6/metatensor-core-cxx-0.2.6.tar.gz +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/PKG-INFO +1 -1
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/SOURCES.txt +1 -1
- metatensor_core-0.2.4/git_version_info +0 -2
- metatensor_core-0.2.4/metatensor-core-cxx-0.2.4.tar.gz +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/AUTHORS +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/LICENSE +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/MANIFEST.in +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/README.rst +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_c_api.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_data/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_data/_array.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_data/_extract.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_status.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/_version.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/io/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/io/_labels.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/io/_tensor.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/io/_utils.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/learn.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/operations.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/torch.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor/utils.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/dependency_links.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/not-zip-safe +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/requires.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/top_level.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/pyproject.toml +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/setup.cfg +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.6}/setup.py +0 -0
|
@@ -14,7 +14,7 @@ set(METATENSOR_CORE_SOURCE_DIR "" CACHE PATH "Path to the sources of metatensor-
|
|
|
14
14
|
|
|
15
15
|
file(REMOVE ${CMAKE_INSTALL_PREFIX}/_external.py)
|
|
16
16
|
|
|
17
|
-
set(REQUIRED_METATENSOR_VERSION "0.2.
|
|
17
|
+
set(REQUIRED_METATENSOR_VERSION "0.2.6")
|
|
18
18
|
if(${METATENSOR_CORE_PYTHON_USE_EXTERNAL_LIB})
|
|
19
19
|
# when building a source checkout, update version to include git information
|
|
20
20
|
# this will not apply when building a sdist
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metatensor-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Python bindings for metatensor
|
|
5
5
|
Author: Guillaume Fraux, Rohit Goswami, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -325,7 +325,7 @@ class TensorBlock:
|
|
|
325
325
|
header = f"<div><strong>{class_name}</strong>{rest}</div>"
|
|
326
326
|
hr = "<hr style='border: none; border-top: 1px solid #888; margin: 0;'>"
|
|
327
327
|
|
|
328
|
-
return header + hr + body
|
|
328
|
+
return header + "\n" + hr + "\n" + body
|
|
329
329
|
|
|
330
330
|
def __eq__(self, other):
|
|
331
331
|
from metatensor.operations import equal_block
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import ctypes
|
|
1
2
|
import os
|
|
2
3
|
import re
|
|
3
4
|
import sys
|
|
4
5
|
from collections import namedtuple
|
|
5
|
-
from ctypes import cdll
|
|
6
|
+
from ctypes import cdll, wintypes
|
|
6
7
|
|
|
7
8
|
from ._c_api import setup_functions
|
|
8
9
|
from ._data._extract import ExternalCpuArray, register_external_data_wrapper
|
|
@@ -43,8 +44,16 @@ class LibraryFinder(object):
|
|
|
43
44
|
|
|
44
45
|
def __call__(self):
|
|
45
46
|
if self._cached_dll is None:
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
# if the library is already loaded in the current process, use this one
|
|
48
|
+
# instead of loading a second, independent copy of it
|
|
49
|
+
dll = _already_loaded(_lib_name())
|
|
50
|
+
if dll is None:
|
|
51
|
+
path = _lib_path()
|
|
52
|
+
dll = cdll.LoadLibrary(path)
|
|
53
|
+
else:
|
|
54
|
+
path = "<already loaded in the current process>"
|
|
55
|
+
|
|
56
|
+
self._cached_dll = dll
|
|
48
57
|
setup_functions(self._cached_dll)
|
|
49
58
|
|
|
50
59
|
# initial setup, disable printing of the error in case of panic
|
|
@@ -66,6 +75,50 @@ class LibraryFinder(object):
|
|
|
66
75
|
return self._cached_dll
|
|
67
76
|
|
|
68
77
|
|
|
78
|
+
def _lib_name():
|
|
79
|
+
"""Name of the metatensor shared library on the current platform"""
|
|
80
|
+
if sys.platform.startswith("darwin"):
|
|
81
|
+
return "libmetatensor.dylib"
|
|
82
|
+
elif sys.platform.startswith("linux"):
|
|
83
|
+
return "libmetatensor.so"
|
|
84
|
+
elif sys.platform.startswith("win"):
|
|
85
|
+
return "metatensor.dll"
|
|
86
|
+
else:
|
|
87
|
+
raise ImportError("Unknown platform. Please edit this file")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _already_loaded(name):
|
|
91
|
+
"""
|
|
92
|
+
Check if the library with the given ``name`` is already loaded in the current
|
|
93
|
+
process, and return the corresponding ``CDLL`` if it is. This makes sure we share
|
|
94
|
+
the global state of the library (error buffers, registered data origins, ...) with
|
|
95
|
+
whoever loaded it first, instead of using a second, independent copy of the library.
|
|
96
|
+
|
|
97
|
+
Returns ``None`` if the library is not already loaded.
|
|
98
|
+
"""
|
|
99
|
+
if sys.platform.startswith("win"):
|
|
100
|
+
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
101
|
+
kernel32.GetModuleHandleW.restype = wintypes.HMODULE
|
|
102
|
+
kernel32.GetModuleHandleW.argtypes = [wintypes.LPCWSTR]
|
|
103
|
+
|
|
104
|
+
handle = kernel32.GetModuleHandleW(name)
|
|
105
|
+
if not handle:
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
return ctypes.CDLL(name, handle=handle)
|
|
109
|
+
else:
|
|
110
|
+
# RTLD_NOLOAD gives us a handle if the library is already loaded, and fails
|
|
111
|
+
# instead of loading it otherwise.
|
|
112
|
+
RTLD_NOLOAD = getattr(os, "RTLD_NOLOAD", None)
|
|
113
|
+
if RTLD_NOLOAD is None:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
return ctypes.CDLL(name, mode=RTLD_NOLOAD | os.RTLD_LOCAL)
|
|
118
|
+
except OSError:
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
|
|
69
122
|
def _lib_path():
|
|
70
123
|
try:
|
|
71
124
|
# check if we are using an externally-provided version of the shared library
|
|
@@ -76,17 +129,11 @@ def _lib_path():
|
|
|
76
129
|
pass
|
|
77
130
|
|
|
78
131
|
# otherwise load from the local installation
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
path = os.path.join(_HERE, "
|
|
82
|
-
elif sys.platform.startswith("linux"):
|
|
83
|
-
windows = False
|
|
84
|
-
path = os.path.join(_HERE, "lib", "libmetatensor.so")
|
|
85
|
-
elif sys.platform.startswith("win"):
|
|
86
|
-
windows = True
|
|
87
|
-
path = os.path.join(_HERE, "bin", "metatensor.dll")
|
|
132
|
+
windows = sys.platform.startswith("win")
|
|
133
|
+
if windows:
|
|
134
|
+
path = os.path.join(_HERE, "bin", _lib_name())
|
|
88
135
|
else:
|
|
89
|
-
|
|
136
|
+
path = os.path.join(_HERE, "lib", _lib_name())
|
|
90
137
|
|
|
91
138
|
if os.path.isfile(path):
|
|
92
139
|
if windows:
|
|
@@ -61,7 +61,7 @@ def labels_html(
|
|
|
61
61
|
for width in widths:
|
|
62
62
|
result.append(f'<col style="width: {width}ch;">')
|
|
63
63
|
result.append("</colgroup>")
|
|
64
|
-
return "".join(result)
|
|
64
|
+
return "\n".join(result)
|
|
65
65
|
|
|
66
66
|
def _tbody_html(rows) -> str:
|
|
67
67
|
result = ["<tbody>"]
|
|
@@ -71,7 +71,7 @@ def labels_html(
|
|
|
71
71
|
result.append(f"<td style='text-align: center;'>{value}</td>")
|
|
72
72
|
result.append("</tr>")
|
|
73
73
|
result.append("</tbody>")
|
|
74
|
-
return "".join(result)
|
|
74
|
+
return "\n".join(result)
|
|
75
75
|
|
|
76
76
|
def _table_html(rows, include_header: bool) -> str:
|
|
77
77
|
result = ["<table style='margin-top: 10px'>"]
|
|
@@ -83,7 +83,7 @@ def labels_html(
|
|
|
83
83
|
result.append("</tr></thead>")
|
|
84
84
|
result.append(_tbody_html(rows))
|
|
85
85
|
result.append("</table>")
|
|
86
|
-
return "".join(result)
|
|
86
|
+
return "\n".join(result)
|
|
87
87
|
|
|
88
88
|
if hidden_total == 0:
|
|
89
89
|
return _table_html(visible_rows, include_header=True)
|
|
@@ -92,7 +92,7 @@ def labels_html(
|
|
|
92
92
|
if hidden_show == 0:
|
|
93
93
|
# no room for any hidden rows in the <details>, just show a message
|
|
94
94
|
result.append(f"<div>... and {hidden_total} more</div>")
|
|
95
|
-
return "".join(result)
|
|
95
|
+
return "\n".join(result)
|
|
96
96
|
|
|
97
97
|
result.append(f"<details><summary>Show {hidden_total} more entries</summary>")
|
|
98
98
|
result.append("<table>")
|
|
@@ -113,7 +113,7 @@ def labels_html(
|
|
|
113
113
|
result.append("</table>")
|
|
114
114
|
|
|
115
115
|
result.append("</details>")
|
|
116
|
-
return "".join(result)
|
|
116
|
+
return "\n".join(result)
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
def labels_html_horizontal(
|
|
@@ -147,7 +147,7 @@ def labels_html_horizontal(
|
|
|
147
147
|
"<td style='text-align: left;'>(empty)</td></tr>"
|
|
148
148
|
)
|
|
149
149
|
result.append("</tbody></table>")
|
|
150
|
-
return "".join(result)
|
|
150
|
+
return "\n".join(result)
|
|
151
151
|
|
|
152
152
|
visible_count = min(default_visible_entries, n_rows)
|
|
153
153
|
hidden_total = n_rows - visible_count
|
|
@@ -187,7 +187,7 @@ def labels_html_horizontal(
|
|
|
187
187
|
)
|
|
188
188
|
result.append("</details>")
|
|
189
189
|
|
|
190
|
-
return "".join(result)
|
|
190
|
+
return "\n".join(result)
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
# This function is used by both the core and torch implementations, do not change it in
|
|
@@ -280,7 +280,7 @@ def block_html(block: TensorBlockData, *, module: str) -> str:
|
|
|
280
280
|
result.append("</div>")
|
|
281
281
|
|
|
282
282
|
result.append("</div>")
|
|
283
|
-
return "".join(result)
|
|
283
|
+
return "\n".join(result)
|
|
284
284
|
|
|
285
285
|
|
|
286
286
|
# This function is used by both the core and torch implementations, do not change it in
|
|
@@ -341,7 +341,7 @@ def tensor_map_html(
|
|
|
341
341
|
for width in widths:
|
|
342
342
|
result.append(f'<col style="width: {width}ch;">')
|
|
343
343
|
result.append("</colgroup>")
|
|
344
|
-
return "".join(result)
|
|
344
|
+
return "\n".join(result)
|
|
345
345
|
|
|
346
346
|
class_name = f"{module}.TensorBlock"
|
|
347
347
|
|
|
@@ -383,7 +383,7 @@ def tensor_map_html(
|
|
|
383
383
|
table.append("</tr>")
|
|
384
384
|
table.append("</tbody>")
|
|
385
385
|
table.append("</table>")
|
|
386
|
-
return "".join(table)
|
|
386
|
+
return "\n".join(table)
|
|
387
387
|
|
|
388
388
|
if hidden_total == 0:
|
|
389
389
|
result.append(_table_html(visible_rows))
|
|
@@ -422,4 +422,4 @@ def tensor_map_html(
|
|
|
422
422
|
|
|
423
423
|
result.append("</div>")
|
|
424
424
|
result.append("</div>")
|
|
425
|
-
return "".join(result)
|
|
425
|
+
return "\n".join(result)
|
|
@@ -103,8 +103,8 @@ class LabelsEntry:
|
|
|
103
103
|
max_html_entries=1,
|
|
104
104
|
)
|
|
105
105
|
return (
|
|
106
|
-
"<div><strong>metatensor.LabelsEntry</strong></div
|
|
107
|
-
+ "<hr style='border: none; border-top: 1px solid #888; margin: 0;'
|
|
106
|
+
"<div><strong>metatensor.LabelsEntry</strong></div>\n"
|
|
107
|
+
+ "<hr style='border: none; border-top: 1px solid #888; margin: 0;'>\n"
|
|
108
108
|
+ html
|
|
109
109
|
)
|
|
110
110
|
|
|
@@ -473,8 +473,8 @@ class Labels:
|
|
|
473
473
|
)
|
|
474
474
|
|
|
475
475
|
return (
|
|
476
|
-
"<div><strong>metatensor.Labels</strong></div
|
|
477
|
-
+ "<hr style='border: none; border-top: 1px solid #888; margin: 0;'
|
|
476
|
+
"<div><strong>metatensor.Labels</strong></div>\n"
|
|
477
|
+
+ "<hr style='border: none; border-top: 1px solid #888; margin: 0;'>\n"
|
|
478
478
|
+ html
|
|
479
479
|
)
|
|
480
480
|
|
|
@@ -176,7 +176,10 @@ class TensorMap:
|
|
|
176
176
|
return TensorMap.unsafe_from_ptr(new_ptr)
|
|
177
177
|
else:
|
|
178
178
|
new_blocks = [block.copy(deep=False) for block in self.blocks()]
|
|
179
|
-
|
|
179
|
+
copy = TensorMap(keys=self.keys, blocks=new_blocks)
|
|
180
|
+
for key, value in self.info().items():
|
|
181
|
+
copy.set_info(key, value)
|
|
182
|
+
return copy
|
|
180
183
|
|
|
181
184
|
def __len__(self):
|
|
182
185
|
return len(self.keys)
|
|
@@ -221,7 +224,7 @@ class TensorMap:
|
|
|
221
224
|
)
|
|
222
225
|
hr = "<hr style='border: none; border-top: 1px solid #888; margin: 0;'>"
|
|
223
226
|
|
|
224
|
-
return header + hr + body
|
|
227
|
+
return header + "\n" + hr + "\n" + body
|
|
225
228
|
|
|
226
229
|
def __getitem__(self, selection) -> TensorBlock:
|
|
227
230
|
"""This is equivalent to self.block(selection)"""
|
|
@@ -300,10 +300,11 @@ def _block_to_dict(block, prefix, is_gradient):
|
|
|
300
300
|
if not is_gradient:
|
|
301
301
|
result[f"{prefix}properties"] = _labels_to_mts(block.properties)
|
|
302
302
|
|
|
303
|
-
|
|
303
|
+
# sort the gradients to make sure the same file is generated every time
|
|
304
|
+
for parameter in sorted(block.gradients_list()):
|
|
304
305
|
result.update(
|
|
305
306
|
_block_to_dict(
|
|
306
|
-
gradient,
|
|
307
|
+
block.gradient(parameter),
|
|
307
308
|
f"{prefix}gradients/{parameter}/",
|
|
308
309
|
is_gradient=True,
|
|
309
310
|
)
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metatensor-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Python bindings for metatensor
|
|
5
5
|
Author: Guillaume Fraux, Rohit Goswami, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
Binary file
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor_core-0.2.4 → metatensor_core-0.2.6}/metatensor_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|