<commit_before>#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include "Models/StateSpace/Multivariate/StateModels/SharedLocalLevel.hpp"
#include "Models/StateSpace/Multivariate/StateModels/ScalarStateModelAdapter.hpp"

#include "cpputil/Ptr.hpp"

namespace py = pybind11;
PYBIND11_DECLARE_HOLDER_TYPE(T, BOOM::Ptr<T>, true);

namespace BayesBoom {
  using namespace BOOM;

  void MultivariateStateModel_def(py::module &boom) {

    py::class_<SharedStateModel,
               StateModelBase,
               BOOM::Ptr<SharedStateModel>>(
                   boom, "SharedStateModel", py::multiple_inheritance())
        ;

    py::class_<SharedLocalLevelStateModelBase,
               SharedStateModel,
               BOOM::Ptr<SharedLocalLevelStateModelBase>>(
                   boom, "SharedLocalLevelStateModelBase", py::multiple_inheritance())
        .def_property_readonly(
            "number_of_factors",
            [](const SharedLocalLevelStateModelBase &state_model) {
              return state_model.number_of_factors();
            },
            "The number of factors in the model.")
        // .def_property_readonly(
        //     "state_dimension",
        //     [](const SharedLocalLevelStateModelBase &state_model) {
        //       return state_model.state_dimension();
        //     },
        //     "The number of dimensions this component adds to the shared "
        //     "state vector.")
        ;


    py::class_<ScalarStateModelMultivariateAdapter,
               SharedStateModel,
               Ptr<ScalarStateModelMultivariateAdapter>>(
                   boom, "ScalarStateModelMultivariateAdapter")
        .def("add_state",
             [](ScalarStateModelMultivariateAdapter *base,
                const Ptr<StateModel> &state_model) {
               base->add_state(state_model);
             },
             "Add 'state_model' to the ")
        ;

    py::class_<ConditionallyIndependentScalarStateModelMultivariateAdapter,
               ScalarStateModelMultivariateAdapter,
               Ptr<ConditionallyIndependentScalarStateModelMultivariateAdapter>>(
                   boom,
                   "ConditionallyIndependentScalarStateModelMultivariateAdapter")
        .def(py::init(
            [](ConditionallyIndependentMultivariateStateSpaceModelBase *host,
               int nseries) {
              using Adapter =
                  ConditionallyIndependentScalarStateModelMultivariateAdapter;<commit_msg>Change from Ptr to reference in call to add_state, to help pybind11 deal with inheritance.<commit_after>#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include "Models/StateSpace/Multivariate/StateModels/SharedLocalLevel.hpp"
#include "Models/StateSpace/Multivariate/StateModels/ScalarStateModelAdapter.hpp"

#include "cpputil/Ptr.hpp"

namespace py = pybind11;
PYBIND11_DECLARE_HOLDER_TYPE(T, BOOM::Ptr<T>, true);

namespace BayesBoom {
  using namespace BOOM;

  void MultivariateStateModel_def(py::module &boom) {

    py::class_<SharedStateModel,
               StateModelBase,
               BOOM::Ptr<SharedStateModel>>(
                   boom, "SharedStateModel", py::multiple_inheritance())
        ;

    py::class_<SharedLocalLevelStateModelBase,
               SharedStateModel,
               BOOM::Ptr<SharedLocalLevelStateModelBase>>(
                   boom, "SharedLocalLevelStateModelBase", py::multiple_inheritance())
        .def_property_readonly(
            "number_of_factors",
            [](const SharedLocalLevelStateModelBase &state_model) {
              return state_model.number_of_factors();
            },
            "The number of factors in the model.")
        // .def_property_readonly(
        //     "state_dimension",
        //     [](const SharedLocalLevelStateModelBase &state_model) {
        //       return state_model.state_dimension();
        //     },
        //     "The number of dimensions this component adds to the shared "
        //     "state vector.")
        ;


    py::class_<ScalarStateModelMultivariateAdapter,
               SharedStateModel,
               Ptr<ScalarStateModelMultivariateAdapter>>(
                   boom, "ScalarStateModelMultivariateAdapter")
        .def("add_state",
             [](ScalarStateModelMultivariateAdapter *base,
                StateModel &state_model) {
               base->add_state(Ptr<StateModel>(&state_model));
             },
             "Add 'state_model' to the state tracked by the adapter.")
        ;

    py::class_<ConditionallyIndependentScalarStateModelMultivariateAdapter,
               ScalarStateModelMultivariateAdapter,
               Ptr<ConditionallyIndependentScalarStateModelMultivariateAdapter>>(
                   boom,
                   "ConditionallyIndependentScalarStateModelMultivariateAdapter")
        .def(py::init(
            [](ConditionallyIndependentMultivariateStateSpaceModelBase *host,
               int nseries) {
              using Adapter =
                  ConditionallyIndependentScalarStateModelMultivariateAdapter;
{'fraction_non_alphanumeric': 0.08852005532503458, 'fraction_numerical': 0.0043469670025686625, 'mean_word_length': 2.4435374149659865, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6748371', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1289, 'n_words': 213}