Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Oscar Benjamin Newsgroups: comp.lang.python Subject: Re: np.searchSorted over 2D array Date: Thu, 10 Dec 2015 19:55:31 +0000 Lines: 19 Message-ID: References: <2b660168-3322-4bf6-bd8b-2dc846a3a874@googlegroups.com> <168a11ec-dd1e-481c-827b-8f5021a315cb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de Wm89WJXuVbnMlsLbQwRRjwgEL2FhZlLJ+eUumJP5uRhw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'indices': 0.07; 'cc:addr :python-list': 0.09; '(ms': 0.09; 'happens.': 0.09; 'occurrences': 0.09; 'appears.': 0.16; 'cc:name:python list': 0.16; 'elements).': 0.16; 'numpy': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:array': 0.16; 'wrote:': 0.16; 'shape': 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'bigger': 0.23; 'dec': 0.23; 'elements': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'message-id:@mail.gmail.com': 0.27; 'does,': 0.29; 'array': 0.29; 'another': 0.32; 'extract': 0.33; 'received:google.com': 0.35; 'there': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'skip:& 10': 0.37; 'thanks': 0.37; 'received:209': 0.38; 'where': 0.40; 'oscar': 0.84; 'peter,': 0.84; 'subject:over': 0.84; 'subject:skip:n 10': 0.84; 'anywhere,': 0.93 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:to :cc:content-type; bh=Z5mXyW47jaFdjZkEZe9yNtZ4aazY9s8ACyOmYcC18s4=; b=vYAlV91v0Q8DFgUpXb6ixAzYx8If1B8hcWpeHzm8m/3YXZ/swrvHgAMgAJ0oaiydCR St9Czs7QfL8e0lK3hENwiRukwoXKmM13TMq0nGOj/xY4NTQkpOV74HF9r0JOlXq79d0q GFkGZyXMAw0K5ym93NcEMVKg5vL6Twk+fyt8ma56G68tWabnqkVC7Nte20uR5OZ11Yv9 iheFElRDVHRijKM/y0ffZ2UD1k8mqXMYNuQV+rYKUR75IbvJ8aZPXPLxk3otheQGJGoJ z+sG4HDdAdKXnGNQTFcgX3O1tZtYxRoMDKep4RJFnzlnV5OGPSooCc9OMeOZCxFpFvXC taew== X-Received: by 10.25.81.17 with SMTP id f17mr5005970lfb.90.1449777331820; Thu, 10 Dec 2015 11:55:31 -0800 (PST) In-Reply-To: <168a11ec-dd1e-481c-827b-8f5021a315cb@googlegroups.com> X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100244 On 10 Dec 2015 14:46, "Heli" wrote: > > Thanks Peter, > > I will try to explain what I really need. > > I have a 3D numpy array of 100*100*100 (1M elements). Then I have another numpy array of for example 10*2*10 (200 elements). I want to know if in the bigger dataset of 100*100*100, there is anywhere, where the second numpy array of 200 elements with shape 10*2*10 appears. If it does, then I want the indices of the bigger dataset where this happens. > So you want to find N in M. First find all occurrences of N[0][0][0] in M[:90][:98][:90]. Then for each of those extract the same size subview from M and check if (Ms == N).all(). -- Oscar