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

BUG: Fix crash in repr for non-BoundColumn inputs. #2247

Merged
merged 2 commits into from Jul 12, 2018
Merged

Conversation

ssanderson
Copy link
Contributor

No description provided.

@llllllllll
Copy link
Contributor

llllllllll commented Jul 12, 2018

+1, should we test this?

@coveralls
Copy link

coveralls commented Jul 12, 2018

Coverage Status

Coverage decreased (-0.05%) to 85.883% when pulling 1e6e478 on fix-names into f288356 on master.

@ssanderson
Copy link
Contributor Author

Just using short_repr isn't quite right actually. short_repr should really only be used for graphviz output now, because it contains graphviz-specific escapes like \l (which means left-aligned newline).

I've updated this to rename short_repr to graph_repr, and added a new recursive_repr to be used in contexts where we want a short repr for recursive rendering. The default recursive_repr is just "TypeName". ComputableTerms have a recursive repr of "TypeName(...)", and BoundColumns have a recursive repr of "DataSet.column_name".

@ssanderson
Copy link
Contributor Author

@jnazaren @llllllllll I'm gonna merge this on pass unless there are any objections.

def recursive_repr(self):
"""A short repr to use when recursively rendering terms with inputs.
"""
# Default graph_repr is just the name of the type.
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment should be updated

window_length=self.window_length,
)

def recursive_repr(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

why not have the ... in the repr but have in in the short repr?

if hasattr(obj, 'short_repr'):
r = obj.short_repr()
if hasattr(obj, 'graph_repr'):
r = obj.graph_repr()
Copy link
Contributor

Choose a reason for hiding this comment

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

don't all terms have this because it is defined on Term

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other stuff runs through this function as well (e.g., non-term parameters).

Copy link
Contributor

Choose a reason for hiding this comment

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

if isinstance(obj, Term):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. idk then. This change was just made with find-replace. This is probably just a holdover from before I put a default impl on short_repr.

r = obj.short_repr()
else:
r = type(obj).__name__
r = obj.graph_repr()
else:
r = obj
return '"%s"' % r
Copy link
Contributor

Choose a reason for hiding this comment

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

This formatting is broken for strings. If you want to repr strings with quotes use %r I wouldn't block on this comment though.

@ssanderson ssanderson merged commit 985d793 into master Jul 12, 2018
@ssanderson ssanderson deleted the fix-names branch July 12, 2018 17:17
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.

None yet

3 participants