Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70819
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <pappgyozo@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'represents': 0.05; 'binary': 0.07; 'element': 0.07; 'tom': 0.07; 'subject:number': 0.09; '-1,': 0.16; 'lambda': 0.16; 'numpy': 0.16; 'subject:Convert': 0.16; 'subject:array': 0.16; 'zeros': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'this?': 0.23; '>>>': 0.24; 'own.': 0.24; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'consisting': 0.31; 'url:python': 0.33; 'maybe': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'representing': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'skip:2 20': 0.60; 'from:charset:utf-8': 0.61; 'email addr:gmail.com': 0.63; 'wish': 0.70; 'power': 0.76; 'converters': 0.84; 'numbers:': 0.91 |
| 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=/zLZU4FRbYxPtxM9Uhc3824bY0CJkayKUaVxFFa4/KA=; b=aU7GcFViR+UWNY7JznLLTVMhWrav1UX7fF1Lty9oh2xGwhw0+Wy0Sd6JG7/1gQPc7U Ys++kdQDoBIPjPO1woUye44Dygsy3CyuLt+BSLHZhk+ngp0aZLYISvSmkXAmiU8znneh JgMBDYjLaiuwp0evSoILMU7PZ3xrHVSSMq7ecuqBcV+wbk/QVRr6JUrHzYMGA2/1ChAf m+BRgOyE23XrAp0hAC+zBt9/YF9MAUQTUAJSqWDJKMHaUsVhm4UFwocWfWmxi6wI4tbF RuFVcATV74fv39Me2qpWIy4LY8pRBw9Xb7e2cZ4bsvxtewUhEn2PLnrjifJ8YvA3w6iX ccMw== |
| X-Received | by 10.66.221.4 with SMTP id qa4mr21435433pac.138.1398950838637; Thu, 01 May 2014 06:27:18 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <bs9vipF2h3pU1@mid.individual.net> |
| References | <088cdf75-f196-404b-ba77-567559f431d8@googlegroups.com> <bs9vipF2h3pU1@mid.individual.net> |
| From | Papp Győző <pappgyozo@gmail.com> |
| Date | Thu, 1 May 2014 15:26:58 +0200 |
| Subject | Re: Convert numpy array to single number |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7b5d472ccb977404f8569f61 |
| X-Mailman-Approved-At | Thu, 01 May 2014 20:51:11 +0200 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9632.1398970272.18130.python-list@python.org> (permalink) |
| Lines | 80 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1398970272 news.xs4all.nl 2934 [2001:888:2000:d::a6]:48525 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:70819 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Maybe something like this? >>> to_num = lambda array: np.sum(array * 2**np.arange(len(array)-1, -1, -1)) >>> to_num(np.array([1,0,1,0])) 10 2014-04-29 17:42 GMT+02:00 Tom P <werotizy@freent.dd>: > On 28.04.2014 15:04, mboyd02255@gmail.com wrote: > >> I have a numpy array consisting of 1s and zeros for representing binary >> numbers: >> >> e.g. >> >> >>> binary >> array([ 1., 0., 1., 0.]) >> >> I wish the array to be in the form 1010, so it can be manipulated. >> >> I do not want to use built in binary converters as I am trying to build >> my own. >> >> > Do you mean that each element in the array represents a power of two? > So array([ 1., 0., 1., 0.]) represents 2^3 + 2 = 6 decimal? > > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Convert numpy array to single number mboyd02255@gmail.com - 2014-04-28 06:04 -0700
Re: Convert numpy array to single number Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-28 14:16 +0000
Re:Convert numpy array to single number Dave Angel <davea@davea.name> - 2014-04-28 15:19 -0400
Re: Convert numpy array to single number Tom P <werotizy@freent.dd> - 2014-04-29 17:42 +0200
Re: Convert numpy array to single number Papp Győző <pappgyozo@gmail.com> - 2014-05-01 15:26 +0200
csiph-web