[x] Describe any tests you have conducted to confirm that your changes behave as expected.
Overview
This PR adds a variety of tests to the repo to ensure robustness. I tried to write tests that ensure that expected functionality behaves properly, as well as a smaller number of tests to handle invalid inputs. As part of this, I also reworked certain functionality that was bugged, which is a great demonstration of the importance of tests!
Changes
Don't rely on mcolors.is_color_like(), which returns True even for named color strings, e.g. white or sky blue. Instead, directly validate whether something is a HEX code using regex via the new _is_hex_code() function.
Use longest_name_length instead of longest_name where appropriate, since it's not the name itself that is returned, but instead the number of characters in the name.
More input validation for Gradient class.
Testing
All the tests I've written are passing right now. I feel like there's more input validation that could be added to a variety of methods. It would be great to have a second opinion for parts of the API that might not behave as a user would expect and to write tests/ input validation logic to handle those.
Questions
How should we test plotting functions, which live in plot.py?
How do we get GitHub Actions to run the tests? I think I can try to reverse engineer by looking at how it's implemented in ProteinCartography but my brain is too melted to do this today.
Next
Probably we'll want to add more tests and evaluate code coverage (would love Keith's help on this!), but I've run out of steam on writing tests. After this, I'll share a somewhat larger PR that implements a whole slew of utilities for matplotlib, including handling fonts, registering colors, updating the stylesheet, etc.
PR checklist
Overview
This PR adds a variety of tests to the repo to ensure robustness. I tried to write tests that ensure that expected functionality behaves properly, as well as a smaller number of tests to handle invalid inputs. As part of this, I also reworked certain functionality that was bugged, which is a great demonstration of the importance of tests!
Changes
mcolors.is_color_like()
, which returnsTrue
even for named color strings, e.g.white
orsky blue
. Instead, directly validate whether something is a HEX code using regex via the new_is_hex_code()
function.longest_name_length
instead oflongest_name
where appropriate, since it's not the name itself that is returned, but instead the number of characters in the name.Gradient
class.Testing
All the tests I've written are passing right now. I feel like there's more input validation that could be added to a variety of methods. It would be great to have a second opinion for parts of the API that might not behave as a user would expect and to write tests/ input validation logic to handle those.
Questions
plot.py
?ProteinCartography
but my brain is too melted to do this today.Next
Probably we'll want to add more tests and evaluate code coverage (would love Keith's help on this!), but I've run out of steam on writing tests. After this, I'll share a somewhat larger PR that implements a whole slew of utilities for
matplotlib
, including handling fonts, registering colors, updating the stylesheet, etc.