MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / NGS_DLL_HEADER ExportNgstd

Function NGS_DLL_HEADER ExportNgstd

ngstd/python_ngstd.cpp:64–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64void NGS_DLL_HEADER ExportNgstd(py::module & m) {
65 try {
66 auto numpy = py::module::import("numpy");
67 have_numpy = !numpy.is_none();
68 }
69 catch(...) {}
70
71
72 std::string nested_name = "ngstd";
73
74 py::class_<DummyArgument>(m, "DummyArgument")
75 .def("__bool__", []( DummyArgument &self ) { return false; } )
76 .def("__repr__", [] ( DummyArgument & self) { return "<ngsolve.ngstd.DummyArgument>"; })
77 ;
78
79 py::class_<ngstd::LocalHeap> (m, "LocalHeap", "A heap for fast memory allocation")
80 .def(py::init<size_t,const char*>(), "size"_a=1000000, "name"_a="PyLocalHeap")
81 ;
82
83 py::class_<ngstd::HeapReset>
84 (m, "HeapReset","stores heap-pointer on init, and resets it on exit")
85 .def(py::init<LocalHeap&>(), py::arg("lh"))
86 ;
87
88 m.def("TestFlagsConversion", []( Flags flags) { cout << flags << endl; }, py::arg("flags") );
89
90 py::class_<ngstd::IntRange> (m, "IntRange")
91 .def( py::init<size_t,size_t>())
92 .def("__str__", &ToString<IntRange>)
93 .def("__iter__", [] (ngstd::IntRange & i)
94 { return py::make_iterator(i.begin(), i.end()); },
95 py::keep_alive<0,1>())
96 .def("__contains__", [] (const IntRange & self, int i)
97 { return i >= self.begin() && i < self.end(); })
98 .def_property_readonly("start", [](IntRange& self) { return self.First();})
99 .def_property_readonly("stop", [](IntRange& self) { return self.Next();})
100 .def_property_readonly("step", [](IntRange& self) { return 1; })
101 ;
102
103 py::class_<Archive, shared_ptr<Archive>> (m, "Archive")
104 /*
105 .def("__init__", [](const string & filename, bool write,
106 bool binary) -> shared_ptr<Archive>
107 {
108 if(binary) {
109 if (write)
110 return make_shared<BinaryOutArchive> (filename);
111 else
112 return make_shared<BinaryInArchive> (filename);
113 }
114 else {
115 if (write)
116 return make_shared<TextOutArchive> (filename);
117 else
118 return make_shared<TextInArchive> (filename);
119 }
120 })
121 */

Callers

nothing calls this directly

Calls 7

argFunction · 0.85
MemoryViewClass · 0.85
beginMethod · 0.45
endMethod · 0.45
FirstMethod · 0.45
PtrMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected