-
-
Notifications
You must be signed in to change notification settings - Fork 617
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
feat(doctest): SSIM metric doctest #2241
Conversation
c3a9ac7
to
d45a576
Compare
ignite/metrics/ssim.py
Outdated
metric = SSIM(data_range=1.0) | ||
metric.attach(engine, "ssim") | ||
>>> def process_function(engine, batch): | ||
... y_pred, y = batch |
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.
Can't it work with code-block ? I'm not a big fan of >>>
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.
It does not work AFAIK. If >>>
is not preferred, we need to use .. testcode::
and .. testoutput::
which is more verbose.
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.
With >>>
when code is copied it is with these useless >>>
. I think it would be better to use other tags instead of >>>
which requires each line modification.
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.
sphinx-copybutton can be modified to strip >>>
in conf.py
.
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.
I agree the @vfdev-5's remark about >>>
. Maybe we could explore an alternative and see ?
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.
@vfdev-5 @sdesrozis changed to using .. testcode::
and .. testoutput::
. If we are using those, we need to use print
to test the expected output.
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.
If we are using those, we need to use
Not sure to understand, sorry.
Does the rendering of the doc show the output ?
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.
I mean if we are using .. testcode::
and .. testoutput::
, we need to use print
like print(state.metrics['ssim'])
to test the expected output.
Does the rendering of the doc show the output ?
Yes, it shows.
d45a576
to
4406826
Compare
@ydcjeff I just would like to see the rendering and that’s fine on my side ! |
Or an alternative would be to mix
|
Each examples above are tested by What do you think ? Everything works fine though ! |
Mostly python doctest is used alongside with output. So it's better to show output as well maybe with "Output" section if we want. |
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.
@ydcjeff Thanks ! Now we can refactor every docstring example.
@vfdev-5 Is it fine for you with this PR ? |
@sdesrozis @ydcjeff I'm OK with this change however can you estimate how much work it would require to rework all doc strings and even if this is feasible for all doc strings ? Will we do a mix of tested and non-tested doc strings ? |
From the first glance, I think most examples can be tested, but I'm not sure for distributed ones. |
First of all, having the metrics and param schedulers tests in the doc validated would be great. Except for idist, I'm not sure we have that many tests distributed in the docstring. |
@sdesrozis @ydcjeff I let you open new tracking issue or update existing one to see clearly the task and how we can involve contributors to that. Sylvain, I let you guide this work and merge this PR or wait for something. Thanks! |
ref #2230
Description:
doctest_global_setup
Check list: