-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add double and int attributes to datasets #314
Comments
Hi @JoeStoneAT Shouldn't be a problem to add those.. I'll check in few days. |
Hi @JoeStoneAT this is just an example. If this correct I'll fully implement the other types |
Looks good |
Yeah it will also work on datasets. |
I need the exact same thing: attributes on datasets. Thanks for your work. |
I have release V1.18.0 which add the support to write numerical attributes. Example unit test: [TestMethod]
public void TestAttributesIntCreation()
{
string filename = $"{nameof(TestAttributesIntCreation)}.h5";
long fileId = Hdf5.CreateFile(filename);
long groupFId = Hdf5.CreateOrOpenGroup(fileId, "GROUP_F");
var featureCodeDs = new Hdf5Dataset();
featureCodeDs.WriteNumericAttributes(groupFId, "Int32Attribute", new int[] { 1,2,3 });
featureCodeDs.WriteNumericAttributes(groupFId, "Int16Attribute", new short[] { 1, 2, 3 });
featureCodeDs.WriteNumericAttributes(groupFId, "DoubleAttribute", new Double[] { 1.1f, 2.2f, 3.3f });
featureCodeDs.WriteNumericAttributes(groupFId, "longAttribute", new long[] { 10, 20, 30 });
Hdf5.CloseGroup(groupFId);
Hdf5.CloseFile(fileId);
File.Delete(filename);
} still working on strings.. |
@LiorBanai doing a test with the new release still inserts the attributes to the group ![]() What I like to achieve is actually add the attributes to the data. Something like the following, but this fails ` public void TestAttributesIntCreation()
|
@LiorBanai, I poked around a little bit regarding the topic with fixed size string attributes and I ended with the following function:
I am able to get Can you use this to write a solid version of WriteAsciiStringAttributes with fixed length strings? |
Hi @JoeStoneAT that is interesting. it still says |
I overwrite the original H5T.VARIABLE assignment with
I took your WriteAsciiStringAttributes and made some more or less dirty modifications. It's only some kind of a proof of concept which you could use for writing a clean function. The major parts are the H5T.C_S1 data type and the set_size with the length of the string I think. Regarding the unsafe part you maybe have a better solution in your WriteAsciiStringAttributes with the GCHandle |
Hi Lior,
I need to add various attributes to >datasets< to generate a file fitting to some other existing application.
For variable length strings there is Hdf5.WriteStringAttributes(long groupId, string name, IEnumerable values, string groupOrDatasetName = null)
But I need also to write double, int32 and constant length ASCII string attributes.
Did I miss a possibility?
The text was updated successfully, but these errors were encountered: