Hi Bjarke!

On 28 Feb., 17:18, Bjarke Hammersholt Roune <bjarke.ro...@gmail.com>
wrote:
> Is it possible to write a test that runs over all polynomial ring over
> a field in Sage? This is as opposed to a test that works in a specific
> ring that the test constructs. Obviously there are infinitely many
> possible rings that can be constructed, so the test should run over
> some representative finite subset.

A test requires some computation that has an expected output: The
computation is done, and it is checked whether the output really is as
expected.

I see several possibilities for what you describe:

1. Choose some representative polynomial rings, ideals,..., and
compute the expected result. Then, in your tests, the input is fixed,
the expected output is known, so, it is easily tested.
2. Construct a ring/ideal/... randomly. Then, of course, you don't
know the output a priori.
   (a) Mark the test as "random". Then, the output of the random
computation is not checked.
   (b) Do consistency tests. E.g., if you know that two different
computations on the same input will always have the same result, then
test the equality.
Example:
  sage: R = PolynomialRing(QQ,'x',randint(1,5))
  sage: I = R*[t for t in R.gens() if randint(0,1)]
  sage: len((I^2).gens())==len(I.gens())^2
  True
So, you have a somewhat random example, and test a property that
should always hold.

The disadvantage of method 1. is that you need to fix the input data.
The advantage is that you have full control on the output.

The disadvantage  of 2.(a) is that this only tests whether there is an
error.

The disadvantage of 2.(b) is that it is more difficult to read for a
user -- mind that the test examples in the sage library are part of
the *documentation*.

Cheers
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to