Repository navigation
Expand file tree
/
Copy pathHeader.python.cpp
More file actions
131 lines (108 loc) · 2.94 KB
/
Copy pathHeader.python.cpp
File metadata and controls
131 lines (108 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
// local includes
#include "ACEtk/Table.hpp"
// namespace aliases
namespace python = pybind11;
void wrapHeader( python::module& module, python::module& ) {
// type aliases
using Component = njoy::ACEtk::Table::Header;
// wrap views created by this component
// create the component
python::class_< Component > component(
module,
"Header",
"The header in an ACE table"
);
// wrap the component
component
.def(
python::init< const std::string&, double, double,
const std::string&, const std::string&,
const std::string& >(),
python::arg( "zaid" ), python::arg( "awr" ), python::arg( "temperature" ),
python::arg( "date" ), python::arg( "title" ), python::arg( "material" ),
"Initialise the component\n\n"
"Arguments:\n"
" self the header\n"
" zaid the zaid (max 10 characters)\n"
" awr the atomic weight ratio (to the neutron mass)\n"
" temperature the temperature in MeV\n"
" date the date (max 10 characters)\n"
" title the title (max 70 characters)\n"
" material the material (max 10 characters)"
)
.def_property_readonly(
"VERS",
&Component::VERS,
"The header version"
)
.def_property_readonly(
"version",
&Component::version,
"The header version"
)
.def_property_readonly(
"zaid",
&Component::ZAID,
"The full ZAID or SZAID of the table"
)
.def_property_readonly(
"AWR",
&Component::AWR,
"The atomic weight ratio (with respect to the neutron mass)"
)
.def_property_readonly(
"atomic_weight_ratio",
&Component::atomicWeightRatio,
"The atomic weight ratio (with respect to the neutron mass)"
)
.def_property_readonly(
"TEMP",
&Component::TEMP,
"The temperature of the table"
)
.def_property_readonly(
"temperature",
&Component::temperature,
"The temperature of the table"
)
.def_property_readonly(
"date",
&Component::date,
"The date"
)
.def_property_readonly(
"title",
&Component::title,
"The title"
)
.def_property_readonly(
"material",
&Component::material,
"The material"
)
.def_static(
"from_string",
[] ( const std::string& string ) -> Component {
njoy::ACEtk::State< decltype(string.begin()) > state{ 1, string.begin(), string.end() };
return Component( state );
},
python::arg( "string" ),
"Read the ACE header from a string\n\n"
"An exception is raised if something goes wrong while reading the\n"
"header\n\n"
"Arguments:\n"
" string the string representing the ACE header"
)
.def(
"to_string",
[] ( const Component& self ) {
std::ostringstream out;
self.print( out );
return out.str();
},
"Return the string representation of the ACE table"
);
}