3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 13:53:40 +01:00

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
This commit is contained in:
Olivier Parcollet 2014-05-30 11:45:58 +02:00
parent 3036fe6529
commit a920697e78
4 changed files with 8 additions and 2 deletions

View File

@ -276,6 +276,7 @@ class class_ :
# Init arithmetic # Init arithmetic
# expect a tuple : "algebra", "scalar1", "scalar2", etc... # expect a tuple : "algebra", "scalar1", "scalar2", etc...
self.number_protocol = {} self.number_protocol = {}
if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,)
if arithmetic : if arithmetic :
if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,) if not isinstance(arithmetic, tuple) : arithmetic = (arithmetic,)
add = arithmetic[0] in ("algebra", "abelian_group", "vector_space", "only_add") add = arithmetic[0] in ("algebra", "abelian_group", "vector_space", "only_add")

View File

@ -74,6 +74,8 @@ int main(int argc, char **argv) {
h5_write(top,"C",C); h5_write(top,"C",C);
h5_write(top,"D",D); h5_write(top,"D",D);
h5_write(top,"S","");
// testing scalar // testing scalar
double x=2.3; double x=2.3;
h5_write(top, "x",x); h5_write(top, "x",x);

View File

@ -25,7 +25,7 @@ namespace triqs {
void h5_write (group g, std::string const & name, std::string const & value) { void h5_write (group g, std::string const & name, std::string const & value) {
try { 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()); H5::DataSet ds = g.create_dataset(name, strdatatype, H5::DataSpace());
ds.write((void*)(value.c_str()), strdatatype ); ds.write((void*)(value.c_str()), strdatatype );
} }

View File

@ -173,7 +173,10 @@ namespace params {
#ifdef TRIQS_WITH_PYTHON_SUPPORT #ifdef TRIQS_WITH_PYTHON_SUPPORT
/// Convertions python <-> C++ /// Convertions python <-> C++
bool from_python_convertible(PyObject *ob) const { return p->from_python_convertible(ob); } 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(); } PyObject *to_python() const { return p->to_python(); }
#endif #endif