Skip to content
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

elec.draw_wiring_graph() in REDD dataset #868

Closed
simplyoptimisticonly opened this issue Apr 6, 2020 · 2 comments
Closed

elec.draw_wiring_graph() in REDD dataset #868

simplyoptimisticonly opened this issue Apr 6, 2020 · 2 comments

Comments

@simplyoptimisticonly
Copy link


AttributeError Traceback (most recent call last)
in
----> 1 elec.draw_wiring_graph()

~.conda\envs\nilmtk-env\lib\site-packages\nilmtk\metergroup.py in draw_wiring_graph(self, show_meter_labels)
634 nx.draw(graph, pos, arrows=False)
635 else:
--> 636 nx.draw(graph, pos, labels=meter_labels, arrows=False)
637
638 ax = plt.gca()

~.conda\envs\nilmtk-env\lib\site-packages\networkx\drawing\nx_pylab.py in draw(G, pos, ax, **kwds)
124
125 try:
--> 126 draw_networkx(G, pos=pos, ax=ax, **kwds)
127 ax.set_axis_off()
128 plt.draw_if_interactive()

~.conda\envs\nilmtk-env\lib\site-packages\networkx\drawing\nx_pylab.py in draw_networkx(G, pos, arrows, with_labels, **kwds)
276
277 node_collection = draw_networkx_nodes(G, pos, **kwds)
--> 278 edge_collection = draw_networkx_edges(G, pos, arrows=arrows, **kwds)
279 if with_labels:
280 draw_networkx_labels(G, pos, **kwds)

~.conda\envs\nilmtk-env\lib\site-packages\networkx\drawing\nx_pylab.py in draw_networkx_edges(G, pos, edgelist, width, edge_color, style, alpha, arrowstyle, arrowsize, edge_cmap, edge_vmin, edge_vmax, ax, arrows, label, node_size, nodelist, node_shape, **kwds)
609 # value globally, since the user can instead provide per-edge alphas
610 # now. Only set it globally if provided as a scalar.
--> 611 if cb.is_numlike(alpha):
612 edge_collection.set_alpha(alpha)
613

AttributeError: module 'matplotlib.cbook' has no attribute 'is_numlike'

image

@PMeira
Copy link
Collaborator

PMeira commented Apr 6, 2020

That's an issue with matplotlib 3.2 and networkx. It seems the conda recipe for networkx is outdated/wrong. I prepared yet another package to restrict it on our side. You can try conda update -c nilmtk nilmtk in your NILMTK environment. All the basic example notebooks should run fine with this one.

There are also a couple more options. You could also manually downgrade matplotlib to 3.1.x, or just add the following code to provide the missing method that networkx expects and hope everything else works:

from numbers import Number
import matplotlib

if not hasattr(matplotlib.cbook, 'is_numlike'):
    # Monkey-patch matplotlib's cbook to make networkx work
    matplotlib.cbook.is_numlike = lambda x: isinstance(x, Number)

@PMeira PMeira closed this as completed Apr 6, 2020
@simplyoptimisticonly
Copy link
Author

Thanks again !!

Following worked for me and it resolved the wiring diagram issue.

>> You can try conda update -c nilmtk nilmtk in your NILMTK environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants