Skip to content

ASV: more for str.cat #22652

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 5 commits into from
Sep 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Review (WillAyd) [ci skip]
  • Loading branch information
h-vetinari committed Sep 13, 2018
commit ddc130ef21eff0d052bd515a01dff6a0dca24189
9 changes: 6 additions & 3 deletions asv_bench/benchmarks/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ def setup(self, other_cols, sep, na_rep, na_frac):
mask_gen = lambda: np.random.choice([True, False], N,
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the lambda here? Figured we could just use the returned array in the subsequent call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's essential IMO that each column gets a different mask to compound the NaNs (for the na_rep=None case) and have a reasonable similarity to real-life data.

p=[1 - na_frac, na_frac])
self.s = Series(tm.makeStringIndex(N)).where(mask_gen())
self.others = (DataFrame({i: tm.makeStringIndex(N).where(mask_gen())
for i in range(other_cols)})
if other_cols > 0 else None)
if other_cols == 0:
# str.cat self-concatenates only for others=None
self.others = None
else:
self.others = DataFrame({i: tm.makeStringIndex(N).where(mask_gen())
for i in range(other_cols)})

def time_cat(self, other_cols, sep, na_rep, na_frac):
# before the concatenation (one caller + other_cols columns), the total
Expand Down