diff --git a/README.md b/README.md index 8ce781e..aceaa7b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Just add include path to `include` directory of this project. ## Syntax - `void` functions can be called in almost the same way as python code (remind yourself to append `_a` literal to keyword arguments). -- For `non-void` functions that return some objects, basically the user will need to capsulate *arguments* in `::util::args_(arg1, arg2, ...) == pybind11:tuple` and *keyword arguments* in `::util::kwargs_("k1"_a = v1, "k2"_a = v2, ...) == pybind11::dict`. The returned value is a corresponding wrapper class. Please refer to the examples below. +- For `non-void` functions that return some objects, basically the user will need to capsulate *arguments* in `args_(arg1, arg2, ...) == pybind11:tuple` and *keyword arguments* in `kwargs_("k1"_a = v1, "k2"_a = v2, ...) == pybind11::dict`. The returned value is a corresponding wrapper class. Please refer to the examples below. - exception: `subplots`, - conversion: Wrapper class of matplotlibcpp17 like [::container::BarContainer](https://github.com/soblin/matplotlibcpp17/blob/master/include/matplotlibcpp17/container.h) needs to be passed to python interpreter using `unwrap()` method in *args* and *kwargs*. diff --git a/gallery/artist_animation/animate_decay.cpp b/gallery/artist_animation/animate_decay.cpp index 494af09..7d493ad 100644 --- a/gallery/artist_animation/animate_decay.cpp +++ b/gallery/artist_animation/animate_decay.cpp @@ -13,7 +13,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; using matplotlibcpp17::animation::ArtistAnimation; int main() { diff --git a/gallery/artist_animation/cla_pause.cpp b/gallery/artist_animation/cla_pause.cpp index 5821fff..89fe56e 100644 --- a/gallery/artist_animation/cla_pause.cpp +++ b/gallery/artist_animation/cla_pause.cpp @@ -10,7 +10,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { py::scoped_interpreter guard{}; diff --git a/gallery/artist_animation/random_walk.cpp b/gallery/artist_animation/random_walk.cpp index beb2e42..a9122f6 100644 --- a/gallery/artist_animation/random_walk.cpp +++ b/gallery/artist_animation/random_walk.cpp @@ -12,7 +12,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; using matplotlibcpp17::animation::ArtistAnimation; array init_pos() { diff --git a/gallery/images_contours_and_fields/quiver_demo.cpp b/gallery/images_contours_and_fields/quiver_demo.cpp index 46aff24..7a29f96 100644 --- a/gallery/images_contours_and_fields/quiver_demo.cpp +++ b/gallery/images_contours_and_fields/quiver_demo.cpp @@ -13,7 +13,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { vector X, Y; diff --git a/gallery/lines_bars_and_markers/bar_label_demo.cpp b/gallery/lines_bars_and_markers/bar_label_demo.cpp index c1cafda..37652e2 100644 --- a/gallery/lines_bars_and_markers/bar_label_demo.cpp +++ b/gallery/lines_bars_and_markers/bar_label_demo.cpp @@ -16,7 +16,7 @@ using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { vector menMeans = {20, 35, 30, 35, -27}; diff --git a/gallery/lines_bars_and_markers/fill.cpp b/gallery/lines_bars_and_markers/fill.cpp index 247b6ab..d431d48 100644 --- a/gallery/lines_bars_and_markers/fill.cpp +++ b/gallery/lines_bars_and_markers/fill.cpp @@ -13,7 +13,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { const double scale = 10; diff --git a/gallery/lines_bars_and_markers/fill_between_demo.cpp b/gallery/lines_bars_and_markers/fill_between_demo.cpp index 3358aa4..13abfa8 100644 --- a/gallery/lines_bars_and_markers/fill_between_demo.cpp +++ b/gallery/lines_bars_and_markers/fill_between_demo.cpp @@ -25,7 +25,7 @@ template std::vector arange(T start, T end, T h) { using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { auto plt = matplotlibcpp17::pyplot::import(); diff --git a/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp b/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp index 94b04c4..eb111af 100644 --- a/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp +++ b/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp @@ -25,7 +25,7 @@ template std::vector arange(T start, T end, T h) { using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { auto plt = matplotlibcpp17::pyplot::import(); diff --git a/gallery/lines_bars_and_markers/scatter_hist.cpp b/gallery/lines_bars_and_markers/scatter_hist.cpp index 080a308..817a4d8 100644 --- a/gallery/lines_bars_and_markers/scatter_hist.cpp +++ b/gallery/lines_bars_and_markers/scatter_hist.cpp @@ -13,7 +13,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; template std::vector arange(T start, T end, T h) { int N = static_cast((end - start) / h); diff --git a/gallery/lines_bars_and_markers/scatter_with_legend.cpp b/gallery/lines_bars_and_markers/scatter_with_legend.cpp index 69de898..ec4301b 100644 --- a/gallery/lines_bars_and_markers/scatter_with_legend.cpp +++ b/gallery/lines_bars_and_markers/scatter_with_legend.cpp @@ -13,7 +13,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { auto plt = matplotlibcpp17::pyplot::import(); diff --git a/gallery/shapes_and_collections/patch_collection.cpp b/gallery/shapes_and_collections/patch_collection.cpp index e578b3d..623fd1e 100644 --- a/gallery/shapes_and_collections/patch_collection.cpp +++ b/gallery/shapes_and_collections/patch_collection.cpp @@ -14,7 +14,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; using namespace matplotlibcpp17; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { py::scoped_interpreter guard{}; diff --git a/gallery/shapes_and_collections/patches_circle_rectangle.cpp b/gallery/shapes_and_collections/patches_circle_rectangle.cpp index 9882c8c..65acdaa 100644 --- a/gallery/shapes_and_collections/patches_circle_rectangle.cpp +++ b/gallery/shapes_and_collections/patches_circle_rectangle.cpp @@ -12,7 +12,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; using namespace matplotlibcpp17::patches; int main() { diff --git a/gallery/statistics/hist.cpp b/gallery/statistics/hist.cpp index 4d0cdde..09e45e0 100644 --- a/gallery/statistics/hist.cpp +++ b/gallery/statistics/hist.cpp @@ -10,7 +10,7 @@ namespace py = pybind11; using namespace py::literals; using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main1() { int N_points = 100000; diff --git a/gallery/subplots_axes_and_figures/align_labels_demo.cpp b/gallery/subplots_axes_and_figures/align_labels_demo.cpp index 8196263..cdbf065 100644 --- a/gallery/subplots_axes_and_figures/align_labels_demo.cpp +++ b/gallery/subplots_axes_and_figures/align_labels_demo.cpp @@ -27,7 +27,7 @@ template std::vector arange(T start, T end, T h) { using namespace std; using matplotlibcpp17::gridspec::GridSpec; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { py::scoped_interpreter guard{}; diff --git a/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp b/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp index 108d3f1..76ce6fd 100644 --- a/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp +++ b/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp @@ -14,7 +14,7 @@ using namespace py::literals; using namespace std; using matplotlibcpp17::gridspec::GridSpec; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { py::scoped_interpreter guard{}; diff --git a/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp b/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp index 5b38ff3..b00081a 100644 --- a/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp +++ b/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp @@ -25,7 +25,7 @@ template std::vector arange(T start, T end, T h) { } using namespace std; -using namespace matplotlibcpp17::util; +using namespace matplotlibcpp17; int main() { py::scoped_interpreter guard{}; diff --git a/include/matplotlibcpp17/matplotlibcpp17.h b/include/matplotlibcpp17/matplotlibcpp17.h index d474ff9..8939ab8 100644 --- a/include/matplotlibcpp17/matplotlibcpp17.h +++ b/include/matplotlibcpp17/matplotlibcpp17.h @@ -18,7 +18,12 @@ namespace matplotlibcpp17 { #include "figure.h" #include "patches.h" #include "pyplot.h" -#include "util.h" + +template pybind11::tuple args_(Args &&... args) { + return pybind11::make_tuple(std::forward(args)...); +} + +using kwargs_ = pybind11::dict; } // namespace matplotlibcpp17 diff --git a/include/matplotlibcpp17/util.h b/include/matplotlibcpp17/util.h index d679c8b..e69de29 100644 --- a/include/matplotlibcpp17/util.h +++ b/include/matplotlibcpp17/util.h @@ -1,9 +0,0 @@ -namespace util { - -template pybind11::tuple args_(Args &&... args) { - return pybind11::make_tuple(std::forward(args)...); -} - -using kwargs_ = pybind11::dict; - -} // namespace util