diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-06-22 09:05:27 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-06-22 09:05:27 -0500 |
commit | d4ea04b4531f218bd7752f675c30b8c8472a5243 (patch) | |
tree | 8f9730de4fddbace175e7e24e3a720d8b37823ca /numpy/core/arrayprint.py | |
parent | adab9034f8791dee0f03566bb05c625dbcacad56 (diff) | |
parent | 7c1c7a86057e72490268f084a4e77d857997312b (diff) | |
download | numpy-d4ea04b4531f218bd7752f675c30b8c8472a5243.tar.gz |
ENH: Merge branch 'datetime_dev'
Highlights:
* Tighten up date unit vs time unit casting rules,
and integrate the NPY_CASTING enum deeper into the datetime conversions
* Determine a unit when converting from a string array,
similar to when converting from lists of strings
* Switch local/utc handling to a timezone= parameter,
which also accepts a datetime.tzinfo object. This, for
example, enables the use of the pytz library with numpy.datetime64
* Remove the events metadata, make the old API functions raise
exceptions, and rename the "frequency" metadata name to "timeunit"
* Abstract the flexible dtype mechanism into a function,
so that it can be more easily changed without having to
add code to many places
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 556d4da04..567573af5 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -245,7 +245,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', 'complexfloat' : ComplexFormat(data, precision, suppress_small), 'longcomplexfloat' : LongComplexFormat(precision), - 'datetime' : DatetimeFormat(True, None, -1), + 'datetime' : DatetimeFormat(), 'timedelta' : TimedeltaFormat(data), 'numpystr' : repr, 'str' : str} @@ -698,16 +698,17 @@ class ComplexFormat(object): return r + i class DatetimeFormat(object): - def __init__(self, uselocaltime=True, overrideunit=None, tzoffset=-1): - self.local = uselocaltime + def __init__(self, overrideunit=None, + timezone='local', casting='same_kind'): + self.timezone = timezone self.unit = overrideunit - self.tzoffset = -1 + self.casting = casting def __call__(self, x): return "'%s'" % datetime_as_string(x, - local=self.local, unit=self.unit, - tzoffset=self.tzoffset) + timezone=self.timezone, + casting=self.casting) class TimedeltaFormat(object): def __init__(self, data): |