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

Fix bug in Node.__repr__ #233

Merged
merged 1 commit into from
Aug 14, 2020
Merged

Fix bug in Node.__repr__ #233

merged 1 commit into from
Aug 14, 2020

Conversation

mschmidt87
Copy link
Member

This PR fixes #232 by following the suggestions of @jakobj in the ticket:

  • Remove _output from repr string of Node class
  • Rename _inputs to _input_nodes for better clarity
  • Add test of CartesianGraph.repr function
  • Add test for repr of 3 example nodes

@mschmidt87 mschmidt87 added the bug Something isn't working label Aug 13, 2020
@mschmidt87 mschmidt87 added this to the 0.2.0 milestone Aug 13, 2020
@mschmidt87 mschmidt87 requested a review from jakobj August 13, 2020 11:25
@jakobj jakobj removed the bug Something isn't working label Aug 13, 2020
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

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

thanks for fixing this!

i think you've missed some occurrences of _inputs, added comments inline

cgp/node.py Show resolved Hide resolved
cgp/node.py Outdated
@@ -79,7 +79,7 @@ def idx(self) -> int:
def __repr__(self) -> str:
return (
f"{self.__class__.__name__}(idx: {self.idx}, active: {self._active}, "
f"arity: {self._arity}, inputs {self._inputs}, output {self._output})"
f"arity: {self._arity}, inputs {self._inputs}"
Copy link
Member

Choose a reason for hiding this comment

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

e.g., here

test/test_cartesian_graph.py Outdated Show resolved Hide resolved
test/test_node.py Outdated Show resolved Hide resolved
@mschmidt87 mschmidt87 requested a review from jakobj August 14, 2020 03:41
Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

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

beautiful, thanks! ✨ 👍

i've added two minor comments that you are free to address or ignore. but please squash/rebase before merging

@@ -173,7 +173,7 @@ def _determine_active_nodes(self) -> Dict[int, Set[Node]]:
continue
active_nodes_by_hidden_column_idx[self._hidden_column_idx(node.idx)].add(node)

for i in node.inputs:
for i in node.input_nodes:
Copy link
Member

Choose a reason for hiding this comment

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

when reading this line, i would prefer something like for input_idx in node.input_node_indices, i.e., renaming input_nodes -> input_node_indices or this overdoing it? ;)

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 think this is overdoing it. ;-)

@@ -12,16 +12,16 @@ def test_inputs_are_cut_to_match_arity():

"""
idx = 0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
idx = 0
node_idx = 0

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 think this is unrelated to this PR and the class member is called idx anyway.

Remove _output from repr string of Node class
Rename _inputs to _input_nodes for better clarity
Add test of CartesianGraph.__repr__ function
Add test for __repr__ of 3 example nodes

Co-authored-by: Jakob Jordan <[email protected]>
@mschmidt87 mschmidt87 merged commit 7265fd1 into master Aug 14, 2020
@mschmidt87 mschmidt87 deleted the bugfix/node_repr branch August 14, 2020 11:47
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.

__repr__ of CartesianGraph is broken by InputNode
2 participants