Repository navigation
Individualize drawing attributes - #7570
Conversation
|
So I've added some basic tests, but some of the tests in Do we need to add more tests for things like font weight, font color, etc? I've added a call using multiple font colors. |
|
The testing is intentionally weak for the drawing tools -- intentional in that we figured it is just a temporary stopgap tool and we'd get to better testing when we made it a real thing. Fast forward 18 years and we're at the point of needing/thinking about tests. The tests with no asserts were our "smoke-tests" to run the code and see if it started smoking or blowing up or something (syntax error). I would suggest that you add tests as much as you feel makes sense. It will help you keep track of which features are set up which way and how they might change. But don't worry about complete testing unless you think that helps your design work. The interface will change so the tests will need to change too. |
|
I've added a few basic tests, mostly form the examples I've included in the PR. I think these are enough to catch any breakage at least until #7589 lands, which has a much more robust set of tests. |
dschult
left a comment
There was a problem hiding this comment.
This looks good to me. Nice tests parametrization. Centralized handling of parameter presence. Thanks @mjschwenne
dschult
left a comment
There was a problem hiding this comment.
I'm going to merge this PR soon. We should exercise the code and see what breaks. The previous tests were not very complete.
| ) | ||
| # Convert to one element np.array if needed | ||
| if not isinstance(node_shape, np.ndarray) and not isinstance(node_shape, list): | ||
| node_shape = np.asarray([node_shape for _ in range(len(nodelist))]) |
There was a problem hiding this comment.
My understanding is that np.array converts the input to an array with a copy and np.asarray converts without a copy if it can. Here we input a list so they both create a new array. So the preferred form is np.array.
| node_shape = np.asarray([node_shape for _ in range(len(nodelist))]) | |
| node_shape = np.asarray([node_shape for _ in range(len(nodelist))]) |
There was a problem hiding this comment.
Hmm, interesting. I did not know this bit of numpy-fu.
* individualize parameters for draw_networkx_label * individualize parameters for draw_networkx_edge_labels * individualize parameters for draw_networkx_nodes * fix node drawing issues * individualize attributes for draw_networkx_edges * update documentation * add some basic tests * add font_color call * basic tests * switch asarray to array
A set of improvements to the existing visualization suite aimed to align the current functionality with what will be implemented after the refactor.
Some attributes can only have one value per visualization, such as node font color or arrow style for directed graphs, but if attributes are read from the graph, we should allow individual values for all of these.
While I haven't broken any of the existing tests, I'm not sure that I fully understand the testing infrastructure for the visualization module. Tests will need to be added, but I'm still working on it.
Below are some examples on the karate club graph.