<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 10:02 PM,  <span dir="ltr"><<a href="mailto:josef.pktd@gmail.com" target="_blank">josef.pktd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Thu, Mar 5, 2015 at 12:33 PM, Charles R Harris<br>
<<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
><br>
><br>
> On Thu, Mar 5, 2015 at 10:04 AM, Chris Barker <<a href="mailto:chris.barker@noaa.gov">chris.barker@noaa.gov</a>> wrote:<br>
>><br>
>> On Thu, Mar 5, 2015 at 8:42 AM, Benjamin Root <<a href="mailto:ben.root@ou.edu">ben.root@ou.edu</a>> wrote:<br>
>>><br>
>>> dare I say... datetime64/timedelta64 support?<br>
>><br>
>><br>
>> well, the precision of those is 64 bits, yes? so if you asked for less<br>
>> than that, you'd still get a dt64. If you asked for 64 bits, you'd get it,<br>
>> if you asked for datetime128  -- what would you get???<br>
>><br>
>> a 128 bit integer? or an Exception, because there is no 128bit datetime<br>
>> dtype.<br>
>><br>
>> But I think this is the same problem with any dtype -- if you ask for a<br>
>> precision that doesn't exist, you're going to get an error.<br>
>><br>
>> Is there a more detailed description of the proposed feature anywhere? Do<br>
>> you specify a dtype as a precision? or jsut the precision, and let the dtype<br>
>> figure it out for itself, i.e.:<br>
>><br>
>> precision=64<br>
>><br>
>> would give you a float64 if the passed in array was a float type, but a<br>
>> int64 if the passed in array was an int type, or a uint64 if the passed in<br>
>> array was a unsigned int type, etc.....<br>
>><br>
>> But in the end,  I wonder about the use case. I generaly use asarray one<br>
>> of two ways:<br>
>><br>
>> Without a dtype -- to simple make sure I've got an ndarray of SOME dtype.<br>
>><br>
>> or<br>
>><br>
>> With a dtype - because I really care about the dtype -- usually because I<br>
>> need to pass it on to C code or something.<br>
>><br>
>> I don't think I'd ever need at least some precision, but not care if I got<br>
>> more than that...<br>
><br>
><br>
> The main use that I want to cover is that float64 and complex128 have the<br>
> same precision and it would be good if either is acceptable.  Also, one<br>
> might just want either float32 or float64, not just one of the two. Another<br>
> intent is to make the fewest possible copies. The determination of the<br>
> resulting type is made using the result_type function.<br>
<br>
<br>
</div></div>How does this work for object arrays, or datetime?<br>
<br>
Can I specify at least float32 or float64, and it raises an exception<br>
if it cannot be converted?<br>
<br>
The problem we have in statsmodels is that pandas frequently uses<br>
object arrays and it messes up patsy or statsmodels if it's not<br>
explicitly converted.<br></blockquote><div><br></div><div>Object arrays go to object arrays, datetime64 depends. <br></div><div><br><span style="font-family:monospace,monospace">In [10]: result_type(ones(1, dtype=object_), float32)<br>Out[10]: dtype('O')</span><br><br><br>Datetime64 seems to use the highest precision<br><br>I<span style="font-family:monospace,monospace">n [12]: result_type(ones(1, dtype='datetime64[D]'), 'datetime64[us]')<br>Out[12]: dtype('<M8[us]')<br><br>In [13]: result_type(ones(1, dtype='datetime64[D]'), 'datetime64[Y]')<br>Out[13]: dtype('<M8[D]')</span><br><br>but doesn't convert to float<br><br><span style="font-family:monospace,monospace">In [11]: result_type(ones(1, dtype='datetime64[D]'), float32)<br>---------------------------------------------------------------------------<br>TypeError                                 Traceback (most recent call last)<br><ipython-input-11-e1a09e933dc7> in <module>()<br>----> 1 result_type(ones(1, dtype='datetime64[D]'), float32)<br><br>TypeError: invalid type promotion<br></span><br></div><div>What would you like it to do?<br><br></div><div>Chuck </div></div></div></div>