diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-05-19 17:09:10 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-05-19 17:13:50 -0500 |
commit | 7045cbc7e65dc13a1bb0d5ca866d455022e29f24 (patch) | |
tree | 8d15072b4bade50f1fd42ceb947eed588386550b /numpy/core/_internal.py | |
parent | 25bcc658a2031d709a052cdf62c8329a59b76b20 (diff) | |
download | numpy-7045cbc7e65dc13a1bb0d5ca866d455022e29f24.tar.gz |
ENH: Reimplement datetime dtype string parser (with error checking)
The previous implementation returned the default datetime type in
many cases instead of raising an exception. I also changed the
hybrid C + Python implementation to be purely in C.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 5298f412b..a5b6d117a 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -166,36 +166,6 @@ def _split(input): return newlist -format_datetime = re.compile(asbytes(r""" - (?P<typecode>M8|m8|datetime64|timedelta64) - ([[] - ((?P<num>\d+)? - (?P<baseunit>Y|M|W|B|D|h|m|s|ms|us|ns|ps|fs|as) - (/(?P<den>\d+))? - []]) - (//(?P<events>\d+))?)?"""), re.X) - -# Return (baseunit, num, den, events), datetime -# from date-time string -def _datetimestring(astr): - res = format_datetime.match(astr) - if res is None: - raise ValueError("Incorrect date-time string.") - typecode = res.group('typecode') - datetime = (typecode == asbytes('M8') or typecode == asbytes('datetime64')) - defaults = [asbytes('us'), 1, 1, 1] - names = ['baseunit', 'num', 'den', 'events'] - func = [bytes, int, int, int] - dt_tuple = [] - for i, name in enumerate(names): - value = res.group(name) - if value: - dt_tuple.append(func[i](value)) - else: - dt_tuple.append(defaults[i]) - - return tuple(dt_tuple), datetime - format_re = re.compile(asbytes(r'(?P<order1>[<>|=]?)(?P<repeats> *[(]?[ ,0-9]*[)]? *)(?P<order2>[<>|=]?)(?P<dtype>[A-Za-z0-9.]*)')) # astr is a string (perhaps comma separated) |