bw-processing 0.9.1__tar.gz → 0.9.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.
Files changed (40) hide show
  1. {bw_processing-0.9.1/bw_processing.egg-info → bw_processing-0.9.2}/PKG-INFO +1 -1
  2. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/__init__.py +1 -1
  3. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/array_creation.py +2 -1
  4. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/datapackage.py +9 -7
  5. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/errors.py +2 -1
  6. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/filesystem.py +2 -1
  7. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/proxies.py +2 -1
  8. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/utils.py +9 -0
  9. {bw_processing-0.9.1 → bw_processing-0.9.2/bw_processing.egg-info}/PKG-INFO +1 -1
  10. {bw_processing-0.9.1 → bw_processing-0.9.2}/LICENSE +0 -0
  11. {bw_processing-0.9.1 → bw_processing-0.9.2}/MANIFEST.in +0 -0
  12. {bw_processing-0.9.1 → bw_processing-0.9.2}/README.md +0 -0
  13. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/constants.py +0 -0
  14. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/examples/__init__.py +0 -0
  15. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/examples/interfaces.py +0 -0
  16. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/examples/parquet_files.py +0 -0
  17. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/examples/simple.zip +0 -0
  18. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/indexing.py +0 -0
  19. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/io_helpers.py +0 -0
  20. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/io_parquet_helpers.py +0 -0
  21. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/io_pyarrow_helpers.py +0 -0
  22. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/merging.py +0 -0
  23. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing/unique_fields.py +0 -0
  24. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing.egg-info/SOURCES.txt +0 -0
  25. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing.egg-info/dependency_links.txt +0 -0
  26. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing.egg-info/not-zip-safe +0 -0
  27. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing.egg-info/requires.txt +0 -0
  28. {bw_processing-0.9.1 → bw_processing-0.9.2}/bw_processing.egg-info/top_level.txt +0 -0
  29. {bw_processing-0.9.1 → bw_processing-0.9.2}/dev/calculation_package.py +0 -0
  30. {bw_processing-0.9.1 → bw_processing-0.9.2}/dev/loading.py +0 -0
  31. {bw_processing-0.9.1 → bw_processing-0.9.2}/dev/processed_package.py +0 -0
  32. {bw_processing-0.9.1 → bw_processing-0.9.2}/dev/resources.py +0 -0
  33. {bw_processing-0.9.1 → bw_processing-0.9.2}/dev/speed_tests.py +0 -0
  34. {bw_processing-0.9.1 → bw_processing-0.9.2}/docs/conf.py +0 -0
  35. {bw_processing-0.9.1 → bw_processing-0.9.2}/pyproject.toml +0 -0
  36. {bw_processing-0.9.1 → bw_processing-0.9.2}/setup.cfg +0 -0
  37. {bw_processing-0.9.1 → bw_processing-0.9.2}/tests/fixtures/basic_arrays.py +0 -0
  38. {bw_processing-0.9.1 → bw_processing-0.9.2}/tests/helpers/__init__.py +0 -0
  39. {bw_processing-0.9.1 → bw_processing-0.9.2}/tests/helpers/basic_array_helpers.py +0 -0
  40. {bw_processing-0.9.1 → bw_processing-0.9.2}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bw-processing
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: Tools to create structured arrays in a common format
5
5
  Home-page: https://github.com/brightway-lca/bw_processing
6
6
  Author: Chris Mutel
@@ -26,7 +26,7 @@ __all__ = (
26
26
  "UndefinedInterface",
27
27
  )
28
28
 
29
- __version__ = "0.9.1"
29
+ __version__ = "0.9.2"
30
30
 
31
31
 
32
32
  from .array_creation import create_array, create_structured_array
@@ -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)
@@ -31,7 +31,7 @@ from .errors import (
31
31
  from .filesystem import clean_datapackage_name
32
32
  from .io_helpers import file_reader, file_writer
33
33
  from .proxies import Proxy, UndefinedInterface
34
- from .utils import check_name, check_suffix, load_bytes, resolve_dict_iterator
34
+ from .utils import check_name, check_suffix, load_bytes, resolve_dict_iterator, utc_now
35
35
 
36
36
 
37
37
  class DatapackageBase(ABC):
@@ -127,7 +127,8 @@ class DatapackageBase(ABC):
127
127
  def del_resource_group(self, name: str) -> None:
128
128
  """Remove a resource group, and delete its data files, if any.
129
129
 
130
- Use ``exclude_resource_group`` if you want to keep the underlying resource in the filesystem."""
130
+ Use ``exclude_resource_group`` if you want to keep the underlying resource in the filesystem.
131
+ """
131
132
  if self._modified:
132
133
  raise PotentialInconsistency(
133
134
  "Datapackage is modified; save modifications or reload"
@@ -181,7 +182,8 @@ class DatapackageBase(ABC):
181
182
 
182
183
  All included objects are the same as in the original data package, i.e. no copies are made. No checks are made to ensure consistency with modifications to the original datapackage after the creation of this filtered datapackage.
183
184
 
184
- This method was introduced to allow for the efficient construction of matrices; each datapackage can have data for multiple matrices, and we can then create filtered datapackages which exclusively have data for the matrix of interest. As such, they should be considered read-only, though this is not enforced."""
185
+ This method was introduced to allow for the efficient construction of matrices; each datapackage can have data for multiple matrices, and we can then create filtered datapackages which exclusively have data for the matrix of interest. As such, they should be considered read-only, though this is not enforced.
186
+ """
185
187
  fdp = FilteredDatapackage()
186
188
  fdp.fs = self.fs
187
189
  fdp.metadata = {k: v for k, v in self.metadata.items() if k != "resources"}
@@ -369,7 +371,7 @@ class Datapackage(DatapackageBase):
369
371
  "id": id_ or uuid.uuid4().hex,
370
372
  "licenses": (metadata or {}).get("licenses", DEFAULT_LICENSES),
371
373
  "resources": [],
372
- "created": datetime.datetime.now(datetime.UTC).isoformat("T") + "Z",
374
+ "created": utc_now().isoformat("T") + "Z",
373
375
  "combinatorial": combinatorial,
374
376
  "sequential": sequential,
375
377
  "seed": seed,
@@ -1115,7 +1117,7 @@ def load_datapackage(
1115
1117
  return obj
1116
1118
 
1117
1119
 
1118
- def simple_graph(data: dict, fs: Optional[FS] = None, **metadata)->Datapackage:
1120
+ def simple_graph(data: dict, fs: Optional[FS] = None, **metadata) -> Datapackage:
1119
1121
  """Easy creation of simple datapackages with only persistent vectors.
1120
1122
 
1121
1123
  Args:
@@ -1123,8 +1125,8 @@ def simple_graph(data: dict, fs: Optional[FS] = None, **metadata)->Datapackage:
1123
1125
  The data dictionary has the form::
1124
1126
 
1125
1127
  {
1126
- matrix_name: [
1127
- (row_id, col_id, value, flip)
1128
+ matrix_name: [
1129
+ (row_id, col_id, value, flip)
1128
1130
  ]
1129
1131
  }
1130
1132
 
@@ -29,7 +29,8 @@ class ShapeMismatch(BrightwayProcessingError):
29
29
  class InvalidName(BrightwayProcessingError):
30
30
  """Name fails datapackage requirements:
31
31
 
32
- A short url-usable (and preferably human-readable) name of the package. This MUST be lower-case and contain only alphanumeric characters along with ".", "_" or "-" characters."""
32
+ A short url-usable (and preferably human-readable) name of the package. This MUST be lower-case and contain only alphanumeric characters along with ".", "_" or "-" characters.
33
+ """
33
34
 
34
35
  pass
35
36
 
@@ -23,7 +23,8 @@ def safe_filename(
23
23
 
24
24
  if `add_hash`, appends hash of `string` to avoid name collisions.
25
25
 
26
- From http://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename-in-python"""
26
+ From http://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename-in-python
27
+ """
27
28
  safe = re.sub(
28
29
  r"[-\s]+",
29
30
  "-",
@@ -13,6 +13,7 @@ class Proxy:
13
13
  def __call__(self):
14
14
  """Retrieve the data.
15
15
 
16
- Rewinds the file or buffer to 0, see https://github.com/brightway-lca/bw_processing/issues/9."""
16
+ Rewinds the file or buffer to 0, see https://github.com/brightway-lca/bw_processing/issues/9.
17
+ """
17
18
  self.kwargs[self.label].seek(0)
18
19
  return self.func(**self.kwargs)
@@ -1,3 +1,4 @@
1
+ from datetime import datetime
1
2
  from io import BytesIO
2
3
  from pathlib import Path
3
4
  from typing import Any, Union
@@ -98,3 +99,11 @@ def resolve_dict_iterator(iterator: Any, nrows: int = None) -> tuple:
98
99
  ),
99
100
  array["flip"],
100
101
  )
102
+
103
+
104
+ def utc_now() -> datetime:
105
+ """Get current datetime compatible with Py 3.8 to 3.12"""
106
+ if hasattr(datetime, "UTC"):
107
+ return datetime.now(datetime.UTC)
108
+ else:
109
+ return datetime.utcnow()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bw-processing
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: Tools to create structured arrays in a common format
5
5
  Home-page: https://github.com/brightway-lca/bw_processing
6
6
  Author: Chris Mutel
File without changes
File without changes
File without changes
File without changes