-
Notifications
You must be signed in to change notification settings - Fork 101
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
stbt.FrameObject repr: Limit float property values to 3 decimal places #602
Conversation
cb05825
to
f068696
Compare
I tried solving this problem with numtest, but:
numtest's implementation is < 200 lines of code. It would be nice to implement this in pytest itself, so that you can enable it globally in pytest.ini instead of adding |
P.S. numtest only applies to doctests written manually; we'd still need something like this for the doctests generated by |
@wmanley what do you think of this idea? |
Note: Even if you do something like this in your FrameObject:
You can still get something like |
Otherwise doctest output of floating-point values might vary from run to run. 60 frames per second is 17ms per frame, so a 1ms precision should be enough for any measurements related to video-frames. For example we have been affected by this in a FrameObject that we use in our A/V sync tests, that has a property showing the lag or lead time from the audio to the corresponding video frame. We only apply this to properties that have "time" or "_secs" in the name, because we don't know what other use-cases people are using floating-point values for. If you need this, at least now you have the option of working "time" or "_secs" into your property name. This won't help properties that are lists of floats, etc. But it's a start.
f068696
to
e83a29a
Compare
I have implemented pytest-dev/pytest#5576 |
I don't think this is true. All the floating-point operations we perform should be deterministic. The real issue solved here is that doctest output varies between Python versions. |
I'm not going to merge this, it'll be too magical. Just the thought of having to document when it does & doesn't apply makes me think it's a bad idea. |
Otherwise doctest output of floating-point values might vary from run to
run.
60 frames per second is 17ms per frame, so a 1ms precision should be
enough for any measurements related to video-frames. For example we have
been affected by this in a FrameObject that we use in our A/V sync
tests, that has a property showing the lag or lead time from the audio
to the corresponding video frame.
We only apply this to properties that have "time" or "_secs" in the
name, because we don't know what other use-cases people are using
floating-point values for. If you need this, at least now you have the
option of working "time" or "_secs" into your property name.
This won't help properties that are lists of floats, etc. But it's a
start.