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

Display silently fails when there are duplicates in links #22

Closed
sildar opened this issue Mar 28, 2018 · 1 comment
Closed

Display silently fails when there are duplicates in links #22

sildar opened this issue Mar 28, 2018 · 1 comment

Comments

@sildar
Copy link
Contributor

sildar commented Mar 28, 2018

Hi and thanks for the great work!

The following code silently fails (i.e. displays nothing without any error message).

faultylinks = [{'source': 'farm1', 'target': 'client1', 'value': 5}, {'source': 'farm1', 'target': 'client1', 'value': 10}]
SankeyWidget(links=faultylinks)

Obviously, having duplicates in the links should not happen, but I think an error message should be displayed when this happens rather than failing silently.

Not sure if this is due to ipysankeywidget directly, but a safety check could be performed anyway during the init.

I see two distinct solutions:

  1. Automatically sum values for entries that have the same source and target. This should be what a large majority of users wanted to do. You can log a warning when this happens.
  2. Raise an exception.

Solution 2 is easier to implement (there is no logging implemented for now) and probably safer too. Solution 1 focuses on ease of use in case that's what the widget aims for.

I can implement any solution or leave it to you.

@ricklupton
Copy link
Owner

Hi, thanks for reporting this! This is a problem in the underlying d3-sankey-diagram library, so one solution would be to fix it there, but it gets a bit complicated as you have to not only sum values but also decide which colour to use, how to set the title of the combined link and so on.

If people are wanting to sum multiple entries they maybe should be using https://github.com/ricklupton/floweaver anyway, which handles this as well as lots of other data processing, colours etc before you get to the actual Sankey diagram.

In the short term I think checking in ipysankeywidget and raising an exception would be best. And if d3-sankey-diagram later supports it, it would be easy to change the exception to a warning then.

If you would like to fix this then that would be great! Just let me know if you have any questions or want any help.

ricklupton added a commit that referenced this issue Mar 30, 2018
Fix #22 : Raise an exception when there are duplicates in links
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

No branches or pull requests

2 participants