public void CanAccessAbsolutePaths() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); using (H5Group GRP = hf.Root.CreateGroup("foo")) { H5Group SUBGRP = GRP.SubGroup("bar", create: true); SUBGRP.Dispose(); Assert.True(H5Link.Exists(hf.ID, "/foo/")); Assert.True(H5Link.Exists(hf.ID, "/foo/bar/")); SUBGRP = hf.Root.SubGroup("/foo"); Assert.NotNull(GRP); SUBGRP.Dispose(); SUBGRP = hf.Root.SubGroup("/foo/bar"); Assert.NotNull(GRP); SUBGRP.Dispose(); SUBGRP = hf.Root.SubGroup("foo/bar"); Assert.NotNull(SUBGRP); SUBGRP.Dispose(); } } }
public void DeleteSubGroup() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); Assert.False(H5Link.Exists(hf.ID, "foo")); Assert.False(H5Link.Exists(hf.ID, "bar")); using (hf.Root.CreateGroup("foo")) { } using (hf.Root.CreateGroup("bar")) { } Assert.True(H5Link.Exists(hf.ID, "foo")); Assert.True(H5Link.Exists(hf.ID, "bar")); hf.Root.DeleteGroup("bar"); Assert.True(H5Link.Exists(hf.ID, "foo")); Assert.False(H5Link.Exists(hf.ID, "bar")); hf.Root.DeleteGroup("foo"); Assert.False(H5Link.Exists(hf.ID, "foo")); Assert.False(H5Link.Exists(hf.ID, "bar")); } }
public void CreateSubGroup() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); Assert.False(H5Link.Exists(hf.ID, "foo")); Assert.Throws <KeyNotFoundException>(() => hf.Root.SubGroup("foo")); using (var GRP = hf.Root.CreateGroup("foo")) { Assert.True(H5Link.Exists(hf.ID, "foo")); using (hf.Root.SubGroup("foo")) { } // dispose immediately Assert.False(H5Link.Exists(hf.ID, "bar")); Assert.Throws <KeyNotFoundException>(() => hf.Root.SubGroup("bar")); // create on-the-fly.. using (hf.Root.SubGroup("bar", create: true)) { } Assert.True(H5Link.Exists(hf.ID, "bar")); } } }
public void Test_Link_Dont_Exist(string key) { using (H5File hf = H5File.Open(demodata + "test_link_exists.h5", mode: "r")) { Assert.False(H5Link.Exists(hf.ID, key)); } }
public void CannotCreateMultipleGroups() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); Assert.False(H5Link.Exists(hf.ID, "grok/")); Assert.False(H5Link.Exists(hf.ID, "grok/fitz")); Assert.Throws <InvalidOperationException>(() => hf.Root.CreateGroup("grok/fitz")); } }
public void InvalidPathLookupFails() { using (H5File hf = H5File.Open(demodata + "test_link_exists.h5", mode: "r")) { Assert.True(H5Link.Exists(hf.ID, "level1/dset1")); // absolute paths are not allowed, as those undermine the local-ness of a group Assert.Throws <KeyNotFoundException>(() => hf.Root["/level1/dset1"]); // dataset cannot have trailing slash, because this would look like a group Assert.Throws <KeyNotFoundException>(() => hf.Root["level1/dset1/"]); } }
public void TestAdvancedInjection() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); using (MyObject myo = new MyObject(hf.Root)) { Assert.True(H5Link.Exists(hf.Root.ID, "alternative_path")); dset2d <float> dset = myo.advancedset as dset2d <float>; Assert.NotNull(dset); Assert.Equal(2, dset.Rank); Assert.Equal(new long[] { 3, 5 }, dset.Dims); Assert.Equal(15L, dset.Length); Assert.Equal(new float[5], dset[2]); if (H5Library.LibVersion == "1.8.12") { Assert.Throws <NotImplementedException>(() => dset.Resize(new long[] { 6, 9 })); } else { dset.Resize(new long[] { 6, 5 }); Assert.Equal(30L, dset.Length); dset[5] = new float[5] { 1, 2, 3, 4, 5 }; dset.Resize(new long[] { 6, 9 }); dset[3] = new float[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; } } } }
public void CreateNestedSubGroups() { using (var container = new TempH5FileContainer()) { H5File hf = container.Content(); Assert.False(H5Link.Exists(hf.ID, "zoom")); Assert.False(H5Link.Exists(hf.ID, "zoom/zoom")); Assert.False(H5Link.Exists(hf.ID, "zoom/zoom/zoom")); H5Group GRP = hf.Root; for (int i = 0; i < 3; i++) { GRP = GRP.CreateGroup("zoom"); } GRP.Dispose(); Assert.True(H5Link.Exists(hf.ID, "zoom/zoom/zoom")); } }