From a64eb920fdf6f8dbcffb0ec497337ad366373784 Mon Sep 17 00:00:00 2001 From: Chris Mutel Date: Wed, 3 Feb 2021 14:03:51 +0100 Subject: [PATCH] And store interface arrays as well --- bw_processing/datapackage.py | 14 +++++++++++--- tests/fixtures/test-fixture.zip | Bin 4060 -> 4075 bytes tests/fixtures/tfd/datapackage.json | 11 ++++++++++- tests/integration.py | 13 +++++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bw_processing/datapackage.py b/bw_processing/datapackage.py index 40d65e2..ad1c3f5 100644 --- a/bw_processing/datapackage.py +++ b/bw_processing/datapackage.py @@ -114,7 +114,7 @@ def get_resource(self, name_or_index: Union[str, int]) -> (Any, dict): obj = self.data[index]() self.data[index] = obj - self._cache[name_or_index] = self.data[index], self.resources[index] + self._cache[name_or_index] = (self.data[index], self.resources[index]) return self._cache[name_or_index] def filter_by_attribute(self, key: str, value: Any) -> "FilteredDatapackage": @@ -604,8 +604,6 @@ def add_dynamic_array( ) name = self._prepare_name(name) - # Do something with dynamic vector - self._add_numpy_array_resource( array=load_bytes(indices_array), name=name + ".indices", @@ -622,6 +620,16 @@ def add_dynamic_array( **kwargs, ) + self.data.append(interface) + resource = { + "profile": "interface", + "name": name + ".data", + "group": name, + "kind": "data", + } + resource.update(**kwargs) + self.resources.append(resource) + def add_csv_metadata( self, *, dataframe: pd.DataFrame, valid_for: list, name: str = None, **kwargs ) -> None: diff --git a/tests/fixtures/test-fixture.zip b/tests/fixtures/test-fixture.zip index af7f892fe14ace412d168018422bf7e7092958b5..c2d751cf3c327e07333b0a03bca892fb99254f53 100644 GIT binary patch delta 1197 zcmca3|5~0Wz?+#xgn@y9gCV_OB2On1ket4tKE1#>Xyc6KXZABOFtm#?FbDuuq$HLk z79=KTC#I+BWfkY=y^ZkAziq&?_jx#nW%$O)YYt4vF4nmqS9U8vq(^soRIcab7i%0Z z{m!kH6y_HBE5aane9eH7~ykGYIi%nPqgwb*=^ zdEM0Zrl3qo9|h$U58f=c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