Skip to content

Commit

Permalink
Need an additional constructor to make pickling work.
Browse files Browse the repository at this point in the history
  • Loading branch information
phyy-nx committed Apr 8, 2020
1 parent 41ed046 commit 1564647
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion model/boost_python/beam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace dxtbx { namespace model { namespace boost_python {
return beam;
}

static Beam *make_beam_w_all(vec3<double> sample_to_source,
static Beam *make_beam_w_most(vec3<double> sample_to_source,
double wavelength,
double divergence,
double sigma_divergence,
Expand Down Expand Up @@ -131,6 +131,23 @@ namespace dxtbx { namespace model { namespace boost_python {
return beam;
}

static Beam *make_beam_w_all(vec3<double> sample_to_source,
double wavelength,
double divergence,
double sigma_divergence,
vec3<double> polarization_normal,
double polarization_fraction,
double flux,
double transmission,
scitbx::af::shared<double> spectrum_energies,
scitbx::af::shared<double> spectrum_weights,
bool deg) {
Beam *beam = make_beam_w_most(sample_to_source, wavelength, divergence, sigma_divergence,
polarization_normal, polarization_fraction, flux, transmission, deg);
beam->set_spectrum(spectrum_energies, spectrum_weights);
return beam;
}

static double get_divergence(const Beam &beam, bool deg) {
double divergence = beam.get_divergence();
return deg ? rad_as_deg(divergence) : divergence;
Expand Down Expand Up @@ -310,6 +327,18 @@ namespace dxtbx { namespace model { namespace boost_python {
default_call_policies(),
(arg("s0"), arg("divergence"), arg("sigma_divergence"), arg("deg") = true)))
.def("__init__",
make_constructor(&make_beam_w_most,
default_call_policies(),
(arg("direction"),
arg("wavelength"),
arg("divergence"),
arg("sigma_divergence"),
arg("polarization_normal"),
arg("polarization_fraction"),
arg("flux"),
arg("transmission"),
arg("deg") = true)))
.def("__init__",
make_constructor(&make_beam_w_all,
default_call_policies(),
(arg("direction"),
Expand All @@ -320,6 +349,8 @@ namespace dxtbx { namespace model { namespace boost_python {
arg("polarization_fraction"),
arg("flux"),
arg("transmission"),
arg("spectrum_energies"),
arg("spectrum_weights"),
arg("deg") = true)))
.def("__str__", &beam_to_string)
.def("get_spectrum_energies",
Expand Down

0 comments on commit 1564647

Please sign in to comment.