+
Skip to content

[c++2py] TRIQS/unstable - NB5 ''max() arg is an empty sequence'' #7

@Wentzell

Description

@Wentzell

Using TRIQS/unstable, the following triqs magic copied out of 5-Parameters.ipynb

%%triqs --only g
#include <vector>
#include <string>

struct params{ 
 int i;
 double x=0;   
 double z=3;
 std::string s = "what ?";   
 std::vector<int> v;
};

/// g
CPP2PY_ARG_AS_DICT
double g(params const & a) {
  std::cout << "s = " << a.s << std::endl;  
  return a.i + a.x + a.v.at(0);   
}

fails with

----------------------------c++2py error ----------------------------
Welcome to the wrapper desc file generator of TRIQS, based on libclang !
Parsing the C++ file (may take a few seconds) ...
... done. 
Extracting ...
Analysing params
... done
Parsing C++ code. Generating the wrapper and converters ...
Transforming no argument accessors into Python properties
Generating the converters for parameters classes : params
Traceback (most recent call last):
  File "/home/nwentzel/opt/triqs/bin/c++2py.py", line 159, in <module>
    rendered = tpl.render(classes = classes_of_parameters, args = args, shell_command= shell_command )
  File "/usr/lib/python2.7/site-packages/mako/template.py", line 462, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "_home_nwentzel_opt_triqs_share_triqs_cpp2py_mako_parameters_rst", line 59, in render_body
  File "_home_nwentzel_opt_triqs_share_triqs_cpp2py_mako_parameters_rst", line 43, in doc_format
ValueError: max() arg is an empty sequence

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-bc9d327f0455> in <module>()
----> 1 get_ipython().run_cell_magic(u'triqs', u'--only g', u'#include <vector>\n#include <string>\n\nstruct params{ \n int i;\n double x=0;   \n double z=3;\n std::string s = "what ?";   \n std::vector<int> v;\n};\n\n/// g\nCPP2PY_ARG_AS_DICT\ndouble g(params const & a) {\n  std::cout << "s = " << a.s << std::endl;  \n  return a.i + a.x + a.v.at(0);   \n}')

/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2113             magic_arg_s = self.var_expand(line, stack_depth)
   2114             with self.builtin_trap:
-> 2115                 result = fn(magic_arg_s, cell)
   2116             return result
   2117 

<decorator-gen-122> in triqs(self, line, cell)

/usr/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/home/nwentzel/opt/triqs/lib/python2.7/site-packages/pytriqs/magic.pyc in triqs(self, line, cell)
    144             only_list = ','.join(args.only)
    145             only_list = (" --only " + only_list) if only_list else ''
--> 146             execute(cpp2py_bin + " ./ext.cpp -p -m ext -o ext" + only_list, "c++2py")
    147 
    148             # Call the wrapper generator

/home/nwentzel/opt/triqs/lib/python2.7/site-packages/pytriqs/magic.pyc in execute(command, message)
    137                 except subprocess.CalledProcessError as E :
    138                    print_out ( message + " error ", E.output)
--> 139                    raise RuntimeError, "Error"
    140                 if args.verbosity>0:
    141                    print_out(message, out)

RuntimeError: Error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载