Search Results

Search found 85 results on 4 pages for 'slicing'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • Numpy: Sorting a multidimensional array by a multidimensional array

    - by JD Long
    Forgive me if this is redundant or super basic. I'm coming to Python/Numpy from R and having a hard time flipping things around in my head. I have a n dimensional array which I want to sort using another n dimensional array of index values. I know I could wrap this in a loop but it seems like there should be a really concise Numpyonic way of beating this into submission. Here's my example code to set up the problem where n=2: a1 = random.standard_normal(size=[2,5]) index = array([[0,1,2,4,3] , [0,1,2,3,4] ]) so now I have a 2 x 5 array of random numbers and a 2 x 5 index. I've read the help for take() about 10 times now but my brain is not groking it, obviously. I thought this might get me there: take(a1, index) array([[ 0.29589188, -0.71279375, -0.18154864, -1.12184984, 0.25698875], [ 0.29589188, -0.71279375, -0.18154864, 0.25698875, -1.12184984]]) but that's clearly reordering only the first element (I presume because of flattening). Any tips on how I get from where I am to a solution that sorts element 0 of a1 by element 0 of the index ... element n?

    Read the article

  • Python Numpy Structured Array (recarray) assigning values into slices

    - by user368877
    Hi, The following example shows what I want to do: >>> test rec.array([(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], dtype=[('ifAction', '|i1'), ('ifDocu', '|i1'), ('ifComedy', '|i1')]) >>> test[['ifAction', 'ifDocu']][0] (0, 0) >>> test[['ifAction', 'ifDocu']][0] = (1,1) >>> test[['ifAction', 'ifDocu']][0] (0, 0) So, I want to assign the values (1,1) to test[['ifAction', 'ifDocu']][0]. (Eventually, I want to do something like test[['ifAction', 'ifDocu']][0:10] = (1,1), assigning the same values for for 0:10. I have tried many ways but never succeeded. Is there any way to do this? Thank you, Joon

    Read the article

  • ValueError: setting an array element with a sequence.

    - by MedicalMath
    This code: import numpy as p def firstfunction(): UnFilteredDuringExSummaryOfMeansArray = [] MeanOutputHeader=['TestID','ConditionName','FilterType','RRMean','HRMean','dZdtMaxVoltageMean','BZMean','ZXMean' ,'LVETMean','Z0Mean','StrokeVolumeMean','CardiacOutputMean','VelocityIndexMean'] dataMatrix = BeatByBeatMatrixOfMatrices[column] roughTrimmedMatrix = p.array(dataMatrix[1:,1:17]) trimmedMatrix = p.array(roughTrimmedMatrix,dtype=p.float64) myMeans = p.mean(trimmedMatrix,axis=0,dtype=p.float64) conditionMeansArray = [TestID,testCondition,'UnfilteredBefore',myMeans[3], myMeans[4], myMeans[6], myMeans[9] , myMeans[10], myMeans[11], myMeans[12], myMeans[13], myMeans[14], myMeans[15]] UnFilteredDuringExSummaryOfMeansArray.append(conditionMeansArray) secondfunction(UnFilteredDuringExSummaryOfMeansArray) return def secondfunction(UnFilteredDuringExSummaryOfMeansArray): RRDuringArray = p.array(UnFilteredDuringExSummaryOfMeansArray,dtype=p.float64)[1:,3] return firstfunction() Throws this error message: File "mypath\mypythonscript.py", line 3484, in secondfunction RRDuringArray = p.array(UnFilteredDuringExSummaryOfMeansArray,dtype=p.float64)[1:,3] ValueError: setting an array element with a sequence. However, this code works: import numpy as p a=range(24) b = p.reshape(a,(6,4)) c=p.array(b,dtype=p.float64)[:,2] I re-arranged the code a bit to put it into a cogent posting, but it should more or less have the same result. Can anyone show me what to do to fix the problem in the broken code above so that it stops throwing an error message?

    Read the article

  • Break the object body

    - by Siddharth
    In my game, I want to break the object body creating slicing effect. After research I found that I have to use ray casting but I don't know how to use it. If some one know how to break the physics body then please provide information to me. EDIT : I don't have any logic how to do that in andengine. Only I have some link to do slicing http://www.emanueleferonato.com/2012/03/05/breaking-objects-with-box2d-the-realistic-way/ Yes I have to slice physics body into two parts. My physics body have 2d objects.

    Read the article

  • Building an interleaved buffer for pyopengl and numpy

    - by Nick Sonneveld
    I'm trying to batch up a bunch of vertices and texture coords in an interleaved array before sending it to pyOpengl's glInterleavedArrays/glDrawArrays. The only problem is that I'm unable to find a suitably fast enough way to append data into a numpy array. Is there a better way to do this? I would have thought it would be quicker to preallocate the array and then fill it with data but instead, generating a python list and converting it to a numpy array is "faster". Although 15ms for 4096 quads seems slow. I have included some example code and their timings. #!/usr/bin/python import timeit import numpy import ctypes import random USE_RANDOM=True USE_STATIC_BUFFER=True STATIC_BUFFER = numpy.empty(4096*20, dtype=numpy.float32) def render(i): # pretend these are different each time if USE_RANDOM: tex_left, tex_right, tex_top, tex_bottom = random.random(), random.random(), random.random(), random.random() left, right, top, bottom = random.random(), random.random(), random.random(), random.random() else: tex_left, tex_right, tex_top, tex_bottom = 0.0, 1.0, 1.0, 0.0 left, right, top, bottom = -1.0, 1.0, 1.0, -1.0 ibuffer = ( tex_left, tex_bottom, left, bottom, 0.0, # Lower left corner tex_right, tex_bottom, right, bottom, 0.0, # Lower right corner tex_right, tex_top, right, top, 0.0, # Upper right corner tex_left, tex_top, left, top, 0.0, # upper left ) return ibuffer # create python list.. convert to numpy array at end def create_array_1(): ibuffer = [] for x in xrange(4096): data = render(x) ibuffer += data ibuffer = numpy.array(ibuffer, dtype=numpy.float32) return ibuffer # numpy.array, placing individually by index def create_array_2(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) for v in data: ibuffer[index] = v index += 1 return ibuffer # using slicing def create_array_3(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) ibuffer[index:index+20] = data index += 20 return ibuffer # using numpy.concat on a list of ibuffers def create_array_4(): ibuffer_concat = [] for x in xrange(4096): data = render(x) # converting makes a diff! data = numpy.array(data, dtype=numpy.float32) ibuffer_concat.append(data) return numpy.concatenate(ibuffer_concat) # using numpy array.put def create_array_5(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) ibuffer.put( xrange(index, index+20), data) index += 20 return ibuffer # using ctype array CTYPES_ARRAY = ctypes.c_float*(4096*20) def create_array_6(): ibuffer = [] for x in xrange(4096): data = render(x) ibuffer += data ibuffer = CTYPES_ARRAY(*ibuffer) return ibuffer def equals(a, b): for i,v in enumerate(a): if b[i] != v: return False return True if __name__ == "__main__": number = 100 # if random, don't try and compare arrays if not USE_RANDOM and not USE_STATIC_BUFFER: a = create_array_1() assert equals( a, create_array_2() ) assert equals( a, create_array_3() ) assert equals( a, create_array_4() ) assert equals( a, create_array_5() ) assert equals( a, create_array_6() ) t = timeit.Timer( "testing2.create_array_1()", "import testing2" ) print 'from list:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_2()", "import testing2" ) print 'array: indexed:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_3()", "import testing2" ) print 'array: slicing:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_4()", "import testing2" ) print 'array: concat:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_5()", "import testing2" ) print 'array: put:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_6()", "import testing2" ) print 'ctypes float array:', t.timeit(number)/number*1000.0, 'ms' Timings using random numbers: $ python testing2.py from list: 15.0486779213 ms array: indexed: 24.8184704781 ms array: slicing: 50.2214789391 ms array: concat: 44.1691994667 ms array: put: 73.5879898071 ms ctypes float array: 20.6674289703 ms edit note: changed code to produce random numbers for each render to reduce object reuse and to simulate different vertices each time. edit note2: added static buffer and force all numpy.empty() to use dtype=float32 note 1/Apr/2010: still no progress and I don't really feel that any of the answers have solved the problem yet.

    Read the article

  • Ways of breaking down SQL transactional/call data into reports -- 'square data'?

    - by RizwanK
    I've got a large database of call-traffic information (although the question could be answered with any generic data set.) For instance, a row contains : call endpoint server (endpoint_name) call endpoint status (sip_disconnect_reason) call destination (destination) call completed (duration) [duration 0 is completed] call account group (account_group) It's pretty easy to run SQL reports against the data, i.e. select count(*), endpoint_name from calls where duration0 group by endpoint_name select count(*),destination from calls where blah group by destination I've been calling this filtering or breakdown reports (I get the number of calls per carrier, etc.). Add another breakdown, and you've got two breakdowns, a la select count(*), endpoint_name, sip_disconnect_reason from calls where duration=0 group by endpoint_name, sip_disconnect_reason Of course, if you keep adding breakdowns, you end up making super-large reports and slicing your data so thin that you can't extract any trends from it. So my question is this : Is there a name for this sort of method of report writing? (I've heard words like squares, slicing and breakdown reports applied to them) --- I'm looking for a Python/Reporting toolkit that I can use to make these easier to generate for my end users. aside : Are there other ways of representing transactional data that might be useful rather than the above method? Thanks,

    Read the article

  • Connect divs with (non-straight) lines [migrated]

    - by Snailer
    I'd like to develop my site with a layout that looks somewhat like houses with connected plumbing, or multiple computers connected to a network. Basically, the will be boxes floating in space, with lines connecting some of the boxes. I'd like these lines to have some turns in them as well (just simple 90 degree corners) rather than just a straight line. My question is what is the best way to achieve this, and perhaps a small example. My thoughts were to use: PHP and CSS: I could create a background grid and then, with some complicated algorithms, draw paths using the grid's borders. This would be more dynamic, but I'm not sure I can plot the math all by myself. just CSS: Perhaps this is as simple as making some pre-drawn lines like L-shapes and T-junctions, then just placing and scaling them. But I don't believe there's a way to scale an image by slicing it.. so the line width would be scaled and thus each image would look different. Any thoughts?

    Read the article

  • Do you continue development in a branch or in the trunk?

    - by Sam McAfee
    Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging it as a release periodically, and doing your experimental work in branches. What do folks think is the trunk considered "gold" or considered a "sand box"?

    Read the article

  • What data structures and algorithms are applied within data warehouse cubes?

    - by Jeff Meatball Yang
    I understand that cubes are optimized data structures for aggregating and "slicing" large amounts of data. I just don't know how they are implemented. I can imagine a lot of this technology is proprietary, but are there any resources that I could use to start implementing my own cube technology? Set theory and lots of math are probably involved (and welcome as suggestions!), but I'm primarily interested in implementations: the data structures and query algorithms. Thanks!

    Read the article

  • Stubhub like map in HTML5?

    - by Switz
    I have an image of a floor plan. Best way to think if it is a hotel floor plan. (Similar to how stubhub does their ticket maps) I want the user to select rooms. Instead of slicing each room in Photoshop, is there a way to split up the image in HTML5 canvas or Javascript. Would like to avoid flash. Thanks for the responses! example: http://adamsaewitz.com/housing/housing.html (top left rooms, hover)

    Read the article

  • Preserving the dimensions of a slice from a Numpy 3d array

    - by Brendan
    I have a 3d array, a, of shape say a.shape = (10, 10, 10) When slicing, the dimensions are squeezed automatically i.e. a[:,:,5].shape = (10, 10) I'd like to preserve the number of dimensions but also ensure that the dimension that was squeezed is the one that shows 1 i.e. a[:,:,5].shape = (10, 10, 1) I have thought of re-casting the array and passing ndmin but that just adds the extra dimensions to the start of the shape tuple regardless of where the slice came from in the array a.

    Read the article

  • Generate 2D cross-section polygon from 3D mesh

    - by nornagon
    I'm writing a game which uses 3D models to draw a scene (top-down orthographic projection), but a 2D physics engine to calculate response to collisions, etc. I have a few 3D assets for which I'd like to be able to automatically generate a hitbox by 'slicing' the 3D mesh with the X-Y plane and creating a polygon from the resultant edges. Google is failing me on this one (and not much helpful material on SO either). Suggestions?

    Read the article

  • Python 3 with numpy and object refernces

    - by user963386
    I need to create a large matrix (array) structure (3 axis) and each element should store the reference to a Python object (myclass instance). Is it possible to use numpy to create such an array. Which data type should I use in order to store Python references? The advantage of numpy is the support of slicing at different levels. The alternativee is to create a nested (nested) list but it is a cumbersome solution.

    Read the article

  • pandas read rotated csv files

    - by EricCoding
    Is there any function in pandas that can directly read a rotated csv file? To be specific, the header information in the first col instead of the first row. For example: A 1 2 B 3 5 C 6 7 and I would like the final DataFrame this way A B C 1 3 5 2 5 7 Of corse we can get around this problem using some data wangling techniques like transpose and slicing. I am wondering there should be a quick way in API but I could not find it.

    Read the article

  • Is Cassandra database row size limited by available memory?

    - by Adam Hollidge
    I'm working with very long time series -- hundreds of millions of data points in one series -- and am considering Cassandra as a data store. In this question, one of the Cassandra committers (the über helpful jbellis) says that Cassandra rows can be very large, and that column slicing operations are faster than row slices, hence my question: Is the row size still limited by available memory?

    Read the article

  • Is it possible to slice off the end of a URL with XSLT 1.0?

    - by Eric
    Title says it all really. Using only XSLT 1.0's string functions, how would I go about slicing off the end of a url? So from http://stackoverflow.com/questions/2981175/is-it-possible-to-slice-the-end-of-a-url-with-xslt-1-0 I would like to extract is-it-possible-to-slice-the-end-of-a-url-with-xslt-1-0 Is this possible?

    Read the article

  • Printing perforated business cards

    - by Gio Borje
    I have a Brother MFC 440CN printer with the paper loaded underneath it. The problem with my stack of perforated business cards is that I can't print double-sided. The printer pulls the paper out from under its paper tray below and rolls it through the top for printing. With perforated business cards, they paper breaks at the perforations. Is there a method to preventing the slicing? Also, my printer also has some trouble pulling up the paper in general but I don't seem to understand why other than that the perforations break before the paper is grabbed for printing.

    Read the article

  • We Convert your PSD into Xhtml

    - by Aditi
    From last few months we have been receiving a lot of inquires for  Psd into Xhtml projects, while we were majorly focusing on custom WordPress, Magento, Drupal & Joomla Projects. Now we are offering PSD into Xhtml/CSS service at an affordable price looking at its demand. We also will cater PSD into any CMS, like wordpress, Drupal, Magento or Joomla. Our custom services will continue as it is. It is very convenient to get your design converted by our Xhtml & CSS experts. We assure 24 hour delivery time. At JustSkins, we have a structured conversion model that works well for any kind of potentially enriched web business solution. Our customized slicing guidelines, besides, W3C approved XHTML and CSS code naming conventions makes us stand distinct from the competitors. Why Should You Let us do it for you? W3C Compliant HTML/XHTML and CSS Codes Well Structured and Written Code. Clean and Hand Coded Mark up no use of WYSIWYG. We offer Fast turn around timeDesign converted into Xhtml/CSS just in one business day. Multi- Browser Accessible Websites Cross-Platform Support. Excellent Customer Service. Affordable We at JustSkins are team of efficient programmers with vast experience in templating for   content management systems (CMS),  Joomla, Drupal, WordPress and other Open Source technologies. Contact us today for your requirement!

    Read the article

  • Podcast Show Notes: Evolving Enterprise Architecture

    - by Bob Rhubart
    The latest series of ArchBeat podcast programs grew out of another virtual meet-up, held on March 11. As with previous meet-ups, I sent out a general invitation to the roster of previous ArchBeat panelists to join me on Skype to talk about whatever topic comes up. For this event, Oracle ACE Directors Mike van Alst and Jordan Braunstein  showed up, along with Oracle product manager Jeff Davies.  The result was an impressive and wide-ranging discussion on the evolution of Enterprise Architecture, the role of technology in EA, the impact of social computing, and challenge of having three generations of IT people at work in the enterprise – each with different perspectives on technology. Mike, Jordan, and Jeff talked for more than an hour, and the conversation was so good that slicing and dicing it to meet the time constraints for these podcasts has been a challenge. The first two segments of the conversation are now available. Listen to Part 1 Listen to Part 2 Part 3 will go live next week, and an unprecedented fourth segment will follow. These guys have strong opinions, and while there is common ground, they don’t always agree. But isn’t that what a community is all about? I suspect that you’ll have questions and comments after listening, so I encourage you to reach out to Mike, Jordan, and Jeff  via the following links: Mike van Alst Blog | Twitter | LinkedIn | Business |Oracle Mix | Oracle ACE Profile Jordan Braunstein Blog | Twitter | LinkedIn | Business | Oracle Mix | Oracle ACE Profile Jeff Davies Homepage | Blog | LinkedIn | Oracle Mix (Also check out Jeff’s book: The Definitive Guide to SOA: Oracle Service Bus)   Coming Soon ArchBeat’s microphones were there for the panel discussions at the recent Oracle Technology Network Architect Days in Dallas and Anaheim. Excerpts from those conversations will be available soon. Stay tuned: RSS Technorati Tags: oracle,otn,enterprise architecture,podcast. arch2arch,archbeat del.icio.us Tags: oracle,otn,enterprise architecture,podcast. arch2arch,archbeat

    Read the article

  • Principles of Service-Oriented Architecture by Douwe P. van den Bos

    - by JuergenKress
    Today I hosted a session on the Principles of Service-Oriented Architecture for my colleagues at Capgemini. A very interesting session because everyone had a very clear view on the Oracle SOA Suite and a technical background. What we wanted to do was creating a common view on what a Service-Oriented Architecture is, what the benefits are that can be achieved and what is needed to create a Service-Oriented Architecture. During this very interactive session we moved from a clearly technology view on the matter (Oracle SOA Suite) to an architectural view slicing from business to technology. And this is where SOA really kicks in, because it is a philosophy. Here is the presentation on SlideShare: Principles of Service-Oriented Architecture. Read also the The Maturity of a Service-Oriented Architecture & SOA Maturity Models. Twitter & LinkedIn SOA & BPM Partner Community For regular information on Oracle SOA Suite become a member in the SOA & BPM Partner Community for registration please visit  www.oracle.com/goto/emea/soa (OPN account required) If you need support with your account please contact the Oracle Partner Business Center. Blog Twitter LinkedIn Mix Forum Technorati Tags: SOA Governance,SOA Community,Oracle SOA,Oracle BPM,BPM Community,OPN,Jürgen Kress,Douwe P. van den Bos

    Read the article

  • From .psd to working HTML and CSS - help me suck less

    - by kevinmajor1
    I am not much of a designer. My strength lies in coding. That said, I'm often forced into the role of "The Man," responsible for all aspects of site creation. So, that said I'm wondering if the pros can give me tips/solutions/links to tutorials to my main questions. Resolution. What should I aim for? What are the lower and upper edges I should be aware of? I know that systems like 960 Grid were popular recently. Is that the number I should still aim for? Slicing up a .psd - are there any tricks I should know? I've always found it difficult to get my slices pixel perfect. I'm also really slow at it. I must be looking at it wrong, or missing something fundamental. The same goes for text. Layouts are always filled with the classic "Lorem...", but I can never seem to get real content to fit quite as well on the screen. The advanced (to me, anyway) looking things, like a part of a logo/image overlaying what looks like a content area. How does one do that? How do layouts change/are informed by the decision to go fixed or liquid? Again, any tips/tricks/suggestions/tutorials you can share would be greatly appreciated.

    Read the article

  • HTML table to “graphical text” for code comments

    - by Atif Aziz
    Is there a tool (ideally command-line-based) that can help in converting the source to HTML tables into “graphical text” (think perhaps ASCII art for HTML tables) for use in code comments (like /*…*/), as show below? /* +--------------------------------------------------------------------+ | Network | +--------------------------------------------------------------------+ | 11.05.2010 | ABC | DEF | +------------+-------------+-------------+-------------+-------------+ | | INPUT | OUTPUT | INPUT | OUTPUT | +------------+-------------+-------------+-------------+-------------+ | Value | 366,899,791 | 0 | 213,001 | 2,132,827 | +------------+-------------+-------------+-------------+-------------+ */ Background: A piece of code that reads values from HTML tables can be annotated with comments depicting text-based graphical representations of complex HTML table layouts. Someone maintaining the code later can then find it easier to understand, for example, how a piece of code is slicing and dicing an HTML table or plucking values at certain cell positions.

    Read the article

< Previous Page | 1 2 3 4  | Next Page >