Re: [Numpy-discussion] New functions.
I'd love to see something like a "count_unique" function included. The numpy.unique function is handy, but it can be a little awkward to efficiently go back and get counts of each unique value after the fact. -Mark On Wed, Jun 1, 2011 at 8:17 AM, Keith Goodman wrote: > On Tue, May 31, 2011 at 8:41 PM, Charles R Harris > wrote: >> On Tue, May 31, 2011 at 8:50 PM, Bruce Southey wrote: > >>> How about including all or some of Keith's Bottleneck package? >>> He has tried to include some of the discussed functions and tried to >>> make them very fast. >> >> I don't think they are sufficiently general as they are limited to 2 >> dimensions. However, I think the moving filters should go into scipy, either >> in ndimage or maybe signals. Some of the others we can still speed of >> significantly, for instance nanmedian, by using the new functionality in >> numpy, i.e., numpy sort has worked with nans for a while now. It looks like >> call overhead dominates the nanmax times for small arrays and this might >> improve if the ufunc machinery is cleaned up a bit more, I don't know how >> far Mark got with that. > > Currently Bottleneck accelerates 1d, 2d, and 3d input. Anything else > falls back to a slower, non-cython version of the function. The same > goes for int32, int64, float32, float64. > > It should not be difficult to extend to higher nd and more dtypes > since everything is generated from template. The problem is that there > would be a LOT of cython auto-generated C code since there is a > separate function for each ndim, dtype, axis combination. > > Each of the ndim, dtype, axis functions currently has its own copy of > the algorithm (such as median). Pulling that out and reusing it should > save a lot of trees by reducing the auto-generated C code size. > > I recently added a partsort and argpartsort. > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] New functions.
Not quite. Bincount is fine if you have a set of approximately sequential numbers. But if you don't >>> a = numpy.array((1,500,1000)) >>> a array([ 1, 500, 1000]) >>> b = numpy.bincount(a) >>> b array([0, 1, 0, ..., 0, 0, 1]) >>> len(b) 1001 -Mark On Wed, Jun 1, 2011 at 9:32 AM, Skipper Seabold wrote: > On Wed, Jun 1, 2011 at 11:31 AM, Mark Miller > wrote: >> I'd love to see something like a "count_unique" function included. The >> numpy.unique function is handy, but it can be a little awkward to >> efficiently go back and get counts of each unique value after the >> fact. >> > > Does bincount do what you're after? > > [~/] > [1]: x = np.random.randint(1,6,5) > > [~/] > [2]: x > [2]: array([1, 3, 4, 5, 1]) > > [~/] > [3]: np.bincount(x) > [3]: array([0, 2, 0, 1, 1, 1]) > > Skipper > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Short-hand array creation in `numpy.mat` style
On Fri, Jul 18, 2014 at 3:37 AM, Nathaniel Smith wrote: > On Thu, Jul 17, 2014 at 11:10 PM, Charles G. Waldman > wrote: > > > > -1 on the 'arr' name. I think if we're going to support this function > at all (which I'm not convinced is a good idea), it should be > np.fromsomething like the other from* functions. > > > > Maybe frommatlab? > > > > I think that 'arr' is just too generic and too close to 'array'. > > Well, it's definitely not a good idea if we name it something like that > :-). > > The whole motivation is to provide a quick way to type 2d arrays > interactively, hence the current name "np.mat". (The fact that it > happens to match matlab syntax is a nice bonus, because stealing is > always better than inventing when it works.) > > Some minor confusion on my part. If the true goal is to just allow quick entry of a 2d array, why not just advocate using a = numpy.array(numpy.mat("1 2 3; 4 5 6; 7 8 9")) If anyone is really set on having this functionality, they could just write a one-line wrapper function and call it a day. Note that I would personally not use this type of shorthand syntax for teaching or presentations. I'd prefer to use proper python syntax myself from the get go rather than having to start over from square one and teach a completely different syntax for constructing >2d arrays. "There should be one-- and preferably only one --obvious way to do it." -Zen of Python -Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?
I'm not 100% sure that I get the question, but does this help at all? >>> a = numpy.array([3,2,8,7]) >>> b = numpy.array([1,3,2,4,5,7,6,8,9]) >>> c = set(a) & set(b) >>> c #contains elements of a that are in b (and vice versa) set([8, 2, 3, 7]) >>> indices = numpy.where([x in c for x in b])[0] >>> indices #indices of b where the elements of a in b occur array([1, 2, 5, 7], dtype=int64) -Mark On Wed, Dec 30, 2015 at 6:45 AM, Nicolas P. Rougier < nicolas.roug...@inria.fr> wrote: > > I’m scratching my head around a small problem but I can’t find a > vectorized solution. > I have 2 arrays A and B and I would like to get the indices (relative to > B) of elements of A that are in B: > > >>> A = np.array([2,0,1,4]) > >>> B = np.array([1,2,0]) > >>> print (some_function(A,B)) > [1,2,0] > > # A[0] == 2 is in B and 2 == B[1] -> 1 > # A[1] == 0 is in B and 0 == B[2] -> 2 > # A[2] == 1 is in B and 1 == B[0] -> 0 > > Any idea ? I tried numpy.in1d with no luck. > > > Nicolas > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] How to find indices of values in an array (indirect in1d) ?
I was not familiar with the .in1d function. That's pretty handy. Yes...it looks like numpy.where(numpy.in1d(b, a)) does what you need. >>> numpy.where(numpy.in1d(b, a)) (array([1, 2, 5, 7], dtype=int64),) It would be interesting to see the benchmarks. On Wed, Dec 30, 2015 at 10:17 AM, Nicolas P. Rougier < nicolas.roug...@inria.fr> wrote: > > Yes, it is the expected result. Thanks. > Maybe the set(a) & set(b) can be replaced by np.where[np.in1d(a,b)], no ? > > > On 30 Dec 2015, at 18:42, Mark Miller wrote: > > > > I'm not 100% sure that I get the question, but does this help at all? > > > > >>> a = numpy.array([3,2,8,7]) > > >>> b = numpy.array([1,3,2,4,5,7,6,8,9]) > > >>> c = set(a) & set(b) > > >>> c #contains elements of a that are in b (and vice versa) > > set([8, 2, 3, 7]) > > >>> indices = numpy.where([x in c for x in b])[0] > > >>> indices #indices of b where the elements of a in b occur > > array([1, 2, 5, 7], dtype=int64) > > > > -Mark > > > > > > On Wed, Dec 30, 2015 at 6:45 AM, Nicolas P. Rougier < > nicolas.roug...@inria.fr> wrote: > > > > I’m scratching my head around a small problem but I can’t find a > vectorized solution. > > I have 2 arrays A and B and I would like to get the indices (relative to > B) of elements of A that are in B: > > > > >>> A = np.array([2,0,1,4]) > > >>> B = np.array([1,2,0]) > > >>> print (some_function(A,B)) > > [1,2,0] > > > > # A[0] == 2 is in B and 2 == B[1] -> 1 > > # A[1] == 0 is in B and 0 == B[2] -> 2 > > # A[2] == 1 is in B and 1 == B[0] -> 0 > > > > Any idea ? I tried numpy.in1d with no luck. > > > > > > Nicolas > > > > ___ > > NumPy-Discussion mailing list > > NumPy-Discussion@scipy.org > > https://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > ___ > > NumPy-Discussion mailing list > > NumPy-Discussion@scipy.org > > https://mail.scipy.org/mailman/listinfo/numpy-discussion > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] np.choose() question
Not pretty, but it works: >>> idx array([[4, 2], [3, 1]]) >>> times array([100, 101, 102, 103, 104]) >>> numpy.reshape(times[idx.flatten()],idx.shape) array([[104, 102], [103, 101]]) >>> On Tue, Jun 8, 2010 at 10:09 AM, Gökhan Sever wrote: > > > On Tue, Jun 8, 2010 at 11:24 AM, Andreas Hilboll wrote: >> >> Hi there, >> >> I have a problem, which I'm sure can somehow be solved using np.choose() >> - but I cannot figure out how :( >> >> I have an array idx, which holds int values and has a 2d shape. All >> values inside idx are 0 <= idx < n. And I have a second array times, >> which is 1d, with times.shape = (n,). >> >> Out of these two arrays I now want to create a 2d array having the same >> shape as idx, and holding the values contained in times, as indexed by >> idx. >> >> A simple np.choose(idx,times) does not work (error "Need between 2 and >> (32) array objects (inclusive)."). >> >> Example: >> >> idx = [[4,2],[3,1]] >> times = [100,101,102,103,104] >> >> From these two I want to create an array >> >> result = [[104,102],[103,101]] >> >> How can this be done? >> >> Thanks a lot for your insight! >> >> Andreas >> >> ___ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion > > Here is a non numpy.choose solution: > newtimes = [times[idx[x][y]] for x in range(2) for y in range(2)] > np.array(newtimes).reshape(2,2) > array([[104, 102], > [103, 101]]) > > -- > Gökhan > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] just curious...why does numpy.where() return tuples?
Just for my own benefit, I am curious about this. I am running into problems because I need to archive the result (tuple) returned by a numpy.where statement. Pickle does not seem to like to deal with numpy scalars, and numpy's archiving functions (memmap) can't work on the tuple that gets returned by the where functions (I think). Is there a way around this? All would be good if the where statements actually returned numpy arrays instead. Thanks, -Mark ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] F2PY ?? Has anyone worked with the F2PY generator?
If numpy is installed, then f2py will be too. On the windows environment, there is a file called f2py.py that you can call from the command line. It should be in the 'scripts' directory of your Python installation. Try something like this: python c:\python25\scripts\f2py.py (of course change to reflect your own python installation directory) -Mark On Mon, Sep 8, 2008 at 4:26 PM, Blubaugh, David A. <[EMAIL PROTECTED]>wrote: > Pauli, > > > Yes, I am utilizing the windows environment. I cannot install f2py. > > I obtain the following error when I try to execute the setup.py file > within the f2py folder located within the numpy master folder: > > > Warning: Assuming default configuration > (lib\parser/{setup_parser,setup}.py was not found) Appending > f2py.lib.parser configuration to f2py.lib Ignoring attempt to set 'name' > (from 'f2py.lib' to 'f2py.lib.parser') > Warning: Assuming default configuration > (lib\extgen/{setup_extgen,setup}.py was not found) Appending > f2py.lib.extgen configuration to f2py.lib Ignoring attempt to set 'name' > (from 'f2py.lib' to 'f2py.lib.extgen') Appending f2py.lib configuration > to f2py Ignoring attempt to set 'name' (from 'f2py' to 'f2py.lib') F2PY > Version 2_4423 > > Traceback (most recent call last): > File "C:\Python25\Lib\site-packages\numpy\f2py\setup.py", line 130, in > >**config) > TypeError: setup() got multiple values for keyword argument 'version' > >>> > > > I do not know as to how to fix the multiple values for version?? > PLEASE HELP!!! > > > David Blubaugh > > > > > > > > -Original Message- > From: Blubaugh, David A. > Sent: Monday, September 08, 2008 6:04 PM > To: '[EMAIL PROTECTED]' > Subject: F2PY ?? Has anyone worked with the F2PY generator? > > To All, > > > Has anyone worked with the F2PY generator? This is something that is > supposedly built within numpy and scipy for the Python environment. I > was wondering if anyone has encountered any issues with this > environment?? This is important to find the answers to these questions. > > > > Thanks, > > > David Blubaugh > > > > This e-mail transmission contains information that is confidential and may > be > privileged. It is intended only for the addressee(s) named above. If you > receive > this e-mail in error, please do not read, copy or disseminate it in any > manner. > If you are not the intended recipient, any disclosure, copying, > distribution or > use of the contents of this information is prohibited. Please reply to the > message immediately by informing the sender that the message was > misdirected. > After replying, please erase it from your computer system. Your assistance > in > correcting this error is appreciated. > > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--
Warning, errors, and failures here on XP Pro (numpy installed with the python 2.5 superpack). Just passing it along, and apologies if these have already been caught. >>> import numpy >>> numpy.__version__ '1.2.0rc2' >>> numpy.test() Running unit tests for numpy NumPy version 1.2.0rc2 NumPy is installed in C:\Python25\lib\site-packages\numpy Python version 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] nose version 0.10.3 ... Warning (from warnings module): File "C:\Python25\lib\unittest.py", line 507 return self.suiteClass(map(testCaseClass, testCaseNames)) DeprecationWarning: NumpyTestCase will be removed in the next release; please update your code to use nose or unittest Warning (from warnings module): File "C:\Python25\lib\site-packages\numpy\core\tests\test_ma.py", line 18 NumpyTestCase.__init__(self, *args, **kwds) DeprecationWarning: NumpyTestCase will be removed in the next release; please update your code to use nose or unittest ... Warning (from warnings module): File "C:\Python25\lib\site-packages\numpy\core\ma.py", line 609 warnings.warn("Cannot automatically convert masked array to "\ UserWarning: Cannot automatically convert masked array to numeric because data is masked in one or more locations. F...E..K..K..KIgnoring "Python was built with Visual Studio 2003; extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have Cygwin installed, you can try compiling with MingW32, by passing "-c mingw32" to setup.py." (one should fix me in fcompiler/compaq.py) .. == ERROR: test_ma.testta -- Traceback (most recent call last): File "c:\python25\Lib\site-packages\nose\case.py", line 182, in runTest self.test(*self.arg) TypeError: testta() takes exactly 2 arguments (0 given) == ERROR: test_ma.testtb -- Traceback (most recent call last): File "c:\python25\Lib\site-packages\nose\case.py", line 182, in runTest self.test(*self.arg) TypeError: testtb() takes exactly 2 arguments (0 given) == ERROR: test_ma.testtc -- Traceback (most recent call last): File "c:\python25\Lib\site-packages\nose\case.py", line 182, in runTest self.test(*self.arg) TypeError: testtc() takes exactly 2 arguments (0 given) == ERROR: test_ma.testf -- Traceback (most recent call last): File "c:\python25\Lib\site-packages\nose\case.py", line 182, in runTest self.test(*self.arg) TypeError: testf() takes exactly 1 argument (0 given) == ERROR: test_ma.testinplace -- Traceback (most recent call last): File "c:\python25\Lib\site-packages\nose\case.py", line 182, in runTest self.test(*self.arg) TypeError: testinplace() takes exactly 1 argument (0 given)
Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--
OK..thanks. That did the trick. All clear now, save for 3 known failures. Again, thanks for letting me know about this. -Mark On Mon, Sep 15, 2008 at 11:03 AM, Jarrod Millman <[EMAIL PROTECTED]>wrote: > On Mon, Sep 15, 2008 at 10:49 AM, Mark Miller <[EMAIL PROTECTED]> > wrote: > > Warning, errors, and failures here on XP Pro (numpy installed with the > > python 2.5 superpack). > > > > Just passing it along, and apologies if these have already been caught. > > Thanks for testing this. It looks like you have some old files > sitting around (e.g., numpy\core\tests\test_ma.py). Could you delete > C:\Python25\lib\site-packages\numpy and reinstall 1.2.0rc2? > > Thanks, > > -- > Jarrod Millman > Computational Infrastructure for Research Labs > 10 Giannini Hall, UC Berkeley > phone: 510.643.4014 > http://cirl.berkeley.edu/ > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Permutations in Simulations`
Out of curiosity, why wouldn't numpy.apply_along_axis be a reasonable approach here. Even more curious: why is it slower than the original explicit loop? Learning, -Mark import numpy as np import timeit def baseshuffle(nx, ny): x = np.arange(nx) res = np.zeros((nx,ny),int) for sim in range(ny): res[:,sim] = np.random.permutation(x) return res def axisshuffle(nx,ny): x=np.arange(nx).reshape(nx,1) res=np.zeros((nx,ny),int) res[:] = x x1 = np.apply_along_axis(np.random.permutation,0,res) return x1 nx = 10 ny = 100 t=timeit.Timer("baseshuffle(nx, ny)", "from __main__ import *") print t.timeit(100) t=timeit.Timer("axisshuffle(nx,ny)", "from __main__ import *") print t.timeit(100) >>> 0.111320049056 0.297792159759 >>> On Tue, Feb 10, 2009 at 12:58 PM, Keith Goodman wrote: > On Tue, Feb 10, 2009 at 12:41 PM, Keith Goodman wrote: >> On Tue, Feb 10, 2009 at 12:28 PM, Keith Goodman wrote: >>> On Tue, Feb 10, 2009 at 12:18 PM, Keith Goodman wrote: On Tue, Feb 10, 2009 at 11:29 AM, Mark Janikas wrote: > I want to create an array that contains a column of permutations for each > simulation: > > import numpy as NUM > > import numpy.random as RAND > > x = NUM.arange(4.) > > res = NUM.zeros((4,100)) > > > for sim in range(100): > > res[:,sim] = RAND.permutation(x) > > > Is there a way to do this without a loop? Thanks so much ahead of time… Does this work? Might not be faster but it does avoid the loop. import numpy as np def weirdshuffle(nx, ny): x = np.ones((nx,ny)).cumsum(0, dtype=np.int) - 1 yidx = np.ones((nx,ny)).cumsum(1, dtype=np.int) - 1 xidx = np.random.rand(nx,ny).argsort(0).argsort(0) return x[xidx, yidx] >>> >>> Hey, it is faster for nx=4, ny=100 >>> >>> def baseshuffle(nx, ny): >>>x = np.arange(nx) >>>res = np.zeros((nx,ny)) >>>for sim in range(ny): >>>res[:,sim] = np.random.permutation(x) >>>return res >>> > timeit baseshuffle(4,100) >>> 1000 loops, best of 3: 1.11 ms per loop > timeit weirdshuffle(4,100) >>> 1 loops, best of 3: 127 µs per loop >>> >>> OK, who can cut that time in half? My first try looks clunky. >> >> This is a little faster: >> >> def weirdshuffle2(nx, ny): >>one = np.ones((nx,ny), dtype=np.int) >>x = one.cumsum(0) >>x -= 1 >>yidx = one.cumsum(1) >>yidx -= 1 >>xidx = np.random.random_sample((nx,ny)).argsort(0).argsort(0) >>return x[xidx, yidx] >> timeit weirdshuffle(4,100) >> 1 loops, best of 3: 129 µs per loop timeit weirdshuffle2(4,100) >> 1 loops, best of 3: 106 µs per loop > > Sorry for all the mail. > > def weirdshuffle3(nx, ny): >return np.random.random_sample((nx,ny)).argsort(0).argsort(0) > >>> timeit weirdshuffle(4,100) > 1 loops, best of 3: 128 µs per loop >>> timeit weirdshuffle3(4,100) > 1 loops, best of 3: 37.5 µs per loop > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Permutations in Simulations`
Got it. Thanks! On Tue, Feb 10, 2009 at 1:50 PM, Keith Goodman wrote: > On Tue, Feb 10, 2009 at 1:41 PM, Mark Miller > wrote: >> Out of curiosity, why wouldn't numpy.apply_along_axis be a reasonable >> approach here. Even more curious: why is it slower than the original >> explicit loop? > > I took a quick look at the apply_along_axis code. It is numpy code > (not c) and it uses a while loop to loop over the axis. > > In ipython just type np.apply_along_axis?? > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Fancier indexing
You're just trying to do this...correct? >>> import numpy >>> items = numpy.array([0,3,2,1,4,2],dtype=int) >>> unique = numpy.unique(items) >>> unique array([0, 1, 2, 3, 4]) >>> counts=numpy.histogram(items,unique) >>> counts (array([1, 1, 2, 1, 1]), array([0, 1, 2, 3, 4])) >>> counts[0] array([1, 1, 2, 1, 1]) >>> On Thu, May 22, 2008 at 9:08 AM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Thu, May 22, 2008 at 8:59 AM, Kevin Jacobs <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> wrote: > > After poking around for a bit, I was wondering if there was a faster > method > > for the following: > > > > # Array of index values 0..n > > items = numpy.array([0,3,2,1,4,2],dtype=int) > > > > # Count the number of occurrences of each index > > counts = numpy.zeros(5, dtype=int) > > for i in items: > > counts[i] += 1 > > > > In my real code, 'items' contain up to a million values and this loop > will > > be in a performance critical area of code. If there is no simple > solution, > > I can trivially code this using the C-API. > > How big is n? If it is much smaller than a million then loop over that > instead. > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] f2py errors: any help interpreting?
To anyone who can help: I recently got around to installing numpy 1.04 over an older version (numpy 1.04dev3982) on a Windows Vista machine. Since then, I have been unable to compile some of my extensions using f2py. I also tested a fresh install of numpy 1.04 on a new XP machine that has never seen Python and am getting the same messages. Here's the relevant bits, I think. Wrote C/API module "pickparents" to file "c:\users\mark\appdata\local\temp\tmpiuxw9j\src.win32-2.5/pickparentsmodule.c" Traceback (most recent call last): File "C:\python25\scripts\f2py.py", line 26, in main() File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 558, in main run_compile() File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 545, in run_compile setup(ext_modules = [ext]) File "C:\Python25\lib\site-packages\numpy\distutils\core.py", line 176, in setup return old_setup(**new_attr) File "C:\Python25\lib\distutils\core.py", line 151, in setup dist.run_commands() File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands self.run_command(cmd) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\distutils\command\build.py", line 112, in run self.run_command(cmd_name) File "C:\Python25\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 130, in run self.build_sources() File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 147, in build_sources self.build_extension_sources(ext) File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 256, in build_extension_sources sources = self.f2py_sources(sources, ext) File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 513, in f2py_sources ['-m',ext_name]+f_sources) File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 367, in run_main ret=buildmodules(postlist) File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 319, in buildmodules dict_append(ret[mnames[i]],rules.buildmodule(modules[i],um)) File "C:\Python25\lib\site-packages\numpy\f2py\rules.py", line 1222, in buildmodule for l in '\n\n'.join(funcwrappers2)+'\n'.split('\n'): TypeError: cannot concatenate 'str' and 'list' objects Any thoughts? Please let me know if more information is needed to troubleshoot. -Mark ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] f2py errors: any help interpreting?
To anyone who can help: I recently got around to installing numpy 1.04 over an older version (numpy 1.04dev3982) on a Windows Vista machine. Since then, I have been unable to compile some of my extensions using f2py. I also tested a fresh install of numpy 1.04 on a new XP machine that has never seen Python and am getting the same messages. Here's the relevant bits, I think. Wrote C/API module "pickparents" to file "c:\users\mark\appdata\local \temp\tmpiuxw9j\src.win32-2.5/pickparentsmodule.c" Traceback (most recent call last): File "C:\python25\scripts\f2py.py", line 26, in main() File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 558, in main run_compile() File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 545, in run_compile setup(ext_modules = [ext]) File "C:\Python25\lib\site-packages\numpy\distutils\core.py", line 176, in setup return old_setup(**new_attr) File "C:\Python25\lib\distutils\core.py", line 151, in setup dist.run_commands() File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands self.run_command(cmd) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\distutils\command\build.py", line 112, in run self.run_command(cmd_name) File "C:\Python25\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 130, in run self.build_sources() File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 147, in build_sources self.build_extension_sources(ext) File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 256, in build_extension_sources sources = self.f2py_sources(sources, ext) File "C:\Python25\lib\site-packages\numpy\distutils\command\build_src.py", line 513, in f2py_sources ['-m',ext_name]+f_sources) File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 367, in run_main ret=buildmodules(postlist) File "C:\Python25\lib\site-packages\numpy\f2py\f2py2e.py", line 319, in buildmodules dict_append(ret[mnames[i]],rules.buildmodule(modules[i],um)) File "C:\Python25\lib\site-packages\numpy\f2py\rules.py", line 1222, in buildmodule for l in '\n\n'.join(funcwrappers2)+'\n'.split('\n'): TypeError: cannot concatenate 'str' and 'list' objects Any thoughts? Please let me know if more information is needed to troubleshoot. -Mark ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] f2py errors: any help interpreting?
Super...I'll give it a try. Or should I just wait for the numpy 1.1 release? thanks, -Mark On Fri, May 23, 2008 at 2:45 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Fri, May 23, 2008 at 4:00 PM, Mark Miller <[EMAIL PROTECTED]> wrote: > > > File "C:\Python25\lib\site-packages\numpy\f2py\rules.py", line 1222, in > > buildmodule > > for l in '\n\n'.join(funcwrappers2)+'\n'.split('\n'): > > TypeError: cannot concatenate 'str' and 'list' objects > > > > > > Any thoughts? Please let me know if more information is needed to > > troubleshoot. > > This is a bug that was fixed in SVN r4335. > > http://projects.scipy.org/scipy/numpy/changeset/4335 > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] f2py errors: any help interpreting?
Thank you...getting much closer now. My current issue is this message: running build_ext error: don't know how to compile C/C++ code on platform 'nt' with 'g95' compiler. Any help? Again, sorry to pester. I'm just pretty unfamiliar with these things. Once I get environmental variables set up, I rarely need to fiddle with them again. So I don't have a specific feel for what might be happening here. thanks, -Mark On Fri, May 23, 2008 at 3:01 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Fri, May 23, 2008 at 4:48 PM, Mark Miller <[EMAIL PROTECTED]> > wrote: > > Super...I'll give it a try. Or should I just wait for the numpy 1.1 > > release? > > Probably. You can get a binary installer for the release candidate here: > > > http://www.ar.media.kyoto-u.ac.jp/members/david/archives/numpy-1.1.0rc1-win32-superpack-python2.5.exe > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] f2py errors: any help interpreting?
Ignore last message: I seem to have figured out the next environmental variable that needed to be set. Still some lingering issues, but I'll work on them some more before pestering here again. thanks, -Mark On Fri, May 23, 2008 at 3:48 PM, Mark Miller <[EMAIL PROTECTED]> wrote: > Thank you...getting much closer now. > > My current issue is this message: > > running build_ext > error: don't know how to compile C/C++ code on platform 'nt' with 'g95' > compiler. > > Any help? > > Again, sorry to pester. I'm just pretty unfamiliar with these things. > Once I get environmental variables set up, I rarely need to fiddle with them > again. So I don't have a specific feel for what might be happening here. > > thanks, > > -Mark > > > > > > On Fri, May 23, 2008 at 3:01 PM, Robert Kern <[EMAIL PROTECTED]> > wrote: > >> On Fri, May 23, 2008 at 4:48 PM, Mark Miller <[EMAIL PROTECTED]> >> wrote: >> > Super...I'll give it a try. Or should I just wait for the numpy 1.1 >> > release? >> >> Probably. You can get a binary installer for the release candidate here: >> >> >> http://www.ar.media.kyoto-u.ac.jp/members/david/archives/numpy-1.1.0rc1-win32-superpack-python2.5.exe >> >> -- >> Robert Kern >> >> "I have come to believe that the whole world is an enigma, a harmless >> enigma that is made terrible by our own mad attempt to interpret it as >> though it had an underlying truth." >> -- Umberto Eco >> ___ >> Numpy-discussion mailing list >> Numpy-discussion@scipy.org >> http://projects.scipy.org/mailman/listinfo/numpy-discussion >> > > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] f2py errors: any help interpreting?
In this case, I am just using the Windows command prompt. I do not have a setup.cfg or pydistutils.cfg file. I did create a file in Python25\Lib\distutils called distutils.cfg containing 2 lines: [build] compiler = mingw32 That took care of the previous message. I am currently getting a 'failed with exit status 1' message, that for the life of me I can't remember what causes it. I have attached the full (albeit tedius) output from an attempt, if someone is willing to wade through it. -Mark On Fri, May 23, 2008 at 3:50 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Fri, May 23, 2008 at 5:48 PM, Mark Miller <[EMAIL PROTECTED]> > wrote: > > Thank you...getting much closer now. > > > > My current issue is this message: > > > > running build_ext > > error: don't know how to compile C/C++ code on platform 'nt' with 'g95' > > compiler. > > > > Any help? > > What command line are you using? Do you have a setup.cfg or > pydistutils.cfg file that you are using? Can you show us the full > output? > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > F:\>c:\python25\scripts\f2py.py --fcompiler=g95 -c pick_parents.f95 -m pick_parents Ignoring "Python was built with Visual Studio 2003; extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have Cygwin installed, you can try compiling with MingW32, by passing "-c mingw32" to setup.py." (one should fix me in fcompiler/compaq.py) running build running scons customize Mingw32CCompiler Found executable C:\MinGW\bin\gcc.exe customize GnuFCompiler Found executable C:\MinGW\bin\g77.exe gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found Found executable C:\MinGW\bin\g77.exe customize GnuFCompiler gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found customize Mingw32CCompiler customize Mingw32CCompiler using scons running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler opti ons running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler opt ions running build_src building extension "pick_parents" sources f2py options: [] f2py:> c:\windows\temp\tmpl5mnqq\src.win32-2.5\pick_parentsmodule.c creating c:\windows\temp\tmpl5mnqq creating c:\windows\temp\tmpl5mnqq\src.win32-2.5 Reading fortran codes... Reading file 'pick_parents.f95' (format:free) Post-processing... Block: pick_parents Block: pick_parents Block: seedinfo Block: setseed Block: getseed Block: bivnorm Block: expo Block: random Block: bivnorm4barr Block: bivnormexpansion Post-processing (stage 2)... Block: pick_parents Block: unknown_interface Block: pick_parents Block: seedinfo Block: setseed Block: getseed Block: bivnorm Block: expo Block: random Block: bivnorm4barr Block: bivnormexpansion Building modules... Building module "pick_parents"... Constructing F90 module support for "pick_parents"... Constructing wrapper function "pick_parents.seedinfo"... a = seedinfo() Constructing wrapper function "pick_parents.setseed"... setseed(seed,[k]) Constructing wrapper function "pick_parents.getseed"... seed = getseed(k) Constructing wrapper function "pick_parents.bivnorm"... bivnorm(sigma,xcoords1,ycoords1,xcoords2,ycoords2,[xdim,ydim]) Constructing wrapper function "pick_parents.expo"... expo(lambda,xcoords1,ycoords1,xcoords2,ycoords2,[xdim,ydim]) Constructing wrapper function "pick_parents.random"...
Re: [Numpy-discussion] f2py errors: any help interpreting?
It appears to be there: dllcrt2.o in g95\lib. I'll re-install g95 to see if it helps. I'll also give gfortran in the meantime too. -Mark On Fri, May 23, 2008 at 4:05 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Fri, May 23, 2008 at 5:59 PM, Mark Miller <[EMAIL PROTECTED]> > wrote: > > In this case, I am just using the Windows command prompt. I do not have > a > > setup.cfg or pydistutils.cfg file. I did create a file in > > Python25\Lib\distutils called distutils.cfg containing 2 lines: > > > > [build] > > compiler = mingw32 > > > > That took care of the previous message. I am currently getting a 'failed > > with exit status 1' message, that for the life of me I can't remember > what > > causes it. > > > > I have attached the full (albeit tedius) output from an attempt, if > someone > > is willing to wade through it. > > The important line is this one: > > ld: dllcrt2.o: No such file: No such file or directory > > This looks like a problem with g95. Either it is misconfigured or we > aren't passing it the right flags. Can you check to see if there is a > dllcrt2.o file somewhere in your g95 installation? > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] f2py errors: any help interpreting?
gfortran is doing the trick. Must be a g95 misconfiguration or some other thing that I have no ability to comprehend. Thanks for the tip about the buggy numpy 1.04. That seemed to be the most serious hurdle. -Mark On Fri, May 23, 2008 at 4:12 PM, Mark Miller <[EMAIL PROTECTED]> wrote: > It appears to be there: dllcrt2.o in g95\lib. > > I'll re-install g95 to see if it helps. I'll also give gfortran in the > meantime too. > > -Mark > > > On Fri, May 23, 2008 at 4:05 PM, Robert Kern <[EMAIL PROTECTED]> > wrote: > >> On Fri, May 23, 2008 at 5:59 PM, Mark Miller <[EMAIL PROTECTED]> >> wrote: >> > In this case, I am just using the Windows command prompt. I do not have >> a >> > setup.cfg or pydistutils.cfg file. I did create a file in >> > Python25\Lib\distutils called distutils.cfg containing 2 lines: >> > >> > [build] >> > compiler = mingw32 >> > >> > That took care of the previous message. I am currently getting a >> 'failed >> > with exit status 1' message, that for the life of me I can't remember >> what >> > causes it. >> > >> > I have attached the full (albeit tedius) output from an attempt, if >> someone >> > is willing to wade through it. >> >> The important line is this one: >> >> ld: dllcrt2.o: No such file: No such file or directory >> >> This looks like a problem with g95. Either it is misconfigured or we >> aren't passing it the right flags. Can you check to see if there is a >> dllcrt2.o file somewhere in your g95 installation? >> >> -- >> Robert Kern >> >> "I have come to believe that the whole world is an enigma, a harmless >> enigma that is made terrible by our own mad attempt to interpret it as >> though it had an underlying truth." >> -- Umberto Eco >> ___ >> Numpy-discussion mailing list >> Numpy-discussion@scipy.org >> http://projects.scipy.org/mailman/listinfo/numpy-discussion >> > > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Masked arrays and pickle/unpickle
On Thu, Jul 17, 2008 at 3:18 PM, Pierre GM <[EMAIL PROTECTED]> wrote: > > Dang, forgot about that. Having a dictionary of options would be cool, but > we > can't store it inside a regular ndarray. If we write to a file, we may want > to write a header first that would store all the metadata we need. > > Not to derail the discussion, but I am a frequent user of Python's shelve function to archive large numpy arrays and associated sets of parameters into one very handy and accessible file. If numpy developers are discouraging use of this type of thing (shelve relies on pickle, is this correct?), then it would be super handy to be able to also include other data when saving arrays using numpy's intrinsic functions. Just a thought. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion