Skip to content

FAQ-D/REF: setting attributes in wrapped results instance #3920

Open

Description

@josef-pkt

this works:
res_gp0._results._attach_nullmodel = True

This does not work:
res_gp0._attach_nullmodel = True
because it attaches the attribute to the wrapper instead of the results instance itself.

I just puzzled for a while again why the second version did not have any effect on the computation.

Currently there is no public reason to set attributes in the results instance. It's only used for "cheating".

In the specific case, we need a better way to signal that we want to keep the null model.

Activity

  1. jbrockmendel commented on Oct 4, 2017

    @jbrockmendel
    Contributor

    I'm unclear on the goal. Are you suggesting patching ResultsWrapper.__setattr__ to pass through to res._results.__setattr__?

  2. josef-pkt commented on Oct 4, 2017

    @josef-pkt
    MemberAuthor

    No, I don't want to touch the Wrapper code.

    The workaround is to have official results.set_xxx methods or settable attributes if needed.
    However, in general we don't "allow" users to change any attributes of a results instance. (We cannot prevent it and I use it for cheating sometimes, but nothing is quaranteed anymore if an attribute is changed by the user.)

    This issue is mainly a reminder and trick for internal code.
    related: from statsmodels.tools.tools import maybe_unwrap_results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions