Skip to content

De-duplicate HoldIt class #4994

Closed
Closed

Description

@jbrockmendel

Defined in tools.dump2module but not used elsewhere within statsmodels (useful externally?). A not-quite-identical class is defined in statsmodels/sandbox/tests/maketests_mlabwrap.py and used both there and in statsmodels/sandbox/tests/savervs.py

Activity

  1. bashtage commented on Aug 24, 2018

    @bashtage
    Member

    You should see how many class Bunch definitions there are.

  2. josef-pkt commented on Aug 24, 2018

    @josef-pkt
    Member

    We don't have yet a proper class hierarchy for Bunch/Holder classes, so the easiest is to just define them where they are needed. For hypothesis tests they get sometimes converted to some kind of Results classes with extra methods.
    Design for inheritable Bunch/Holder/TestResults classes is still open.

    (My Stata export do file defines new Holder classes each time.)

  3. N-Wouda commented on Aug 24, 2018

    @N-Wouda
    Contributor

    All class Bunch definitions 'out there' follow one of the following two templates, (i),

    class Bunch(dict):
        def __init__(self, **kw):
            dict.__init__(self, kw)
            self.__dict__ = self

    And (ii),

    class Bunch(dict):
        def __init__(self, **kw):
            dict.__init__(self, kw)
            self.__dict__ = self
    
            for i,att in enumerate(['params', 'bse', 'tvalues', 'pvalues']):
                self[att] = self.params_table[:,i]

    I have some spare time and could consolidate this, i.a., into a proper class hierarchy, and then redirect current definitions to use one of the two classes. After that, I'm very willing to look at Hold(It/er) and TestResults, but that might not get done soon.

    @josef-pkt @bashtage where'd you suggest to place the Bunch definition in the code base? My initial thoughts were to create a new module parameter_objects in sm/tools , which would then expose these classes.

  4. josef-pkt commented on Aug 24, 2018

    @josef-pkt
    Member

    The problem is that I actually don't like Bunch classes (subclass of dict) anymore, i.e. I never use the dictionary access, and only like attribute access as in our Model Results classes.

    based on a file search:
    tsa (Chad in newer code) uses them quite a bit, but imported:
    from statsmodels.tools.tools import Bunch

    there are some miscellaneous uses where a Bunch class is not always a Bunch(dict), but are just what I switched to calling Holder classes.
    And there are many Bunch classes in Stata results, but those are part of the do file, i.e. autogenerated. (Those could be Holder classes because we only use attribute access AFAIK)

    for test results as replacement of Bunch and Holder classes
    #277 first open issue from 2012
    #1182 initial discussion from 2013
    with still no general outcome, just a lot more special cases

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

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