Skip to content

Commit

Permalink
Merge branch 'feature/move-util'
Browse files Browse the repository at this point in the history
  • Loading branch information
soblin committed Feb 7, 2022
2 parents c780ee6 + c3d7b33 commit d59477c
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*.

Expand Down
2 changes: 1 addition & 1 deletion gallery/artist_animation/animate_decay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion gallery/artist_animation/cla_pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
2 changes: 1 addition & 1 deletion gallery/artist_animation/random_walk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, 3> init_pos() {
Expand Down
2 changes: 1 addition & 1 deletion gallery/images_contours_and_fields/quiver_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace py = pybind11;
using namespace py::literals;
using namespace std;
using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

int main1() {
vector<double> X, Y;
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/bar_label_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace py::literals;

using namespace std;

using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

int main1() {
vector<int> menMeans = {20, 35, 30, 35, -27};
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/fill_between_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ template <typename T> std::vector<T> arange(T start, T end, T h) {

using namespace std;

using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

int main1() {
auto plt = matplotlibcpp17::pyplot::import();
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/fill_betweenx_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ template <typename T> std::vector<T> arange(T start, T end, T h) {

using namespace std;

using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

int main1() {
auto plt = matplotlibcpp17::pyplot::import();
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/scatter_hist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace py = pybind11;
using namespace py::literals;
using namespace std;
using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

template <typename T> std::vector<T> arange(T start, T end, T h) {
int N = static_cast<int>((end - start) / h);
Expand Down
2 changes: 1 addition & 1 deletion gallery/lines_bars_and_markers/scatter_with_legend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion gallery/shapes_and_collections/patch_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion gallery/statistics/hist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gallery/subplots_axes_and_figures/align_labels_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ template <typename T> std::vector<T> 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{};
Expand Down
2 changes: 1 addition & 1 deletion gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
2 changes: 1 addition & 1 deletion gallery/subplots_axes_and_figures/multiple_figs_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ template <typename T> std::vector<T> arange(T start, T end, T h) {
}

using namespace std;
using namespace matplotlibcpp17::util;
using namespace matplotlibcpp17;

int main() {
py::scoped_interpreter guard{};
Expand Down
7 changes: 6 additions & 1 deletion include/matplotlibcpp17/matplotlibcpp17.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ namespace matplotlibcpp17 {
#include "figure.h"
#include "patches.h"
#include "pyplot.h"
#include "util.h"

template <typename... Args> pybind11::tuple args_(Args &&... args) {
return pybind11::make_tuple(std::forward<Args>(args)...);
}

using kwargs_ = pybind11::dict;

} // namespace matplotlibcpp17

Expand Down
9 changes: 0 additions & 9 deletions include/matplotlibcpp17/util.h
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
namespace util {

template <typename... Args> pybind11::tuple args_(Args &&... args) {
return pybind11::make_tuple(std::forward<Args>(args)...);
}

using kwargs_ = pybind11::dict;

} // namespace util

0 comments on commit d59477c

Please sign in to comment.