bw-processing 0.8.5__tar.gz → 0.9.5__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.
- bw_processing-0.9.5/MANIFEST.in +3 -0
- {bw-processing-0.8.5/bw_processing.egg-info → bw_processing-0.9.5}/PKG-INFO +34 -23
- {bw-processing-0.8.5 → bw_processing-0.9.5}/README.md +7 -7
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/__init__.py +3 -2
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/array_creation.py +2 -1
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/constants.py +17 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/datapackage.py +211 -107
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/errors.py +2 -1
- bw_processing-0.9.5/bw_processing/examples/__pycache__/__init__.cpython-312.pyc +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/another name.indices.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/datapackage.json +121 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.data.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.distributions.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.flip.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.indices.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/some name.data.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/some name.flip.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_1/some name.indices.parquet +0 -0
- bw_processing-0.9.5/bw_processing/examples/datapackage_2.zip +0 -0
- bw_processing-0.9.5/bw_processing/examples/parquet_files.py +109 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/filesystem.py +3 -4
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/indexing.py +7 -6
- bw_processing-0.9.5/bw_processing/io_helpers.py +159 -0
- bw_processing-0.9.5/bw_processing/io_parquet_helpers.py +143 -0
- bw_processing-0.9.5/bw_processing/io_pyarrow_helpers.py +282 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/merging.py +12 -20
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/proxies.py +2 -1
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/unique_fields.py +3 -2
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/utils.py +9 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5/bw_processing.egg-info}/PKG-INFO +34 -23
- bw_processing-0.9.5/bw_processing.egg-info/SOURCES.txt +65 -0
- bw_processing-0.9.5/bw_processing.egg-info/requires.txt +19 -0
- bw_processing-0.9.5/bw_processing.egg-info/top_level.txt +1 -0
- bw_processing-0.9.5/docs/conf.py +109 -0
- bw_processing-0.9.5/pyproject.toml +106 -0
- bw_processing-0.9.5/setup.cfg +4 -0
- bw_processing-0.9.5/tests/fixtures/basic_arrays.py +42 -0
- bw_processing-0.9.5/tests/helpers/__init__.py +6 -0
- bw_processing-0.9.5/tests/helpers/basic_array_helpers.py +33 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/tests/test_utils.py +1 -6
- bw-processing-0.8.5/MANIFEST.in +0 -3
- bw-processing-0.8.5/bw_processing/io_helpers.py +0 -102
- bw-processing-0.8.5/bw_processing.egg-info/SOURCES.txt +0 -33
- bw-processing-0.8.5/bw_processing.egg-info/not-zip-safe +0 -1
- bw-processing-0.8.5/bw_processing.egg-info/requires.txt +0 -17
- bw-processing-0.8.5/bw_processing.egg-info/top_level.txt +0 -5
- bw-processing-0.8.5/docs/conf.py +0 -48
- bw-processing-0.8.5/pyproject.toml +0 -3
- bw-processing-0.8.5/setup.cfg +0 -86
- {bw-processing-0.8.5 → bw_processing-0.9.5}/LICENSE +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/examples/__init__.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/examples/interfaces.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing/examples/simple.zip +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/bw_processing.egg-info/dependency_links.txt +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/dev/calculation_package.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/dev/loading.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/dev/processed_package.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/dev/resources.py +0 -0
- {bw-processing-0.8.5 → bw_processing-0.9.5}/dev/speed_tests.py +0 -0
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Author-email: <cmutel@gmail.com>
|
|
8
|
-
Maintainer: Chris Mutel
|
|
9
|
-
Maintainer-email: <cmutel@gmail.com>
|
|
10
|
-
License: BSD-3-Clause
|
|
2
|
+
Name: bw_processing
|
|
3
|
+
Version: 0.9.5
|
|
4
|
+
Summary: Foo
|
|
5
|
+
Author-email: Chris Mutel <cmutel@gmail.com>
|
|
6
|
+
Maintainer-email: Chris Mutel <cmutel@gmail.com>
|
|
11
7
|
Project-URL: source, https://github.com/brightway-lca/bw_processing
|
|
12
8
|
Project-URL: homepage, https://github.com/brightway-lca/bw_processing
|
|
13
9
|
Project-URL: tracker, https://github.com/brightway-lca/bw_processing/issues
|
|
14
|
-
Keywords: "brightway","development"
|
|
15
|
-
Platform: any
|
|
16
10
|
Classifier: Development Status :: 4 - Beta
|
|
17
11
|
Classifier: Programming Language :: Python
|
|
18
12
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
21
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
22
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: fsspec
|
|
24
|
+
Requires-Dist: morefs
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: pandas
|
|
25
27
|
Provides-Extra: testing
|
|
28
|
+
Requires-Dist: bw_processing; extra == "testing"
|
|
29
|
+
Requires-Dist: pytest; extra == "testing"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "testing"
|
|
31
|
+
Requires-Dist: python-coveralls; extra == "testing"
|
|
26
32
|
Provides-Extra: dev
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
Requires-Dist: build; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
35
|
+
Requires-Dist: pylint; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-randomly; extra == "dev"
|
|
39
|
+
Requires-Dist: setuptools; extra == "dev"
|
|
29
40
|
|
|
30
41
|
# bw-processing
|
|
31
42
|
|
|
@@ -34,10 +45,10 @@ Library for storing numeric data for use in matrix-based calculations. Designed
|
|
|
34
45
|
[][pypi status]
|
|
35
46
|
[][pypi status]
|
|
36
47
|
[][pypi status]
|
|
37
|
-
[][license]
|
|
38
49
|
|
|
39
50
|
[][read the docs]
|
|
40
|
-
[][tests]
|
|
41
52
|
[][codecov]
|
|
42
53
|
|
|
43
54
|
[][pre-commit]
|
|
@@ -45,7 +56,7 @@ Library for storing numeric data for use in matrix-based calculations. Designed
|
|
|
45
56
|
|
|
46
57
|
[pypi status]: https://pypi.org/project/bw-processing/
|
|
47
58
|
[read the docs]: https://bw-processing.readthedocs.io/
|
|
48
|
-
[tests]: https://github.com/brightway-lca/
|
|
59
|
+
[tests]: https://github.com/brightway-lca/bw_processing/actions/workflows/python-test.yml
|
|
49
60
|
[codecov]: https://app.codecov.io/gh/brightway-lca/bw-processing
|
|
50
61
|
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
51
62
|
[black]: https://github.com/psf/black
|
|
@@ -136,10 +147,10 @@ class ExampleArrayInterface:
|
|
|
136
147
|
Serialized datapackages cannot contain executable code, both because of our chosen data formats, and for security reasons. Therefore, when loading a datapackage with an interface, that interface object needs to be reconstituted as Python code - we call this cycle dehydration and rehydration. Dehydration happens automatically when a datapackage is finalized with `finalize_serialization()`, but rehydration needs to be done manually using `rehydrate_interface()`. For example:
|
|
137
148
|
|
|
138
149
|
```python
|
|
139
|
-
from
|
|
150
|
+
from fsspec.implementations.zip import ZipFileSystem
|
|
140
151
|
from bw_processing import load_datapackage
|
|
141
152
|
|
|
142
|
-
my_dp = load_datapackage(
|
|
153
|
+
my_dp = load_datapackage(ZipFileSystem("some-path.zip"))
|
|
143
154
|
my_dp.rehydrate_interface("some-resource-name", ExampleVectorInterface())
|
|
144
155
|
```
|
|
145
156
|
|
|
@@ -148,7 +159,7 @@ You can list the dehydrated interfaces present with `.dehydrated_interfaces()`.
|
|
|
148
159
|
You can store useful information for the interface object initialization under the resource key `config`. This can be used in instantiating an interface if you pass `initialize_with_config`:
|
|
149
160
|
|
|
150
161
|
```python
|
|
151
|
-
from
|
|
162
|
+
from fsspec.implementations.zip import ZipFileSystem
|
|
152
163
|
from bw_processing import load_datapackage
|
|
153
164
|
import requests
|
|
154
165
|
import numpy as np
|
|
@@ -162,7 +173,7 @@ class MyInterface:
|
|
|
162
173
|
return np.array(requests.get(self.url).json())
|
|
163
174
|
|
|
164
175
|
|
|
165
|
-
my_dp = load_datapackage(
|
|
176
|
+
my_dp = load_datapackage(ZipFileSystem("some-path.zip"))
|
|
166
177
|
data_obj, resource_metadata = my_dp.get_resource("some-interface")
|
|
167
178
|
print(resource_metadata['config'])
|
|
168
179
|
>>> {"url": "example.com"}
|
|
@@ -5,10 +5,10 @@ Library for storing numeric data for use in matrix-based calculations. Designed
|
|
|
5
5
|
[][pypi status]
|
|
6
6
|
[][pypi status]
|
|
7
7
|
[][pypi status]
|
|
8
|
-
[][license]
|
|
9
9
|
|
|
10
10
|
[][read the docs]
|
|
11
|
-
[][tests]
|
|
12
12
|
[][codecov]
|
|
13
13
|
|
|
14
14
|
[][pre-commit]
|
|
@@ -16,7 +16,7 @@ Library for storing numeric data for use in matrix-based calculations. Designed
|
|
|
16
16
|
|
|
17
17
|
[pypi status]: https://pypi.org/project/bw-processing/
|
|
18
18
|
[read the docs]: https://bw-processing.readthedocs.io/
|
|
19
|
-
[tests]: https://github.com/brightway-lca/
|
|
19
|
+
[tests]: https://github.com/brightway-lca/bw_processing/actions/workflows/python-test.yml
|
|
20
20
|
[codecov]: https://app.codecov.io/gh/brightway-lca/bw-processing
|
|
21
21
|
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
22
22
|
[black]: https://github.com/psf/black
|
|
@@ -107,10 +107,10 @@ class ExampleArrayInterface:
|
|
|
107
107
|
Serialized datapackages cannot contain executable code, both because of our chosen data formats, and for security reasons. Therefore, when loading a datapackage with an interface, that interface object needs to be reconstituted as Python code - we call this cycle dehydration and rehydration. Dehydration happens automatically when a datapackage is finalized with `finalize_serialization()`, but rehydration needs to be done manually using `rehydrate_interface()`. For example:
|
|
108
108
|
|
|
109
109
|
```python
|
|
110
|
-
from
|
|
110
|
+
from fsspec.implementations.zip import ZipFileSystem
|
|
111
111
|
from bw_processing import load_datapackage
|
|
112
112
|
|
|
113
|
-
my_dp = load_datapackage(
|
|
113
|
+
my_dp = load_datapackage(ZipFileSystem("some-path.zip"))
|
|
114
114
|
my_dp.rehydrate_interface("some-resource-name", ExampleVectorInterface())
|
|
115
115
|
```
|
|
116
116
|
|
|
@@ -119,7 +119,7 @@ You can list the dehydrated interfaces present with `.dehydrated_interfaces()`.
|
|
|
119
119
|
You can store useful information for the interface object initialization under the resource key `config`. This can be used in instantiating an interface if you pass `initialize_with_config`:
|
|
120
120
|
|
|
121
121
|
```python
|
|
122
|
-
from
|
|
122
|
+
from fsspec.implementations.zip import ZipFileSystem
|
|
123
123
|
from bw_processing import load_datapackage
|
|
124
124
|
import requests
|
|
125
125
|
import numpy as np
|
|
@@ -133,7 +133,7 @@ class MyInterface:
|
|
|
133
133
|
return np.array(requests.get(self.url).json())
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
my_dp = load_datapackage(
|
|
136
|
+
my_dp = load_datapackage(ZipFileSystem("some-path.zip"))
|
|
137
137
|
data_obj, resource_metadata = my_dp.get_resource("some-interface")
|
|
138
138
|
print(resource_metadata['config'])
|
|
139
139
|
>>> {"url": "example.com"}
|
|
@@ -15,6 +15,7 @@ __all__ = (
|
|
|
15
15
|
"generic_zipfile_filesystem",
|
|
16
16
|
"INDICES_DTYPE",
|
|
17
17
|
"load_datapackage",
|
|
18
|
+
"MatrixSerializeFormat",
|
|
18
19
|
"md5",
|
|
19
20
|
"merge_datapackages_with_mask",
|
|
20
21
|
"reindex",
|
|
@@ -25,11 +26,11 @@ __all__ = (
|
|
|
25
26
|
"UndefinedInterface",
|
|
26
27
|
)
|
|
27
28
|
|
|
28
|
-
__version__ = "0.
|
|
29
|
+
__version__ = "0.9.5"
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
from .array_creation import create_array, create_structured_array
|
|
32
|
-
from .constants import DEFAULT_LICENSES, INDICES_DTYPE, UNCERTAINTY_DTYPE
|
|
33
|
+
from .constants import DEFAULT_LICENSES, INDICES_DTYPE, UNCERTAINTY_DTYPE, MatrixSerializeFormat
|
|
33
34
|
from .datapackage import (
|
|
34
35
|
Datapackage,
|
|
35
36
|
DatapackageBase,
|
|
@@ -68,7 +68,8 @@ def create_structured_array(iterable, dtype, nrows=None, sort=False, sort_fields
|
|
|
68
68
|
|
|
69
69
|
``iterable`` can be data already in memory, or a generator.
|
|
70
70
|
|
|
71
|
-
``nrows`` can be supplied, if known. If ``iterable`` has a length, it will be determined automatically. If ``nrows`` is not known, this function generates chunked arrays until ``iterable`` is exhausted, and concatenates them.
|
|
71
|
+
``nrows`` can be supplied, if known. If ``iterable`` has a length, it will be determined automatically. If ``nrows`` is not known, this function generates chunked arrays until ``iterable`` is exhausted, and concatenates them.
|
|
72
|
+
"""
|
|
72
73
|
if nrows or hasattr(iterable, "__len__"):
|
|
73
74
|
if not nrows:
|
|
74
75
|
nrows = len(iterable)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
from enum import Enum
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
|
|
@@ -30,3 +31,19 @@ DEFAULT_LICENSES = [
|
|
|
30
31
|
"title": "Open Data Commons Public Domain Dedication and License v1.0",
|
|
31
32
|
}
|
|
32
33
|
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class MatrixSerializeFormat(str, Enum):
|
|
37
|
+
"""
|
|
38
|
+
Enum with the serializing formats for the vectors and matrices.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
NUMPY = "numpy" # numpy .npy format
|
|
42
|
+
PARQUET = "parquet" # Apache .parquet format
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# FILE EXTENSIONS
|
|
46
|
+
NUMPY_SERIALIZE_FORMAT_EXTENSION = ".npy"
|
|
47
|
+
NUMPY_SERIALIZE_FORMAT_NAME = "npy"
|
|
48
|
+
PARQUET_SERIALIZE_FORMAT_EXTENSION = ".parquet"
|
|
49
|
+
PARQUET_SERIALIZE_FORMAT_NAME = "pqt"
|