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.
Can't it work with code-block ? I'm not a big fan of >>>
There was a problem hiding this comment.
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.
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.
sphinx-copybutton can be modified to strip >>> in conf.py.
There was a problem hiding this comment.
I agree the @vfdev-5's remark about >>>. Maybe we could explore an alternative and see ?
There was a problem hiding this comment.
@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.
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.
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. |
sdesrozis
left a comment
There was a problem hiding this comment.
@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_setupCheck list: