Re: [Numpy-discussion] dealing with datetime UTC vs linear time

2011-06-06 Thread Matt Knox
Mark Wiebe gmail.com> writes: > I guess part of the point of this work is that with > full datetime support in NumPy the need for such conversions would be > relatively rare, so maybe there's no real problem here. > > > Yeah, as long as the calendar-related API is sufficient, I think that's tru

Re: [Numpy-discussion] dealing with datetime UTC vs linear time

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 3:47 PM, Mark Dickinson wrote: > On Mon, Jun 6, 2011 at 9:24 PM, Mark Wiebe wrote: > > Sorry for being dense, but: > > > C. Add a metadata item which chooses between "UTC" and "TAI". For seconds > > and finer, converting between UTC and TAI units is safe, and for minutes >

Re: [Numpy-discussion] dealing with datetime UTC vs linear time

2011-06-06 Thread Mark Dickinson
On Mon, Jun 6, 2011 at 9:24 PM, Mark Wiebe wrote: Sorry for being dense, but: > C. Add a metadata item which chooses between "UTC" and "TAI". For seconds > and finer, converting between UTC and TAI units is safe, and for minutes and > coarser, is unsafe. UTC involves leap-seconds This bit I und

[Numpy-discussion] dealing with datetime UTC vs linear time

2011-06-06 Thread Mark Wiebe
I've given the UTC leap-second issue a bit of thought, and here are some related requirements I've come up with: 1. The underlying data representation of datetime64 should be linearly related to time. 2. Default calendar functionality should be based on ISO 8601, and by reference be in UTC 3. It s

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 2:31 PM, Mark Wiebe wrote: > On Mon, Jun 6, 2011 at 1:33 PM, Christopher Barker > wrote: > >> >> > This is even self inconsistent: >> >> 1Y == 365D >> >> 1Y == 12M == 12 * 30D == 360D >> >> 1Y == 12M == 12 * 4W == 12 * 4 * 7D == 336D >> >> 1Y == 52W == 52 * 7D == 364D >>

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Pierre GM
On Jun 6, 2011, at 8:33 PM, Christopher Barker wrote: > Mark Wiebe wrote: >> I'm wondering if removing the business-day unit from datetime64, and >> adding a business-day API would be a good approach to support all the >> things that are needed? > > That sounds like a good idea to me -- and pe

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 1:33 PM, Christopher Barker wrote: > Mark Wiebe wrote: > > I'm wondering if removing the business-day unit from datetime64, and > > adding a business-day API would be a good approach to support all the > > things that are needed? > > That sounds like a good idea to me -- and

Re: [Numpy-discussion] error when numpy is imported

2011-06-06 Thread akshar bhosale
thanks for pointer..it helped me a lot. -akshar On Sat, Jun 4, 2011 at 9:39 PM, Ralf Gommers wrote: > > > On Fri, Jun 3, 2011 at 11:05 PM, akshar bhosale > wrote: > >> [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Christopher Barker
Mark Wiebe wrote: > I'm wondering if removing the business-day unit from datetime64, and > adding a business-day API would be a good approach to support all the > things that are needed? That sounds like a good idea to me -- and perhaps it could be a general Calendar Functions API, to handle ot

Re: [Numpy-discussion] tighten up ufunc casting rule

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 10:30 AM, Mark Wiebe wrote: > On Sun, Jun 5, 2011 at 3:43 PM, Ralf Gommers > wrote: > >> On Thu, Jun 2, 2011 at 10:12 PM, Mark Wiebe wrote: >> >>> On Thu, Jun 2, 2011 at 3:09 PM, Gael Varoquaux < >>> gael.varoqu...@normalesup.org> wrote: >>> On Thu, Jun 02, 2011 at 0

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread RadimRehurek
> On Mon, Jun 6, 2011 at 6:57 AM, gary ruben wrote: > > I learn a lot by watching the numpy and scipy lists (today Olivier > > taught me about heapq :), but he may not have noticed that Python 2.4 > > added an nsmallest method) I needed indices of the selected elements as well (not just the k-sm

Re: [Numpy-discussion] tighten up ufunc casting rule

2011-06-06 Thread Mark Wiebe
On Sun, Jun 5, 2011 at 3:43 PM, Ralf Gommers wrote: > On Thu, Jun 2, 2011 at 10:12 PM, Mark Wiebe wrote: > >> On Thu, Jun 2, 2011 at 3:09 PM, Gael Varoquaux < >> gael.varoqu...@normalesup.org> wrote: >> >>> On Thu, Jun 02, 2011 at 03:06:58PM -0500, Mark Wiebe wrote: >>> >Would anyone object t

Re: [Numpy-discussion] Using NumPy iterators in C extension

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 4:06 AM, Irwin Zaid wrote: > Hi all, > > I am writing a C extension for NumPy that implements a custom function. > I have a minor question about iterators, and their order of iteration, > that I would really appreciate some help with. Here goes... > > My function takes a seq

Re: [Numpy-discussion] _sort module.

2011-06-06 Thread Mark Wiebe
On Sat, Jun 4, 2011 at 1:34 PM, Charles R Harris wrote: > Hi All, > > Numpy has a _sort module which contains *no* methods and whose only purpose > is to modify the type descriptors by adding pointers to the sorting > functions when it is loaded. Consequently _sort is imported early in > numpy/cor

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 4:43 AM, Wes McKinney wrote: > On Mon, Jun 6, 2011 at 8:16 AM, Mark Dickinson > wrote: > > On Thu, Jun 2, 2011 at 5:42 PM, Mark Wiebe wrote: > >> Leap years are easy compared with leap seconds. Leap seconds involve a > >> hardcoded table of particular leap-seconds that ar

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Mark Wiebe
On Mon, Jun 6, 2011 at 2:16 AM, Mark Dickinson wrote: > On Thu, Jun 2, 2011 at 5:42 PM, Mark Wiebe wrote: > > Leap years are easy compared with leap seconds. Leap seconds involve a > > hardcoded table of particular leap-seconds that are added or subtracted, > and > > are specified roughly 6 month

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread Keith Goodman
On Mon, Jun 6, 2011 at 6:57 AM, gary ruben wrote: > I learn a lot by watching the numpy and scipy lists (today Olivier > taught me about heapq :), but he may not have noticed that Python 2.4 > added an nsmallest method) > > import heapq > q = list(x) > heapq.heapify(q) > k_smallest = heapq.nsmalle

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread gary ruben
I learn a lot by watching the numpy and scipy lists (today Olivier taught me about heapq :), but he may not have noticed that Python 2.4 added an nsmallest method) import heapq q = list(x) heapq.heapify(q) k_smallest = heapq.nsmallest(k,q) On Mon, Jun 6, 2011 at 10:52 PM, Olivier Delalleau wrote

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread Keith Goodman
On Mon, Jun 6, 2011 at 6:44 AM, Keith Goodman wrote: > On Sun, Jun 5, 2011 at 11:15 PM, Alex Ter-Sarkissov > wrote: >> I have a vector of positive integers length n. Is there a simple (i.e. >> without sorting/ranking) of 'pulling out' k larrgest (or smallest) values. >> Something like >> >> sum(

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread Keith Goodman
On Sun, Jun 5, 2011 at 11:15 PM, Alex Ter-Sarkissov wrote: > I have a vector of positive integers length n. Is there a simple (i.e. > without sorting/ranking) of 'pulling out' k larrgest (or smallest) values. > Something like > > sum(x[sum(x,1)>(max(sum(x,1)+min(sum(x,1/2,]) > > but smarter Y

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread David Cournapeau
On Mon, Jun 6, 2011 at 3:15 PM, Alex Ter-Sarkissov wrote: > I have a vector of positive integers length n. Is there a simple (i.e. > without sorting/ranking) of 'pulling out' k larrgest (or smallest) values. Maybe not so simple, but does not require sorting (and its associated o(NlogN) cost): htt

Re: [Numpy-discussion] k maximal elements

2011-06-06 Thread Olivier Delalleau
I don't really understand your proposed solution, but you can do something like: import heapq q = list(x) heapq.heapify(q) k_smallest = [heapq.heappop(q) for i in xrange(k)] which is in O(n + k log n) -=- Olivier 2011/6/6 Alex Ter-Sarkissov > I have a vector of positive integers length n. Is

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Wes McKinney
On Mon, Jun 6, 2011 at 8:16 AM, Mark Dickinson wrote: > On Thu, Jun 2, 2011 at 5:42 PM, Mark Wiebe wrote: >> Leap years are easy compared with leap seconds. Leap seconds involve a >> hardcoded table of particular leap-seconds that are added or subtracted, and >> are specified roughly 6 months in

[Numpy-discussion] Using NumPy iterators in C extension

2011-06-06 Thread Irwin Zaid
Hi all, I am writing a C extension for NumPy that implements a custom function. I have a minor question about iterators, and their order of iteration, that I would really appreciate some help with. Here goes... My function takes a sequence of N-dimensional input arrays and a single (N+1)-dimensio

Re: [Numpy-discussion] fixing up datetime

2011-06-06 Thread Mark Dickinson
On Thu, Jun 2, 2011 at 5:42 PM, Mark Wiebe wrote: > Leap years are easy compared with leap seconds. Leap seconds involve a > hardcoded table of particular leap-seconds that are added or subtracted, and > are specified roughly 6 months in advance of when they happen by > the International Earth Rot