Re: [Numpy-discussion] State-of-the-art to use a C/C++ library from Python
On Wed, Aug 31, 2016, at 13:57, Jason Newton wrote: > Hey Ian - I hope I gave Cython a fair comment, but I have to add the > disclaimer that your capability to understand/implement those > solutions/workarounds in that project is greatly enhanced from your > knowing the innards of Cython from being core developer on the Cython > project. This doesn't detract from DyDN's accomplishments (if nothing > it means Cython users should look there for how to use C++ with Cython > and the workarounds used + shortcomings) but I would not expect not > everyone would want to jump through those hoops to get things working > without a firm understanding of Cython's edges, and all this potential > for special/hack adaption code is still something to keep in mind when > comparing to something more straight forward and easier to understand > coming from a more pure C/C++ side, where things are a bit more > dangerous and fairly more verbose but make play with the language and > environment first-class (like Boost.Python/pybind). Since this thread > is a survey over state and options it's my intent just to make sure > readers have something bare in mind for current pros/cons of the > approaches. There are many teaching resources available for Cython, after which exposure to sharp edges may be greatly reduced. See, e.g., https://github.com/stefanv/teaching/blob/master/2014_assp_split_cython/slides/split2014_cython.pdf and accompanying problems and exercises at https://github.com/stefanv/teaching/tree/master/2014_assp_split_cython Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Which NumPy/Numpy/numpy spelling?
On Mon, Aug 29, 2016, at 04:43, m...@telenczuk.pl wrote: > The documentation is not consistent and it mixes both NumPy and Numpy. > For example, the reference manual uses both spellings in the introduction > paragraph (http://docs.scipy.org/doc/numpy/reference/): > > "This reference manual details functions, modules, and objects > included in Numpy, describing what they are and what they do. For > learning how to use NumPy, see also NumPy User Guide." That's technically a bug: the official spelling is NumPy. But, no one really cares :) Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Help wanted: implementation of 3D medial axis skeletonization
Hi all, I have been approached by a group that is interested in sponsoring the development of 3D skeletonization in scikit-image. One potential starting place would be: http://www.insight-journal.org/browse/publication/181 Is anyone interested in working on this? Please get in touch either on the scikit-image mailing list or by mailing me directly. Thanks! Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Fwd: Numpy for data manipulation
On 2015-10-01 11:46:59, Alex Rogozhnikovwrote: > Hi, I have written some numpy tips and tricks I am using, which may be > interesting to you. > This is quite long reading, so I've splitted it into two parts: > > http://arogozhnikov.github.io/2015/09/29/NumpyTipsAndTricks1.html > http://arogozhnikov.github.io/2015/09/30/NumpyTipsAndTricks2.html I think that's a nice list already! I would probably start with: %matplotlib inline import numpy as np Then port all the code to Python 3 (or at least Python 2 & 3 compatible). Perhaps some illustrations could be useful, e.g. how to use the IronTransform to do histogram equalization. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] ANN: Numpy 1.10.0rc1 released.
On 2015-09-24 00:17:33, Jens Jørgen Mortensenwrote: > jensj@jordan:~$ python > Python 2.7.9 (default, Apr 2 2015, 15:33:21) > [GCC 4.9.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import numpy as np > >>> a = np.zeros((2, 2, 2)) > >>> b = np.zeros((2, 2, 2)) > >>> a[0, 0] = 7 > >>> b[0, 0] = 6 > >>> np.vdot(a[:, :, 0], b[:, :, 0]).real > 84.0 > >>> np.__version__ > '1.10.0rc1' > > The result should be 42. This is on Ubuntu 15.04. The input is not supposed to be matrices—but the docstring specifically states that those should then be ravelled, so this is indeed a bug. If I bisected correctly, the problematic change is this one: commit 44877b36870ec2a0505c536a30b9fbf06a414c17 Author: Sebastian Berg Date: Wed Sep 3 18:33:06 2014 +0200 ENH: Allow ravel to reshape in place when possible This fixes a lot of corner cases in reshape 'K' when the array is not contiguous in the first place, it was previously never ravelled in place. Closes gh-5033 Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
On 2015-09-23 13:36:35, Fernando Perezwrote: > On Wed, Sep 23, 2015 at 12:57 PM, Matthew Brett > wrote: > >> I see a severe reaction to perceived 'suspicion and innuendo', but I >> see no 'suspicion and innuendo'. Unless you mean that any suggestion >> of potential conflict of interest is suspicion and innuendo. >> > > No, as I said, COIs are absolutely a fact of life, and *should* be talked > about, openly and directly. I was referring generically about the tone of > this thread, that Ryan described as "bizarre", others as "surpised", > "disheartened", etc. What I thought Matthew was saying is that you writing "I hope the discussion can move past the suspicion and innuendo about Continuum and Travis" gives validity to the view that those things are real whereas, in my view, they were constructed in responses by others who didn't accurately summarize the intent of what was being said (and I'm not laying blame to anyone, I could certainly have worded myself more clearly). But, yes, it was disheartening—especially because we all know one another and have hacked together late into the night at SciPy conferences. My experience has always been that we are reasonable people who listen; but perhaps we forget that about one another from time to time. It is important to me that we work towards making this mailing list a safe place for discussion again. Part of that may be to do some maintenance on bridges of trust that seem to have eroded a bit over the years. Perhaps some kind of group bonding activity, such as working on a shared project, would help? ;) > b) a suggestion that we discuss it further personally, taking advantage of > the fact that we happen to be physically close. Sure, I'm happy to discuss the personal side of this offline. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] "Become an Open Source Contributor" workshop
Hi Jaime On 2015-09-23 14:06:08, Jaime Fernández del Ríowrote: >3. If you have organized anything similar in the past, and have material >that I could use to, ahem, draw inspiration from, or recommendations to >make, or whatever, I'd love to hear from you. Here's the new developer workflow page for scikit-image, I'm sure many other projects have similar ones: http://scikit-image.org/docs/stable/contribute.html Perhaps you can harvest some ideas. Also, a beginner's summary to git workflow: http://rogerdudler.github.io/git-guide/ It's a lot to teach in only an hour or two, so if I were teaching I'd keep it simple (basic) and clear (to make sure the students can "keep it in their heads"), and to make sure they have a clear avenue for questions when they get stuck after the class. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] ANN: numtraits v0.2
On 2015-09-23 17:16:14, Nathaniel Smithwrote: >> This looks great! At the moment, a pip install tries to install a >> different version of NumPy, even though I already have the development >> version on my tree. > > FYI the alternative solution is to fix your local numpy install to > give pip an accurate picture of what you have installed. The key thing > is to make sure you have a .egg-info / .dist-info for your numpy -- > that's what pip looks for to figure out what's installed. (python > setupegg.py egg_info will generate one IIRC). Looks like 'pip install -e .' in the numpy directory also fixed it. Good to know, thanks. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] ANN: numtraits v0.2
Hi Thomas On 2015-09-23 09:39:00, Thomas Robitaillewrote: > We have released a small experimental package called numtraits that > builds on top of the traitlets package and provides a NumericalTrait > class that can be used to validate properties such as: This looks great! At the moment, a pip install tries to install a different version of NumPy, even though I already have the development version on my tree. In scikit-image, we use something like the following in setup.py to prevent that from happening: # Do not try and upgrade larger dependencies INSTALL_REQUIRES = ['numpy', 'traitlets'] try: __import__('numpy') INSTALL_REQUIRES = ['traitlets'] except ImportError: pass Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Tentative NumPy Tutorial inaccessible
On 2015-09-22 23:53:19, Nathaniel Smithwrote: > On Tue, Sep 22, 2015 at 10:58 PM, Andriy Yurchuk wrote: >> Hi! >> >> The Tentative NumPy Tutorial is no longer accessible by the URL >> http://wiki.scipy.org/Tentative_NumPy_Tutorial, it returns a 403. The link >> to this page is still on NumPy homepage though. Has the page been moved >> somewhere else? > > No, our infrastructure is just in some disarray right now... there's > some discussion here: https://github.com/numpy/numpy/issues/6325 > (and I just pointed this out there as well since the relevant admins > seem to be reading that thread). FWIW, that tutorial is not that useful any longer. I'd refer to http://scipy-lectures.github.io/ instead. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
Hi Travis On 2015-09-21 23:29:12, Travis Oliphantwrote: > 1) nobody believes that the community should be forced to adopt numba as > part of ufunc core yet --- but this could happen someday just as Cython is > now being adopted but was proposed 8 years ago that it "could be adopted" > That's a red-hearing. Yes, I'd like to clarify: I was not against including any specific technology in NumPy. I was highlighting that there may be different motivations for members of the general community and those working for, say, Continuum, to get certain features adopted. > 2) I have stated that breaking the ABI is of little consequence because > of conda as well as other tools.I still believe that. This has nothing > to do with any benefit Continuum might or might not receive because of > conda. Everyone else who wants to make a conda-based distribution also > benefits (Cloudera, Microsoft, Intel, ...) or use conda also benefits. > I don't think the community realizes the damange that is done with FUD like > this. There are real implications. It halts progress, creates confusion, > and I think ultimately damages the community. This is an old argument, and the reason why we have extensive measures in place to guard against ABI breakage. But, reading what you wrote above, I would like to understand better what FUD you are referring to, because I, rightly or wrongly, believe there is a real concern here that is being glossed over. > I don't see how.None of these have been proposed for integrating into > NumPy.I don't see how integrating numba into NumPy benefits Continuum > at all. It's much easier for us to keep it separate. At this point > Continuum doesn't have an opinion about integrating DyND into NumPy or > not. I think that touches, tangentially at least, on the problem. If an employee of Continuum were steering NumPy, and the company developed an opinion on those integrations, would such a person not feel compelled to toe the company line? (Whether the company is Continuum or another is besides the point—I am only trying to understand the dynamics of working for a company and leading an open source project that closely interacts with their producs.) > I know that you were responding to specific question by Brian as to how > their could be a conflict of interest for Continuum and NumPy development. > I don't think this is a useful conversation --- we could dream up all > kinds of conflicts of interest for BIDS and NumPy too (e.g. perhaps BIDS > really wants Spark to take over and for NumPy to have special connections > to Spark). Are we to not allow anyone at BIDS to participate in the > steering council because of their other interests? I guess that's an interesting example, but BIDS (which sits inside a university and is funded primarily by foundations) has no financial, and very few other, incentives to do so. > But remember, the original point is whether or not someone from Continuum > (or I presume any company and not just singling out Continuum for special > treatment) should be on the steering council.Are you really arguing > that they shouldn't because there are other projects Continuum is working > on that have some overlap with NumPy.I really hope you don't actually > believe that. Here's what I'm trying to say (and I apologise for ruffling feathers in the process): There are concerns amongst members of the community that (will) arise when strong players from industry try / hint at exerting (some) executive control over NumPy. We can say that these concerns amount to spreading FUD, that they are uninformed, unrealistic, etc., but ultimately they are still out there, and until they are discussed and addressed, I find it hard to see how we can move forward with ease. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
On 2015-09-21 22:15:55, Bryan Van de Venwrote: > Beyond that, what (even in a broad sense) is an example of a goal that > "Continuum might need" that would conceivably do detriment to the > NumPy community? That it be faster? Simpler to maintain? Easier to > extend? Integrate better with more OS projects? Attract new active > developers? Receive more financial support? Grow its user base even > more? I don't know how productive it is to dream up examples, but it's not very hard to do. Currently, e.g., the community is not ready to adopt numba as part of the ufunc core. But it's been stated by some that, with so many people running Conda, breaking the ABI is of little consequence. And then it wouldn't be much of a leap to think that numba is an acceptable dependency. There's a broad range of Continuum projects that intersect with what NumPy does: numba, DyND, dask and Odo to name a few. Integrating them into NumPy may make a lot more sense for someone from Continuum than for other members of the community. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
Hi Brian On 2015-09-21 23:28:48, Bryan Van de Venwrote: >> very hard to do. Currently, e.g., the community is not ready to adopt >> numba as part of the ufunc core. But it's been stated by some that, > > Who are you speaking for? The entire community? Under what mandate? I am speaking on behalf of myself, under no mandate. > The current somewhat concrete proposal I am aware of involves funding > cleaning up dtypes. Is there another concrete, credible proposal to > make Numba a dependency of NumPy that you can refer to? If not, why > are we mired in hypotheticals? I'm sorry if I misunderstood, but I thought you wanted us to explore hypothetical confictual situations. > May? Can you elaborate? More speculation. My own position is that > these projects want to integrate with NumPy, not the > converse. Regardless of my opinion, can you actually make any specific > arguements, one way or the otehr? What if if some integrations > actually make more sense for the community? Is this simply a dogmatic > ideological position that anything whatsoever that benefits both NumPy > and Continuum simultaneously is bad, on principle? That's fine, as > such, but let's make that position explicit if that's all it is. No, I don't have such a dogmatic ideological position. I think, however, that it is somewhat unimaginative to propose that there are no potential conflicts whatsoever. I am happy if we can find solutions that benefit both numpy and any company out there. But in the end, I'm sure you'd agree that we want the decisions that lead to such solutions to be taken in the best interest of the project, and not be weighed by alterior motivations of any sorts. In the end, even the *perception* that that is not the case can be very harmful. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
Hi Travis On 2015-09-22 03:44:12, Travis Oliphantwrote: > I'm actually offended that so many at BIDS seem eager to crucify my > intentions when I've done nothing but give away my time, my energy, my > resources, and my sleep to NumPy for many, many years.I guess if your > intent is to drive me away, then you are succeeding. I guess we've gone off the rails pretty far at this point, so let me at least take a step back, and make sure that you know that: - I have never doubted that your intensions for NumPy are anything but good (I know they are!), - I *want* the community to be a welcoming place for companies to contribute (otherwise, I guess I'd not be such a fervent supporter of the scientific eco-system using the BSD license), and - I love your enthusiasm for the project. After all, that is a big part of what inspired me to become involved in the first place. My goal is not to spread uncertainty, fear nor doubt—if that was the perception left, I apologize. I'll re-iterate that I wanted to highlight a concern about the interactions of a (somewhat weakly cohesive) community and strong, driven personalities such as yourself backed by a formidable amount of development power. No matter how good your intensions are, there are risks involved in this kind of interaction, and if we fail to even *admit* that, we are in trouble. Lest the above be read in a negative light again, let me state it up-front: *I don't think you will hijack the project, use it for your own gain, or attempt to do anything you don't believe to be in the best interest of NumPy.* What I'm saying is that we absolutely need to move forward in a way that brings everyone along, and makes everyone rest assured that their voice will be heard. Also, please know that I have not discussed these matters with Nathaniel behind the scenes, other than an informal hour-long discussion about his original governance proposal. There is no BIDS conspiracy or attempts at crucifixion. After all, you were an invited guest speaker at an event I organized this weekend, since I value your opinion and insights. Either way, let me again apologize if my suggested lack of insight hurt people's feelings. I can only hope that, in educating me, we all learn a few lessons. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Governance model request
On 2015-09-20 11:20:28, Travis Oliphantwrote: > I would recommend three possible adjustments to the steering council > concept. > > 1 - define a BDFL for the council. I would nominate chuck Harris > > 2 - limit the council to 3 people. I would nominate chuck, nathaniel, and > pauli. > > 3 - add me as a permanent member of the steering council. I would split the above into two parts: a suggestion on how to change the governance model (first half of 1 and 2) and then some thoughts on what to do once those changes have been made (latter half of 1 and 2, as well as 3). For now, since those changes are not in place yet, it's probably best to focus on the governance model. I would agree that one person (or a very small group) is best suited to "getting things unstuck". And, personally, I believe it best for that person/persons to be elected by the community (whatever we define "the community" to be)---which is what I presume you suggested when you mentioned nominating candidates. Since Matthew mentioned the governance proposal we're working on, here is a very early draft: https://github.com/stefanv/skimage-org/blob/governance_proposal/governance.md As I said, this is still a work-in-progress--comments are welcome. E.g., the weighting element in the voting has to be fine tuned (but was put in place to prevent rapid take-overs). Essentially, we need: - a way for community members to express disagreement without being ousted, - protection against individuals who want to exert disproportional influence, - protection against those in leadership roles who cause the project long-term harm, - and a way for the community to change the direction of the project if they so wished. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Numpy FFT.FFT slow with certain samples
On 2015-08-28 11:51:47, Joseph Codadeen jdm...@hotmail.com wrote: my_1_minute_noise_with_gaps_truncated - Array len is 2646070my_1_minute_noise_with_gaps - Array len is 2649674 In [6]: from sympy import factorint In [7]: max(factorint(2646070)) Out[7]: 367 In [8]: max(factorint(2649674)) Out[8]: 1324837 Those numbers give you some indication of how long the FFT will take to compute. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Numpy FFT.FFT slow with certain samples
On 2015-08-28 16:20:33, Pierre-Andre Noel noel.pierre.an...@gmail.com wrote: If your sequence is not meant to be periodic (i.e., if after one minute there is no reason why the signal should start back at the beginning right away), then you should do zero-padding. And while you zero-pad, you can zero-pad to a sequence that is a power of two, thus preventing awkward factorizations. Zero-padding won't help with the non-periodicity, will it? For that you may want to window instead. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Comments on governance proposal (was: Notes from the numpy dev meeting at scipy 2015)
On 2015-08-27 11:06:10, Matthew Brett matthew.br...@gmail.com wrote: So, in the spirit of fruitful discussion, can I ask what y'all consider to be the current problems with working on numpy (other than the technical ones). What is numpy doing well, and what is it doing badly? What risks do we have to plan for in the future? It looks to me as though the team is doing an excellent job of maintaining NumPy. The growth of the project has stagnated somewhat for numerous reasons---and a lack of ideas on the table is not one of them, rather whether / how to take them forward. The question, and I think what you also highlighted in the earlier part of this discussion, is: how to decide on which vision to adopt, and who takes responsibility for making that happen? Are the two models proposed thus far so different, or can they be merged in a way that makes sense? E.g., can we work as a community to rally behind a vision as set out by one person, and then repeat that process to focus on another a year later? Think of it as the iterative development equivalent of governance. This may just be another way of phrasing a precedency, but with a strong emphasis on its temporary nature, as well as a focus on a group-decided outcome. Alternatively, see it as a community governance model with a strong emphasis on responsibility. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Comments on governance proposal (was: Notes from the numpy dev meeting at scipy 2015)
Hi Sebastian On 2015-08-27 14:45:50, Sebastian Berg sebast...@sipsolutions.net wrote: Agreed. Are not PEP's/NEP's just that (and could possibly be formalized more, not sure how much they are in the current proposal) in some sense? Since they have a sponsor/author who can be said to be assigned to it/responsible once accepted. I would consider a collection of NEPs for the following year to be such a thing. When implementing a bigger plan, it does help to have one person who owns the entire vision at the helm, pushing it forward. I think of it like a symphony orchestra: we agree to play the same music, and then let the director oversee the execution of the piece as a whole. The governance has to be create as little hassle as possible and it should be simple/short enough to quickly understand. I completely agree; and I think bikeshedding (everyone gets to argue their point of view, regardless of the stakes) can be the antithesis to productive focus. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Comments on governance proposal (was: Notes from the numpy dev meeting at scipy 2015)
Hi Matthew On 2015-08-26 10:50:47, Matthew Brett matthew.br...@gmail.com wrote: In short, the core structure seems to be characteristically associated with a conservatism and lack of vision that causes the project to stagnate. Can you describe how a democratic governance structure would look? It's not clear from the discussions linked where successful examples are to be found. Thanks Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Development workflow (not git tutorial)
On 2015-08-14 10:08:11, Benjamin Root ben.r...@ou.edu wrote: I should also note that there is currently an open issue with pip install -e and namespace packages. This has been reported to matplotlib with regards to mpl_toolkits. Essentially, if you have namespace packages, it doesn't get installed correctly in this mode, and python won't find them. There are lots of issues with namespace packages, which is why what used to be scikits.learn and scikits.image are now all standalone packages. Perhaps mpl_toolkits should think of becoming mpl_3d, mpl_basemaps, etc.? Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Development workflow (not git tutorial)
On 2015-08-13 08:52:22, Anne Archibald peridot.face...@gmail.com wrote: My current approach is to build an empty virtualenv, pip install nose, and from the numpy root directory do python setup.py build_ext --inplace and python -c 'import numpy; numpy.test()'. This works, for my stock system python, though I get a lot of weird messages suggesting distutils problems (for example python setup.py develop, although suggested by setup.py itself, claims that develop is not a command). But I don't know how (for example) to test with python3 without starting from a separate clean source tree. Nowadays, you can use pip install -e . to install an in-place editable version of numpy. This should also execute build_ext for you. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative
On 2015-05-10 14:46:12, Jaime Fernández del Río jaime.f...@gmail.com wrote: Isn't what you are trying to build a cartesian product function? There is a neat, efficient implementation of such a function in StackOverflow, by our own pv.: http://stackoverflow.com/questions/1208118/using-numpy-to-build-an-array-of-all-combinations-of-two-arrays/1235363#1235363 And a slightly faster version just down that page ;) Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] appveyor CI
Hi Chuck On 2015-03-05 10:09:08, Charles R Harris charlesr.har...@gmail.com wrote: Anyone familiar with appveyor http://www.appveyor.com/? Is this something we could use to test/build numpy on windows machines? It is free for open source. We already use this for scikit-image, and you are welcome to grab the setup here: https://github.com/scikit-image/scikit-image/blob/master/appveyor.yml GitHub now also supports multiple status reporting out of the box: https://github.com/blog/1935-see-results-from-all-pull-request-status-checks Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] ANN: scikit-image 0.11
Announcement: scikit-image 0.11.0 = We're happy to announce the release of scikit-image v0.11.0! scikit-image is an image processing toolbox for SciPy that includes algorithms for segmentation, geometric transformations, color space manipulation, analysis, filtering, morphology, feature detection, and more. For more information, examples, and documentation, please visit our website: http://scikit-image.org Highlights -- For this release, we merged over 200 pull requests with bug fixes, cleanups, improved documentation and new features. Highlights include: - Region Adjacency Graphs - Color distance RAGs (#1031) - Threshold Cut on RAGs (#1031) - Similarity RAGs (#1080) - Normalized Cut on RAGs (#1080) - RAG drawing (#1087) - Hierarchical merging (#1100) - Sub-pixel shift registration (#1066) - Non-local means denoising (#874) - Sliding window histogram (#1127) - More illuminants in color conversion (#1130) - Handling of CMYK images (#1360) - `stop_probability` for RANSAC (#1176) - Li thresholding (#1376) - Signed edge operators (#1240) - Full ndarray support for `peak_local_max` (#1355) - Improve conditioning of geometric transformations (#1319) - Standardize handling of multi-image files (#1200) - Ellipse structuring element (#1298) - Multi-line drawing tool (#1065), line handle style (#1179) - Point in polygon testing (#1123) - Rotation around a specified center (#1168) - Add `shape` option to drawing functions (#1222) - Faster regionprops (#1351) - `skimage.future` package (#1365) - More robust I/O module (#1189) API Changes --- - The ``skimage.filter`` subpackage has been renamed to ``skimage.filters``. - Some edge detectors returned values greater than 1--their results are now appropriately scaled with a factor of ``sqrt(2)``. Contributors to this release (Listed alphabetically by last name) - Fedor Baart - Vighnesh Birodkar - François Boulogne - Nelson Brown - Alexey Buzmakov - Julien Coste - Phil Elson - Adam Feuer - Jim Fienup - Geoffrey French - Emmanuelle Gouillart - Charles Harris - Jonathan Helmus - Alexander Iacchetta - Ivana Kajić - Kevin Keraudren - Almar Klein - Gregory R. Lee - Jeremy Metz - Stuart Mumford - Damian Nadales - Pablo Márquez Neila - Juan Nunez-Iglesias - Rebecca Roisin - Jasper St. Pierre - Jacopo Sabbatini - Michael Sarahan - Salvatore Scaramuzzino - Phil Schaf - Johannes Schönberger - Tim Seifert - Arve Seljebu - Steven Silvester - Julian Taylor - Matěj Týč - Alexey Umnov - Pratap Vardhan - Stefan van der Walt - Joshua Warner - Tony S Yu ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Context manager for seterr
Hi all, Since the topic of context managers recently came up, what do you think of adding a context manager for seterr? with np.seterr(divide='ignore'): frac = num / denom Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Context manager for seterr
On 2014-12-15 02:23:18, Julian Taylor jtaylor.deb...@googlemail.com wrote: with np.errstate(divide='ignore'): Perfect, thanks! Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] slicing an n-dimensional array
On 2014-12-04 03:41:35, Jaime Fernández del Río jaime.f...@gmail.com wrote: nx = np.arange(A.shape[0])[:, np.newaxis] ny = np.arange(A.shape[1]) C = A[nx, ny, B] That's the correct answer--in my answer I essentially wrote C = A[B] (== A[B, :, :]) which broadcasts the shape of B against the second and third dimensions of A (it's almost always a bad idea to combine index broadcasting and slicing). The notes I linked to are correct, though, and explain Jamie's answer in more detail (search for Jack's Dilemma). Regards Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] slicing an n-dimensional array
Hi Catherine On 2014-12-04 01:12:30, Moroney, Catherine M (398E) catherine.m.moro...@jpl.nasa.gov wrote: I have an array A of shape (NX, NY, NZ), and then I have a second array B of shape (NX, NY) that ranges from 0 to NZ in value. I want to create a third array C of shape (NX, NY) that holds the B-th slice for each (NX, NY) Those two arrays can broadcast if you expand the dimensions of B: A: (NX, NY, NZ) B: (NX, NY, 1) Your result would be B = B[..., np.newaxis] # now shape (NX, NY, 1) C = A[B] For more information on this type of broadcasting manipulation, see http://nbviewer.ipython.org/github/stefanv/teaching/blob/master/2014_assp_split_numpy/numpy_advanced.ipynb and http://wiki.scipy.org/EricsBroadcastingDoc Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Initializing array from buffer
Hi Andrea On 2014-11-16 19:42:09, Andrea Arteaga andyspi...@gmail.com wrote: My use case is the following: we have a some 3D arrays in our C++ framework. The ordering of the elements in these arrays is neither C nor Fortran style: it might be IJK (i.e. C style, 3rd dimension contiguous in memory), KJI (i.e. Fortran style, first dimension contiguous) or, e.g. IKJ. Moreover we put some padding to optimize aligned access. This kind of memory structure cannot be just expressed as 'C' or 'Fortran', but it can be perfectly expressed using the Python buffer protocol by providing the shape and the strides. We would like to export this structure to a numpy array that should be able of accessing the same memory locations in a consistent way and make some operations like initializing the content or plotting it. Is this currently possible? If not, is it planned to implement such a feature? This looks like something that should be accomplished fairly easily using the ``__array_interface__`` dictionary, as described here: http://docs.scipy.org/doc/numpy/reference/arrays.interface.html Any object that exposes a suitable dictionary named ``__array_interface__`` may be converted to a NumPy array. It has the following important keys: shape typestr data: (20495857, True); 2-tuple—pointer to data and boolean to indicate whether memory is read-only strides version: 3 Regards Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] median filtering a masked array
On 2014-11-06 11:10:29, Daπid davidmen...@gmail.com wrote: On 5 November 2014 19:11, Moroney, Catherine M (398E) catherine.m.moro...@jpl.nasa.gov wrote: What is the recommended way of doing a fast median filter on an array where only certain elements of the array need to be calculated? I'm trying to avoid a nested loop over all (I,J) elements. Since you are using FORTRAN, I believe the simplest way is to do this double loop in Cython. If you'd prefer to stay on the Python side, have a look at scipy.ndimage.generic_filter Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] FFT of 2D array along last axis
Hi Brad On 2014-11-07 00:51:02, Brad Buran bbu...@alum.mit.edu wrote: On Windows 7 using Anaconda with numpy 1.9.1 I get False (indicating that the FFT is not treating each row separately). When I test on a Ubuntu box using numpy 1.9.1 I get True. Is this expected behavior? If I understand the documentation correctly, the FFT on each row should be independent (i.e. the result should not be influenced by the other rows). The results should be the same. As an additional test, can you check: np.testing.assert_array_almost_equal(np.fft.fft(z, axis=-1)[0], np.fft.fft(z[0])) Thanks Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Choosing between NumPy and SciPy functions
Hi Michael On 2014-10-27 15:26:58, D. Michael McFarland dm...@dmmcf.net wrote: What I would like to ask about is the situation this illustrates, where both NumPy and SciPy provide similar functionality (sometimes identical, to judge by the documentation). Is there some guidance on which is to be preferred? I could argue that using only NumPy when possible avoids unnecessary dependence on SciPy in some code, or that using SciPy consistently makes for a single interface and so is less error prone. Is there a rule of thumb for cases where SciPy names shadow NumPy names? I'm not sure if you've received an answer to your question so far. My advice: use the SciPy functions. SciPy is often built on more extensive Fortran libraries not available during NumPy compilation, and I am not aware of any cases where a function in NumPy is faster or more extensive than the equivalent in SciPy. If you want code that falls back gracefully when SciPy is not available, you may use the ``numpy.dual`` library. Regards Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] FFTS for numpy's FFTs (was: Re: Choosing between NumPy and SciPy functions)
On 2014-10-28 19:37:17, Daniele Nicolodi dani...@grinta.net wrote: On 28/10/14 16:50, David Cournapeau wrote: Nothing impossible (looks like Sony at least uses this code on windows: https://github.com/anthonix/ffts/issues/27#issuecomment-40204403), but not a 2 hours thing either. One of the downsides of the BSD license :) Perhaps one of the upsides, as they may be willing to contribute back if asked nicely. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] FFTS for numpy's FFTs (was: Re: Choosing between NumPy and SciPy functions)
On 2014-10-28 19:55:57, Daniele Nicolodi dani...@grinta.net wrote: On 28/10/14 18:44, Stefan van der Walt wrote: On 2014-10-28 19:37:17, Daniele Nicolodi dani...@grinta.net wrote: On 28/10/14 16:50, David Cournapeau wrote: Nothing impossible (looks like Sony at least uses this code on windows: https://github.com/anthonix/ffts/issues/27#issuecomment-40204403), but not a 2 hours thing either. One of the downsides of the BSD license :) Perhaps one of the upsides, as they may be willing to contribute back if asked nicely. If it would be GPL or similar the would have to, and there would not be need to ask nicely. But then they would not have written the code to start off with, so that point is moot. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] higher accuracy in diagonialzation
On 2014-10-27 10:37:58, Sunghwan Choi sunghwancho...@gmail.com wrote: I am now diagonalizing a 200-by-200 symmetric matrix. But the two methods, scipy.linalg.eigh and numpy.linalg.eigh give significantly different result. The results from two methods are different within 10^-4 order. One of them is inaccurate or both two of them are inaccurate within that range. Which one is more accurate? or Are there any ways to control the accuracy for diagonalization? If you have some idea please let me know. My first (naive) attempt would be to set up a matrix, M, in sympy and then use M.diagonalize() to find the symbolic expression of the solution. You can then do the same numerically to see which method yields a result closest to the desired answer. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Request for enhancement to numpy.random.shuffle
Hi Warren On 2014-10-12 00:51:56, Warren Weckesser warren.weckes...@gmail.com wrote: A small wart in this API is the meaning of shuffle(a, independent=False, axis=None) It could be argued that the correct behavior is to leave the array unchanged. I like the suggested changes. Since independent loses its meaning when axis is None, I would expect this to have the same effect as `shuffle(a, independent=True, axis=None)`. I think a shuffle function that doesn't shuffle will confuse a lot of people! Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy 1.9b1 bug in pad function?
On 2014-06-14 14:40:29, Nadav Horesh nad...@visionsense.com wrote: This is most likely a documentation error since: In [7]: np.pad(a) --- TypeError Traceback (most recent call last) ipython-input-7-7a0346d77134 in module() 1 np.pad(a) TypeError: pad() missing 1 required positional argument: 'pad_width' That is because the signature is pad(array, pad_width, mode=None, ...) But mode *does* need to be specified. I see why this can be confusing, though, so perhaps we should simply make mode a positional argument too. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy 1.9b1 bug in pad function?
On 2014-06-14 14:40:29, Nadav Horesh nad...@visionsense.com wrote: TypeError: pad() missing 1 required positional argument: 'pad_width' I've added a PR here for further discussion: https://github.com/numpy/numpy/pull/4808 Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] matrix wart
On Thu, Feb 21, 2008 at 07:10:24PM -0500, Alan G Isaac wrote: On Thu, Feb 21, 2008 at 12:08:32PM -0500, Alan G Isaac wrote: a matrix behavior that I find bothersome and unnatural:: M = N.mat('1 2;3 4') M[0] matrix([[1, 2]]) M[0][0] matrix([[1, 2]]) On Fri, 22 Feb 2008, Stefan van der Walt apparently wrote: This is exactly what I would expect for matrices: M[0] is the first row of the matrix. Define what first row means! There is no standard definition that says this is means the **submatrix** that can be created from the first row. Someone once pointed out on this list that one might consider a matrix to be a container of 1d vectors. For NumPy, however, it is natural that it be a container of 1d arrays. (See the discussion for the distinction.) Could you explain to me how you'd like this to be fixed? If the matrix becomes a container of 1-d arrays, then you can no longer expect x[:,0] to return a column vector -- which was one of the reasons the matrix class was created. While not entirely consistent, one workaround would be to detect when a matrix is a vector, and then do 1-d-like indexing on it. You expect this matrix behavior only from experience with it, which is why I expect it too, while hating it. No, really, I don't ever use the matrix class :) But it is not like the behaviour is set in stone, so I would spend less time hating and more time patching. The example really speaks for itself. Since Konrad is an extremely experienced user/developer, his reaction should speak volumes. Of course, I meant no disrespect to Konrad. I'm just trying to understand the best way to address your concern. Regards Stefan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] change memmap.sync function
On Thu, Feb 21, 2008 at 04:17:26PM -0800, Christopher Burns wrote: Would anyone oppose deprecating the memmap.sync function and replacing it with memmap.flush? This would match python's mmap module, and I think be more intuitive. I made the change in http://projects.scipy.org/scipy/numpy/changeset/4817 If anyone objects, please revert. Chris, hope you don't mind that I went ahead so long -- I committed before noticing that you were working on the module earlier. Then again, you guys are probably all in bed by now! Cheers Stefan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Matching 0-d arrays and NumPy scalars
On Thu, Feb 21, 2008 at 12:08:32PM -0500, Alan G Isaac wrote: On Thu, 21 Feb 2008, Konrad Hinsen apparently wrote: What I see as more fundamental is the behaviour of Python container objects (lists, sets, etc.). If you add an object to a container and then access it as an element of the container, you get the original object (or something that behaves like the original object) without any trace of the container itself. I am not a CS type, but your statement seems related to a matrix behavior that I find bothersome and unnatural:: M = N.mat('1 2;3 4') M[0] matrix([[1, 2]]) M[0][0] matrix([[1, 2]]) This is exactly what I would expect for matrices: M[0] is the first row of the matrix. Note that you don't see this behaviour for ndarrays, since those don't insist on having a minimum of 2-dimensions. In [2]: x = np.arange(12).reshape((3,4)) In [3]: x Out[3]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) In [4]: x[0][0] Out[4]: 0 In [5]: x[0] Out[5]: array([0, 1, 2, 3]) Regards Stefan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Matching 0-d arrays and NumPy scalars
Hi Travis, On Wed, Feb 20, 2008 at 10:14:07PM -0600, Travis E. Oliphant wrote: In writing some generic code, I've encountered situations where it would reduce code complexity to allow NumPy scalars to be indexed in the same number of limited ways, that 0-d arrays support. For example, 0-d arrays can be indexed with * Boolean masks I've tried to use this before, but an IndexError (0-d arrays can't be indexed) is raised. * Ellipses x[...] and x[..., newaxis] This, especially, seems like it could be very useful. This is an easy change to implement, and I don't think it would cause any backward compatibility issues. Any opinions from the list? This is maybe a fairly esoteric use case, but one I can imagine coming across. I'm in favour of implementing the change. Could I ask that we also consider implementing len() for 0-d arrays? numpy.asarray returns those as-is, and I would like to be able to handle them just as I do any other 1-dimensional array. I don't know if a length of 1 would be valid, given a shape of (), but there must be some consistent way of handling them. Regards Stefan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] partial_sum/adj_difference?
On Tue, Feb 19, 2008 at 05:36:52PM -0700, Charles R Harris wrote: On Feb 19, 2008 2:20 PM, Stefan van der Walt [EMAIL PROTECTED] wrote: On Tue, Feb 19, 2008 at 01:50:04PM -0700, Charles R Harris wrote: And here I thought you were going to fix that. Deleting the blahs isn't a fix, it's a coverup. Now there is no extended documentation at all. I wouldn't call Blah, blah extended documentation -- in fact, I would've been rather embarrassed if that showed up on my screen during a workshop. Blah, blah also doesn't strike me as the ideal TODO marker. We can maybe use some more sensible text, or write a decorator to mark these functions. It has certainly been effective in practice. Yes, ironically :) http://projects.scipy.org/scipy/numpy/changeset/4813 http://projects.scipy.org/scipy/numpy/changeset/4814 The first courtesy of Matthew Brett. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Rename record array fields
Hi Sameer On Wed, Feb 20, 2008 at 03:10:16PM -0600, Sameer DCosta wrote: Is there a way to rename record array fields without making a copy of the whole record array? Thanks in advance for your replies. Simply view the array as a new dtype: In [2]: x Out[2]: array([(1, 2), (3, 4)], dtype=[('a', 'i4'), ('b', 'i4')]) In [3]: x.view([('other',int),('names',int)]) Out[3]: array([(1, 2), (3, 4)], dtype=[('other', 'i4'), ('names', 'i4')]) Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] partial_sum/adj_difference?
Hi Neal On Tue, Feb 19, 2008 at 01:38:06PM -0500, Neal Becker wrote: Does numpy/scipy have a partial_sum and adj_difference function? partial_sum[i] = \sum_{j=0}^{i} x[j] numpy.cumsum Yikes, the docstring contains Blah, blah. I'll fix that immediately. adj_diff[i] = x[i] - x[i-1] : i 1, x[i] otherwise numpy.diff Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] partial_sum/adj_difference?
On Tue, Feb 19, 2008 at 01:50:04PM -0700, Charles R Harris wrote: And here I thought you were going to fix that. Deleting the blahs isn't a fix, it's a coverup. Now there is no extended documentation at all. I wouldn't call Blah, blah extended documentation -- in fact, I would've been rather embarrassed if that showed up on my screen during a workshop. Blah, blah also doesn't strike me as the ideal TODO marker. We can maybe use some more sensible text, or write a decorator to mark these functions. I'd say we add them to the TODO list for the next doc-day and run with it... Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] List Array References?
Hi Alexander On Thu, Feb 14, 2008 at 03:43:46PM -0500, Alexander Michael wrote: Is there a way to list all of the arrays that are referencing a given array? Similarly, is there a way to get a list of all arrays that are currently in memory? As far as I know, the reference count to the array is increased when you create a view, but the views themselves are not tracked anywhere. You can therefore say whether there are references around, but you cannot identify the Python objects. I'm curious why you need this information -- maybe there is an alternative solution to your problem? Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] List Array References?
On Fri, Feb 15, 2008 at 08:28:08AM -0500, Alexander Michael wrote: On Fri, Feb 15, 2008 at 7:12 AM, Stefan van der Walt [EMAIL PROTECTED] wrote: As far as I know, the reference count to the array is increased when you create a view, but the views themselves are not tracked anywhere. You can therefore say whether there are references around, but you cannot identify the Python objects. I would like to occasionally dynamically grow an array (i.e. add length to existing dimensions) as I do not know th ultimately required length beforehand, but I have a good guess so I won't be need to reallocate that often if at all. The only way I know how to do this is numpy is to create a new larger array with the new dimensions and copy the existing data from the smaller array into it. Perhaps there is a better way that doesn't invalidate views on the array? I want to make sure that there are no outstanding references to the old array (i.e. views on it, etc.) so that I can raise a helpful exception while developing. Numpy does complain if you attempt to resize an array with views on it: In [8]: x = np.array([1,2,3]) In [14]: y = x[::-1] In [18]: x.resize((4,)) --- ValueErrorTraceback (most recent call last) /tmp/ipython console in module() ValueError: cannot resize an array that has been referenced or is referencing another array in this way. Use the resize function You can catch that exception and work from there. I hope that is what you had in mind? Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] test failures
Hi Charles On Wed, Feb 13, 2008 at 03:39:53PM -0700, Charles R Harris wrote: I believe these come from your latest commit. My changeset is here: http://projects.scipy.org/scipy/numpy/changeset/4800 I don't see how that would have broken the tests you listed. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ma.compress
Hi Pierre On Wed, Jan 23, 2008 at 08:45:26PM -0500, Pierre GM wrote: All, I just committed a fix on the SVN. Now, the axis keyword should be recognized. Sorry for the delay. I'm not 100% sure about the new behaviour -- compress now removes masked elements, instead of ignoring them. Whereas a person would have been able to do compress(x,condition).compressed() before, the mask information is now thrown away. The numpy docstring states that compress should be equivalent to a[condition], which is no longer the case. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Docstring standard: how to specify variable types
Hi Charles On Wed, Jan 23, 2008 at 09:34:44AM -0700, Charles R Harris wrote: 2. How do we specify default values? I like to put them first in the list: {-1, integer} When exactly is this list used? That should be made clear in the standard as well. 3. Why do we need the optional keyword (the function signature already indicates that the parameter is optional). It's extra information, true, but that isn't always a bad thing. It's like looking up whole numbers in a book index and, instead of the page reference, the index directs you to numbers, whole. Flip, flip, flip. Drives me crazy. Besides, the function signature might be missing. When would the function signature be missing? In C functions we copy the signature into the docstring. I am concerned about duplicating information that may change. 4. Do we really need the Other Parameters list? It would make more sense to split positional and keyword arguments, but I'm not even sure that is necessary, since that information is already specified in the function signature. I agree, but Travis likes this section and I don't feel strongly about it. If I understood its role properly, I would be happier to use it, but at the moment I'm not convinced that it contributes anything useful. Parameters are normally sorted from most to least valuable anyway. 5. Is the {'hi', 'ho'} syntax used when a parameter can only assume a limited number of values? In Python {} is a dictionary, so why not use ('hi','ho') instead? Either would be fine. IIRC, the {} was inherited from epydoc consolidated fields. I thought that, since we threw all epydoc guidelines out the window, this would be a good time talk about it -- the next docday is just around the corner! Thank you very much for your response. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [ANN] numscons 0.3.0 release
Hi David On Thu, Jan 24, 2008 at 12:34:56AM +0900, David Cournapeau wrote: I've just released the 0.3.0 release of numscons, an alternative build system for numpy. The tarballs are available on launchpad. https://launchpad.net/numpy.scons.support/0.3/0.3.0 To use it, you need to get the build_with_scons numpy branch: see http://projects.scipy.org/scipy/numpy/wiki/NumpyScons for more details. Fantastic job, thank you for investing so much time in improving the build system. I noticed that you were trying to get scipy building -- how is that progressing? Scons should make building on non-*nix platforms a lot easier. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Docstring standard: how to specify variable types
Hi Robert On Thu, Jan 24, 2008 at 01:15:13PM -0600, Robert Kern wrote: 5. Is the {'hi', 'ho'} syntax used when a parameter can only assume a limited number of values? In Python {} is a dictionary, so why not use ('hi','ho') instead? Either would be fine. IIRC, the {} was inherited from epydoc consolidated fields. I thought that, since we threw all epydoc guidelines out the window, this would be a good time talk about it -- the next docday is just around the corner! Personally, I don't think it's worth standardizing. If it's readable and valid reST, just do it. The attached output shows the difference between using {} and () -- it doesn't seem to make a difference. Since [] or () is normally used to indicate a set, I found it more natural. Either way, I think I'll follow your other suggestion and not use such a list -- rather specify the default value in the prose. Thanks Stéfan Title: ReST lists test ReST lists test Two different ways of specifying parameter lists. Parameters a : {1, sometype, sometype2} This is some keyword description. b : (2, sometype, sometype3) And so is this. c : 3, why, have, brackets, at, all Another keyword prose. Default: 3. ReST text: ReST lists test === Two different ways of specifying parameter lists. Parameters -- a : {1, sometype, sometype2} This is some keyword description. b : (2, sometype, sometype3) And so is this. c : 3, why, have, brackets, at, all Another keyword prose. Default: 3. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ma.compress
Hi Pierre On Thu, Jan 24, 2008 at 04:58:04AM -0500, Pierre GM wrote: On Thursday 24 January 2008 04:02:52 Stefan van der Walt wrote: I'm not 100% sure about the new behaviour -- compress now removes masked elements, instead of ignoring them. Whereas a person would have been able to do compress(x,condition).compressed() before, the mask information is now thrown away. Mmh, OK, I see. The problem arises when the condition is masked. Filling w/ False will get rid of the masked values, filling with True won't work either (cf example below). An option is then to simply take the condition as a ndarray. How about masking the output where the condition is masked? I.e. keep where condition is True, remove where condition is False and mask where condition is masked. The numpy docstring states that compress should be equivalent to a[condition], which is no longer the case. Good point... In most cases, as long as an axis is not specified. Note that the equivalence a.compress(condition) and a[condition] is not strictly true even for regular ndarrays: take a look at the example on the scipy site (http://www.scipy.org/Numpy_Example_List_With_Doc) b = array([[10,20,30],[40,50,60]]) b.compress(b.ravel() = 22) array([30, 40, 50, 60]) b[b.ravel()=22] IndexError: index (2) out of range (0=index=1) in dimension 0 You're right, better equivalent code would be a.flat[condition] Anyhow, I just commited an update fixing our initial problem (viz, forcing condition to a regular ndarray). Thanks! I'll check it out. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] segfault problem with numpy and pickle
Hi David On Thu, Jan 24, 2008 at 01:18:45PM -0700, David Bolme wrote: A am having some trouble when pickling numpy arrays. Basically I use one python script to create the array and then pickle it. When I load the pickled array using a different python script it appears to load fine. When I try to perform a matrix multiply on the array with a vector (using dot) python crashes with a segmentation violation. Please see if http://projects.scipy.org/scipy/numpy/ticket/551 matches your problem, and add your comments there. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] location of ma in maskedarray branch
Hi Matt On Tue, Jan 22, 2008 at 10:37:29PM -0500, Matt Knox wrote: I noticed that the new masked array module resides in numpy/ma in the maskedarray branch as opposed to numpy/core/ma like it does in the current trunk. Was this intentional? Code that explicitly imports ma from the core subfolder will break from this change (like the __init__.py script for the ma subfolder in matplotlib for example). Yes, the move was intentional and was discussed beforehand. I may be mistaken, but as far as I know numpy.core is not a public API, so code should rather do from numpy import ma (that works with both the current trunk and the maskedarray branch). Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Docstring standard: how to specify variable types
Hi all, The numpy documentation standard example shows: Parameters -- var1 : array_like Array_like means all those objects -- lists, nested lists, etc. -- that can be converted to an array. var2 : integer Write out the full type long_variable_name : {'hi', 'ho'}, optional Choices in brackets, default first when optional. I'd like to know: 1. array_like describes objects that can be forced to quack like ndarrays. Are there any other such special descriptions? 2. How do we specify default values? 3. Why do we need the optional keyword (the function signature already indicates that the parameter is optional). 4. Do we really need the Other Parameters list? It would make more sense to split positional and keyword arguments, but I'm not even sure that is necessary, since that information is already specified in the function signature. 5. Is the {'hi', 'ho'} syntax used when a parameter can only assume a limited number of values? In Python {} is a dictionary, so why not use ('hi','ho') instead? Thanks for your feedback! Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ma.compress
On Wed, Jan 23, 2008 at 11:17:51AM -1000, Eric Firing wrote: Pierre, numpy.compress exists, but numpy.ma.compress does not; is this intentional? Looks like x.compress exists, but it doesn't work as expected: x = N.ma.array([1,2,3],mask=[True,False,Fals]) x.compress(x2) throws ValueError: total size of new array must be unchanged Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.ma.compress
Hi Eric, On Wed, Jan 23, 2008 at 11:17:51AM -1000, Eric Firing wrote: Pierre, numpy.compress exists, but numpy.ma.compress does not; is this intentional? Thanks for the report. I added a simple implementation to SVN for the time being. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] maskedarray bug?
Hi Pierre, Eric On Mon, Jan 21, 2008 at 03:35:37PM -0500, Pierre GM wrote: Yep, bug indeed. Thanks for pointing that out ! The following patch should take care of the problem. (In short, a getmask function was used instead of getmaskarray). Note that the patch takes also into account elements I had sent to Stefan 2 weeks ago, that were not ported yet to the SVN: I still can't commit to the numpy/branches/maskedarray. The patch you refer to was applied in r4718 on 10 January: http://projects.scipy.org/scipy/numpy/changeset/4718 I hope there weren't others I missed. I shall work in your latest patch as soon as I can access the repo again. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Building a static libnumpy
On Tue, Jan 22, 2008 at 05:12:32PM +0900, David Cournapeau wrote: On Jan 22, 2008 3:44 PM, Jussi Enkovaara [EMAIL PROTECTED] wrote: Hi, I need to use numpy in an environment which does not support shared libraries. Previously, I have used the old Numeric where I created a Makefile to build a static Numeric library which was later on linked to the python interpreter. Interesting, did not know it was possible. How did you do it ? I am working on an alternative build system for numpy, based on scons, and depending on the necessary steps, I could add this feature to the build system. scons itself certainly support static libraries, but I have never built static python extensions. I would also be interested in making such a build, since it would allow profiling using gcov. Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] data type specifications
Hi Gary On Tue, Jan 22, 2008 at 11:18:01AM -0500, Gary Pajer wrote: Occasionally I find myself poking into docstrings and googling randomly trying to find the proper way to specify a data type, or trying to remind myself just what a float is. I can never find the info easily. Preferable: Is there a docstring somewhere that lists the data types and acceptable ways to specify them? Less Preferable: Is there a web page? This should be a good starting place (search for dtype): http://www.scipy.org/Numpy_Example_List Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] r4730 broke numpy in maskedarray branch
Hi Eric Sorry for the inconvenience -- I applied Pierre's patch. Thanks, Stéfan On Sat, Jan 19, 2008 at 11:25:02AM -1000, Eric Firing wrote: Stefan, The renaming of concatenator to AxisConcatenator in r4730 in the maskedaray branch needs to be propagated into ma/extras.py; I don't know whether there are other places that similar changes are needed. As it stands, after 4730, numpy cannot be imported. Eric ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] maskedarray branch
Hi David On Fri, Jan 18, 2008 at 10:53:28AM -0500, David Huard wrote: Stefan, It seems that the current maskedarray branch is not compatible with the current scipy trunk. Would you mind expanding on that? Thanks Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Setting WRITEABLE flag on array scalar
Hi, On Thu, Jan 10, 2008 at 10:21:28AM -0600, Travis E. Oliphant wrote: You can't do it, because there is no place for the information to go. The array scalars are always read-only anyway. So, there should be no reason to set this flag. Right, I was confused because I saw: In [1]: x = N.bool_(3) In [2]: x Out[2]: True In [3]: x += 1 In [4]: x Out[4]: 2 But now I see that iadd does not actually change the original value. Thanks Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Moving away from svn ?
On Sat, Jan 05, 2008 at 03:00:21PM -0600, Travis E. Oliphant wrote: I suspect there are others with serious reservations about jumping off of SVN just now (just when a lot of people have finally figured out how to use it). I recall something you said to David last week, regarding merges with SVN: that a person never knows how to do it until *after* you've done it! We often make branches in scipy and numpy, and stand a lot to gain from a distributed RCS. Once a person knows how to use SVN, it doesn't take much effort at all to learn bzr or hg (even the commands are often the same). The main change is a mind-shift: that branches are now a lot friendlier, and that they are accessable to everybody. At the end of 2005, back when I was still working with Octave, we had a discussion on the merits of switching over to Subversion. That conversation never went anywhere, which is the reason you can still obtain Octave today using cvs -d :ext:[EMAIL PROTECTED]:/cvs I know there are reservations about doing the switch *right now*, which is fine -- we must just not wait too long. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] branches/maskedarray patch + lost password
Hi Pierre On Fri, Jan 04, 2008 at 04:30:47PM -0500, Pierre GM wrote: Here's a patch to the current version of svn/numpy/branches/maskedarray, that corrects several bugs. Those tests at the end of core.py should be included in the test suite before we commit (otherwise they won't be ran by numpy.test()). Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Moving away from svn ?
Hi Matthieu On Fri, Jan 04, 2008 at 03:26:52PM +0100, Matthieu Brucher wrote: Beside this, I'm starting to use bazaar (in fact it's the successor of arch) for a small project of mine hosted on launchpad.net, and it works great. As Note that bzr refers to bazaar-ng (new generation), which is not the same as the bazaar which succeeded arch/tla. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Moving away from svn ?
Hi David On Fri, Jan 04, 2008 at 08:24:04PM +0900, David Cournapeau wrote: First things first, happy new year to all ! Happy new year! It's been great so far :) Having recently felt the pain to use subversion merge, I was wondering about people's feeling on moving away from subversion and using a better system, ala mercurial or bzr (I will talk about bzr because that's the one I know the most, but this discussion is really about using something better than subversion, not that much about bzr). I think this could be an important step forward, and is somewhat related to the discusions on scikits and co. I have a couple of questions, that you may be able to answer more quickly than what I could, googling for a few hours: 1) Is it easy to setup bzr so that many people have submit-access to the main-branch, i.e. so that we don't need a central patch-manager? 2) With a DRCS, we have to check out the whole repository, instead of the current sources only. Currently, the history amounts to roughly 70Mb, but that includes files that have been deleted etc. Is there any way to compact the repository, or to say let's only go 100 revisions back, and for the rest query the main branch? I'm just worried that, some day in the future, a user will need to do an extremely large checkout to hack on a fairly small codebase. 3) Which of bzr, mercurial and git has the best merging capabilities? I heard a while back that git does not try to be too clever about it, while the others do -- I wonder how that worked out. I am very fond of the distributed model, and use it for my own development, too. Regardless, I would still like to hear more from people who have used it on a larger scale. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Moving away from svn ?
On Fri, Jan 04, 2008 at 07:45:06PM +0100, Ondrej Certik wrote: Charles actually said another point in favor of Mercurial - it works on Windows (at least people say so), while git not that much (at least people say so). I never use Windows myself, so I don't know. Note that bzr also runs under Windows, and is also written in Python+C. Here is the URL I referred to this afternoon on IRC, regarding the diff-algorithm: http://bramcohen.livejournal.com/37690.html Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] planet.scipy.org
Hi Jarrod On Mon, Dec 31, 2007 at 02:43:37PM -0800, Jarrod Millman wrote: I just wanted to announce that we now have a NumPy/SciPy blog aggregator thanks to Gaël Varoquaux: http://planet.scipy.org/ Feel free to contact me if you have a blog that you would like included. Great, thanks! Would you mind putting links to templates like http://planet.scipy.org/rss20.xml somewhere on the page, so that it can be easily found using external RSS readers? Thanks Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Numpy code coverage
Hi all, I read about Titus Brown's Figleaf code coverage tool [1] on the Planet SciPy aggregator [2]. The results of running figleaf on the numpy test-suite [3] covers Python code only. What the best way of discovering the C and C++ code coverage as well? Regards Stéfan [1] http://darcs.idyll.org/~t/projects/figleaf/README.html [2] http://planet.scipy.org [3] http://mentat.za.net/refer/numpy_figleaf/ ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] Doc-day
On Thu, Dec 27, 2007 at 09:27:09PM -0800, Jarrod Millman wrote: On Dec 27, 2007 7:42 PM, Travis E. Oliphant [EMAIL PROTECTED] wrote: Doc-day will start tomorrow (in about 12 hours). It will be Friday for much of America and be moving into Saturday for Europe and Asia. Join in on the irc.freenode.net (channel scipy) to coordinate effort. I imaging people will be in an out. I plan on being available in IRC from about 9:30 am CST to 6:00 pm CST and then possibly later. If you are available at different times in different parts of the world, jump in and pick something to work on. Since this is our first doc-day, it will be fairly informal. Travis is going to be trying to get some estimate of which packages need the most work. But if there is some area of NumPy or SciPy you are familiar with, please go ahead and pitch in. Here is the current NumPy/ SciPy coding standard including docstring standards: http://projects.scipy.org/scipy/numpy/wiki/CodingStyleGuidelines I have some questions regarding Travis' latest modifications to the documentation guidelines: The following section was removed, why? A reST-documented module should define:: __docformat__ = 'restructuredtext en' at the top level in accordance with `PEP 258 http://www.python.org/dev/peps/pep-0258`__. Note that the ``__docformat__`` variable in a package's ``__init__.py`` file does not apply to objects defined in subpackages and submodules. We had a long discussion on the mailing list on the pros and cons of *Parameters*: vs. Parameters:. I see now that it has been changed to Parameters -- Is this still recognised as a list? I noted that the examples are now no longer indented: does ReST allow this? Note that building the example documentation, `epydoc example.py`, now warns: File /tmp/example.py, line 19, in example.foo Warning: Line 24: Wrong underline character for heading. Warning: Lines 27, 30, 32, 37, 39, 41, 43, 48, 50: Improper paragraph indentation. While I understand the rationale behind The guiding principle is that human readers of the text itself are given precedence over contorting the docstring so that epydoc_ produces nice output. I think that it would be impractical to break compatibility with the only documentation builder we currently have (unless there are others I am unaware of?). Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] Doc-day
On Fri, Dec 28, 2007 at 11:32:03AM -0600, Travis E. Oliphant wrote: I don't see the point in every file having a __docformat__ line, when our documentaion formatting tool should already know the standard we are using is. It's just more cruft. Besides the PEP was rejected, so I don't know why we should be following it. Sorry, I didn't see the PEP was rejected. Moot point, then. We obviously need a pre-processor to map our files to epydoc, so let's do that instead of contorting docstrings into a format demanded by the tool. That's a good idea, thanks. I'll take a look. It seems better to have docstrings than to have them fit into an epydoc_-defined pattern. Certainly. Thanks for the feedback. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] SciPy Sprint results
Hi Travis On Thu, Dec 20, 2007 at 05:24:44PM -0600, Travis E. Oliphant wrote: * bool(x) raises a ValueError, as it does for ndarrays. What does bool(x) raise for numpy.core.ma. It now behaves the same way as numpy does, raising a ValueError: In [1]: bool(N.ma.array([0,1])) --- ValueErrorTraceback (most recent call last) /home/stefan/work/scipy/ipython console in module() ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() In [2]: bool(N.array([0,1])) --- ValueErrorTraceback (most recent call last) /home/stefan/work/scipy/ipython console in module() ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] SciPy Sprint results
On Fri, Dec 21, 2007 at 10:43:28AM +0200, Stefan van der Walt wrote: On Thu, Dec 20, 2007 at 05:24:44PM -0600, Travis E. Oliphant wrote: * bool(x) raises a ValueError, as it does for ndarrays. What does bool(x) raise for numpy.core.ma. Sorry, I realise you were talking about the old numpy.core.ma: z = N.core.ma.masked_array([True,False,True]) bool(z) == True Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] SciPy Sprint results
On Thu, Dec 20, 2007 at 06:52:38PM -0500, Pierre GM wrote: If we can document exactly what the compatibility issues are (and it looks like we are almost there), we should move forward. OK, I'll take care of that this week-end. Stefan, feel free to beat me to it... A first draft is here: http://svn.scipy.org/svn/numpy/branches/maskedarray/numpy/ma/API_CHANGES.txt Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Propose modification to binary_repr
On Thu, Dec 13, 2007 at 02:33:01PM -0500, David Huard wrote: Change done. All tests pass. Now's a good time to fix that :) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy large arrays?
On Wed, Dec 12, 2007 at 03:29:57PM +0100, Søren Dyrsting wrote: I need to perform computations involving large arrays. A lot of rows and no more than e.g. 34 columns. My first choice is python/numpy because I'm already used to code in matlab. However I'm experiencing memory problems even though there is still 500 MB available (2 GB total). I have cooked down my code to following meaningless code snip. This code share some of the same structure and calls as my real program and shows the same behaviour. I would guess that this is due to memory fragmentation. Have you tried the same experiment under Linux? This article details some of the problems you may encounter under Windows: http://www.ittvis.com/services/techtip.asp?ttid=3346 Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] resize in old Numeric
Hi Christiaan On Wed, Dec 12, 2007 at 07:39:49PM +0100, Christian Meesters wrote: I need to flatten a simple 3x3 array and try to do that with resize. First time works, next time it doesn't. Here is an example: In [1]: from Numeric import * In [2]: a = array([[ 0.50622966, -0.54764389, -0.66619644], [ 0.44338279, -0.4973092, 0.7457228 ],[-0.73969131, -0.67288704, -0.00893311]]) In [3]: a.resize((9,)) Out[3]: array([ 0.50622966, -0.54764389, -0.66619644, 0.44338279, -0.4973092 , 0.7457228 , -0.73969131, -0.67288704, -0.00893311]) In [4]: a.resize((9,)) --- type 'exceptions.ValueError'Traceback (most recent call last) You'll notice that this doesn't happen when you run those commands as a script. IPython remembers the answer to the last command (as '_' and in the output history), hence the reference that Numeric complains about. Unfortunately, when applying resize on the actual array I have, I get a similar, yet slightly different error: Traceback (most recent call last): File sym_get.py, line 37, in module s.inquire_relation() File /usr/lib/python2.5/site-packages/mc_saxs/mc_rigid.py, line 915, in inquire_relation print rotation, rotation.resize((9,)) ValueError: resize only works on contiguous arrays The arrays 'a' and 'rotation' are identical. They may have identical values without having identical layout in memory. Try a.ascontiguousarray(). Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Missing file in SVN repository (test_ufunc)
On Tue, Dec 04, 2007 at 08:13:56PM +0900, David Cournapeau wrote: Since revision 4528, it is not possible to run the tests for numpy.core, because of a missing file, test_ufunc.py. Since the change in the test was done in r4528 whose log refers increase of code coverage, I guess the file was not added to the repository, Sorry about that. I added the file in r4492. Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] display numpy array as image
Hi Zach Attached is some code for removing radial distortion from images. It shows how to draw lines based on user input using matplotlib. It is not suited for a big application, but useful for demonstrations. Try it on http://mentat.za.net/results/window.jpg Regards Stéfan On Thu, Nov 29, 2007 at 11:59:05PM -0500, Zachary Pincus wrote: Thanks for the suggestions, everyone! All very informative and most helpful. For what it's worth, here's my application: I'm building a tool for image processing which needs some manual input in a few places (e.g. user draws a few lines). The images are greyscale images with 12-14 bits of dynamic range (from a microscope), so I need to have some basic brightness/contrast/gamma controls, as well as allowing basic drawing on the image to get the needed user input. It looks like GL or wx will be best suited here, I think? (I presume that python/numpy/ [GL|wx] can keep up with things like dragging a slider to change brightness/contrast/other LUT changes, as long as I code reasonably.) Anyhow, thanks for all the input, Zach Remove radial distortion. Author: Stefan van der Walt Date: 2006 import scipy as S import scipy.optimize import scipy.ndimage import pylab as P import numpy as N import math import sys class RadialDistortionInterface: Mouse interaction interface for radial distortion removal. def __init__(self, img): imshape = img.shape self.figure = P.imshow(img, extent=(0,imshape[1],imshape[0],0)) P.title('Removal of radial distortion') P.xlabel('Select sets of three points with left mouse button,\nclick right button to process.') P.connect('button_press_event', self.button_press) P.connect('motion_notify_event', self.mouse_move) self.img = N.atleast_3d(img) self.points = [] self.centre = ((N.array(self.img.shape)-1)/2.)[:2][::-1] self.height = imshape[0] self.width = imshape[1] self.make_cursorline() self.figure.axes.set_autoscale_on(False) P.show() P.close() def make_cursorline(self): self.cursorline, = P.plot([0],[0],'r:+', linewidth=2,markersize=15,markeredgecolor='b') def button_press(self,event): Register mouse clicks. if (event.button == 1 and event.xdata and event.ydata): self.points.append((event.xdata,event.ydata)) print Coordinate entered: (%f,%f) % (event.xdata, event.ydata) if len(self.points) % 3 == 0: P.gca().lines.append(self.cursorline) self.make_cursorline() if (event.button != 1 and len(self.points) = 3): print Removing distortion... P.gca().lines = [] P.draw() self.remove_distortion() self.points = [] def mouse_move(self,event): Handle cursor drawing. pt_sets,pts_last_set = divmod(len(self.points),3) pts = N.zeros((3,2)) if pts_last_set 0: # Line follows up to 3 clicked points: pts[:pts_last_set] = self.points[-pts_last_set:] # The last point of the line follows the mouse cursor pts[pts_last_set:] = [event.xdata,event.ydata] self.cursorline.set_data(pts[:,0],pts[:,1]) P.draw() def stackcopy(self,a,b): a[:,:,0] = a[:,:,1] = ... = b if a.ndim == 3: a.transpose().swapaxes(1,2)[:] = b else: a[:] = b def remove_distortion(self,reshape=True): def radii_tf(x,y,p): Radially distort coordinates. Given a coordinate (x,y), apply the radial distortion defined by L(r) = 1 + p[2]r + p[3]r^2 + p[4]r^3 where r = sqrt((x-p[0])^2 + (y-p[1])^2) so that x' = L(r)x and y' = L(r)y Inputs: x,y -- Coordinate p[0],p[1] -- Distortion centre p[2],p[3],p[4] -- Distortion parameters Outputs: x', y' x = x - p[0] y = y - p[1] r = N.sqrt(x**2 + y**2) f = 1 + p[2]*r + p[3]*r**2 + p[4]*r**3 return x*f + p[0], y*f + p[1] def height_difference(p): Measure deviation of distorted data points from straight line. out = 0 for sets in 3*N.arange(len(self.points)/3): pts = N.array(self.points[sets:sets+3]) x,y = radii_tf(pts[:,0],pts[:,1],p) # Find point on line (point0 - point2) closest to point1 (midpoint) u0 = ((x[0]-x[2])**2 + (y[0]-y[2])**2) if u0
Re: [Numpy-discussion] How can I constrain linear_least_squares to integer solutions?
On Tue, Nov 27, 2007 at 11:07:30PM -0700, Charles R Harris wrote: This is not a trivial problem, as you can see by googling mixed integer least squares (MILS). Much will depend on the nature of the parameters, the number of variables you are using in the fit, and how exact the solution needs to be. One approach would be to start by rounding the coefficients that must be integer and improve the solution using annealing or genetic algorithms to jig the integer coefficients while fitting the remainder in the usual least square way, but that wouldn't have the elegance of some of the specific methods used for this sort of problem. However, I don't know of a package in scipy that implements those more sophisticated algorithms, perhaps someone else on this list who knows more about these things than I can point you in the right direction. Would this be a good candidate for a genetic algorithm? I haven't used GA before, so I don't know the typical rate of convergence or its applicability to optimization problems. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] moving window in numpy
Hi Matthew On Sun, Nov 25, 2007 at 05:00:48PM -0800, Matthew Perry wrote: I'm not sure if my terminology is familiar but I'm trying to do a moving window analysis (ie a spatial filter or kernel) on a 2-D array representing elevation. For example, a 3x3 window centered on each cell is used to calculate the derivate slope of that cell. Take a look at Anne Archibald's post: http://projects.scipy.org/pipermail/numpy-discussion/2006-November/024760.html and its attachment here: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061120/d057cb0b/attachment.py Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] freebsd patch
Hi all, Ticket 618 [1] proposes a patch to make numpy pass all tests on FreeBSD. Would anyone familiar with FreeBSD please glance over the patch, apply it and make sure that it works as intended? Thanks Stéfan [1] http://scipy.org/scipy/numpy/ticket/618 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Patch for numpy.i (not C89 compliant)
On Fri, Nov 23, 2007 at 10:24:07AM +0100, Matthieu Brucher wrote: I submitted a ticket and then a patch for numpy.i (http://projects.scipy.org/scipy/numpy/ticket/620). the problem is that some typemaps use a C99 syntax whereas most C compiler still are only C89 compliant (mainly Visual Studio). Thanks, Matthieu. It is fixed in SVN. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] my derived ndarray class object loses its attribute after a transpose()
Hi Sebastian On Fri, Nov 23, 2007 at 09:25:37AM +0100, Sebastian Haase wrote: Hi, this question might habe been answered before: I have my own ndarray-derived class. I did this, so that I can add another custom attribute -- let's say arr.filename All works very except, except when I do arr2 = arr.transpose() my arr2 is still of the *type* of my derived class, however trying a arr2.filename now gives me an AtttributeError. What am I doing wrong? How can this be fixed? (I'm using numpy 1.0.1 - please let me know if this has been fixed since) Show us the code, then we can take a look. I assume you have read http://www.scipy.org/Subclasses Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] SegFault/double free with simple array mask operation
On Sat, Nov 17, 2007 at 12:55:57PM +0100, Achim Gaedke wrote: Achim Gaedke wrote: David Cournapeau wrote: Could you open a ticket on the numpy trac system ? (I can confirm the bug) cheers, David It is Ticket #614 . The version information in trac are outdated, I could not select version 1.0.3 or 1.0.4 . Here is the solution for Segmentation Fault reported. It is basicly copied from the function iter_subscript_Bool, which alredy does the necessary range checks. Thanks, Achim. This is now fixed in SVN. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] SegFault/double free with simple array mask operation
On Sun, Nov 18, 2007 at 11:18:10AM -1000, Eric Firing wrote: Ticket #607 should be closed now also. It looks like I can't do that, even though I created the ticket. I'm not sure whether it was the fix for #614 that did it, or whether it is the code it referred to, but now a proper exception is raised instead of a segfault. Thanks, Eric. I closed #607. Those reports referred to the same bug (indexing with too many booleans). Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy : your experiences?
On Sat, Nov 17, 2007 at 02:07:34AM -0500, Anne Archibald wrote: On 16/11/2007, Rahul Garg [EMAIL PROTECTED] wrote: It would be awesome if you guys could respond to some of the following questions : a) Can you guys tell me briefly about the kind of problems you are tackling with numpy and scipy? b) Have you ever felt that numpy/scipy was slow and had to switch to C/C++/Fortran? c) Do you use any form of parallel processing? Multicores? SMPs? Clusters? If yes how did u utilize them? If you feel its not relevant to the list .. feel free to email me personally. I would be very interested in talking about these issues. I think it would be interesting and on-topic to hear a few words from people to see what they do with numpy. a) I use python/numpy/scipy to work with astronomical observations of pulsars. This includes a range of tasks including: simple scripting to manage jobs on our computation cluster; minor calculations (like a better scientific calculator, though frink is sometimes better because it keeps track of units); So does 'ipython -p physics': In [1]: x = 3 m/s^2 In [2]: y = 15 s In [3]: x*y Out[3]: 45 m/s Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Bug in arange dtype f was: Using arr.dtype.type to check byteorder-independed dtype fails for bool
On Tue, Nov 13, 2007 at 02:53:32PM +0100, Sebastian Haase wrote: On Nov 13, 2007 2:18 PM, Stefan van der Walt [EMAIL PROTECTED] wrote: Hi Sebastian On Tue, Nov 13, 2007 at 01:11:33PM +0100, Sebastian Haase wrote: Hi, I need to check the array dtype in a way that it is ignoring differences coming only from big-endian vs. little-endian. Does N.issubdtype(first_dtype, second_dtype) work? Hi Stéfan, trying to anwer your question with a quick arange test, I ran into more confusion: a = N.arange(.5, dtype=f) `a.dtype` 'dtype('float32')' a = N.arange(.5, dtype=f) `a.dtype` 'dtype('float32')' Both equal positively with N.float32 now ! N.__version__ '1.0.1' This should now be fixed in SVN r4465. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Using arr.dtype.type to check byteorder-independed dtype fails for bool
Hi Sebastian On Tue, Nov 13, 2007 at 01:11:33PM +0100, Sebastian Haase wrote: Hi, I need to check the array dtype in a way that it is ignoring differences coming only from big-endian vs. little-endian. Does N.issubdtype(first_dtype, second_dtype) work? Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] how to convert btw rgb and pixel value
Since PIL Images now have array interfaces, it has become a lot simpler. The following should do the job: from numpy import array from PIL import Image def imread(fname,flatten=False): Return a copy of a PIL image as a numpy array. *Parameters*: im : PIL image Input image. flatten : bool If true, convert the output to grey-scale. *Returns*: img_array : ndarray The different colour bands/channels are stored in the third dimension, such that a grey-image is MxN, an RGB-image MxNx3 and an RGBA-image MxNx4. im = Image.open(fname) if flatten: im = im.convert('F') return array(im) Cheers Stéfan On Mon, Nov 05, 2007 at 12:58:45PM +0200, Nadav Horesh wrote: If the image is in the form of a standard image format (png, bmp, jpeg...) you can use the PIL library. png file can be read by pylab's imread function. Nadav. On Sun, 2007-11-04 at 23:37 -0800, [EMAIL PROTECTED] wrote: hi i wish to convert an rgb image into an array of double values..is there a method for that in numpy? also i want to create an array of doubles into corresponding rgb tuples of an image can anyone guide me? dn ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] weird numpy/pickle problem
On Fri, Nov 02, 2007 at 12:58:33PM -0400, Brian Blais wrote: I encountered a peculiar numpy and pickle problem. My version: Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) Mac OS X Tiger In [2]:numpy.__version__ Out[2]:'1.0.4.dev3869' I pickle a matrix, and reload it. Some operations work ok, but others give a hardware error and a crash! I boiled it down to the code below. Can anyone reproduce (or not) this error? This ticket looks similar: http://projects.scipy.org/scipy/numpy/ticket/551 Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] MTL 4
On Tue, Oct 30, 2007 at 10:48:25AM -0600, Charles R Harris wrote: Just a note that an alpha version of the hitherto mostly invisible MTL4 library has been released. It is template based and has automatic bindings to blas. You can download it from http://www.osl.iu.edu/research/mtl/mtl4/. I wonder why they are so paranoid with their licensing: 5. Products derived from this software may not be called MTL, nor may MTL appear in their name, without prior written permission of Indiana University Advanced Research Technology Institute. No MTL4py, then :) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] convolution and wiener khinchin
Hi John The signals should be zero-padded, otherwise you get circular convolution: F = npy.fft.fft(r,len(r)+len(x)-1) X = npy.fft.fft(x,len(r)+len(x)-1) Y = F*X yi = npy.fft.ifft(Y)[:len(x)].real Also take a look at fftconv. Regards Stéfan On Thu, Oct 25, 2007 at 01:00:29PM -0500, John Hunter wrote: I am working on an example to illustrate convolution in the temporal and spectral domains, using the property that a convolution in the time domain is a multiplication in the fourier domain. I am using numpy.fft and numpy.convolve to compute the solution two ways, and comparing them. I am getting an error for small times in my fourier solution. At first I thought this was because of edge affects, but I see it even when I apply a windowing function. Can anyone advise me about what I am doing wrong here? In signal processing, the output of a linear system to an arbitrary input is given by the convolution of the impulse response function (the system response to a Dirac-delta impulse) and the input signal. Mathematically: y(t) = \int_0^\t x(\tau)r(t-\tau)d\tau where x(t) is the input signal at time t, y(t) is the output, and r(t) is the impulse response function. In this exercise, we will compute investigate the convolution of a white noise process with a double exponential impulse response function, and compute the results 3 ways: * using numpy.convolve * in Fourier space using the property that a convolution in the temporal domain is a multiplication in the fourier domain import numpy as npy import matplotlib.mlab as mlab from pylab import figure, show # build the time, input, output and response arrays dt = 0.01 t = npy.arange(0.0, 10.0, dt)# the time vector from 0..5 Nt = len(t) def impulse_response(t): 'double exponential response function' return (npy.exp(-t) - npy.exp(-5*t))*dt win = npy.hanning(Nt) x = npy.random.randn(Nt)# gaussian white noise x = win*x r = impulse_response(t)*dt # evaluate the impulse function r = win*r y = npy.convolve(x, r, mode='full') # convultion of x with r y = y[:Nt] # plot t vs x, t vs y and t vs r in three subplots fig = figure() ax1 = fig.add_subplot(311) ax1.plot(t, x) ax1.set_ylabel('input x') ax2 = fig.add_subplot(312) ax2.plot(t, y, label='convolve') ax2.set_ylabel('output y') ax3 = fig.add_subplot(313) ax3.plot(t, r) ax3.set_ylabel('input response') ax3.set_xlabel('time (s)') # compute y via numerical integration of the convolution equation F = npy.fft.fft(r) X = npy.fft.fft(x) Y = F*X yi = npy.fft.ifft(Y).real ax2.plot(t, yi, label='fft') ax2.legend(loc='best') show() ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Iterate over all 1-dim views
On Sun, Oct 07, 2007 at 06:52:11AM -0400, Neal Becker wrote: Suppose I have a function F(), which is defined for 1-dim arguments. If the user passes an n1 dim array, I want to apply F to each 1-dim view. For example, for a 2-d array, apply F to each row and return a 2-d result. For a 3-d array, select each 2-d subarray and see above. Return 3-d result. Any suggestions on how to code something like this in numpy? Not the most efficient way, but easy to read and understand: import numpy as N def func(a): return a.shape z = N.zeros((2,2,2,2)) print N.array([func(sub) for sub in z]) Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] beginner question: rank-1 arrays
On Mon, Oct 08, 2007 at 11:00:39PM +0100, Robin wrote: Hi, I am trying to implement a project in scipy. I think I am getting somewhere finally. However in my code (I am converting from MATLAB) it is important to maintain 2d arrays, and keep the difference between row and column vectors. After working through some initial problems I think I am getting more of a picture of how things work in numpy. However I am finding my code littered with things like: np.array(np.r_[0:nterms],ndmin=2)(for a row vector) or np.array(np.r_[0:nterms],ndmin=2).T (for a column vector) You can use N.arange(10).reshape(-1,1) or N.c_[:10,] But if you use this sort of thing often, just write your own factory method: def col(n): return N.arange(n).reshape(-1,1) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
On Thu, Oct 04, 2007 at 11:47:40AM -0500, Robert Kern wrote: Edson Tadeu wrote: * Is there any field in the NumPy object where I can keep this information (the shape of the element), without creeping it with the dtype='(M,N)f8' representation I explained above? There isn't. You could make a subclass that tracks this, but you would have to implement it carefully to maintain the information. There is an example of how to do that here: http://www.scipy.org/Subclasses Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion