Skip to content

TST7337: Fix test failures on windows. #7362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2014

Conversation

dbew
Copy link
Contributor

@dbew dbew commented Jun 5, 2014

closes #7337

Use dateutil.tz.tzutc() to construct UTC timezone instead of dateutil.tz.gettz('UTC')
Update docs to reflect this.
Tidy up examples in the timezones section of the docs.

@jreback
Copy link
Contributor

jreback commented Jun 5, 2014

passed 26-32/26-64 builds so far!

looking good

@dbew
Copy link
Contributor Author

dbew commented Jun 5, 2014

Fingers crossed!

@jreback
Copy link
Contributor

jreback commented Jun 5, 2014

ok...good news and bad news...

py 2 looks good all fixed
py 3 otoh....(this happens with 33 & 34 on 32/64 bit

======================================================================
ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\tests\test_pytables.py", line 2086, in test_append_with_timezones_dateutil
    store.append('df_tz', df, data_columns=['A'])
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 911, in append
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
    s.write(obj=value, append=append, complib=complib, **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3605, in write
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3293, in create_axes
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 3288, in create_axes
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\io\pytables.py", line 1755, in set_atom
    "invalid timezone specification")
TypeError: invalid timezone specification

======================================================================
ERROR: test_convert_datetime_list (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 695, in test_convert_datetime_list
    dr2 = DatetimeIndex(list(dr), name='foo')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 214, in __new__
    data = tools.to_datetime(data, errors='raise')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_convert_tz_aware_datetime_datetime (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 588, in test_convert_tz_aware_datetime_datetime
    result = to_datetime(dates_aware)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_datetimeindex_tz_nat (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 760, in test_datetimeindex_tz_nat
    idx = to_datetime([Timestamp("2013-1-1", tz=self.tzstr('US/Eastern')), NaT])
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
ERROR: test_tzaware_datetime_to_index (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 311, in _convert_listlike
    return DatetimeIndex._simple_new(values, None, tz=tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 468, in _simple_new
    result.tz = tools._maybe_get_tz(tz)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 60, in _maybe_get_tz
    tz = tslib.maybe_get_tz(tz)
  File "tslib.pyx", line 1044, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17381)
  File "tslib.pyx", line 1051, in pandas.tslib.maybe_get_tz (pandas\tslib.c:17272)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 919, in gettz
    tz = tzfile(name)
  File "c:\python33-32\lib\site-packages\dateutil\tz.py", line 232, in __init__
    if fileobj.read(4).decode() != "TZif":
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 677, in test_tzaware_datetime_to_index
    index = DatetimeIndex(d)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\index.py", line 214, in __new__
    data = tools.to_datetime(data, errors='raise')
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 323, in to_datetime
    return _convert_listlike(arg, box, format)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 313, in _convert_listlike
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tools.py", line 302, in _convert_listlike
    coerce=coerce, unit=unit)
  File "tslib.pyx", line 1183, in pandas.tslib.array_to_datetime (pandas\tslib.c:19139)
ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

======================================================================
FAIL: test_field_access_localize (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 389, in test_field_access_localize
    self.assert_numpy_array_equal(dr.hour, expected)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\util\testing.py", line 91, in assert_numpy_array_equal
    raise AssertionError('{0} is not equal to {1}.'.format(np_array, assert_equal))
AssertionError: [ 1  2  3  4  5  6  7  8  9 10] is not equal to [0 1 2 3 4 5 6 7 8 9].

======================================================================
FAIL: test_frame_reset_index (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win32-3.3\pandas\tseries\tests\test_timezones.py", line 713, in test_frame_reset_index
    self.assertEqual(xp, rs)
AssertionError: tzfile('c:\\python33-32\\lib\\site-packages\\dateutil\\zoneinfo\\zoneinfo--latest.tar.gz') != None

----------------------------------------------------------------------
Ran 7271 tests in 417.895s

FAILED (SKIP=320, errors=5, failures=2)

@dbew
Copy link
Contributor Author

dbew commented Jun 6, 2014

The tests with UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte errors are due to the fact that the following code has different results between python 2 and python 3 on windows:

>>>from dateutil.tz import gettz
>>>gettz('Europe/London')._filename
# python 2
'Europe/London'
# python 3
'c:\\python33-32\\lib\\site-packages\\dateutil\\zoneinfo\\zoneinfo--latest.tar.gz'

In python 3, you get the same filename for all timezones.

We follow the dateutil package and rely on the filename for serializing timezones. Obviously if they all report the same filename then this isn't going to work.

The change in behaviour is actually due to a change in the tarfile package from the standard library. When you extract a file from a tar archive in python 3, it's named for the archive, in python 2 for the filename you are extracting.

This covers all but 3 of the test failures but I think this is a bug in tarfile for python 3.

@dbew
Copy link
Contributor Author

dbew commented Jun 6, 2014

I hacked dateutil locally to fix the timezone name issue and all of these failures go away. (I did get some pytz related failures but hopefully they're not related.)

So I think we can say that all of these failures are related to the timezone/filename issue.

@jreback I'm not sure how best to solve this. Ideally we'd fix the tarfile package - and failing that the dateutil package to work around the bug - but I guess both of those will be a slowish process and certainly would take a while to roll out to all pandas users.

I can't think of a good workaround in pandas for this - there's always the possibility that a user constructs a 'bad' dateutil timezone outside of our control and uses it with pandas.

Some less-than-good suggestions:

  • Hack _maybe_get_tz to correct the filename on the timezones it constructs then that would help in some cases but only when you construct the timezone from a string.
  • Hack _maybe_get_tz and _get_tz_cache_key it to reject tzfile objects with ".tar.gz" in the filename (on windows/py3 only)

I'll have a play with these but let me know what you think.

@jreback
Copy link
Contributor

jreback commented Jun 6, 2014

what do you DO with the _filename?

doesn't gettz('Europe/London').tzname(datetime.datetime.today()) get what you need which is the timezone name?

@dbew
Copy link
Contributor Author

dbew commented Jun 6, 2014

Use it to identify the timezone. dateutil itself uses the filename.

tzname is different depending on the date e.g.

In [14]: from dateutil.tz import gettz
In [15]: tz = gettz('Europe/London')
In [18]: tz.tzname(datetime.datetime(2001, 1, 1))
Out[18]: 'GMT'
In [19]: tz.tzname(datetime.datetime(2001, 6, 1))
Out[19]: 'BST'

so you can't use it as an identifier. [edit] and it doesn't match the timezone!

Originally I used the tz object itself (since different instances of the same zone are equal) but that doesn't serialize (so pytables, ujson stuff failed). As far as I can tell, there isn't an equivalent to tz.zone which you'd use with a pytz timezone.

@jreback
Copy link
Contributor

jreback commented Jun 6, 2014

ok...so its mainly test failures and serialization. e.g. you need to know a unique 'name' for the zone, rigth?

yeah I simply would not allow them on construction, I know its hacky, but rejecting if .tar.gz in the _filename looks like a good soln (you don't have to check the platform at all).. raise a helpful error.

and I would file a bug-report with dateutil (as this works on linux, so odd that it doesn't on windows) and works in py2.

@dbew
Copy link
Contributor Author

dbew commented Jun 6, 2014

Exactly. We need to be able to identify the zone in a few other places as well:

  • repr via tslib.get_timezone() (and the standard dateutil repr).
  • checking timezones are the same (e.g. tseries.tools._infer_tzinfo, Index.equals, various places in tslib)
  • cache key for looking up transition/deltas in tslib.

Rejecting .tar.gz should be a good solution and there are relatively few places where we need to check. On linux or on python 2, as far as I can tell the filename will never contain that string so we shouldn't need any platform checks.

If we modify maybe_get_tz to set the filename correctly then users will still be able to use strings to specify dateutil timezones as well.

Agree re filing a bug - probably with the maintainer of the tarfile package as well.

I'll try and sort this out this afternoon. I'll put the changes in this PR but won't squash them so we can see the two parts - let me know if that suits you.

@jreback
Copy link
Contributor

jreback commented Jun 6, 2014

yep sounds fine

@jreback
Copy link
Contributor

jreback commented Jun 6, 2014

also, their seems to be a dateutil.tz.tzwin that help any? (that has functions in it on windows but not on linux)

dbew added 2 commits June 9, 2014 15:26
Avoid constructing dateutil timezones explicitly because of filename issue.
Use dateutil.tz.tzutc() to construct UTC timezone instead of
dateutil.tz.gettz('UTC')
Update docs to reflect this.
Tidy up examples in the timezones section of the docs.
@dbew
Copy link
Contributor Author

dbew commented Jun 9, 2014

I think that class is for windows registry timezones - but it doesn't seem to be used when you call gettz. That prefers to use the data in dateutil.zoneinfo. I'm not sure why.

Anyway, I think I've got this working. I've tested on python 2.7 and 3.3 on windows and 2.7 on linux. The timezone related test failures are gone (with the exception of one failure which I can't replicate manually but which wasn't failing for you and doesn't seem to be tz-related).

The changes are:

  • Enforce correct filename when creating (maybe_get_tz) or reading (get_zone) the timezone information.
  • Update tests to construct utc timezones correctly as dateutil.tz.tzutc().
  • Update tests to avoid constructing dateutil timezones to avoid the filename issue.

tz=dateutil.tz.tzutc())
rng_utc.tz

Note that the ``UTC`` timezone is a special case in ``dateutil`` and should be constructed explicitly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you test interactions somewhere where you say are creating a DatetimeIndex with a Timestamp of 'UTC', but using a dateutil_tz_utc in another element?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - although they would be separate objects and we would be converting between them with the same code as converting between other timezones.

I'll add something like this:

ts = Timestamp('2001-01-05 11:56', tz='dateutil/UTC')
ts.tz_convert(dateutil.tz.tzutc())
# check that the time hasn't changed.
assert (ts.hour, ts.minute) == (11, 56)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, maybe also need some kind of raising if you try to mix pytz/dateutil in a creation, e.g.

DatetimeIndex([Timestamp('20130101',tz='Europe/London'),Timestamp('20130102',tz='dateutil/Europe/London')]) should raise loudly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does already. In fact, pandas already raises for mixed timezones in pytz e.g.

DatetimeIndex([Timestamp('20130101', tz='Europe/London'), Timestamp('20130101', tz='Europe/Paris')])

I've just added the test for different versions of utc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I mean is a supplemental message that explicity compares pytz and dateutil mixed (not sure that this is easy to catch)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. There doesn't seem to be a single place where we could put that check. At least, by the time you get to the exception that's raised, you can't tell if you have both dateutil and pytz zones.

In principle though, I think it's something we can check because all pytz timezones except UTC have a common base class and you can assume anything else is dateutil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.....well the check can be one when tz's are not all the same (e.g. at that point you can do a more detailed comparison to see if they are different and at least one is pytz and one dateutil)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this as a separate feature/PR so that we can get all of the tests passing on windows?

I think it's a good idea to have a better exception message and I'm happy to look into it but it feels like a separate issue from the test failures on windows.

Looking a bit deeper into the code, there are at least two places where an exception would currently be raised, tslib.array_to_datetime and tslib.array_to_datetime - both called via tseries.tools.to_datetime. The test could go in to_datetime - if there is an exception, check timezone types - but mismatched timezones wouldn't be the only reason for an exception there so we could mask a different problem.

@jreback
Copy link
Contributor

jreback commented Jun 9, 2014

@dbew yes....let's get passing...then go from them to make even more robust!

if you are satisfied that works on windows then ping me when passing travis (we can merge and then address any follow up failing tests).

@jreback
Copy link
Contributor

jreback commented Jun 9, 2014

@dbew ok, ready to go on this?

@dbew
Copy link
Contributor Author

dbew commented Jun 9, 2014

Yes, travis all fine, so let's go.

jreback added a commit that referenced this pull request Jun 9, 2014
TST7337: Fix test failures on windows.
@jreback jreback merged commit f17c3c4 into pandas-dev:master Jun 9, 2014
@jreback
Copy link
Contributor

jreback commented Jun 9, 2014

thanks!

@jreback
Copy link
Contributor

jreback commented Jun 9, 2014

Just a couple of test failures remain....these you know about?

C:\Users\Jeff Reback\Documents\GitHub\pandas>more test.33-64.log
............c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: str() < int(), sort order is undefined for incomparable o
bjects
  "incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: int() < str(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
..c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: int() > str(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: str() > int(), sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
....................S...........S...........S...........S...............................................................................................................................................
.............................................................S...S.SSSS.....SSSSSSSSSSSSSSS.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.SS.S........................................................................................................................................
......S..........................................................................................................................................................S......................................
...........................................................................................................................................................S............................................
......................SS................Exception AttributeError: AttributeError("'File' object has no attribute '_node_manager'",) in .......Exception ValueError: ValueError('Bad tz filename. Dateuti
l on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London"
 when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tslib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See https://github.com/pydata/pandas/pull/7362',) in 'pandas.tsl
ib._localize_tso' ignored
E..SSSS............................S...................................................S.................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....S......................................................
.............S.............................SSSSSSSSSSS..................................................................................................................................................
.............................S..........S..................................S..................S..S.SSSSSSS.......................S.......S..........S......S.....SSSSSSSSSSSSSSSSSSSSSSSSSS.............
.....................................................................................................................................................SS......................................S..........
.............................................................................S..S.......................................................................................................................
..................................................S...S.................................................................................................................................................
...............................S........................................................................................................................................................................
........................................................S.............................................S.................................................................................................
...............E...............................................................................................................................................S........................................
....................................................................S...................................................................................................................................
............................................................................................................................................S.SSSSS.....................................................
...................................................................................................................S..S......................................S.S........................................
..................................................................................S.....................................................................................................................
........SS.....S...SS.......S.S.......................SS.....S...SS.......S.S..............SS..SS............................................S.....S..SS..S......S......S..............SS.SSSSS.S....S..
.....SSS.......................................................................................................................................................................................S......S.
..................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with type 'str', sort
order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
.................................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with ty
pe 'int', sort order is undefined for incomparable objects
  "incomparable objects" % e, RuntimeWarning)
....................................................................................................S............................................................................S.....S................
...............................................S........................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
..........................................................................................................................................................S.............................................
.....................................................................................................................S.....SS......................S...S.............SSS.........S............SS........
.....SSS....SSSS......................SSSSS..SS..............................................................................SS.........................................................................
....S.......................S.............................SS............................................S...............................................................................................
.....................................................................S.......
======================================================================
ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\tests\test_pytables.py", line 2097, in test_append_with_timezones_dateutil
    store.append('df_tz', df)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 911, in append
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
    s.write(obj=value, append=append, complib=complib, **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3605, in write
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3293, in create_axes
    raise e
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3288, in create_axes
    **kwargs)
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1755, in set_atom
    "invalid timezone specification")
TypeError: invalid timezone specification

======================================================================
ERROR: test_utc_with_system_utc (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tslib.pyx", line 862, in pandas.tslib._get_utcoffset (pandas\tslib.c:15096)
AttributeError: 'tzwin' object has no attribute '_utcoffset'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\tseries\tests\test_timezones.py", line 795, in test_utc_with_system_utc
    ts = Timestamp('2001-01-05 11:56', tz=maybe_get_tz('dateutil/UTC'))
  File "tslib.pyx", line 196, in pandas.tslib.Timestamp.__new__ (pandas\tslib.c:5959)
  File "tslib.pyx", line 946, in pandas.tslib.convert_to_tsobject (pandas\tslib.c:16117)
  File "tslib.pyx", line 864, in pandas.tslib._get_utcoffset (pandas\tslib.c:15145)
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 31, in utcoffset
    if self._isdst(dt):
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 66, in _isdst
    self._dstweeknumber)
  File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 165, in picknthweekday
    first = datetime.datetime(year, month, 1, hour, minute)
ValueError: month must be in 1..12

----------------------------------------------------------------------
Ran 7001 tests in 139.652s

FAILED (SKIP=397, errors=2)

C:\Users\Jeff Reback\Documents\GitHub\pandas>

@dbew
Copy link
Contributor Author

dbew commented Jun 9, 2014

Argh! I thought I'd got them all. Running all of the tests was crashing
python on my Windows system so I was doing things a bit piecemeal. I'll
take a look when I get to work tomorrow. Sorry this has taken so many
goes...

On Monday, 9 June 2014, jreback [email protected] wrote:

Just a couple of test failures remain....these you know about?

C:\Users\Jeff Reback\Documents\GitHub\pandas>more test.33-64.log
............c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: str() < int(), sort order is undefined for incomparable o
bjects
"incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: unorderable types: int() < str(), sort order is undefined for incomparable objects
"incomparable objects" % e, RuntimeWarning)
..c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: int() > str(), sort order is undefined for incomparable objects
"incomparable objects" % e, RuntimeWarning)
c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1028: RuntimeWarning: unorderable types: str() > int(), sort order is undefined for incomparable objects
"incomparable objects" % e, RuntimeWarning)
....................S...........S...........S...........S...............................................................................................................................................
.............................................................S...S.SSSS.....SSSSSSSSSSSSSSS.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.SS.S........................................................................................................................................
......S..........................................................................................................................................................S......................................
...........................................................................................................................................................S............................................
......................SS................Exception AttributeError: AttributeError("'File' object has no attribute '_node_manager'",) in .......Exception ValueError: ValueError('Bad tz filename. Dateuti
l on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones implicitly by passing a string like "dateutil/Europe/London"
when you construct your pandas objects instead of passing a timezone object. See #7362',) in 'pandas.tslib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See #7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See #7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See #7362',) in 'pandas.tsl
ib._localize_tso' ignored
Exception ValueError: ValueError('Bad tz filename. Dateutil on python 3 on windows has a bug which causes tzfile._filename to be the same for all timezone files. Please construct dateutil timezones im
plicitly by passing a string like "dateutil/Europe/London" when you construct your pandas objects instead of passing a timezone object. See #7362',) in 'pandas.tsl
ib._localize_tso' ignored
E..SSSS............................S...................................................S.................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....S......................................................
.............S.............................SSSSSSSSSSS..................................................................................................................................................
.............................S..........S..................................S..................S..S.SSSSSSS.......................S.......S..........S......S.....SSSSSSSSSSSSSSSSSSSSSSSSSS.............
.....................................................................................................................................................SS......................................S..........
.............................................................................S..S.......................................................................................................................
..................................................S...S.................................................................................................................................................
...............................S........................................................................................................................................................................
........................................................S.............................................S.................................................................................................
...............E...............................................................................................................................................S........................................
....................................................................S...................................................................................................................................
............................................................................................................................................S.SSSSS.....................................................
...................................................................................................................S..S......................................S.S........................................
..................................................................................S.....................................................................................................................
........SS.....S...SS.......S.S.......................SS.....S...SS.......S.S..............SS..SS............................................S.....S..SS..S......S......S..............SS.SSSSS.S....S..
.....SSS.......................................................................................................................................................................................S......S.
..................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with type 'str', sort
order is undefined for incomparable objects
"incomparable objects" % e, RuntimeWarning)
.................................................c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\core\index.py:1014: RuntimeWarning: Cannot compare type 'Timestamp' with ty
pe 'int', sort order is undefined for incomparable objects
"incomparable objects" % e, RuntimeWarning)
....................................................................................................S............................................................................S.....S................
...............................................S........................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
..........................................................................................................................................................S.............................................
.....................................................................................................................S.....SS......................S...S.............SSS.........S............SS........
.....SSS....SSSS......................SSSSS..SS..............................................................................SS.........................................................................
....S.......................S.............................SS............................................S...............................................................................................

.....................................................................S.......

ERROR: test_append_with_timezones_dateutil (pandas.io.tests.test_pytables.TestHDFStore)

Traceback (most recent call last):
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\tests\test_pytables.py", line 2097, in test_append_with_timezones_dateutil
store.append('df_tz', df)
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 911, in append
*_kwargs)
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1270, in _write_to_group
s.write(obj=value, append=append, complib=complib, *_kwargs)
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3605, in write
*_kwargs)
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3293, in create_axes
raise e
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 3288, in create_axes
*_kwargs)
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\io\pytables.py", line 1755, in set_atom
"invalid timezone specification")
TypeError: invalid timezone specification

ERROR: test_utc_with_system_utc (pandas.tseries.tests.test_timezones.TestTimeZoneSupportDateutil)

Traceback (most recent call last):
File "tslib.pyx", line 862, in pandas.tslib._get_utcoffset (pandas\tslib.c:15096)
AttributeError: 'tzwin' object has no attribute '_utcoffset'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\Jeff Reback\Documents\GitHub\pandas\build\lib.win-amd64-3.3\pandas\tseries\tests\test_timezones.py", line 795, in test_utc_with_system_utc
ts = Timestamp('2001-01-05 11:56', tz=maybe_get_tz('dateutil/UTC'))
File "tslib.pyx", line 196, in pandas.tslib.Timestamp.new (pandas\tslib.c:5959)
File "tslib.pyx", line 946, in pandas.tslib.convert_to_tsobject (pandas\tslib.c:16117)
File "tslib.pyx", line 864, in pandas.tslib._get_utcoffset (pandas\tslib.c:15145)
File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 31, in utcoffset
if self._isdst(dt):
File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 66, in _isdst
self._dstweeknumber)
File "C:\Python33-64\lib\site-packages\python_dateutil-2.2-py3.3.egg\dateutil\tzwin.py", line 165, in picknthweekday
first = datetime.datetime(year, month, 1, hour, minute)
ValueError: month must be in 1..12


Ran 7001 tests in 139.652s

FAILED (SKIP=397, errors=2)

C:\Users\Jeff Reback\Documents\GitHub\pandas>


Reply to this email directly or view it on GitHub
#7362 (comment).

@jreback
Copy link
Contributor

jreback commented Jun 9, 2014

np....thanks for the followups!

@dbew
Copy link
Contributor Author

dbew commented Jun 10, 2014

So, the pytables test I just missed this when I was updating the tests to construct the dateutil timezones correctly.

The test_utc_with_system_utc is the one I added yesterday. Not sure how I missed that this was failing - it definitely fails for me on windows. The problem is that

from dateutil.tz import gettz
from datetime import datetime
u = gettz('UTC')
u.utcoffset(datetime(2001, 1, 1))

raises an exception on Windows. The result of gettz('UTC') is a tzwin object that hasn't been constructed properly. Definitely a bug in dateutil - see this bug report.

Given that, I think it makes sense to skip the test on windows until the bug in dateutil is fixed.

I've run the tests in pandas/io/tests/test_pytables.py and pandas/tseries/tests/test_timezones.py on windows in python 2.7 and 3 and on linux in python 2.7. As I've only changed the tests in those files there shouldn't be any extra failures this time!

I've pushed the changes onto a new branch in the @AHLMSS repository here, pull request here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Timezones Timezone data dtype Windows Windows OS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: dateutil testing failures on windows
2 participants