Skip to content

Commit

Permalink
Changing default node face color (#141)
Browse files Browse the repository at this point in the history
* changing default node face color

* updating images

* always upload images

* how about these images
  • Loading branch information
dfm committed Nov 9, 2021
1 parent 4a34cf1 commit 5cde6e0
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run: python -m pytest -v test

- uses: actions/upload-artifact@v2
if: always()
with:
path: ./result_images
name: images
Expand Down
27 changes: 23 additions & 4 deletions daft.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class PGM(object):
:param node_ec: (optional)
The default edge color for the nodes.
:param node_fc: (optional)
The default face color for the nodes.
:param plate_fc: (optional)
The default face color for plates.
:param directed: (optional)
Should the edges be directed by default?
Expand All @@ -80,6 +86,8 @@ def __init__(
alternate_style="inner",
line_width=1.0,
node_ec="k",
node_fc="w",
plate_fc="w",
directed=True,
aspect=1.0,
label_params=None,
Expand Down Expand Up @@ -108,6 +116,8 @@ def __init__(
alternate_style=alternate_style,
line_width=line_width,
node_ec=node_ec,
node_fc=node_fc,
plate_fc=plate_fc,
directed=directed,
aspect=aspect,
label_params=label_params,
Expand Down Expand Up @@ -643,8 +653,9 @@ def render(self, ctx):
plot_params, ctx.node_ec, "ec", "edgecolor"
)

fc_is_set = "fc" in plot_params or "facecolor" in plot_params
plot_params["fc"] = _pop_multiple(
plot_params, "none", "fc", "facecolor"
plot_params, ctx.node_fc, "fc", "facecolor"
)
fc = plot_params["fc"]

Expand Down Expand Up @@ -674,7 +685,7 @@ def render(self, ctx):
label_params.pop("verticalalignment", None)
label_params.pop("ma", None)

if plot_params["fc"] == "none":
if not fc_is_set:
plot_params["fc"] = "k"

diameter = ctx.node_unit * scale
Expand Down Expand Up @@ -736,7 +747,7 @@ def render(self, ctx):
plot_params["fc"] = fc

# Draw the foreground ellipse.
if style == "inner" and not self.fixed and self.observed:
if not fc_is_set and not self.fixed and self.observed:
plot_params["fc"] = "none"

if self.shape == "ellipse":
Expand Down Expand Up @@ -1104,7 +1115,7 @@ def render(self, ctx):

rect_params["ec"] = _pop_multiple(rect_params, "k", "ec", "edgecolor")
rect_params["fc"] = _pop_multiple(
rect_params, "none", "fc", "facecolor"
rect_params, ctx.plate_fc, "fc", "facecolor"
)
rect_params["lw"] = _pop_multiple(
rect_params, ctx.line_width, "lw", "linewidth"
Expand Down Expand Up @@ -1228,6 +1239,12 @@ class _rendering_context(object):
:param node_ec:
The default edge color for the nodes.
:param node_fc:
The default face color for the nodes.
:param plate_fc:
The default face color for plates.
:param directed:
Should the edges be directed by default?
Expand Down Expand Up @@ -1279,6 +1296,8 @@ def __init__(self, **kwargs):

self.node_unit = kwargs.get("node_unit", 1.0)
self.node_ec = kwargs.get("node_ec", "k")
self.node_fc = kwargs.get("node_fc", "w")
self.plate_fc = kwargs.get("plate_fc", "w")
self.directed = kwargs.get("directed", True)
self.aspect = kwargs.get("aspect", 1.0)
self.label_params = dict(kwargs.get("label_params", {}) or {})
Expand Down
Binary file modified test/baseline_images/test_examples/bca.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/classic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/deconvolution.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/exoplanets.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/fixed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/gaia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/galex.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/huey_p_newton.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/mrf.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/no_circles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/no_gray.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/recursive.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/thick_lines.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/weaklensing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline_images/test_examples/wordy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5cde6e0

Please sign in to comment.