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

Conductance of the empty set should return clear error message #8

Closed
pmacg opened this issue Nov 15, 2021 · 0 comments · Fixed by #17
Closed

Conductance of the empty set should return clear error message #8

pmacg opened this issue Nov 15, 2021 · 0 comments · Fixed by #17
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@pmacg
Copy link
Owner

pmacg commented Nov 15, 2021

Requesting the conductance (or bipartiteness) of an empty set should return a meaningful error message to the client.

Minimal working example

>>> import sgtl.graph
>>> graph = sgtl.graph.cycle_graph(10)
>>> graph.conductance([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/wc/py-sgtl/sgtl/graph.py", line 144, in conductance
    return 1 - (2 * self.weight(vertex_set_s, vertex_set_s, sets_are_equal=True)) / self.volume(vertex_set_s)
ZeroDivisionError: division by zero

For the bipartiteness case:

>>> graph.bipartiteness([], [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/wc/py-sgtl/sgtl/graph.py", line 159, in bipartiteness
    return 1 - 2 * self.weight(vertex_set_l, vertex_set_r) / self.volume(vertex_set_l + vertex_set_r)
ZeroDivisionError: division by zero

Desired Behaviour

Something like:

>>> import sgtl.graph
>>> graph = sgtl.graph.cycle_graph(10)
>>> graph.conductance([])
<snip>
ValueError: conductance of the empty set is undefined
@pmacg pmacg added enhancement New feature or request good first issue Good for newcomers labels Nov 15, 2021
@pmacg pmacg added this to the Release 0.3.4 milestone Nov 29, 2021
@pmacg pmacg closed this as completed in #17 Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant