-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
sage -fixdoctests
: Handle directory names, call sage -t
only once
#36024
sage -fixdoctests
: Handle directory names, call sage -t
only once
#36024
Conversation
I checked that handling directory works well against On the other hand, comparing the docs after fixing doctests with the docs before fixing, I have one concern. While we are here, let me explain. Now that we can replace many individual doctest line tags with block-scoped tags, it seems that needs tags are rather informative than visually cluttering. Hence we don't need to make efforts to hide needs tags anymore. See for instance So I suggest the following.
You may disagree with me. Certainly accepting my suggestions or not is not considered for review of this PR. |
I think making this change would be a premature step. I, of course, also consider the tags informative, but the burden for the few developers who already find the new tags informative -- having to scroll horizontally to get the full information -- is rather low. |
OK. I agree. |
if args.filename[0] == filename: | ||
print("sage-fixdoctests: When passing two filenames, the second one is taken as an output filename; " | ||
"this is deprecated. To pass two input filenames, use the option --overwrite.") | ||
return args.filename[1] |
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 get
$ sage -fixdoctests src/sage/rings/function_field/constructor.py output
Running "sage -t -p src/sage/rings/function_field/constructor.py output"
ERROR: file or directory not found: output
sage-runtests: Skipping 'output' because it does not have one of the recognized file name extensions
too few successful tests, not using stored timings
Skipping 'output' because it does not have one of the recognized file name extensions
No fixes made in 'src/sage/rings/function_field/constructor.py'
Shouldn't I get the deprecation warning?
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 testing this case. I've made the necessary fixes.
Thanks. That works now. I get
See the line |
That comes from We can avoid that if we give |
I never use that option, what should we use? |
|
The default is 60, but adjusted by an actual timing on the local computer based the collected data. |
def _init_warn_long(self):
"""
Pick a suitable default for the ``--warn-long`` option if not specified.
It is desirable to have all tests (even ``# long`` ones)
finish in less than about 5 seconds. Longer tests typically
don't add coverage, they just make testing slow.
The default used here is 60 seconds on a modern computer. It
should eventually be lowered to 5 seconds, but its best to
boil the frog slowly.
The stored timings are used to adjust this limit according to
the machine running the tests.
EXAMPLES::
sage: from sage.doctest.control import DocTestDefaults, DocTestController
sage: DC = DocTestController(DocTestDefaults(), [])
sage: DC.options.warn_long = 5.0
sage: DC._init_warn_long()
sage: DC.options.warn_long # existing command-line options are not changed
5.00000000000000
"""
# default is -1.0
if self.options.warn_long >= 0: # Specified on the command line
return
try:
self.options.warn_long = 60.0 * self.second_on_modern_computer()
except RuntimeError as err:
if not sage.doctest.DOCTEST_MODE:
print(err) # No usable timing information
def second_on_modern_computer(self):
"""
Return the wall time equivalent of a second on a modern computer.
OUTPUT:
Float. The wall time on your computer that would be equivalent
to one second on a modern computer. Unless you have kick-ass
hardware this should always be >= 1.0. Raises a
``RuntimeError`` if there are no stored timings to use as
benchmark.
EXAMPLES::
sage: from sage.doctest.control import DocTestDefaults, DocTestController
sage: DC = DocTestController(DocTestDefaults(), [])
sage: DC.second_on_modern_computer() # not tested
"""
if len(self.stats) == 0:
raise RuntimeError('no stored timings available')
success = []
failed = []
for mod in self.stats.values():
if mod.get('failed', False):
failed.append(mod['walltime'])
else:
success.append(mod['walltime'])
if len(success) < 2500:
raise RuntimeError('too few successful tests, not using stored timings')
if len(failed) > 20:
raise RuntimeError('too many failed tests, not using stored timings')
expected = 12800.0 # Core i7 Quad-Core 2014
return sum(success) / expected |
I don't understand the reasoning in |
Thanks. This simple fix seems to do the trick |
I never looked into this before, but I just did. The data is stored in For my case, it happens to contain too few timings, so I get the If I had run say |
I don't know what is a "right" fix. Your fix basically sets |
I get
The same message twice. |
The first one comes from |
OK then. This is a minor annoyance. Otherwise LGTM. |
Documentation preview for this PR (built with commit 2dccf18; changes) is ready! 🎉 |
Thank you! |
We change the handling of file name arguments in
sage -fixdoctests
: Instead of callingsage -t
on files one by one, we just pass them tosage -t
as a whole and then handle its output for all files. This is much faster because of the startup overhead ofsage -t
, and also adds the handling of directory names.Cherry-picked from
Part of
📝 Checklist
⌛ Dependencies