Is there an open-source alternative to MATLAB's fmincon function for constrained linear optimization? I'm rewriting a MATLAB program to use Python / NumPy / SciPy and this is the only function I haven't found an equivalent to. A NumPy-based solution would be ideal, but any language will do.
...

If you are creating a 1d array in Python is there any benefit to using the NumPy package?
...

This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the feature works.
...

On the Python side, I can create new numpy record arrays as follows:
numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')])
How do I do the same from a C program? I suppose I have to call PyArray_SimpleNewFromDescr(nd, dims, descr), but how do I construct a PyArray_Descr that is appropriate for passing as the third argument to PyArray_S...

I would like to trim long sequences of the same value from a binary file in python. A simple way of doing it is simply reading in the file and using re.sub to replace the unwanted sequence. This will of course not work on large binary files. Can it be done in something like numpy?
...

I'm trying to transform each element of a numpy array into an array itself (say, to interpret a greyscale image as a color image). In other words:
>>> my_ar = numpy.array((0,5,10))
[0, 5, 10]
>>> transformed = my_fun(my_ar) # In reality, my_fun() would do something more useful
array([
[ 0, 0, 0],
[ 5, 10, 15],
[10,...

I'm a relatively new convert to Python. I've written some code to grab/graph data from various sources to automate some weekly reports and forecasts. I've been intrigued by the Jython concept, and would like to port some Python code that I've written to Jython. In order to do this quickly, I need a NumPy clone for Jython (or Java). I...

I am running a windows machine have installed Python 2.5. I also used the windows installer to install NumPy.
This all works great when I run the Python (command line) tool that comes with Python.
However, if I run cygwin and then run Python from within, it cannot find the numpy package.
What environment variable do I need to set? W...

Using NumPy, a matrix A has n rows and m columns, and I want add a guard ring to matrix A. That guard ring is all zero.
What should I do? Use Reshape? But the element is not enough to make a n+1 m+1 matrix.
Or etc.?
Thanks in advance
I mean an extra ring of cells that always contain 0 surround matrix A.Basically there is a Matrix B h...

Hi, just a quick question, if I have a matrix has n rows and m columns, how can I cut off the 4 sides of the matrix and return a new matrix? (the new matrix would have n-2 rows m-2 columns).
Thanks in advance
...

How can I build a numpy array out of a generator object?
Let me illustrate the problem:
>>> import numpy
>>> def gimme():
... for x in xrange(10):
... yield x
...
>>> gimme()
<generator object at 0x28a1758>
>>> list(gimme())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> numpy.array(xrange(10))
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> numpy...

Alright, I'm toying around with converting a PIL image object back and forth to a numpy array so I can do some faster pixel by pixel transformations than PIL's PixelAccess object would allow. I've figured out how to place the pixel information in a useful 3D numpy array by way of:
pic = Image.open("foo.jpg")
pix = numpy.array(pic.getda...

I'm forced to upgrade to Python 2.6 and am having issues using Numerical Python (Numpy) with Python 2.6 in windows. I'm getting the following error...
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from numpy.core.numeric import array,dot,all
File "C:\svn\svn_urbansim\UrbanSimDev\Builds\working\urban...

I know there is a method for python list to return the first index of something
l = list(1,2,3)
l.index(2)
>>> 1
Is there something like that for numpy arrays?
Thanks for your help :)
...

Let me illustrate this question with an example:
import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arange(5,30,5) #This could be any 1-d arra...

Hi, All,
This confused me a lot. I read the manual of Numpy that there is function det(M) that can calculate the determinant. However, I can't find the det() in Numpy. By the way, I use Python 2.5. There should be no compatabile problem with Numpy.
Thanks very much for your help!
...

let's say I have a bi-dimensional array like that
numpy.array([[0,1,1.2,3],[1,5,3.2,4],[3,4,2.8,4], [2,6,2.3,5]])
I want to have an array formed eliminating whole rows based on uniqueness of values of last column, selecting the row to keep based on value of third column.
e.g. in this case i would like to keep only one of the rows with ...

I'm writing some Python numerical code and would like to use some functions from the special module. So far, my code only depends on numpy, which I've found very easy to install in a variety of Python environments. Installing scipy, on the other hand, has generally been an exercise in frustration. Is there a way to get just the special ...

Is there an existing function in numpy that will tell me if a value is either a numeric type or a numpy array? I'm writing some data-processing code which needs to handle numbers in several different representations (by "number" I mean any representation of a numeric quantity which can be manipulated using the standard arithmetic operato...

I'm trying to add two images together using numpy and PIL. The way I would do this in matlab would be something like:
>> M1 = imread('_1.jpg');
>> M2 = imread('_2.jpg');
>> resM = M1 + M2;
>> imwrite(resM, 'res.jpg');
I get something like this:
Using a compositing program and adding the images the matlab result seems to be right.
...