Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79256
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'binary,': 0.16; 'bits.': 0.16; 'bitwise': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'zeroes': 0.16; 'index': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'skip:1 30': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'received:google.com': 0.35; 'representing': 0.36; 'so,': 0.37; 'two': 0.37; 'easiest': 0.38; 'pm,': 0.38; 'does': 0.39; 'tell': 0.60; 'no.': 0.61; 'simple': 0.61; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=9Y+F3R1mqEnDP5fWFW9LeYVlOKSxzO2r8b7xCi+3edg=; b=Rp1VkZxAiQbd7IWVB+ANOcDsWXAYCgnjGhD5igoASgDlU63Bdn+rrT8DLgDhtgMzjn 8jSilxhS+skHgM3Nrx99J/9bKok8mo3/LvBtSUdpnuQTPxwOTxDhxp4zJ2SEuI1X8wHp 2Fm7j7Ye+EVQigxuVBelvLdXErq/fCLYmWx7TO0GVzGaCSRUT5OcMEamEy8CG+Fxf4yG NuQcMs3Zb88Up9tmqKu6UeKo5/bzTKx3t4KU8SrZEMb6X/NCrwj9XIKweauAOqpapOd0 VJEqsGaBI4pzfa45bTWoBKV/gG8H1h1SVZycePNw8rQu/s1NrPucXV3uT3YALqlRsn9S idvA== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.79.167 with SMTP id k7mr3764099igx.14.1413613479979; Fri, 17 Oct 2014 23:24:39 -0700 (PDT) |
| In-Reply-To | <CA+F4vi=SMCNO-v55ZyKBau6+HAt=HPRYECnVkUr28wzgG3praA@mail.gmail.com> |
| References | <CA+F4vi=SMCNO-v55ZyKBau6+HAt=HPRYECnVkUr28wzgG3praA@mail.gmail.com> |
| Date | Sat, 18 Oct 2014 17:24:39 +1100 |
| Subject | Re: Extract Indices of Numpy Array Based on Given Bit Information |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| 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.14956.1413613488.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1413613488 news.xs4all.nl 2871 [2001:888:2000:d::a6]:41852 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:79256 |
Show key headers only | View raw
On Sat, Oct 18, 2014 at 4:58 PM, Artur Bercik <vbubbly21@gmail.com> wrote: > I want to get the index of my data where the following occurs: > > Bit No. 0–1 > Bit Combination: 00 So, what you want to do is look at each number in binary, and find the ones that have two zeroes in the last two places? 1073741824: 1000000000000000000000000000000 1073741877: 1000000000000000000000000110101 The easiest way to do this is with simple bitwise operations: >>> 1073741824 & 3 0 >>> 1073741877 & 3 1 3 is 0000000000000011 in binary, so a bitwise AND with that will tell you about just the last two bits. The result will be an integer - 0, 1, 2, or 3, representing 00, 01, 10, or 11 for those last two bits. So all you have to do is AND each number with 3, and when the result is 0, that's what you want. Does that make sense? ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Extract Indices of Numpy Array Based on Given Bit Information Chris Angelico <rosuav@gmail.com> - 2014-10-18 17:24 +1100
csiph-web