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 support for labelling of lines #20

Merged
merged 3 commits into from Oct 30, 2017
Merged

Add support for labelling of lines #20

merged 3 commits into from Oct 30, 2017

Conversation

AnjoMan
Copy link
Member

@AnjoMan AnjoMan commented Oct 30, 2017

  • add support for labels like A----(my_label)-----B in edges

@coveralls
Copy link

coveralls commented Oct 30, 2017

Coverage Status

Coverage increased (+0.3%) to 96.774% when pulling 45a04e1 on line-labels into 5f96045 on master.

@coveralls
Copy link

coveralls commented Oct 30, 2017

Coverage Status

Coverage increased (+0.3%) to 96.774% when pulling c3ad5a0 on line-labels into 5f96045 on master.

@AnjoMan AnjoMan requested a review from etimberg October 30, 2017 12:54
@AnjoMan AnjoMan changed the title Add support for labelling of lines WIP: Add support for labelling of lines Oct 30, 2017
""")

assert ("A", "B") in graph.edges()
assert ("A", "(ABC)") not in graph.edges()
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reason for checking that a link between A and (ABC) does not exist?

for offset, _ in enumerate(node_label)
}
if node_label.startswith("(") and node_label.endswith(")"):
label_value = node_label[1:-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

was pleasantly surprised to find that this works even if node_label == '()' (at least on python 3.6)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, you should just get an empty string on the edge attribute.

Choose a reason for hiding this comment

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

Also 2.x

Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> "()"[1:-1]
''

Choose a reason for hiding this comment

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

It makes sense it's the substring with the same starting and ending index in the string.

@coveralls
Copy link

coveralls commented Oct 30, 2017

Coverage Status

Coverage increased (+0.3%) to 96.774% when pulling f2c20e9 on line-labels into 5f96045 on master.

@AnjoMan AnjoMan changed the title WIP: Add support for labelling of lines Add support for labelling of lines Oct 30, 2017

# nodes = node_chars
# we'll treat edge labels (e.g. "(my_label)") as consecutive "-" edge chars
Copy link

@dvincelli dvincelli Oct 30, 2017

Choose a reason for hiding this comment

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

I don't agree because renaming it means when we rename the label, we change the length, though I understand it's probably easier for other reasons like it makes it simpler to align with other lines and points on the graph.

Choose a reason for hiding this comment

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

So basically I agree but I don't 100% love it. It's pragmatic and simple which is good.

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 could go back at the end and modify the lengths of all the edges by subtracting the length of the label.

Choose a reason for hiding this comment

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

That makes sense. How hard is it?

Choose a reason for hiding this comment

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

Thinking about it more, it also means the user is forced to lengthen lines that connect to the the graph so it might be best to keep the current behaviour, at least everything will be of the same length in relative terms.


# nodes = node_chars
# we'll treat edge labels (e.g. "(my_label)") as consecutive "-" edge chars

Choose a reason for hiding this comment

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

So basically I agree but I don't 100% love it. It's pragmatic and simple which is good.

* support line labels using brackets
* test them
* don't add label nodes to the graph
@coveralls
Copy link

coveralls commented Oct 30, 2017

Coverage Status

Coverage increased (+0.3%) to 96.774% when pulling 6b1bcdd on line-labels into 5f96045 on master.

|
|
D---(string)----E

Choose a reason for hiding this comment

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

Delete this empty line.


# nodes = node_chars
# we'll treat edge labels (e.g. "(my_label)") as consecutive "-" edge chars

Choose a reason for hiding this comment

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

That makes sense. How hard is it?


# nodes = node_chars
# we'll treat edge labels (e.g. "(my_label)") as consecutive "-" edge chars

Choose a reason for hiding this comment

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

Thinking about it more, it also means the user is forced to lengthen lines that connect to the the graph so it might be best to keep the current behaviour, at least everything will be of the same length in relative terms.

n0-------------n1----------n2
|
| (3)
| <3>

Choose a reason for hiding this comment

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

Can we add a test that covers mixing (labels) and <lengths> ?

@AnjoMan AnjoMan merged commit 4416e4b into master Oct 30, 2017
@etimberg etimberg deleted the line-labels branch November 18, 2017 13:08
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

4 participants