Skip to content

Commit a566e1f

Browse files
committed
API changes
1 parent 463755c commit a566e1f

21 files changed

+159
-143
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ int main() {
5858
column::expression([](std::vector<double> const& v){return v.size()}), x
5959
);
6060

61-
auto h_x0_w = df.make(
62-
query::plan<h1d>( linax(100,0.0,1.0) )
61+
auto h_x0_w = df.get(
62+
query::output<h1d>( linax(100,0.0,1.0) )
6363
).fill(x0).book(sel).result();
6464

6565
std::ostringstream os;

docs/pages/example.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int main() {
5151
v)
5252
.filter(column::expression([](double x) { return x > 100.0; }), x);
5353

54-
auto h_x0_w = df.make(query::plan<h1d>(linax(20, 0.0, 200.0)))
54+
auto h_x0_w = df.get(query::output<h1d>(linax(20, 0.0, 200.0)))
5555
.fill(v0)
5656
.book(sel)
5757
.result();
@@ -275,7 +275,7 @@ int main() {
275275
// ---------------------------------------------------------------------------
276276

277277
auto [pth_2los_sr, pth_2ldf_sr, pth_2lsf_sr] =
278-
df.make(query::plan<HepQ::Hist<1, float>>("pth", 30, 0, 150))
278+
df.get(query::output<HepQ::Hist<1, float>>("pth", 30, 0, 150))
279279
.fill(higgs_pt)
280280
.book(cut_2los_sr, cut_2ldf_sr, cut_2lsf_sr);
281281

@@ -425,7 +425,7 @@ int main(int argc, char *argv[]) {
425425
.filter(column::expression(TwoElectrons), selectedElectrons);
426426

427427
auto selectedElectronsPtHist =
428-
df.make(query::plan<HepQ::Hist<1,float>>("diElectronMass", 100, 0, 500))
428+
df.get(query::output<HepQ::Hist<1,float>>("diElectronMass", 100, 0, 500))
429429
.fill(diElectronsMassGeV)
430430
.book(atLeastTwoSelectedElectrons);
431431

@@ -559,7 +559,7 @@ void task(int n) {
559559
goodjet_mask);
560560

561561
auto h_sumpt_goodjet =
562-
df.make(query::plan<HepQ::Hist<1, float>>("goodjet_sumpt", 185, 15, 200))
562+
df.get(query::output<HepQ::Hist<1, float>>("goodjet_sumpt", 185, 15, 200))
563563
.fill(goodjet_sumpt)
564564
.book(cut_goodjet);
565565

docs/pages/guide.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ using h2d = qty::hist::hist<double,double>;
208208
using linax = qty::hist::axis::regular;
209209

210210
// plan a 1d/2d histogram query filled with x/(x,y)
211-
auto q_1d = df.make(query::plan<h1d>(linax(100,0.0,1.0))).fill(x);
212-
auto q_2d = df.make(query::plan<h2d>(linax(100,0.0,1.0), linax(100,0.0,1.0))).fill(x,y);
211+
auto q_1d = df.get(query::output<h1d>(linax(100,0.0,1.0))).fill(x);
212+
auto q_2d = df.get(query::output<h2d>(linax(100,0.0,1.0), linax(100,0.0,1.0))).fill(x,y);
213213

214214
// query at multiple selections
215215
auto [q_1d_a, q_1d_b] = q_1d.book(cut_a, cut_b);
@@ -226,7 +226,7 @@ auto hxy_c = q_2d_c.result(); // instantaneous
226226
@endcpp
227227

228228
@see
229-
- queryosity::query::plan (API)
229+
- queryosity::query::output (API)
230230
- queryosity::query::definition<T(Obs...)> (ABC)
231231
- queryosity::hist::hist (Extension)
232232

@@ -281,17 +281,6 @@ auto z = systematic::vary(
281281
// (column::valued<double> is the common denominator base class)
282282
@endcpp
283283

284-
285-
@cpp
286-
// definitions are varied by alternate constructor arguments+input columns
287-
// since the constructor arguments of an arbitrary class is not known a-priori,
288-
// each must be provided on its own, rather than in a mapping.
289-
auto defn = df.vary(
290-
column::definition<>(),
291-
systematic::variation("vary_c", )
292-
)();
293-
@endcpp
294-
295284
The list of variations in a (set of) action(s) can be always be checked as they are propagated through the dataflow.
296285
After the dust settles, the nominal and each varied result of a query can be accessed individually.
297286

docs/poxy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ paths = [ 'images' ]
8484
'queryosity::todo?' = 'classqueryosity_1_1todo.html'
8585
'queryosity::todo::varied?' = 'classqueryosity_1_1todo_1_1varied.html'
8686
'queryosity::column::definition<Out(Ins...)>?' = 'classqueryosity_1_1column_1_1definition_3_01_out_07_ins_8_8_8_08_4.html'
87-
'queryosity::query::plan?' = 'classqueryosity_1_1query_1_1definition_3_01_t_07_obs_8_8_8_08_4.html'
87+
'queryosity::query::output?' = 'classqueryosity_1_1query_1_1definition_3_01_t_07_obs_8_8_8_08_4.html'
8888
'queryosity::query::definition<T(Obs...)>?' = 'classqueryosity_1_1query_1_1definition_3_01_t_07_obs_8_8_8_08_4.html'
8989
'queryosity::hist::hist<Vals...>?' = 'classqueryosity_1_1hist_1_1hist.html'
9090
'Modules?' = 'modules.html'

examples/example-hello_world.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ int main() {
3333
[](std::vector<double> const &v) { return v.size(); }))(v)
3434
.filter(column::expression([](double x) { return x > 100.0; }))(x);
3535

36-
auto h_x0_w = df.make(query::plan<h1d>(linax(20, 0.0, 200.0)))
36+
auto h_x0_w = df.get(query::output<h1d>(linax(20, 0.0, 200.0)))
3737
.fill(v0)
38-
.book(sel)
38+
.at(sel)
3939
.result();
4040

4141
std::ostringstream os;

examples/example-multiple_datasets.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ int main() {
3131

3232
auto all = df.all();
3333

34-
auto h_z = df.make(query::plan<h1d>(linax(20,90.0,110.0)))
34+
auto h_z = df.get(query::output<h1d>(linax(20,90.0,110.0)))
3535
.fill(z)
36-
.book(all)
36+
.at(all)
3737
.result();
3838

3939
std::ostringstream os;

include/queryosity/column_series.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ queryosity::column::series<Col>::series(Col const &col) : m_column(col){};
4444
template <typename Col>
4545
auto queryosity::column::series<Col>::_get(lazy<selection::node> &sel) const {
4646
auto df = sel.m_df;
47-
return df->make(query::plan<query::series<value_type>>())
47+
return df->get(query::output<query::series<value_type>>())
4848
.fill(m_column)
49-
.book(sel);
49+
.at(sel);
5050
}
5151

5252
template <typename Col>
5353
auto queryosity::column::series<Col>::_get(lazy<selection::node>::varied &sel)
5454
const -> typename lazy<query::series<value_type>>::varied {
5555
auto df = sel.nominal().m_df;
56-
return df->make(query::plan<query::series<value_type>>())
56+
return df->get(query::output<query::series<value_type>>())
5757
.fill(m_column)
58-
.book(sel);
58+
.at(sel);
5959
}

include/queryosity/dataflow.h

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,35 @@ class dataflow {
219219
/**
220220
* @brief Plan a query.
221221
* @tparam Qry Concrete queryosity::query::definition implementation.
222-
* @param[in] plan Query plan (constructor arguments).
222+
* @param[in] output Query output (constructor arguments).
223223
* @return queryosity::todo query booker.
224224
*/
225225
template <typename Qry>
226-
auto make(query::plan<Qry> const &plan) -> todo<query::booker<Qry>>;
226+
auto get(query::output<Qry> const &output) -> todo<query::booker<Qry>>;
227+
228+
/**
229+
* @brief Get a column series.
230+
* @tparam Col (Varied) lazy column.
231+
* @param[in] col Column as series argument.
232+
* @return queryosity::todo query booker.
233+
*/
234+
template <typename Col> auto get(column::series<Col> const &srs);
227235

228236
template <typename Val>
229-
auto vary(column::constant<Val> const &cnst, std::map<std::string, Val> vars);
237+
auto vary(column::constant<Val> const &cnst, std::map<std::string, Val> vars)
238+
-> typename lazy<column::fixed<Val>>::varied;
230239

231240
template <typename Fn>
232241
auto
233242
vary(column::expression<Fn> const &expr,
234243
std::map<std::string,
235-
typename column::expression<Fn>::function_type> const &vars);
244+
typename column::expression<Fn>::function_type> const &vars) ->
245+
typename todo<column::evaluator<column::equation_t<Fn>>>::varied;
236246

237-
template <typename Defn, typename... Vars>
238-
auto vary(column::definition<Defn> const &defn, Vars const &...vars);
247+
template <typename Def>
248+
auto vary(column::definition<Def> const &defn,
249+
std::map<std::string, column::definition<Def>> const &vars) ->
250+
typename todo<column::evaluator<Def>>::varied;
239251

240252
/* "public" API for Python layer */
241253

@@ -312,9 +324,9 @@ class dataflow {
312324
void _vary(Syst &syst, const std::string &name,
313325
column::expression<Fn> const &expr);
314326

315-
template <typename Syst, typename Defn>
327+
template <typename Syst, typename Def>
316328
void _vary(Syst &syst, const std::string &name,
317-
column::definition<Defn> const &defn);
329+
column::definition<Def> const &defn);
318330

319331
protected:
320332
dataset::processor m_processor;
@@ -367,7 +379,7 @@ class dataflow::node {
367379

368380
#include "column_constant.h"
369381
#include "column_expression.h"
370-
#include "query_plan.h"
382+
#include "query_output.h"
371383

372384
#include "systematic_nominal.h"
373385
#include "systematic_resolver.h"
@@ -534,9 +546,14 @@ auto queryosity::dataflow::_make(Args &&...args) -> todo<query::booker<Qry>> {
534546
}
535547

536548
template <typename Qry>
537-
auto queryosity::dataflow::make(queryosity::query::plan<Qry> const &cntr)
549+
auto queryosity::dataflow::get(queryosity::query::output<Qry> const &qry)
538550
-> todo<query::booker<Qry>> {
539-
return cntr._make(*this);
551+
return qry.make(*this);
552+
}
553+
554+
template <typename Col>
555+
auto queryosity::dataflow::get(queryosity::column::series<Col> const &srs) {
556+
return this->all().get(srs);
540557
}
541558

542559
template <typename Def, typename... Cols>
@@ -558,7 +575,7 @@ auto queryosity::dataflow::_apply(
558575
todo<selection::applicator<Sel, Def>> const &appl,
559576
lazy<Cols> const &...columns) -> lazy<selection::node> {
560577
auto act = ensemble::invoke(
561-
[](dataset::player *plyr, selection::applicator<Sel,Def> const *appl,
578+
[](dataset::player *plyr, selection::applicator<Sel, Def> const *appl,
562579
Cols const *...cols) { return plyr->template apply(*appl, *cols...); },
563580
m_processor.get_slots(), appl.get_slots(), columns.get_slots()...);
564581
auto lzy = lazy<selection::node>(*this, act);
@@ -598,7 +615,8 @@ inline void queryosity::dataflow::reset() { m_analyzed = false; }
598615

599616
template <typename Val>
600617
auto queryosity::dataflow::vary(column::constant<Val> const &cnst,
601-
std::map<std::string, Val> vars) {
618+
std::map<std::string, Val> vars) ->
619+
typename lazy<column::fixed<Val>>::varied {
602620
auto nom = this->define(cnst);
603621
using varied_type = typename decltype(nom)::varied;
604622
varied_type syst(std::move(nom));
@@ -612,7 +630,8 @@ template <typename Fn>
612630
auto queryosity::dataflow::vary(
613631
column::expression<Fn> const &expr,
614632
std::map<std::string, typename column::expression<Fn>::function_type> const
615-
&vars) {
633+
&vars) ->
634+
typename todo<column::evaluator<column::equation_t<Fn>>>::varied {
616635
auto nom = this->_equate(expr);
617636
using varied_type = typename decltype(nom)::varied;
618637
using function_type = typename column::expression<Fn>::function_type;
@@ -623,15 +642,17 @@ auto queryosity::dataflow::vary(
623642
return syst;
624643
}
625644

626-
template <typename Defn, typename... Vars>
627-
auto queryosity::dataflow::vary(column::definition<Defn> const &defn,
628-
Vars const &...vars) {
645+
template <typename Def>
646+
auto queryosity::dataflow::vary(
647+
column::definition<Def> const &defn,
648+
std::map<std::string, column::definition<Def>> const &vars) ->
649+
typename todo<column::evaluator<Def>>::varied {
629650
auto nom = this->_define(defn);
630651
using varied_type = typename decltype(nom)::varied;
631652
varied_type syst(std::move(nom));
632-
((this->_vary(syst, vars.name(),
633-
vars.template _vary_arg<column::definition<Defn>>())),
634-
...);
653+
for (auto const &var : vars) {
654+
this->_vary(syst, var.first, var.second);
655+
}
635656
return syst;
636657
}
637658

@@ -722,7 +743,8 @@ auto queryosity::dataflow::_select(column::expression<Fn> const &expr)
722743
}
723744

724745
template <typename Sel, typename Fn>
725-
auto queryosity::dataflow::_select(lazy<selection::node> const& prev, column::expression<Fn> const &expr)
746+
auto queryosity::dataflow::_select(lazy<selection::node> const &prev,
747+
column::expression<Fn> const &expr)
726748
-> todo<selection::applicator<Sel, column::equation_t<Fn>>> {
727749
return expr.template _select<Sel>(*this, prev);
728750
}
@@ -764,9 +786,9 @@ void queryosity::dataflow::_vary(Syst &syst, const std::string &name,
764786
syst.set_variation(name, this->_equate(expr));
765787
}
766788

767-
template <typename Syst, typename Defn>
789+
template <typename Syst, typename Def>
768790
void queryosity::dataflow::_vary(Syst &syst, const std::string &name,
769-
column::definition<Defn> const &defn) {
791+
column::definition<Def> const &defn) {
770792
syst.set_variation(name, this->_define(defn));
771793
}
772794

include/queryosity/lazy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ template <typename Agg>
309309
auto queryosity::lazy<Action>::book(Agg &&agg) const {
310310
static_assert(std::is_base_of_v<selection::node, Action>,
311311
"book must be called from a selection");
312-
return agg.book(*this);
312+
return agg.at(*this);
313313
}
314314

315315
template <typename Action>
316316
template <typename... Aggs>
317317
auto queryosity::lazy<Action>::book(Aggs &&...aggs) const {
318318
static_assert(std::is_base_of_v<selection::node, Action>,
319319
"book must be called from a selection");
320-
return std::make_tuple((aggs.book(*this), ...));
320+
return std::make_tuple((aggs.at(*this), ...));
321321
}
322322

323323
template <typename Action>

0 commit comments

Comments
 (0)