Skip to content

BUG: Fix busdaycalendar's handling of a bool array weekmask. (#30885)#30923

Merged
charris merged 1 commit intonumpy:maintenance/2.4.xfrom
charris:backport-30885
Mar 4, 2026
Merged

BUG: Fix busdaycalendar's handling of a bool array weekmask. (#30885)#30923
charris merged 1 commit intonumpy:maintenance/2.4.xfrom
charris:backport-30885

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Mar 4, 2026

Backport of #30885.

Closes gh-30883.

This change is simple but it has implications beyond the problem observed in gh-30883. With this change, when weekmask is a sequence, the boolean array is created by evaluating the "truthiness" of the elements in the sequence. This might be more flexible than desired.

For example, with this PR, we have the following behavior:

In [1]: mask = ["x", "x", "x", "x", "", "", ""]

In [2]: cal = np.busdaycalendar(weekmask=mask)

In [3]: cal.weekmask
Out[3]: array([ True,  True,  True,  True, False, False, False])

Before this change, that sequence of strings would result in a TypeError:

In [13]: np.__version__
Out[13]: '2.4.2'

In [14]: mask = ["x", "x", "x", "x", "", "", ""]

In [15]: cal = np.busdaycalendar(weekmask=mask)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[15], line 1
----> 1 cal = np.busdaycalendar(weekmask=mask)

TypeError: 'str' object cannot be interpreted as an integer

@charris charris added this to the 2.4.3 release milestone Mar 4, 2026
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Mar 4, 2026
@charris charris merged commit d1917ed into numpy:maintenance/2.4.x Mar 4, 2026
74 checks passed
@charris charris deleted the backport-30885 branch March 4, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants