Skip to content

Access configs from config objects #934

@cpaniaguam

Description

@cpaniaguam

Add deprecation warnings to these getters

HSSM/src/hssm/hssm.py

Lines 399 to 408 in 6f3f20a

# Set up shortcuts so old code will work
# TODO: add to HSSMBase
self.response = self.model_config.response[:]
self.list_params = self.model_config.list_params
self.choices = self.model_config.choices
self.model_name = self.model_config.model_name
self.loglik = self.model_config.loglik
self.loglik_kind = self.model_config.loglik_kind
self.extra_fields = self.model_config.extra_fields

and instead access these from the config objects.

Examples:

    def _deprecation_warn(self, name: str) -> None:
        """Emit a DeprecationWarning advising to use the typed config.

        Parameters
        ----------
        name
            Attribute name being deprecated.
        """
        warnings.warn(
            f"`{name}` is deprecated; use `self.model_config.{name}` instead.",
            DeprecationWarning,
            stacklevel=2,
        )

    @property
    def response(self):
        """Deprecated proxy for `self.model_config.response`.

        Returns the list of observed response column names or None.
        """
        self._deprecation_warn("response")
        return (
            list(self.model_config.response)
            if self.model_config.response is not None
            else None
        )

    @response.setter
    def response(self, value):
        """Set the model_config.response value (deprecated).

        Converts the assigned value to a list or None before assignment.
        """
        self._deprecation_warn("response")
        self.model_config.response = list(value) if value is not None else None

    @property
    def list_params(self):
        """Deprecated proxy for `self.model_config.list_params`.

        Returns the parameter name list used by the likelihood.
        """
        self._deprecation_warn("list_params")
        return self.model_config.list_params

    @list_params.setter
    def list_params(self, value):
        """Set the model_config.list_params value (deprecated)."""
        self._deprecation_warn("list_params")
        self.model_config.list_params = value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions