{"action":"closed","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3897","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3897/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3897/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3897/events","html_url":"https://github.com/matplotlib/matplotlib/issues/3897","id":51197575,"number":3897,"title":"bug: inconsistent types accepted in DateLocator subclasses","user":{"login":"wholmgren","id":4383303,"avatar_url":"https://avatars.githubusercontent.com/u/4383303?v=3","gravatar_id":"","url":"https://api.github.com/users/wholmgren","html_url":"https://github.com/wholmgren","followers_url":"https://api.github.com/users/wholmgren/followers","following_url":"https://api.github.com/users/wholmgren/following{/other_user}","gists_url":"https://api.github.com/users/wholmgren/gists{/gist_id}","starred_url":"https://api.github.com/users/wholmgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wholmgren/subscriptions","organizations_url":"https://api.github.com/users/wholmgren/orgs","repos_url":"https://api.github.com/users/wholmgren/repos","events_url":"https://api.github.com/users/wholmgren/events{/privacy}","received_events_url":"https://api.github.com/users/wholmgren/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/API%20consistency","name":"API consistency","color":"000000"},{"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/date%20handling","name":"date handling","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12","html_url":"https://github.com/matplotlib/matplotlib/milestones/2.1%20(next%20point%20release)","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12/labels","id":534144,"number":12,"title":"2.1 (next point release)","description":"Next feature release.\r\n\r\nBig ticket items:\r\n\r\n - MEP 22/27\r\n - traitlets","creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":469,"closed_issues":313,"state":"open","created_at":"2014-01-13T03:21:09Z","updated_at":"2016-03-17T16:11:59Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2014-12-06T21:56:07Z","updated_at":"2016-03-17T16:11:59Z","closed_at":"2016-03-17T16:11:59Z","body":"I've usually used np arrays, mostly out of habit, to construct my HourLocator and MinuteLocator objects, and today I was surprised to find that this did not work for MonthLocator objects. I also tested DayLocator and WeekdayLocator and found that they did not work with np arrays. The mpl docs suggest that the arguments can be \"an int or sequence\" -- not sure if this would include np arrays or not.\r\n\r\nNot a big deal, but it did confuse me for a few minutes.\r\n\r\n```python\r\nIn [47]:\r\n\r\nmpl.dates.DayLocator(np.arange(2,13,2))\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-47-b23ea962d29f> in <module>()\r\n----> 1 mpl.dates.DayLocator(np.arange(2,13,2))\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, bymonthday, interval, tz)\r\n   1097             bymonthday = list(xrange(1, 32))\r\n   1098         o = rrulewrapper(DAILY, bymonthday=bymonthday,\r\n-> 1099                          interval=interval, **self.hms0d)\r\n   1100         RRuleLocator.__init__(self, o, tz)\r\n   1101 \r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, freq, **kwargs)\r\n    593         self._construct = kwargs.copy()\r\n    594         self._construct[\"freq\"] = freq\r\n--> 595         self._rrule = rrule(**self._construct)\r\n    596 \r\n    597     def set(self, **kwargs):\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/dateutil/rrule.py in __init__(self, freq, dtstart, interval, wkst, count, until, bysetpos, bymonth, bymonthday, byyearday, byeaster, byweekno, byweekday, byhour, byminute, bysecond, cache)\r\n    272                     raise ValueError(\"bysetpos must be between 1 and 366, \"\r\n    273                                      \"or between -366 and -1\")\r\n--> 274         if not (byweekno or byyearday or bymonthday or\r\n    275                 byweekday is not None or byeaster is not None):\r\n    276             if freq == YEARLY:\r\n\r\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\r\n\r\nIn [48]:\r\n\r\nmpl.dates.HourLocator(np.arange(2,13,2))\r\nOut[48]:\r\n<matplotlib.dates.HourLocator at 0x7f05a2149470>\r\nIn [49]:\r\n\r\nmpl.dates.MinuteLocator(np.arange(2,13,2))\r\nOut[49]:\r\n<matplotlib.dates.MinuteLocator at 0x7f05a1e941d0>\r\nIn [50]:\r\n\r\nmpl.dates.MonthLocator(np.arange(2,13,2))\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-50-971e82a6be3a> in <module>()\r\n----> 1 mpl.dates.MonthLocator(np.arange(2,13,2))\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, bymonth, bymonthday, interval, tz)\r\n   1056             bymonth = list(xrange(1, 13))\r\n   1057         o = rrulewrapper(MONTHLY, bymonth=bymonth, bymonthday=bymonthday,\r\n-> 1058                          interval=interval, **self.hms0d)\r\n   1059         RRuleLocator.__init__(self, o, tz)\r\n   1060 \r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, freq, **kwargs)\r\n    593         self._construct = kwargs.copy()\r\n    594         self._construct[\"freq\"] = freq\r\n--> 595         self._rrule = rrule(**self._construct)\r\n    596 \r\n    597     def set(self, **kwargs):\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/dateutil/rrule.py in __init__(self, freq, dtstart, interval, wkst, count, until, bysetpos, bymonth, bymonthday, byyearday, byeaster, byweekno, byweekday, byhour, byminute, bysecond, cache)\r\n    283                 byweekday = dtstart.weekday()\r\n    284         # bymonth\r\n--> 285         if not bymonth:\r\n    286             self._bymonth = None\r\n    287         elif isinstance(bymonth, integer_types):\r\n\r\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\r\n\r\nIn [51]:\r\n\r\nmpl.dates.SecondLocator(np.arange(2,13,2))\r\nOut[51]:\r\n<matplotlib.dates.SecondLocator at 0x7f05a1f25d68>\r\nIn [52]:\r\n\r\nmpl.dates.WeekdayLocator(np.arange(2,13,2))\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-52-94aba8a8506e> in <module>()\r\n----> 1 mpl.dates.WeekdayLocator(np.arange(2,13,2))\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, byweekday, interval, tz)\r\n   1079         o = rrulewrapper(DAILY, byweekday=byweekday,\r\n-> 1080                          interval=interval, **self.hms0d)\r\n   1081         RRuleLocator.__init__(self, o, tz)\r\n   1082 \r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/matplotlib/dates.py in __init__(self, freq, **kwargs)\r\n    593         self._construct = kwargs.copy()\r\n    594         self._construct[\"freq\"] = freq\r\n--> 595         self._rrule = rrule(**self._construct)\r\n    596 \r\n    597     def set(self, **kwargs):\r\n\r\n/home/will/.virtualenvs/dev3/lib/python3.4/site-packages/dateutil/rrule.py in __init__(self, freq, dtstart, interval, wkst, count, until, bysetpos, bymonth, bymonthday, byyearday, byeaster, byweekno, byweekday, byhour, byminute, bysecond, cache)\r\n    347                 if isinstance(wday, integer_types):\r\n    348                     self._byweekday.append(wday)\r\n--> 349                 elif not wday.n or freq > MONTHLY:\r\n    350                     self._byweekday.append(wday.weekday)\r\n    351                 else:\r\n\r\nAttributeError: 'numpy.int64' object has no attribute 'n'\r\n\r\nIn [53]:\r\n\r\nmpl.dates.MonthLocator(np.arange(2,13,2).tolist())\r\nOut[53]:\r\n<matplotlib.dates.MonthLocator at 0x7f05a20a0ba8>\r\n```"}}