Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101442

What use of these _ prefix members?

Newsgroups comp.lang.python
Date 2016-01-10 09:55 -0800
Message-ID <4ee5810e-abe9-4c4b-9ebd-d989b5c2b341@googlegroups.com> (permalink)
Subject What use of these _ prefix members?
From Robert <rxjwg98@gmail.com>

Show all headers | View raw


Hi,

When I read a sample file from hmm learn package, which is on top of 
scikit-learn package, I see there are many member functions (prefix with 
'_') have no caller. That is, I don't see anything uses those functions.
Below is a sample part from class GMMHMM(_BaseHMM):





//////////
    def __init__(self, n_components=1, n_mix=1,........
                 params="stmcw", init_params="stmcw"):
        _BaseHMM.__init__(self, n_components,.........
                          params=params, init_params=init_params)

        # XXX: Hotfit for n_mix that is incompatible with the scikit's
        # BaseEstimator API
        self.n_mix = n_mix
        self.covariance_type = covariance_type
        self.covars_prior = covars_prior
        self.gmms_ = []
        for x in range(self.n_components):
            if covariance_type is None:
                gmm = GMM(n_mix)
            else:
                gmm = GMM(n_mix, covariance_type=covariance_type)
            self.gmms_.append(gmm)

    def _init(self, X, lengths=None):
        super(GMMHMM, self)._init(X, lengths=lengths)

        for g in self.gmms_:
            g.set_params(init_params=self.init_params, n_iter=0)
            g.fit(X)

    def _compute_log_likelihood(self, X):
        return np.array([g.score(X) for g in self.gmms_]).T

    def _generate_sample_from_state(self, state, random_state=None):
        return self.gmms_[state].sample(1, random_state=random_state).flatten()
////////////

Some online tutorials tell me '_' prefix is a kind of convention of private 
members. hmm is not a formal package. Do these '_' member functions are
unfinished? Or, they may be used in some way I don't know yet?

Thanks,

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

What use of these _ prefix members? Robert <rxjwg98@gmail.com> - 2016-01-10 09:55 -0800
  Re: What use of these _ prefix members? Steven D'Aprano <steve@pearwood.info> - 2016-01-11 05:03 +1100
  Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-10 19:34 +0100
    Re: What use of these _ prefix members? me <self@example.org> - 2016-01-12 14:12 +0000
      Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-12 15:52 +0100
      Re: What use of these _ prefix members? Jason Swails <jason.swails@gmail.com> - 2016-01-12 10:01 -0500

csiph-web