-
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
[ENH, MAINT] Refactor directed-undirected graph class #72
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jaron Lee <[email protected]>
Signed-off-by: Jaron Lee <[email protected]>
Signed-off-by: Jaron Lee <[email protected]>
of the sample induces association between ``A`` and ``B``) [1]_. | ||
|
||
|
||
The implementation supports representation of both Lauritzen-Wermuth-Frydenberg (LWF) |
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 like this. Maybe citations?
self, | ||
incoming_directed_edges=None, | ||
incoming_undirected_edges=None, | ||
directed_edge_name: str = "directed", |
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.
whitespace around " = "
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.
LGTM
I know it's still a WIP but I approved in case you wanted to get initial work in. |
Signed-off-by: Jaron Lee <[email protected]>
@@ -184,6 +143,90 @@ def possible_parents(self, n: Node) -> Iterator[Node]: | |||
""" | |||
return self.sub_undirected_graph().neighbors(n) | |||
|
|||
|
|||
class CPDAG(DiUnGraph, ConservativeMixin): | |||
"""Completed partially directed acyclic graphs (CPDAG). |
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.
Perhaps it is worth adding a note or warning even to the classes that validity is not guaranteed. Please use the validity check if you need to rigorously check that your construction is valid?
Same in chaingraph? Maybe also in the ADMG, and PAG too?
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.
Yeah this is a good idea. I will address just CPDAG and Chain Graph in this PR but will look to redo the other classes in another PR.
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 like the direction of these changes. It keeps us lean but also doesn't commit to one design yet.
Signed-off-by: Jaron Lee <[email protected]>
Signed-off-by: Jaron Lee <[email protected]>
Signed-off-by: Jaron Lee <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #72 +/- ##
==========================================
+ Coverage 84.42% 84.67% +0.25%
==========================================
Files 34 35 +1
Lines 2555 2597 +42
Branches 687 695 +8
==========================================
+ Hits 2157 2199 +42
Misses 251 251
Partials 147 147
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 fixes and then LGTM.
@@ -25,6 +25,7 @@ Version 0.1 | |||
|
|||
Changelog | |||
--------- | |||
- |Feature| Introduce chain graphs and validity checks, and refactor CPDAG and chain graphs to use a directed-undirected private class, by `Jaron Lee`_ (:pr:`73`) |
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.
Typically change log goes on the bottom. I think the Changelog CI check should get fixed that way
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 fair enough I was just following https://keepachangelog.com/en/1.0.0/ which has everything in reverse chronological order
|
||
# Search over all nodes. | ||
for v in all_nodes: | ||
queue = deque([]) |
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.
Add a type annotation to queue
to fix the mypy complaint
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.
Can do - also I have the pre-commit hooks PR which is open for review which will help me catch this :)))
# Fill queue with paths from v starting with outgoing directed edge | ||
# OrderedDict used for O(1) set membership and ordering | ||
for _, z in G_directed.out_edges(nbunch=v): | ||
d = OrderedDict() |
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.
Add a type annotation to d
to fix the mypy complaint
|
||
|
||
@pytest.fixture | ||
def fig_g1_frydenberg(): |
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.
Perhaps add a docstring and a link to the reference for all the fixtures that come from some paper, so its back traceable?
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.
yes that's a good idea, i have the reference in the function but not the test
I will also implement the corresponding changes for CPDAG before I unmark as draft but thanks for the early reviews on this PR |
@jaron-lee hey know you're prolly busy doing more interesting things at your internship :) Just wanted to check in to see if you think we should just do a release v0.1 first for now. I think we should def refactor by v0.2 into whatever this PR manifests? |
Yes I think going ahead with v0.1 is a good idea. I should hopefully have
some more time at the end of summer - I may just reduce the scope of the
refactor and let others work on it in the meantime so I don't hold anything
up.
…On Wed, Jun 28, 2023, 2:04 PM Adam Li ***@***.***> wrote:
@jaron-lee <https://github.com/jaron-lee> hey know you're prolly busy
doing more interesting things at your internship :)
Just wanted to check in to see if you think we should just do a release
v0.1 first for now. I think we should def refactor by v0.2 into whatever
this PR manifests?
—
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEE2MJLRSC42JHJ4TDPNLTXNRW2TANCNFSM6AAAAAAWUY2CPY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Towards #65
Changes proposed in this pull request:
DiUnGraph
Before submitting
section of the
CONTRIBUTING
docs.Writing docstrings section of the
CONTRIBUTING
docs.After submitting