ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 28 Jun 2023 18:16:59 +0200Doctest doesn't find new functionhttps://ask.sagemath.org/question/69581/doctest-doesnt-find-new-function/ I thought that I would fix gihub bug #22313 (Implement Euler Polynomials)
So I added a function (boiled down, the implementation here is obviously incorrect)
def euler_polynomial(x, n):
r"""
Compute the value of the ``n``-th Euler polynomial at ``x``.
TESTS::
sage: y=QQ['y'].gen()
sage: euler_polynomial(y, 0)
1
"""
return 1
Now if I run `./sage -t src/sage/combinat/combinat.py` I get
[...]
File "<doctest sage.combinat.combinat.euler_polynomial[1]>", line 1, in <module>
euler_polynomial(y, Integer(0))
^^^^^^^^^^^^^^^^
NameError: name 'euler_polynomial' is not defined
**********************************************************************
1 item had failures:
1 of 3 in sage.combinat.combinat.euler_polynomial
[462 tests, 1 failure, 2.38 s]
I am obviously doing something wrong, but am at a loss as to what. I have tried rebuilding sage.
Wed, 28 Jun 2023 17:59:25 +0200https://ask.sagemath.org/question/69581/doctest-doesnt-find-new-function/Answer by John Palmieri for <p>I thought that I would fix gihub bug #22313 (Implement Euler Polynomials)</p>
<p>So I added a function (boiled down, the implementation here is obviously incorrect)</p>
<pre><code>def euler_polynomial(x, n):
r"""
Compute the value of the ``n``-th Euler polynomial at ``x``.
TESTS::
sage: y=QQ['y'].gen()
sage: euler_polynomial(y, 0)
1
"""
return 1
</code></pre>
<p>Now if I run <code>./sage -t src/sage/combinat/combinat.py</code> I get</p>
<pre><code>[...]
File "<doctest sage.combinat.combinat.euler_polynomial[1]>", line 1, in <module>
euler_polynomial(y, Integer(0))
^^^^^^^^^^^^^^^^
NameError: name 'euler_polynomial' is not defined
**********************************************************************
1 item had failures:
1 of 3 in sage.combinat.combinat.euler_polynomial
[462 tests, 1 failure, 2.38 s]
</code></pre>
<p>I am obviously doing something wrong, but am at a loss as to what. I have tried rebuilding sage.</p>
https://ask.sagemath.org/question/69581/doctest-doesnt-find-new-function/?answer=69584#post-id-69584Functions are not automatically imported, so you need to add a line to the doctest:
TESTS::
sage: from sage.combinat.combinat import euler_polynomial
sage: y = QQ['y'].gen()
...Wed, 28 Jun 2023 18:16:59 +0200https://ask.sagemath.org/question/69581/doctest-doesnt-find-new-function/?answer=69584#post-id-69584