3
0
mirror of https://github.com/triqs/dft_tools synced 2024-08-06 20:40:00 +02:00

Adjust hdf5 usage to changes in triqs/nda

This commit is contained in:
Nils Wentzell 2020-04-03 16:20:03 -04:00
parent 6a61fe0740
commit 68cac838cc
4 changed files with 10 additions and 10 deletions

View File

@ -16,13 +16,13 @@ namespace app4triqs {
bool toto::operator==(toto const &b) const { return (this->i == b.i); }
void h5_write(triqs::h5::group grp, std::string subgroup_name, toto const &m) {
void h5_write(h5::group grp, std::string subgroup_name, toto const &m) {
grp = subgroup_name.empty() ? grp : grp.create_group(subgroup_name);
h5_write(grp, "i", m.i);
h5_write_attribute(grp, "TRIQS_HDF5_data_scheme", toto::hdf5_scheme());
h5_write_attribute(grp, "TRIQS_HDF5_data_scheme", toto::hdf5_format());
}
void h5_read(triqs::h5::group grp, std::string subgroup_name, toto &m) {
void h5_read(h5::group grp, std::string subgroup_name, toto &m) {
grp = subgroup_name.empty() ? grp : grp.open_group(subgroup_name);
int i;
h5_read(grp, "i", i);

View File

@ -1,5 +1,6 @@
#pragma once
#include <triqs/gfs.hpp>
#include <h5/h5.hpp>
namespace app4triqs {
@ -51,10 +52,10 @@ namespace app4triqs {
bool operator==(toto const &b) const;
/// HDF5
static std::string hdf5_scheme() { return "Toto"; }
static std::string hdf5_format() { return "Toto"; }
friend void h5_write(triqs::h5::group grp, std::string subgroup_name, toto const &m);
friend void h5_read(triqs::h5::group grp, std::string subgroup_name, toto &m);
friend void h5_write(h5::group grp, std::string subgroup_name, toto const &m);
friend void h5_read(h5::group grp, std::string subgroup_name, toto &m);
/// Serialization
template <class Archive> void serialize(Archive &ar, const unsigned int) { ar &i; }

View File

@ -13,7 +13,6 @@ module.add_include("app4triqs/app4triqs.hpp")
# Add here anything to add in the C++ code at the start, e.g. namespace using
module.add_preamble("""
#include <cpp2py/converters/string.hpp>
#include <triqs/cpp2py_converters/h5.hpp>
using namespace app4triqs;
""")
@ -47,7 +46,7 @@ Parameters
u
Nothing useful""")
c.add_method("""std::string hdf5_scheme ()""",
c.add_method("""std::string hdf5_format ()""",
is_static = True,
doc = r"""HDF5""")

View File

@ -16,13 +16,13 @@ TEST(Toto, H5) { // NOLINT
toto a(0);
{ // Local scope for file
triqs::h5::file f("f.h5", H5F_ACC_TRUNC);
h5::file f("f.h5", 'w');
h5_write(f, "a", a);
}
toto a2;
{
triqs::h5::file f("f.h5", H5F_ACC_RDWR);
h5::file f("f.h5", 'a');
h5_read(f, "a", a2);
}