File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -423,7 +423,7 @@ def cons_row(x):
423
423
result .name = name
424
424
return result
425
425
426
- def _get_series_list (self , others ):
426
+ def _get_series_list (self , others ) -> list [ Series ] :
427
427
"""
428
428
Auxiliary function for :meth:`str.cat`. Turn potentially mixed input
429
429
into a list of Series (elements without an index must match the length
@@ -474,8 +474,8 @@ def _get_series_list(self, others):
474
474
for x in others
475
475
):
476
476
los : list [Series ] = []
477
- while others : # iterate through list and append each element
478
- los = los + self ._get_series_list (others . pop ( 0 ))
477
+ for other in others :
478
+ los . extend ( self ._get_series_list (other ))
479
479
return los
480
480
# ... or just strings
481
481
elif all (not is_list_like (x ) for x in others ):
Original file line number Diff line number Diff line change 1
1
# being a bit too dynamic
2
2
from __future__ import annotations
3
3
4
- from math import ceil
4
+ from math import (
5
+ ceil ,
6
+ floor ,
7
+ log2 ,
8
+ )
5
9
from typing import TYPE_CHECKING
6
10
import warnings
7
11
@@ -126,9 +130,7 @@ def _get_layout(
126
130
try :
127
131
return layouts [nplots ]
128
132
except KeyError :
129
- k = 1
130
- while k ** 2 < nplots :
131
- k += 1
133
+ k = floor (log2 (nplots ))
132
134
133
135
if (k - 1 ) * k >= nplots :
134
136
return k , (k - 1 )
Original file line number Diff line number Diff line change @@ -116,9 +116,8 @@ def next_workday(dt: datetime) -> datetime:
116
116
returns next workday used for observances
117
117
"""
118
118
dt += timedelta (days = 1 )
119
- while dt .weekday () > 4 :
120
- # Mon-Fri are 0-4
121
- dt += timedelta (days = 1 )
119
+ # Mon-Fri are 0-4
120
+ dt += timedelta (days = max (dt .weekday () - 4 , 0 ))
122
121
return dt
123
122
124
123
@@ -127,9 +126,8 @@ def previous_workday(dt: datetime) -> datetime:
127
126
returns previous workday used for observances
128
127
"""
129
128
dt -= timedelta (days = 1 )
130
- while dt .weekday () > 4 :
131
- # Mon-Fri are 0-4
132
- dt -= timedelta (days = 1 )
129
+ # Mon-Fri are 0-4
130
+ dt -= timedelta (days = max (dt .weekday () - 4 , 0 ))
133
131
return dt
134
132
135
133
You can’t perform that action at this time.
0 commit comments