Skip to content
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

ENH/BUG: Support string slicing with other expressions #1627

Closed
wants to merge 1 commit into from

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Sep 17, 2018

Closes #1626

@cpcloud cpcloud added bug Incorrect behavior inside of ibis feature Features or general enhancements labels Sep 17, 2018
@cpcloud cpcloud added this to the Next Release milestone Sep 17, 2018
@cpcloud
Copy link
Member Author

cpcloud commented Sep 19, 2018

@kszucs Can you give this a review when you get a chance?

@cpcloud cpcloud requested a review from kszucs September 19, 2018 15:26
ibis/expr/api.py Outdated
raise ValueError('negative slicing not yet supported')
if not isinstance(stop, ir.Expr):
if stop is not None and stop < 0:
raise ValueError('negative slicing not yet supported')
Copy link
Member

Choose a reason for hiding this comment

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

Uppercase n

ibis/expr/api.py Outdated
if stop is not None and stop < 0:
raise ValueError('negative slicing not yet supported')
if stop is None:
stop = self.length()
Copy link
Member

Choose a reason for hiding this comment

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

Minor, just not consistent with the previous validation order.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't follow, what was the previous validation order?

Copy link
Member

Choose a reason for hiding this comment

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

is None goes to the top + elif

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, nevermind, I see it

def execute_string_substring_series_series(op, data, start, length, **kwargs):
end = start + length

def iterate(value,
Copy link
Member

Choose a reason for hiding this comment

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

This "general" case wouldn't be enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose we could farm out the other functions to this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

We definitely need to handle the integer, series and series, integer cases distinctly, but those two can be made to be instances of the general case.

ibis/expr/api.py Outdated
if start is None:
start = 0
if start < 0:
raise ValueError('Negative slicing not yet supported')
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps self.length() + start?

Copy link
Member

Choose a reason for hiding this comment

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

Crossed out because of this comment.

@cpcloud
Copy link
Member Author

cpcloud commented Sep 19, 2018

Merging on green

@cpcloud cpcloud closed this in fbe516c Sep 19, 2018
@cpcloud cpcloud deleted the fix-str-slice branch September 19, 2018 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis feature Features or general enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants