-
Notifications
You must be signed in to change notification settings - Fork 8
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
[DOCS] Add an example for the Inducing Path function #83
Conversation
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
@adam2392 How do you want me to proceed with this? Should I include scenarios where there is no path as well? And are the comments like this ok? |
The goal is to educate the user and serve as a quick reminder for yourself as a dev in case you need to review something. I would proceed in sections:
Lmk if that makes sense
|
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
@adam2392 What do you think? |
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
Yes I think this is a good start and direction! Can you take a look at the other examples and use "# %%" to break up into sections where it makes sense? It makes the final rendering easier to read. |
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
@adam2392 How about now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few comments I left. The most major one is that I'm surprised the code ran if you used a PAG with circle-edges.
An inducing path definition only mentions directed and bidirected edges, so for any graph with other kinds of edges (e.g. CPDAG or PAG) it is not defined what it is.
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
@adam2392 can you take a look now? |
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
Can you add a test in E.g. I would expect it to return an error if passed a PAG. |
Signed-off-by: Adam Li <adam2392@gmail.com>
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
Do you want me to add it to this PR or create a new issue and a new PR? |
You can just add it here since it's just a line just checking the types of edges present. |
@adam2392 there's one problem. There is no graph class that is only has directed and bidirected edges. Even ADMG can have undirected edges. Do you want me to just check if the argument is an instance of PAG or CPDAG instead? |
I wouldn't check the class as we are going to eventually try to refactor that so there is no explicit PAG/CPDAG class. Instead, I would check the edge types for right now 'directed', 'bidirected' keywords. |
The problem is PAG would pass this test. It can have both of these edge types. |
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
We don't want any other edge. It can only have these types of edges. |
@adam2392 Unless you're ok with instances of PAG class being valid as long as they only have directed and bidirected edges. Otherwise there is no way to differentiate between the different types. |
Signed-off-by: Aryan Roy <aryanroy5678@gmail.com>
@adam2392 I added the check. Also, I can't get the references to render, can you take a look at both? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Adam Li <adam2392@gmail.com> Signed-off-by: Aryan Roy <50577809+aryan26roy@users.noreply.github.com>
@adam2392 The last run didn't make any documentation artifacts? |
Are you able to see the status of the circle CI docs build? The artifacts are listed there. |
Now I can see it! I guess github was glitching out for me. Anyway, are you happy with the current state? |
pywhy_graphs/algorithms/generic.py
Outdated
edges = G.edges() | ||
|
||
for elem in edges.keys(): | ||
if elem not in {"directed", "bidirected"}: | ||
if len(edges[elem]) != 0: | ||
raise ValueError("Inducing Path is not defined for this graph.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would instead do something like:
if any(edge_type not in {'directed', 'bidirected'} for edge_type in G.edge_types):
raise...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam2392 If I use this test all of the ADMG classes are raising errors as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay I see. Can you add a comment marking this as something we should fix in the future # XXX: fix this when graph classes are refactored to only check for directed/bidirected edge types
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes. Otw LGTM and can merge one these are addressed.
pywhy_graphs/algorithms/generic.py
Outdated
edges = G.edges() | ||
|
||
for elem in edges.keys(): | ||
if elem not in {"directed", "bidirected"}: | ||
if len(edges[elem]) != 0: | ||
raise ValueError("Inducing Path is not defined for this graph.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay I see. Can you add a comment marking this as something we should fix in the future # XXX: fix this when graph classes are refactored to only check for directed/bidirected edge types
?
Signed-off-by: Adam Li <adam2392@gmail.com>
Signed-off-by: Adam Li <adam2392@gmail.com>
Thanks @aryan26roy ! |
Closes #81
Changes proposed in this pull request:
Before submitting
section of the
CONTRIBUTING
docs.Writing docstrings section of the
CONTRIBUTING
docs.After submitting