Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes
PyScriptHandle.hpp File Reference

utility to use python script within tests More...

#include "shambindings/pytypealias.hpp"
#include "shamsys/legacy/log.hpp"
#include <pybind11/embed.h>
#include <pybind11/eval.h>
#include <pybind11/pybind11.h>
+ Include dependency graph for PyScriptHandle.hpp:

Go to the source code of this file.

Classes

struct  PyScriptHandle
 Class allowing use of python scripts within a test case. More...
 

Detailed Description

utility to use python script within tests

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Example :

TestStart(Unittest, "shamtest/PyScriptHandle(plot)", shamtestpyscriptplot, 1) {
std::vector<f64> x = {0, 1, 2, 4, 5};
std::vector<f64> y = {1, 2, 4, 6, 1};
hdnl.data()["x"] = x;
hdnl.data()["y"] = y;
hdnl.exec(R"(
import matplotlib.pyplot as plt
plt.plot(x,y)
plt.savefig("tests/figures/test.pdf")
)");
}
#define TestStart(type, name, func_name, node_cnt)
Macro to declare a test.
Definition shamtest.hpp:131
Class allowing use of python scripts within a test case.
pybind11::dict & data()
return reference to the locals
Date
2023-01-04

Definition in file PyScriptHandle.hpp.