Skip to content
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

Fix doctests in src/sage/databases/oeis.py #36976

Merged
merged 3 commits into from
Jan 14, 2024

Conversation

dcoudert
Copy link
Contributor

Fixes #36966.

πŸ“ Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

βŒ› Dependencies

@dcoudert
Copy link
Contributor Author

When I run ./sage -t --long --optional=internet src/sage/databases/oeis.py, I still get the following errors that I'm not sure how to fix

File "src/sage/databases/oeis.py", line 1046, in sage.databases.oeis.OEISSequence.natural_object
Failed example:
    av = oeis('A087778'); av              # optional -- internet
Expected:
    A087778: Decimal expansion ... Avogadro...
Got:
    doctest:warning
      File "/Users/dcoudert/sage/src/bin/sage-runtests", line 163, in <module>
        err = DC.run()
      File "/Users/dcoudert/sage/src/sage/doctest/control.py", line 1540, in run
        self.run_doctests()
      File "/Users/dcoudert/sage/src/sage/doctest/control.py", line 1152, in run_doctests
        self.dispatcher.dispatch()
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 2104, in dispatch
        self.parallel_dispatch()
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1997, in parallel_dispatch
        w.start()  # This might take some time
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 2273, in start
        super().start()
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 121, in start
        self._popen = self._Popen(self)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
        return Popen(process_obj)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
        self._launch(process_obj)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
        code = process_obj._bootstrap(parent_sentinel=child_r)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
        self.run()
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 2245, in run
        task(self.options, self.outtmpfile, msgpipe, self.result_queue)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 2575, in __call__
        doctests, extras = self._run(runner, options, results)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 2627, in _run
        result = runner.run(test)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 908, in run
        return self._run(test, compileflags, out)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.oeis.OEISSequence.natural_object[9]>", line 1, in <module>
        av = oeis('A087778'); av              # optional -- internet
      File "/Users/dcoudert/sage/src/sage/repl/rich_output/display_manager.py", line 831, in displayhook
        plain_text, rich_output = self._rich_output_formatter(obj, dict())
      File "/Users/dcoudert/sage/src/sage/repl/rich_output/display_manager.py", line 654, in _rich_output_formatter
        plain_text = self._backend.plain_text_formatter(obj, **rich_repr_kwds)
      File "/Users/dcoudert/sage/src/sage/repl/rich_output/backend_base.py", line 328, in plain_text_formatter
        plain_text = self._apply_pretty_printer(SagePrettyPrinter, obj)
      File "/Users/dcoudert/sage/src/sage/repl/rich_output/backend_base.py", line 273, in _apply_pretty_printer
        printer.pretty(obj)
      File "/Users/dcoudert/sage/src/sage/repl/display/pretty_print.py", line 144, in pretty
        ok = representation(obj, self, cycle)
      File "/Users/dcoudert/sage/src/sage/repl/display/fancy_repr.py", line 273, in __call__
        output = repr(obj)
      File "/Users/dcoudert/sage/src/sage/databases/oeis.py", line 1303, in _repr_
        return "%s: %s" % (self.id(), self.name())
      File "/Users/dcoudert/sage/src/sage/databases/oeis.py", line 875, in name
        return self._field('N')[0]
      File "/Users/dcoudert/sage/src/sage/databases/oeis.py", line 745, in _field
        self.is_dead(warn_only=warn)
      File "/Users/dcoudert/sage/src/sage/databases/oeis.py", line 1144, in is_dead
        warn('This sequence is dead: "{}: {}"'.format(self.id(), self.name()), RuntimeWarning)
      File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/warnings.py", line 109, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    RuntimeWarning: This sequence is dead: "A087778: Decimal expansion of experimental Avogadro's constant (in mol^(-1))."
    A087778: Decimal expansion of experimental Avogadro's constant (in mol^(-1)).
**********************************************************************
File "src/sage/databases/oeis.py", line 1049, in sage.databases.oeis.OEISSequence.natural_object
Failed example:
    av.natural_object()                   # optional -- internet
Expected:
    6.022141000000000?e23
Got:
    [6, 0, 2, 2, 1, 4, 1]

@mantepse
Copy link
Collaborator

This should simply be replaced by oeis('A322578').

@@ -890,7 +891,7 @@ def old_IDs(self):
A000045: Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.

sage: f.old_IDs() # optional -- internet
('M0692', 'N0256')
('M0692', 'N0256'...)
Copy link
Collaborator

@mantepse mantepse Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is the correct fix. Rather, we should probably first strip of the date. For example, f._field("I") currently gives ['M0692 N0256 #2128 Dec 18 2023 00:21:04']. Unfortunately, this is not documented at https://oeis.org/eishelp1.html. Maybe we should ask? In any case, it seems quite clear that everything after the # should be ignored for our purposes.

(I don't know what the 2128 means. Experimentally, we always have #XXX MMM DD YYYY TT:TT:TT)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, we should ask.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent email to seqfan. I suspect that the number after the #-sign is the version number. In any case, we should strip it off, it appears that it is always there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ok with ed94024.

Copy link

Documentation preview for this PR (built with commit b798d69; changes) is ready! πŸŽ‰

Copy link
Collaborator

@mantepse mantepse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dcoudert
Copy link
Contributor Author

Thanks for the hints and the review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 2, 2024
    
Fixes sagemath#36966.

<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### πŸ“ Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### βŒ› Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36976
Reported by: David Coudert
Reviewer(s): David Coudert, Martin Rubey
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 5, 2024
    
Fixes sagemath#36966.

<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### πŸ“ Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### βŒ› Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36976
Reported by: David Coudert
Reviewer(s): David Coudert, Martin Rubey
@vbraun vbraun merged commit eee1416 into sagemath:develop Jan 14, 2024
22 of 23 checks passed
@mkoeppe mkoeppe added this to the sage-10.3 milestone Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple internet doc-test failing in oeis fields
4 participants