# Possible bug in RDataFrame Define with lambdas?

**URL:** <https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132>\
**Category:** ROOT\
**Tags:** rdataframe, python\
**Created:** [August 10, 2022, 11:10am UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132 "2022-08-10T11:10:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Day](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/dc4da7/32.png) [@Day](https://root-forum.cern.ch/u/Day)\
**Post date:** [August 10, 2022, 11:10am UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132/1 "2022-08-10T11:10:28Z")

</div>

So, say you are trying to define a column in RDataFrame via pyroot, and you need a lambda function to manage it in line. To take a silly example, I’d like to have a vector of jet pT, transformed by the quadratic 2p\_T^2 + 5p\_T. What I’m actually trying to do is harder to isolate that this, but it does involve a call to `Map`. Maybe I would try;

```python
import ROOT;ROOT.xAOD.Init()
r_frame = ROOT.RDataFrame("CollectionTree", "example_data/from_lxplus/DAOD_PHYSLITE.28673837._000002.pool.root")
quadratic_lambda = "[](const float &x){return 2*x*x + 5*x;}"
map_call = f"ROOT::VecOps::Map(AnalysisJetsAuxDyn.pt, {quadratic_lambda})"
r_frame = r_frame.Define("my_col", map_call)
r_frame.Mean("my_col").GetValue()

```

Seemed reasonable to me, but gave a lengthy error message. Understandably, error messages that come from jitting c++ are effectively c++ errors, which I’m less practised at reading, but this one really didn’t help me;

> **Long error message**
>
> ```auto
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/ext/alloc_traits.h:62:23: error: 
> cannot form a reference to 'void'
> typedef value_type& reference;
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:86:35: note: in instantiation of template class ' __gnu_cxx::__ alloc_traits<std::allocator<void>, void>' requested here
> typedef typename __gnu_cxx::__ alloc_traits<_Alloc>::template
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:389:30: note: in instantiation of template class 'std::_Vector_base<void, std::allocator<void> >' requested here
> class vector : protected _Vector_base<_Tp, _Alloc>
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager*>(0xff33600), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/ext/alloc_traits.h:63:29: error: 
> cannot form a reference to 'void'
> typedef const value_type& const_reference;
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:87:2: error: no
> member named 'rebind' in ' __gnu_cxx::__ alloc_traits<std::allocator<void>, void>'
> rebind<_Tp>::other _Tp_alloc_type;
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:389:30: note: in instantiation of template class 'std::_Vector_base<void, std::allocator<void> >' requested here
> class vector : protected _Vector_base<_Tp, _Alloc>
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager 00), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/ext/alloc_traits.h:47:47: error: 
> type 'int' cannot be used prior to '::' because it has no members
> template<typename _Alloc, typename = typename _Alloc::value_type>
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:88:35: note: in instantiation of default argument for '__alloc_traits<int>' required here
> typedef typename __gnu_cxx::__ alloc_traits<_Tp_alloc_type>::pointer
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:389:30: note: in instantiation of template class 'std::_Vector_base<void, std::allocator<void> >' requested here
> class vector : protected _Vector_base<_Tp, _Alloc>
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager*>(0xff33600), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:129:11: error: 
> base specifier must name a class
> : public _Tp_alloc_type, public _Vector_impl_data
> ~~~~~~~^~~~~~~~~~~~~~
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:340:20: note: in instantiation of member class 'std::_Vector_base<void, std::allocator<void> >::_Vector_impl' requested here [157/1601]
> _Vector_impl _M_impl;
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:389:30: note: in instantiation of template class 'std::_Vector_base<void, std::allocator<void> >' requested here
> class vector : protected _Vector_base<_Tp, _Alloc>
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager*>(0xff33600), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/ext/alloc_traits.h:47:47: error: 
> type 'int' cannot be used prior to '::' because it has no members
> template<typename _Alloc, typename = typename _Alloc::value_type>
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:411:26: note: in instantiation of default argument for '__alloc_traits<int>' required here
> typedef __gnu_cxx::__ alloc_traits<_Tp_alloc_type> _Alloc_traits;
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested
> here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager 00), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:522:45: error: 
> cannot form a reference to 'void'
> vector(size_type __n, const value_type&__ value,
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RDefine.hxx:64:20: note: in instantiation of template class 'std::vector<void, std::allocator<void> >' requested here
> ValuesPerSlot_t fLastResults;
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/InterfaceUtils.hxx:441:11: note: in instantiation of template class 'ROOT::Detail::RDF::RDefine<__rdf::(lambda at input_line_213:2:16), ROOT::Detail::RDF::CustomColExtraArgs::None>' requested here
> new NewCol_t(name, dummyType, std::forward<F>(f), cols, lm->GetNSlots(), *defines, lm->GetDSValuePtrs(), ds)));
> ^
> input_line_214:2:23: note: in instantiation of function template specialization 'ROOT::Internal::RDF::JitDefineHelper<__rdf::(lambda at input_line_213:2:16) &>' requested
> here
> ROOT::Internal::RDF::JitDefineHelper(__rdf::lambda1, new const char*[1]{"AnalysisJetsAuxDyn.pt"}, 1, "my_col", reinterpret_cast<ROOT::Detail::RDF::RLoopManager*>(0xff33600), reinterpret_cast<std::weak_ptr<ROOT::Detail::RDF::RJittedDefine>*>(0x10e39e90), reinterpret_cast<ROOT::Internal::RDF::RBookedDefines*>(0x10e45890), reinterpret_cast<
> std::shared_ptr<ROOT::Detail::RDF::RNodeBase>*>(0x10e15bf0));
> ^
> In module 'std' imported from input_line_1:1:
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:749:45: error: 
> cannot form a reference to 'void'
> assign(size_type __n, const value_type&__ val)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:957:52: error: 
> cannot form a reference to 'void'
> resize(size_type __new_size, const value_type&__ x)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1187:33: error:
> cannot form a reference to 'void'
> push_back(const value_type& __x)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1203:27: error:
> cannot form a reference to 'void'
> push_back(value_type&& __x)
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1263:57: error:
> cannot form a reference to 'void'
> insert(const_iterator __position, const value_type&__ x);
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1293:51: error:
> cannot form a reference to 'void'
> insert(const_iterator __position, value_type&&__ x)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1335:72: error:
> cannot form a reference to 'void'
> insert(const_iterator __position, size_type__ n, const value_type& __x)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1593:57: error:
> cannot form a reference to 'void'
> _M_fill_initialize(size_type __n, const value_type&__ value)
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1645:53: error:
> cannot form a reference to 'void'
> _M_fill_assign(size_type __n, const value_type&__ val);
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1684:69: error:
> cannot form a reference to 'void'
> _M_fill_insert(iterator __pos, size_type__ n, const value_type& __x);
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1741:59: error:
> cannot form a reference to 'void'
> _M_insert_rval(const_iterator __position, value_type&&__ v);
> ^
> /cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_vector.h:1750:59: error:
> cannot form a reference to 'void'
> _M_emplace_aux(const_iterator __position, value_type&&__ v)
> ^
> fatal error: too many errors emitted, stopping now [-ferror-limit=]
> In module 'ROOTDataFrame':
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:90:9: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::Initialize' is not defined [-Wundefin
> ed-inline]
> void Initialize() final { fHelper.Initialize(); }
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:92:9: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::InitSlot' is not defined [-Wundefined
> -inline]
> void InitSlot(TTreeReader *r, unsigned int slot) final
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:116:9: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::TriggerChildrenCount' is not defined
> [-Wundefined-inline]
> void TriggerChildrenCount() final { fPrevData.IncrChildrenCount(); }
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:119:9: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::FinalizeSlot' is not defined [-Wundefined-inline]
> void FinalizeSlot(unsigned int slot) final
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:130:9: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::Finalize' is not defined [-Wundefined-inline]
> void Finalize() final
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:154:10: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::PartialUpdate' is not defined [-Wundefined-inline]
> void *PartialUpdate(unsigned int slot) final { return PartialUpdateImpl(slot); }
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:136:48: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::GetGraph' is not defined [-Wundefined-inline]
> std::shared_ptr<RDFGraphDrawing::GraphNode> GetGraph()
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:85:52: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::GetMergeableValue' is not defined [-Wundefined-inline]
> std::unique_ptr<RDFDetail::RMergeableValueBase> GetMergeableValue() const final
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:156:38: warning: inline function 'ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::MeanHelper, ROOT::Detail::RDF::RNodeBase, ROOT::TypeTraits::TypeList<void> >::GetDataBlockCallback' is not defined [-Wundefined-inline]
> std::function<void(unsigned int)> GetDataBlockCallback() final { return fHelper.GetDataBlockCallback(); }
> ^
> /cvmfs/atlas.cern.ch/repo/sw/software/22.0/sw/lcg/releases/LCG_101_ATLAS_14/ROOT/6.24.06/x86_64-centos7-gcc11-opt/include/ROOT/RDF/RAction.hxx:65:4: note: used here
> RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr<PrevDataFrame> pd, const RBookedDefines &defines)
> ^
> ---------------------------------------------------------------------------
> runtime_error Traceback (most recent call last)
> <ipython-input-2-84d58f9035de> in <module>
> 4 map_call = f"ROOT::VecOps::Map(AnalysisJetsAuxDyn.pt, {quadratic_lambda})"
> 5 r_frame = r_frame.Define("my_col", map_call)
> ----> 6 r_frame.Mean("my_col").GetValue()
> 
> runtime_error: const double& ROOT::RDF::RResultPtr<double>::GetValue() =>
> runtime_error: 
> An error occurred during just-in-time compilation in RLoopManager::Run. The lines above might indicate the cause of the crash
> All RDF objects that have not run their event loop yet should be considered in an invalid state.
> 
> ```

Eventually I realised it works if I add a `return` to the `map_call` like so;

```python
map_call = f"return ROOT::VecOps::Map(AnalysisJetsAuxDyn.pt, {quadratic_lambda})"
r_frame = r_frame.Define("my_col", map_call)
r_frame.Mean("my_col").GetValue() # Works!

```

Note that `return` is not normally needed in a `Define`. It’s not given in the [documentation example](https://root.cern/doc/master/classROOT_1_1RDF_1_1RInterface.html#a4698601205a55ac49279150d56fc904f) either. Though, adding one never seems to cause problems. I guess the existance of the return statement inside the lambda confused the compiler into thinking the whole block already had a return statement?

This could be a bug, or just my lack of comprehension of what is normally possible when jitting c++. If it’s the latter, maybe it could go in the docs anyway though, because it seemed like a reasonable confusion to me?

* * *

_ROOT Version:_ 6.24/06  
_Platform:_ NAME=“CentOS Linux” VERSION=“7 (Core)” ID\_LIKE=“rhel fedora” CLUSTER=“sunrise”  
_Compiler:_ using pyroot

* * *

---

<div class="post-metadata">

**Author:** ![FoxWise](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/foxwise/32/37588_2.png) [@FoxWise](https://root-forum.cern.ch/u/FoxWise)\
**Post date:** [August 10, 2022, 3:23pm UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132/2 "2022-08-10T15:23:10Z")

</div>

Hi Day,

I guess it is expected and known behaviour that you need a `return` there.

I also stumbled in the same problem a while ago.  
You can see detailed Enrico’s reply in the post below on why is that the case:

> [@Call method for every object in RVec in a single line](https://root-forum.cern.ch/t/call-method-for-every-object-in-rvec-in-a-single-line/49428):
>
> Hi all, I have a std::vector\<XYZVector\> stored in TTree. Is there an easy way to get absolute momentum XYZVector.R() for each element of the array within RDataFrame? The one I am currently using is: ROOT.gInterpreter.Declare(''' using namespace ROOT::Math; using namespace ROOT::VecOps; RVec \<double\> getAbsOfVectors(const RVec\<XYZVector\>& vecs){ auto getAbs = [&](const XYZVector& vec) { return vec.R(); }; return Map(vecs, getAbs); } ''') df = ROOT.RDataFrame("tree", "file.root")…

as far as I understood, the issue is that in your expression inside lambda function you already have a `return` word. So RDF does not automatically put any returns inside to avoid confusion, so you have to write it manually in the beginning in this case.

I agree a better documentation&example for this case would be nice.

cheers,  
Bohdan

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 11, 2022, 5:40pm UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132/3 "2022-08-11T17:40:30Z")

</div>

> [@Day](#):
>
> I guess the existance of the return statement inside the lambda confused the compiler into thinking the whole block already had a return statement?

That’s exactly it. I think it would be fair to classify this as a bug, unfortunately it is quite complicated and expensive to do more sophisticated C++ parsing of the string expression to figure out whether it needs a `return` or not. I hope one day someone better than me at parsing C++ will come up with a solution, for now we cannot but live with this limitation

I completely agree with you and @FoxWise that this behavior should at the very least be clearly documented, I opened a pull request [here](https://github.com/root-project/root/pull/11175).

Thank you for the feedback and sorry about the problem!  
Enrico

---

<div class="post-metadata">

**Author:** ![Day](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/dc4da7/32.png) [@Day](https://root-forum.cern.ch/u/Day)\
**Post date:** [August 12, 2022, 2:18pm UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132/4 "2022-08-12T14:18:42Z")

</div>

@eguiraud and @FoxWise thank you both of you.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 26, 2022, 2:19pm UTC](https://root-forum.cern.ch/t/possible-bug-in-rdataframe-define-with-lambdas/51132/5 "2022-08-26T14:19:11Z")

</div>

Closed on August 26, 2022, 2:19pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
