Popular recipes tagged "array"http://code.activestate.com/recipes/tags/array/2016-09-22T12:25:30-07:00ActiveState Code RecipesSimple Matlab/Ocave like arrays conversion to numpy.arrays in python interpreter (Python) 2016-09-22T12:25:30-07:00Przemyslaw Podczasihttp://code.activestate.com/recipes/users/4179716/http://code.activestate.com/recipes/580700-simple-matlabocave-like-arrays-conversion-to-numpy/ <p style="color: grey"> Python recipe 580700 by <a href="/recipes/users/4179716/">Przemyslaw Podczasi</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/interpreter/">interpreter</a>, <a href="/recipes/tags/matlab/">matlab</a>). </p> <p>Matlab/Octave syntax for 1D/2D arrays is more packed and doesn't require putting extra ',' and extra '[', ']' between dimensions. For this I wrote a parser that intercepts python interpreter and using numpy functionality parses Matlab's style arrays 1D and 2D into numpy.arrays.</p> Python - from nD array to flat array (Python) 2014-03-21T16:09:39-07:00Roberto Bellohttp://code.activestate.com/recipes/users/4189498/http://code.activestate.com/recipes/578854-python-from-nd-array-to-flat-array/ <p style="color: grey"> Python recipe 578854 by <a href="/recipes/users/4189498/">Roberto Bello</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/nd/">nd</a>). </p> <p>From a multidimensional array to a flat array avoiding numpy. The code could be better?</p> Easy Bit Arrays using Long Integers (Python) 2013-12-01T02:21:14-08:00Mike Sweeneyhttp://code.activestate.com/recipes/users/4177990/http://code.activestate.com/recipes/578777-easy-bit-arrays-using-long-integers/ <p style="color: grey"> Python recipe 578777 by <a href="/recipes/users/4177990/">Mike Sweeney</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/bit/">bit</a>, <a href="/recipes/tags/bitwise/">bitwise</a>, <a href="/recipes/tags/integer/">integer</a>, <a href="/recipes/tags/long/">long</a>). </p> <p>Some simple techniques for working with long integers as bit arrays. Python support for long integers allows fast bitwise operations on large bit arrays. Bitwise operations on 100 million bit arrays happen in the blink of an eye. They are also fast and compact when saving and loading to disk. Unfortunately bit set, get, append, pop etc are slow so another bit array technique may be preferred.</p> Multidimensional arrays (Ruby) 2012-11-19T08:43:11-08:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578338-multidimensional-arrays/ <p style="color: grey"> Ruby recipe 578338 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/ironruby/">ironruby</a>, <a href="/recipes/tags/multidimensional/">multidimensional</a>). </p> <p>The next example shows how to create rectangular and jagged arrays.</p> Creating array into batch (Batch) 2012-11-01T18:35:05-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578314-creating-array-into-batch/ <p style="color: grey"> Batch recipe 578314 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/array/">array</a>). Revision 2. </p> <p>Command language supports creation array. For example:</p> Flatten Array/Tuple (Python) 2011-10-31T10:53:39-07:00Luca Zarottihttp://code.activestate.com/recipes/users/4179728/http://code.activestate.com/recipes/577932-flatten-arraytuple/ <p style="color: grey"> Python recipe 577932 by <a href="/recipes/users/4179728/">Luca Zarotti</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/tuple/">tuple</a>). </p> <p>Flatten a nested array/tuple</p> Simple numeric database (Python) 2011-05-16T08:41:46-07:00Mike Sweeneyhttp://code.activestate.com/recipes/users/4177990/http://code.activestate.com/recipes/577697-simple-numeric-database/ <p style="color: grey"> Python recipe 577697 by <a href="/recipes/users/4177990/">Mike Sweeney</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>). Revision 2. </p> <p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p> Simple numeric database (Python) 2011-05-16T12:11:24-07:00Hamidreza Joshaghanihttp://code.activestate.com/recipes/users/4177804/http://code.activestate.com/recipes/577698-simple-numeric-database/ <p style="color: grey"> Python recipe 577698 by <a href="/recipes/users/4177804/">Hamidreza Joshaghani</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>). </p> <p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p> Infix operators for numpy arrays (Python) 2010-06-07T05:57:07-07:00John Schulmanhttp://code.activestate.com/recipes/users/4171677/http://code.activestate.com/recipes/577201-infix-operators-for-numpy-arrays/ <p style="color: grey"> Python recipe 577201 by <a href="/recipes/users/4171677/">John Schulman</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/infix/">infix</a>, <a href="/recipes/tags/matrix/">matrix</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/numpy/">numpy</a>). Revision 3. </p> <p>This recipe adapts the infix operator trick from <a href="http://code.activestate.com/recipes/384122-infix-operators/" rel="nofollow">http://code.activestate.com/recipes/384122-infix-operators/</a> to give the appropriate behavior with numpy arrays, so you can write A *dot* B for np.dot(A,B)</p> <p>UPDATE A solution to the dot problem was recently added to the numpy trunk: the dot method was added to the ndarray class so you can write a.dot(b). See <a href="http://projects.scipy.org/numpy/ticket/1456" rel="nofollow">http://projects.scipy.org/numpy/ticket/1456</a></p>