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, 17 Mar 2021 19:23:57 +0100Testing the codehttps://ask.sagemath.org/question/56214/testing-the-code/I was told that one can use `sage -t namefile.py` to test some code.
When I used the code, I got the following thing that is not what I want
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
File "/usr/share/sagemath/bin/sage-runtests", line 178, in <module>
DC = DocTestController(options, args)
File "/usr/lib/python3/dist-packages/sage/doctest/control.py", line 358, in __init__
for pkg in list_packages('optional', local=True).values():
File "/usr/lib/python3/dist-packages/sage/misc/package.py", line 236, in list_packages
for p in os.listdir(SAGE_PKGS):
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/sagemath/build/pkgs'Blue skyWed, 17 Mar 2021 19:23:57 +0100https://ask.sagemath.org/question/56214/Test sage codehttps://ask.sagemath.org/question/55980/test-sage-code/Hi,
I want to test my code to see whether it is correct. I googled and I find out there is a code " sage -t/...py" I tried it for my windows and linux systems, but that does not work. Could you please explain to me what I should do? thanks in advance.Blue skyMon, 01 Mar 2021 15:42:09 +0100https://ask.sagemath.org/question/55980/make ptest fails after compilation based on Python3https://ask.sagemath.org/question/42924/make-ptest-fails-after-compilation-based-on-python3/I installed sagemath 8.3rc0 on my fedora 28 linux x86_64 system using the following commands:
make configure
./configure --prefix=$HOME/sage --with-python=3 --with-mp=gmp
make build
This seemed to have installed sage successfully but when I run tests with:
$ make ptest
I get the following errors and make ptest fails:
[manifolds] from Queue import Queue
[manifolds] ModuleNotFoundError: No module named 'Queue'
OSError: [manifolds] /home/user/sagemath/inst/lib/python3.6/site-packages/sage/manifolds/differentiable/curve.py:docstring of sage.manifolds.differentiable.curve.DifferentiableCurve:58: WARNING: Exception occurred in plotting curve-1
[dochtml] [manifolds] dumping object inventory... done
[dochtml] [manifolds] build succeeded.
[dochtml] [manifolds] The HTML pages are in ../inst/share/doc/sage/inventory/en/reference/manifolds.
[dochtml] Error building the documentation.
Error building Sage.
The following package(s) may have failed to build (not necessarily
during this run of 'make all-start'):
* documentation: dochtml
log file: /home/user/sagemath/src/logs/pkgs/../dochtml.log
The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run 'make' again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to 'yes' to prevent this.
make[1]: *** [Makefile:33: all-start] Error 1
make[1]: Leaving directory '/home/user/sagemath/src'
make: *** [Makefile:13: all] Error 2
I believe one of the `OSError` or the `dochtml` error is causing `make ptest` to fail. Can I get advice on how I can correct these problems?number123Wed, 11 Jul 2018 17:19:16 +0200https://ask.sagemath.org/question/42924/How to doctest an exception ?https://ask.sagemath.org/question/39306/how-to-doctest-an-exception/I'd like to doctest an exception, to show that some call is *expected* to fail (and, latter, to show how to cope with that). Something along the lines of:
sage: foo(x)
ValueError
... #Elided
ValueError: x is not palatable to foo
I haven't found any doctest directive allowing me to tell "This test is *expected* to raise an exception" ; so, when I run the doctest, I can't even compare what I get with the text of the expected traceback. The only solution I found so far is to wrap my test in a ```try:... except: ...``` construct, which is not very demonstrative.
Any idea ?Emmanuel CharpentierSat, 28 Oct 2017 13:24:29 +0200https://ask.sagemath.org/question/39306/howto get Sage doctest coverage statisticshttps://ask.sagemath.org/question/7568/howto-get-sage-doctest-coverage-statistics/How can a user get/see recent Sage doctest coverage statistics?
>
Thanks,
Jackjack77Mon, 12 May 2014 05:56:26 +0200https://ask.sagemath.org/question/7568/Running sage --testall in parallelhttps://ask.sagemath.org/question/10865/running-sage-testall-in-parallel/Hello there! After an install of sage from binaries (Fedora20), I ran `sage --testall`. However, it takes quite a lot of time (`3000s`). I have 4 processors and running this in parallel would shorten it significantly (and it should be easily possible to run the tests in parallel).
Therefore my question: **Can I run the tests in parallel? And how?**toheczSun, 29 Dec 2013 11:07:33 +0100https://ask.sagemath.org/question/10865/injecting names into global namespace doesn't work with doctesthttps://ask.sagemath.org/question/10423/injecting-names-into-global-namespace-doesnt-work-with-doctest/Here is a minimal example of the problem I am running into. I have a file "MyClass.py":
class MyClass(object):
def __init__(self,subscript):
self.subscript = subscript
def __repr__(self):
return "MyClass " + str(self.subscript)
def make_MyClass(n):
"""
Creates n MyClass instances and assigns them to to variables A0, ..., A(n-1).
Examples::
sage: make_MyClass(3)
sage: A0
MyClass 0
sage: A2
MyClass 2
sage: A1.subscript
1
"""
for i in range(n):
globals()["A" + str(i)] = MyClass(i)
If I doctest it, I get `NameError: name 'A0' is not defined`, but if I just load the file and type in the commands, it works how I want it to. It must be something about how globals() interacts with doctest.
I know it is possible to make this work, because for example the function var does something like this. I tried looking at the var.pyx source, but it looks like they are doing the same thing as me. (There is a comment about globals() being the reason that it had to be Cython. I tried making the example above a pyx, but that didn't seem to help.)paragonMon, 12 Aug 2013 17:39:10 +0200https://ask.sagemath.org/question/10423/Doctesting a cython filehttps://ask.sagemath.org/question/9601/doctesting-a-cython-file/Bonjour à tous,
I have a cython file stab.pyx, which uses a C file libstab.c, located in the same directory. Everything works fine with:
sage: load stab.pyx
Compiling ./stab.pyx...
and I can use classes, methods and so on defined in my file. It works fine too in notebook, I just need to give the full access path for loading (compiling) this file.
Today I had the strange idea of adding some documentation (wow) and doctests. Again the notebook displays my doc with nice formatting when I use the usual '?'. The problem is that I can't verify doctests with:
sage -t stab.pyx
Sage complains gcc fails because it does'nt find libstab.c. What's a simple way for automatic doctesting this file ?
Amitiés [JB]
BétrémaMon, 03 Dec 2012 15:03:26 +0100https://ask.sagemath.org/question/9601/