diff --git a/pyeris/core/Market.cpp b/pyeris/core/Market.cpp index 032a095e8cf1908b8708c69fd904c073a598c8fa..8cc09f5fe82883193b133c066d12a4a6395e4e94 100644 --- a/pyeris/core/Market.cpp +++ b/pyeris/core/Market.cpp @@ -58,7 +58,15 @@ void bind_market(py::module &m) { "Creates a Reservation object for the given agent, quantity, and maximum expenditure. This method is for internal use by Market subclasses to actually create the object; external callers should call reserve() instead. This method removes the payment from the agent ") .def("add_firm", &Market::addFirm, "Adds the given firm to the firms supplying output units in this market.") .def("remove_firm", &Market::removeFirm, "Removes the given firm from the firms supplying output units in this market. This only needs to be called explicitly when the firm remains in the simulation; firms removed from the simulation will have this called automatically.") - .def("firms", &Market::firms, "Returns the set of firms that supply this market") + // NB: firms in the Python interface is a python set of firms, unlike the C++ interface + // where firms() is a (C++) unordered_set of firm *ids* + .def("firms", [](Market &m) { + py::set firms; + auto sim = m.simulation(); + for (auto fid : m.firms()) + firms.add(py::cast(sim->agent(fid))); + return firms; }, "Returns a set of firms that supply this market.") + .def_readonly("output_unit", &Market::output_unit, "The bundle in terms of which output quantities are measured.") .def_readonly("price_unit", &Market::price_unit, "The bundle in terms of which output prices are measured.") ;