-
Notifications
You must be signed in to change notification settings - Fork 62
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
Matplotlib drawer: fix bug #1437 and add tests #1438
Matplotlib drawer: fix bug #1437 and add tests #1438
Conversation
for more information, see https://pre-commit.ci
Already noticed that the CI is still not running... |
@alecandido I have the suspicion that they changed |
@scarrazza this is the only related change I've found in the last six months But maybe I should keep checking, I may have missed something. (I believe the workflow runner is not even open source, but GitHub docs are, so we can check those, at least) |
Ok, the problem is the qibo/.github/workflows/rules.yml Line 13 in 4f2314a
This line is forcing a skip due to missing pushes (this PR was opened with a series of pushes already performed). We should add the "PR opened event" in the if condition too.
|
Correct, thanks for the investigation. In any case, even the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @scarrazza for spotting the CI problem and @sergiomtzlosa for the fix.
The lint is now fine. Anyway, there is a problem in the test code we added to the documentation. Please remove the %matplotlib inline
line from this example and ask me for a new review @sergiomtzlosa :)
…mtzlosa/qibo into matplotlib-circuit-drawer
thanks @alecandido @scarrazza for tune in the CI pipeline, I removed the line!! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1438 +/- ##
==========================================
+ Coverage 97.10% 99.94% +2.83%
==========================================
Files 81 81
Lines 11653 11708 +55
==========================================
+ Hits 11316 11701 +385
+ Misses 337 7 -330
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sergiomtzlosa for the fix!
Now we miss the tests. I would suggest to create a test_ui_mlpdrawings.py
file (or something like that) in which we test all the code of your contribution.
Some dummy tests will be enough to cover it.
A complete report of the covered lines is provided by codecov everytime a new commit is pushed here (see last lines in the checks list) :)
Let me know if you need some help in writing/defining the tests!
for more information, see https://pre-commit.ci
Hi, thanks @MatteoRobbiati , just a question, which version should I install to do the test? I had installed pytest and I get this errors on runing the tests:
Maybe codecov is not triggering.... |
During the meeting we agreed in setting up a bit more robust strategy to test the images. What is done so far is perfectly fine, but we just need to be sure the output of our plots is actually what we expect during the tests. For doing this, we can:
Alternatively, we can also think to use the Matplotlib testing tools. |
Good!!! I will start with the plot arrays comparison... |
Hi there! Do you need any help here? It would be ideal to fix this for the next review (friday). Let me know about the status/if help is needed @sergiomtzlosa. |
Hi @MatteoRobbiati , everything is done in the latest commit, please let me know if something is missing, you can launch CI indeed |
Hi @MatteoRobbiati , I am wondering why all test are correct , but the macos test fail or got cancelled, please can you gibe some light? Is the CI maybe crashing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @sergiomtzlosa! It sounds like what I had in mind. I was thinking if the PNG images are the best way to store the data, but I think this can work.
- PIL is used to test the assertions here, but I think it has to be added to the
pyproject.toml
and update the lock (we need to specify this package has to be installed when performing tests); - tests are failing on ios right now. It seems the arrays are not equivalent.. maybe we should consider to use some specific Matplotlib backend?
Sorry!! Missed it! Remember also to ask me for review once you are done with modifications :) |
Hi @MatteoRobbiati , now I have a big issue, I cannot fix this until the next week then I cannot finish this for friday, and i would ask for some help to get this on time otherwise i fix it next week, sorry! |
Testing exact equality pixel by pixel is definitely a hard constraint, so you should make sure there is no platform-dependent behavior in matplotlib as well (even driven by the environment, i.e. variables and packages available on a certain system). A different option could be generating the pictures directly in the CI, and caching them somewhere, separately for each platform, skipping the tests if they are not available. If you're able to debug the issue, and fix some env var to obtain the same result, so much the better. |
Finally, I could take some time and I changed the images by arrays in files for matching, so it is not needed to use PIL library, also I set the matplotlib backend and I hope this time all test are passing, otherwise I will go with the solutions you suggested @alecandido @MatteoRobbiati |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this effort @sergiomtzlosa, and again sorry not to have noticed this before.
Now everything sounds good to me. I re run the tests and everything is passing.
Thanks @alecandido @MatteoRobbiati , finally we made It! |
Checklist: