Skip to content

Commit

Permalink
Implemented Mixture.__repr__ and MixtureComponent.__repr__.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Mar 8, 2017
1 parent fad1031 commit 4ff14dd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions python/lsst/meas/modelfit/mixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ static PyMixtureComponent declareMixtureComponent(py::module &mod) {
"dim1"_a, "dim2"_a);
cls.def(py::init<int>(), "dim"_a);
cls.def(py::init<Scalar, Vector const &, Matrix const &>(), "weight"_a, "mu"_a, "sigma"_a);
cls.def("__str__", [](MixtureComponent const &self) {
auto streamStr = [](MixtureComponent const &self) {
std::ostringstream os;
os << self;
return os.str();
});
};
cls.def("__str__", streamStr);
cls.def("__repr__", streamStr);
return cls;
}

Expand Down Expand Up @@ -131,11 +133,14 @@ static PyMixture declareMixture(py::module &mod) {
cls.def("clone", &Mixture::clone);
cls.def(py::init<int, Mixture::ComponentList &, Scalar>(), "dim"_a, "components"_a,
"df"_a = std::numeric_limits<Scalar>::infinity());
cls.def("__str__", [](Mixture const &self) {
auto streamStr = [](Mixture const &self) {
std::ostringstream os;
os << self;
return os.str();
});
};
return cls;
cls.def("__str__", streamStr);
cls.def("__repr__", streamStr);
return cls;
}

Expand Down

0 comments on commit 4ff14dd

Please sign in to comment.