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

Add lower/upper/strip/contains to StringExpression #3199

Merged
merged 2 commits into from
Mar 21, 2018

Conversation

tpoterba
Copy link
Contributor

No description provided.

@@ -2048,6 +2048,75 @@ def split(self, delim, n=None):
else:
return self._method("split", tarray(tstr), delim, n)

def lower(self):
"""Returns a string of only lower-case characters.
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be something like "Returns a string with all letters converted to lowercase." or something? (Basically making it more clear that it's performing an action on the given string---I got a little confused because s is defined quite a ways up.) Ditto for upper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about this (copied from Python stdlib docs):
Return a copy of s, but with upper case letters converted to lower case.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good! I don't have strong feelings about exact verbiage.

cseed
cseed previously requested changes Mar 21, 2018
registerMethod("lower", (s: String) => s.toLowerCase)
registerMethod("upper", (s: String) => s.toUpperCase)
registerMethod("strip", (s: String) => s.trim())
registerMethod("contains", (s: String, t: String) => s.contains(t))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to be difficult: no new FunctionRegistry methods without corresponding IR methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you point me to the code to mimic?

Copy link
Contributor

Choose a reason for hiding this comment

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

in is.hail.expr.ir.functions. You probably want a StringFunctions to mimic MathFunctions, and then you need to call registerAll in IRFunctionRegistry.

@tpoterba tpoterba dismissed stale reviews from catoverdrive and cseed March 21, 2018 20:13

addressed

@tpoterba tpoterba merged commit a8a9c63 into hail-is:master Mar 21, 2018
@tpoterba tpoterba deleted the string-lower-upper branch March 21, 2018 22:41
jbloom22 pushed a commit to jbloom22/hail that referenced this pull request Mar 22, 2018
* Add lower/upper/strip/contains to StringExpression

* added StringFunctions IR
konradjk pushed a commit to konradjk/hail that referenced this pull request Jun 12, 2018
* Add lower/upper/strip/contains to StringExpression

* added StringFunctions IR
jackgoldsmith4 pushed a commit to jackgoldsmith4/hail that referenced this pull request Jun 25, 2018
* Add lower/upper/strip/contains to StringExpression

* added StringFunctions IR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants