Open flyaflya opened 2 years ago
Looks like this warning originates here (the line numbers have changed since the release):
https://github.com/daft-dev/daft/blob/75a4052a87514c328af21730bcbdf57e027acfbf/daft.py#L851
when the node shape is "rectangle"
and dx = 0
. This definitely seems like a bug and should be looked into!
In that case, I should mention that something similar occurs when using a horizontal edge from the rectangle as well:
pgm = daft.PGM(node_fc="aliceblue", dpi = 150, alternate_style="outer")
pgm.add_node("sb","Start\nBalance", 1, 4, aspect = 2.2, observed = True, plot_params = {'facecolor': 'cadetblue'})
pgm.add_node("ba","Bet\nAmount", 1, 3, aspect = 2.2, shape = "rectangle", plot_params = {'facecolor': 'thistle'})
pgm.add_node("w","Winnings", 2.7, 3, aspect = 2.2, alternate = True)
pgm.add_edge("sb", "ba")
pgm.add_edge("ba","w")
pgm.render()
yields:
/usr/local/lib/python3.7/dist-packages/daft.py:852: RuntimeWarning: divide by zero encountered in double_scalars
* (np.sign(dy) or 1.0)
/usr/local/lib/python3.7/dist-packages/daft.py:857: RuntimeWarning: divide by zero encountered in double_scalars
dxx2 = self.scale * 0.5 * np.abs(dx / dy) * (np.sign(dx) or 1.0)
<matplotlib.axes._axes.Axes at 0x7f220e0761d0>
Thanks for looking into it!!! I really like the package.👍
For the following code:
I get a runtime warning error message:
The graph renders just fine, but I am unsure whether I am doing something wrong or if the Warning should not really occur. Thanks!