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
New attempt for HDF5 support using HighFive #41
Conversation
P.S. As I missed some functions to smoothen HighFive, I have made some wrapper functions: |
do you want to integrate these functions in Nice name, btw! |
Well I don't know. On first sight, I find the one-line syntax very much in the line of xtensor, and a bit less with HighFive, as HighFive appears to focus on keeping the full flexibility of HDF5. On the other hand, I believe that h5py features both. In any case, I find the one-line syntax vital to get readable main-files. So I strongly believe that such syntax should be available. Maybe you can share your thoughts?
|
I have upgraded the PR significantly. I will carefully review the code again tomorrow or so, but it would be great to have general feedback. The syntax is now: #include <xtensor-io/xhighfive.hpp>
int main()
{
HighFive::File file("example.h5", HighFive::File::Overwrite);
xt::xtensor<double,2> A = xt::ones<double>({10,5});
xt::dump(file, "/path/to/data", A);
xt::overwrite(file, "/path/to/data", A);
xt::xtensor<double,2> B = xt::load<xt::xtensor<double,2>>(file, "/path/to/data");
return 0;
} whereby As discussed with @wolfv in private, I will also submit these functions to be integrated upstream. They will stay also in
The more dedicated Beyond code review, to-do are:
|
Regarding testing: We ship + download all dependencies on |
Nice PR! Regarding the interface, as discussed with @wolfv, and to summarize what have been told on gitter channel, there should be a clean separation between pure xtensor API and lower level API making use of HighFive: namespace xt
{
// Not specific to HDF5, can be used by functions writing other file formats,
// so that should be in a separate header
enum class dump_mode
{
create,
overwrite
}
template <class T>
void dump_hdf5(const std::string& file_path,
const std::string& data_path,
const T& data,
dump_mode mode);
template <class T>
T load_hdf5(cons std::string& file_path, const std::string& data_path);
} These functions forward to the |
The I'm not strongly opinionated about the |
You mean so one can replace the entire file and not only the path to the data inside? That's what |
@JohanMabille Overwriting a DataSet may not be specific to HDF5, e.g. the same operation is perceivable for an NPZ-file (though I'm not an expert, so I don't know if it is actually possible). So I would argue for
|
Sounds perfect for me. |
Please find as I believe all discussed updates + documentation + tests. I do still need help to complete |
Did you already add We could try to make tests pass on Travis/Linux by adding |
Ok, now i am hopeful that the tests will be passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff in this PR :)
Some nitpicking follows:
For function arguments we usually write references like so: HighFive::File& file
(e.g. &
right after type, then space).
We put spaces around operators (e.g. i + j
)
And I just asked for a bit of clarification with the scalar load interface.
Let's merge this soon!
btw feel free to squash my commits |
I could also squash them all right?
… On 22 Nov 2018, at 14:13, Wolf Vollprecht ***@***.***> wrote:
btw feel free to squash my commits
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#41 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AGtGrVwGeEcTF4pw1_Zt29x1xz3y5EJhks5uxqLlgaJpZM4YXWtK>.
|
yep, that would be nice. Or at least reduce the number of commits a bit so we have a clean history. |
Yep, if there is only one thats enough .
But for the `dump` methods, shouldn't they go here as well?
Le 23 nov. 2018 10:19, "Tom de Geus" <notifications@github.com> a écrit :
… ***@***.**** commented on this pull request.
------------------------------
In docs/source/api_reference.rst
<#41 (comment)>:
> @@ -21,6 +21,17 @@ Defined in ``xtensor-io/xnpz.hpp``
.. doxygenfunction:: xt::dump_npz
:project: xtensor-io
+HDF5 files
+----------
+
+Defined in ``xtensor-io/xhighfive.hpp``
+
+.. doxygenfunction:: xt::dump_hdf5
+ :project: xtensor-io
+
+.. doxygenfunction:: xt::load_hdf5
+ :project: xtensor-io
+
Actually, there is only one signature with an all accepting template. So
this should be correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2BPuc8PCNs-f1OB0hYfo4pAlccagwvks5ux72IgaJpZM4YXWtK>
.
|
I'll push a complete version for you to double check. I think I have everything now. |
It's there for you to check! |
@wolfv Maybe you can add a conda install/compile strategy to the documentation? |
Let's merge for now! I'll try to find some time next week to make this interface also take an xexpression (as discussed). |
And then we should cut a new release soon |
Awesome! |
Hereby my attempt for a cleaner HighFive support. It allows the following syntax:
What do you guys think?
Note that:
I still want to add some
overwrite
function to overwrite an existing data-set (of the correct shape/type) with new data.Ideally I want to add some user friendliness, like having
dump
also work for example forstd::string
, that I miss in HighFive, but I could also construct my own wrapper for that.I believe that the recursive
createGroup
function should really be in the HighFive library. I have openend an issue there: Recursively create groups BlueBrain/HighFive#139