Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101349
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Question about a class member |
| Date | Thu, 7 Jan 2016 11:38:52 -0700 |
| Lines | 46 |
| Message-ID | <mailman.52.1452191974.2305.python-list@python.org> (permalink) |
| References | <a199a9b7-784e-4e12-8030-4e3fffd636a7@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de 1Gt5LXimXUoxMEP/co/m9Q4ntHQhoN7/PQbObklTyyUg== |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'received:209.85.223': 0.03; 'none:': 0.05; 'subject:Question': 0.05; 'skip:/ 10': 0.07; '[1,': 0.09; 'attribute.': 0.09; 'definition,': 0.09; 'jan': 0.11; 'def': 0.13; 'thu,': 0.15; "'int'": 0.16; '2016': 0.16; 'last)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:class': 0.16; 'subject:member': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'element': 0.18; 'refers': 0.18; 'class,': 0.22; 'am,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; '(which': 0.26; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'code': 0.30; 'class.': 0.30; "can't": 0.32; 'message.': 0.33; 'skip:_ 30': 0.33; 'instances': 0.33; 'traceback': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'skip:c 30': 0.35; 'instance': 0.35; 'robert': 0.35; "isn't": 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'method': 0.37; 'list.': 0.37; 'received:209': 0.38; 'anything': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'per': 0.62; 'sample': 0.63; 'state,': 0.66; '100%': 0.72; '..........': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=9N8ehNJs2qqV3xhWXxgUbIowfxfH9Z4wedyrQMEYgBk=; b=nqJTt+0pPEQ6KR3K2IMs4u3e2L53A3dp0fv0YXIybVbrjReB/Wk/au1NCXL72Y1FkX mtueiMZGEDnTwECW49CPm3bTyY7ENkjstj529o7FDLbKW4XIbURUYH75lpICln8Z9cxv cIDSf2RBfhqLYdsGttBapddZPtEBAsoEqbMpoB7z/C9gls9mTxKRMw5rU4/yFsmwEgv0 rc2gSk3dHug8JoxhfJ6u4UBIR33H0Od9VVHfUF8TkrQmnGW/uY9K/eLITDId06ae2REO K1rCLJbxdOyFOu/+szmoF2UIlfsy+IO1sEkUI3NdKu3rbhMTiIGPHO/eoxnLqn3i+lm0 zp9w== |
| X-Received | by 10.107.11.68 with SMTP id v65mr95791100ioi.188.1452191971962; Thu, 07 Jan 2016 10:39:31 -0800 (PST) |
| In-Reply-To | <a199a9b7-784e-4e12-8030-4e3fffd636a7@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101349 |
Show key headers only | View raw
On Thu, Jan 7, 2016 at 10:23 AM, Robert <rxjwg98@gmail.com> wrote: > When I read its (class) definition, I find the following part (which may not > be sure 100% the above origination yet, but it is the only line being > 'sample'). > ////////////// > 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) self.gmms_ is a list. The contents of the list are instances of the GMM class, which I can't tell you anything about because it isn't reproduced in your message. > def _generate_sample_from_state(self, state, random_state=None): > return self.gmms_[state].sample(1, random_state=random_state).flatten() > //////////// > > The above code looks like self.gmms is a list, which has an attribute > 'sample'. But when I play with a list, there is no 'sample' attribute. self.gmms_[state] refers to a particular element of the list, which per the above should be an instance of the GMM class. The sample method would be part of the GMM class. > .......... > a=[1, 32.0, 4] > > a > Out[68]: [1, 32.0, 4] > > type(a) > Out[69]: list > > a[0].sample(1,5) > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > <ipython-input-70-ce2e8159b438> in <module>() > ----> 1 a[0].sample(1,5) > > AttributeError: 'int' object has no attribute 'sample' Because you're playing with a list of ints and floats, not GMMs.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question about a class member Robert <rxjwg98@gmail.com> - 2016-01-07 09:23 -0800
Re: Question about a class member Robert <rxjwg98@gmail.com> - 2016-01-07 09:39 -0800
Re: Question about a class member John Gordon <gordon@panix.com> - 2016-01-07 18:37 +0000
Re: Question about a class member Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-07 11:38 -0700
Re: Question about a class member Steven D'Aprano <steve@pearwood.info> - 2016-01-08 09:05 +1100
Re: Question about a class member Robert <rxjwg98@gmail.com> - 2016-01-07 15:02 -0800
csiph-web