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


Groups > comp.lang.python > #79264

Re: Extract Indices of Numpy Array Based on Given Bit Information

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <vbubbly21@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.051
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'binary,': 0.16; 'bits.': 0.16; 'bitwise': 0.16; 'sense,': 0.16; 'zeroes': 0.16; 'index': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'skip:1 30': 0.19; '>>>': 0.22; 'example': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'integer': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'combination': 0.36; 'representing': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'so,': 0.37; 'two': 0.37; 'easiest': 0.38; 'pm,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'tell': 0.60; 'hope': 0.61; 'new': 0.61; 'no.': 0.61; 'simple': 0.61; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'answer.': 0.68; 'imagine': 0.93
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 :cc:content-type; bh=BiY6QeLpndEPNYNhzF6ZWHR45LztQUIZcSi4Q116Hik=; b=KySnIWSPgoTK19hL78lAlHSUT3u8Tdm4PrZC4OYJKIZmFlB2y4AH0/muge3yAG5PFw VQIdv+rxyR0hupOjH1PSsn9Ate2JZnPUx5ClBe1wAs5yda1/uhXMTt83DVGyhnJly4D+ VelSNsPHhtyg6+BGOd+RzYOSI/TDWuL6Z99IrwoZ6w660s0AUIOl2GIpkBH9+5IyDW02 /EnaUd+fyDPoOhl9RiFQSz8IZb5VVMVLqWdw8T23PElTBz111Dxx+Gct+gpxoG4QKV8m rtcq8MdibW6EbFJRgouyJHw2CcGBvWWb2ThnfIItT8NP1dLlRujoKMViXh+fqFlpOKge fOxA==
X-Received by 10.60.34.74 with SMTP id x10mr11180639oei.10.1413614540502; Fri, 17 Oct 2014 23:42:20 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAPTjJmohbdOOn_Ug1iYBJO6NMoR944OY+ecUCamGO26hTNZEcA@mail.gmail.com>
References <CA+F4vi=SMCNO-v55ZyKBau6+HAt=HPRYECnVkUr28wzgG3praA@mail.gmail.com> <CAPTjJmohbdOOn_Ug1iYBJO6NMoR944OY+ecUCamGO26hTNZEcA@mail.gmail.com>
From Artur Bercik <vbubbly21@gmail.com>
Date Sat, 18 Oct 2014 15:42:00 +0900
Subject Re: Extract Indices of Numpy Array Based on Given Bit Information
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=089e013cc066893cff0505acc8df
X-Mailman-Approved-At Sat, 18 Oct 2014 10:20:33 +0200
Cc "python-list@python.org" <python-list@python.org>
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.14962.1413620435.18130.python-list@python.org> (permalink)
Lines 97
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413620435 news.xs4all.nl 2958 [2001:888:2000:d::a6]:33822
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79264

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Thanks Chris Angelico for your nice answer.
I got some sense, but could not imagine if required Bit No. 2–5, and  Bit
Combination 0000.

I hope example with the new case would make me more sense.

Artur



On Sat, Oct 18, 2014 at 3:24 PM, Chris Angelico <rosuav@gmail.com> wrote:

> 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
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: Extract Indices of Numpy Array Based on Given Bit Information Artur Bercik <vbubbly21@gmail.com> - 2014-10-18 15:42 +0900

csiph-web