From a920697e78a5ab538cad6744fc70d68dbbb4f68d Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Fri, 30 May 2014 11:45:58 +0200 Subject: [PATCH] fixes in wrap_generator, parameters, h5 for strings - string size in h5. Add +1 (or empty string is wrong). - parameters : modified flags from python - minor corrections in wrapper --- pytriqs/wrap_generator/wrap_generator.py | 1 + test/triqs/arrays/hdf5.cpp | 2 ++ triqs/h5/string.cpp | 2 +- triqs/parameters/_field.hpp | 5 ++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pytriqs/wrap_generator/wrap_generator.py b/pytriqs/wrap_generator/wrap_generator.py index 3b7e4ff8..366bd23b 100644 --- a/pytriqs/wrap_generator/wrap_generator.py +++ b/pytriqs/wrap_generator/wrap_generator.py @@ -276,6 +276,7 @@ class class_ : # Init arithmetic # expect a tuple : "algebra", "scalar1", "scalar2", etc... self.number_protocol = {} + if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,) if arithmetic : if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,) add = arithmetic[0] in ("algebra", "abelian_group", "vector_space", "only_add") diff --git a/test/triqs/arrays/hdf5.cpp b/test/triqs/arrays/hdf5.cpp index c7cfd2bd..c1e1829a 100644 --- a/test/triqs/arrays/hdf5.cpp +++ b/test/triqs/arrays/hdf5.cpp @@ -74,6 +74,8 @@ int main(int argc, char **argv) { h5_write(top,"C",C); h5_write(top,"D",D); + h5_write(top,"S",""); + // testing scalar double x=2.3; h5_write(top, "x",x); diff --git a/triqs/h5/string.cpp b/triqs/h5/string.cpp index dc0a03cb..1a0908f0 100644 --- a/triqs/h5/string.cpp +++ b/triqs/h5/string.cpp @@ -25,7 +25,7 @@ namespace triqs { void h5_write (group g, std::string const & name, std::string const & value) { try { - H5::StrType strdatatype(H5::PredType::C_S1, value.size()); + H5::StrType strdatatype(H5::PredType::C_S1, value.size() + 1); // +1 for the 0 terminating char H5::DataSet ds = g.create_dataset(name, strdatatype, H5::DataSpace()); ds.write((void*)(value.c_str()), strdatatype ); } diff --git a/triqs/parameters/_field.hpp b/triqs/parameters/_field.hpp index 3c1aab71..43c1fcdf 100644 --- a/triqs/parameters/_field.hpp +++ b/triqs/parameters/_field.hpp @@ -173,7 +173,10 @@ namespace params { #ifdef TRIQS_WITH_PYTHON_SUPPORT /// Convertions python <-> C++ bool from_python_convertible(PyObject *ob) const { return p->from_python_convertible(ob); } - void set_from_python(PyObject *ob) { p->set_from_python(ob); } + void set_from_python(PyObject *ob) { + p->set_from_python(ob); + modified = true; + } PyObject *to_python() const { return p->to_python(); } #endif