Skip to content

Commit

Permalink
Merge pull request #2 from IntelLabs/fixes_for_clear_demo
Browse files Browse the repository at this point in the history
Fixes for clear demo
  • Loading branch information
guyazran authored Jan 2, 2023
2 parents 47ae990 + 228ac74 commit 950b88d
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 4 deletions.
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# pycharm filesgit
.idea/

# vs-code files
.vscode/

# jupyter notebook caches
.ipynb_checkpoints/

# mac stores
.DS_Store

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
14 changes: 10 additions & 4 deletions plot_utils/draw_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def draw_node(axes, pos, node_radius,


def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white', fgcolor='black', line_color='auto',
layout_type=None):
layout_type=None, node_labels=None, top=1, right=1):
"""
Draw a graph. Currently supported graph types are DAG and PAG. Matplotlib is used as a backend.
:param graph: the graph to be plotted
Expand All @@ -168,18 +168,24 @@ def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white',
:param fgcolor: foreground color of the node
:param line_color: color of the node contour and text
:param layout_type: type of node position layout: 'circular' or 'force' (default; force-directed algorithm)
:param node_labels: a mapping from node ID's to desired labels in the rendered graph.
:return:
"""
assert isinstance(graph, (DAG, PAG))
if selection_nodes is None:
selection_nodes = set()
if latent_nodes is None:
latent_nodes = set()
if node_labels is None:
node_labels = {}
for node in graph.nodes_set:
if node not in node_labels:
node_labels[node] = node

bottom = 0
top = 1
# top = 1
left = 0
right = 1
# right = 1
node_radius = 0.04
width = right - left
height = top - bottom
Expand Down Expand Up @@ -221,7 +227,7 @@ def draw_graph(graph, latent_nodes=None, selection_nodes=None, bkcolor='white',
contour = 'circle'
fg = fgcolor
bk = bkcolor
draw_node(ax, nodes_pos[node], node_radius=node_radius, node_name=str(node), contour=contour,
draw_node(ax, nodes_pos[node], node_radius=node_radius, node_name=node_labels[node], contour=contour,
line_color=fgcolor, fill_color=bk, text_color=fg)

if isinstance(graph, PAG):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[metadata]
name = causality_lab
version = 0.0.0
author = Intel Labs
description = Research code of novel causal discovery algorithms developed at Intel Labs.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/IntelLabs/causality-lab
keywords = AI, ML, causal discovery, causality
classifiers =
'License :: OSI Approved :: Apache License 2.0'
'Programming Language :: Python'
'Programming Language :: Python :: 3'
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.8'
'Programming Language :: Python :: 3.9'
'Programming Language :: Python :: 3.10'
'Programming Language :: Python :: Implementation :: CPython'
'Programming Language :: Python :: Implementation :: PyPy'

[options]
packages = find:
python_requires = >=3.7
install_requires = file: requirements.txt

[options.packages.find]
exclude =
unit_tests
imgs
notebooks
example_data

0 comments on commit 950b88d

Please sign in to comment.