np-struct 0.2.0__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: np-struct
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Interface for NumPy structured arrays
5
5
  Author-email: Rick Lyon <rlyon14@gmail.com>
6
6
  Project-URL: repository, https://github.com/ricklyon/np_struct
@@ -672,6 +672,7 @@ class ldarray(np.ndarray):
672
672
 
673
673
  # if dim and the obj shape match, update the dim member of the indexed obj and return
674
674
  obj.coords = ncoords
675
+ obj.attrs = dcopy(self.attrs)
675
676
  return obj
676
677
 
677
678
  # if the coords were unable to be indexed, clear the coords and return a unlabeled numpy array.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: np-struct
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Interface for NumPy structured arrays
5
5
  Author-email: Rick Lyon <rlyon14@gmail.com>
6
6
  Project-URL: repository, https://github.com/ricklyon/np_struct
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "np-struct"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Interface for NumPy structured arrays"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Rick Lyon", email = "rlyon14@gmail.com" }]
@@ -30,7 +30,7 @@ include = ["np_struct"]
30
30
  repository = "https://github.com/ricklyon/np_struct"
31
31
 
32
32
  [tool.bumpversion]
33
- current_version = "0.2.0"
33
+ current_version = "0.2.1"
34
34
  commit = true
35
35
  tag = true
36
36
 
@@ -326,5 +326,23 @@ class TestLdArray(unittest.TestCase):
326
326
 
327
327
  npt.assert_array_equal(new_ld[dict(j=1.201)], [10, 11])
328
328
 
329
+ def test_attribute_selection(self):
330
+
331
+ coords = dict(a=['data1', 'data2'], b=np.arange(0, 20, 0.2))
332
+ data = np.arange(200).reshape(2, 100)
333
+ attrs = dict(attr1="test1", attr2="...test2", attr3=np.array([9, 8]))
334
+ ld = ldarray(data, coords=coords, attrs=attrs)
335
+
336
+ # check that attributes are passed to the indexed copy of the array
337
+ ld_sel = ld.sel(a="data1")
338
+
339
+ # change the attribute on the original array and verify the copy isn't affected
340
+ ld.attrs["attr3"] = np.array([[8, 7]])
341
+
342
+ self.assertEqual(ld_sel.attr1, attrs["attr1"])
343
+ self.assertEqual(ld_sel.attr2, attrs["attr2"])
344
+ np.testing.assert_array_equal(ld_sel.attr3, attrs["attr3"])
345
+
346
+
329
347
  if __name__ == '__main__':
330
348
  unittest.main()
File without changes
File without changes
File without changes
File without changes