#15919: Notation S[i] for i-th element of enumerated set S conflicts with
notation
R[x] for polynomial ring
-----------------------+-------------------------------------------------
Reporter: darij | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.2
Component: algebra | Keywords: notation, algebra, polynomial
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
-----------------------+-------------------------------------------------
{{{
FF = IntegerModRing(29)
tester = FF._tester()
list(tester.some_elements(CartesianProduct(FF, FF, FF)))
}}}
This should give a list of 3-arrays of elements of Z/29. Instead I get:
{{{
sage: FF = IntegerModRing(29)
sage: tester = FF._tester()
sage: list(tester.some_elements(CartesianProduct(FF, FF, FF)))
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
<ipython-input-3-5d7e71a13340> in <module>()
----> 1 list(tester.some_elements(CartesianProduct(FF, FF, FF)))
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/misc/sage_unittest.pyc in some_elements(self, S)
498 if n > self._max_runs:
499 from random import sample
--> 500 S = sample(S, self._max_runs)
501 except (TypeError, AttributeError):
502 # We already can't tell what the length of n is, so
/home/darij/gitsage/sage-5.13.beta1/local/lib/python/random.pyc in
sample(self, population, k)
342 j = _int(random() * n)
343 selected_add(j)
--> 344 result[i] = population[j]
345 except (TypeError, KeyError): # handle (at least)
sets
346 if isinstance(population, list):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/combinat/combinat.pyc in __getitem__(self, i)
1220 ValueError: the value must be between 0 and 2
inclusive
1221 """
-> 1222 return self.unrank(i)
1223
1224 def __str__(self):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/combinat/cartesian_product.pyc in unrank(self, x)
258 raise IndexError("x larger than the size of the
Cartesian Product")
259 positions.reverse()
--> 260 return [L[i] for L,i in zip(self.iters, positions)]
261
262 def random_element(self):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent.so in
sage.structure.parent.Parent.__getitem__ (sage/structure/parent.c:11060)()
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/categories/rings.pyc in __getitem__(self, arg)
859
860 from sage.rings.polynomial.polynomial_ring_constructor
import PolynomialRing
--> 861 return PolynomialRing(self, elts)
862
863 class ElementMethods:
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in
PolynomialRing(base_ring, arg1, arg2, sparse, order, names, name,
var_array, implementation)
467 raise TypeError("if second arguments is a string
with no commas, then there must be no other non-optional arguments")
468 name = arg1
--> 469 R = _single_variate(base_ring, name, sparse,
implementation)
470 else:
471 # 2-4. PolynomialRing(base_ring, names,
order='degrevlex'):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in
_single_variate(base_ring, name, sparse, implementation)
518 def _single_variate(base_ring, name, sparse, implementation):
519 import sage.rings.polynomial.polynomial_ring as m
--> 520 name = normalize_names(1, name)
521 key = (base_ring, name, sparse, implementation if not sparse
else None)
522 R = _get_from_cache(key)
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent_gens.so in
sage.structure.parent_gens.normalize_names
(sage/structure/parent_gens.c:2759)()
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent_gens.so in
sage.structure.parent_gens._certify_names
(sage/structure/parent_gens.c:2322)()
ValueError: first letter of variable name must be a letter
}}}
And 29 is the smallest number where this seems to throw this error; also,
it doesn't fail if I only take the cartesian product of two copies of the
field.
I get a similar error if I do `CartesianProduct(FF, FF).unrank(3)`, and
this has been around for a while (not just since beta4):
{{{
sage: FF = IntegerModRing(3)
sage: CartesianProduct(FF, FF).unrank(3)
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
<ipython-input-15-98d0a571cc61> in <module>()
----> 1 CartesianProduct(FF, FF).unrank(Integer(3))
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/combinat/cartesian_product.pyc in unrank(self, x)
258 raise IndexError("x larger than the size of the
Cartesian Product")
259 positions.reverse()
--> 260 return [L[i] for L,i in zip(self.iters, positions)]
261
262 def random_element(self):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent.so in
sage.structure.parent.Parent.__getitem__ (sage/structure/parent.c:11060)()
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/categories/rings.pyc in __getitem__(self, arg)
859
860 from sage.rings.polynomial.polynomial_ring_constructor
import PolynomialRing
--> 861 return PolynomialRing(self, elts)
862
863 class ElementMethods:
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in
PolynomialRing(base_ring, arg1, arg2, sparse, order, names, name,
var_array, implementation)
467 raise TypeError("if second arguments is a string
with no commas, then there must be no other non-optional arguments")
468 name = arg1
--> 469 R = _single_variate(base_ring, name, sparse,
implementation)
470 else:
471 # 2-4. PolynomialRing(base_ring, names,
order='degrevlex'):
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/rings/polynomial/polynomial_ring_constructor.pyc in
_single_variate(base_ring, name, sparse, implementation)
518 def _single_variate(base_ring, name, sparse, implementation):
519 import sage.rings.polynomial.polynomial_ring as m
--> 520 name = normalize_names(1, name)
521 key = (base_ring, name, sparse, implementation if not sparse
else None)
522 R = _get_from_cache(key)
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent_gens.so in
sage.structure.parent_gens.normalize_names
(sage/structure/parent_gens.c:2759)()
/home/darij/gitsage/sage-5.13.beta1/local/lib/python2.7/site-
packages/sage/structure/parent_gens.so in
sage.structure.parent_gens._certify_names
(sage/structure/parent_gens.c:2322)()
ValueError: first letter of variable name must be a letter
}}}
So it seems that both bugs are due to the fancy `R[x]` syntax for
polynomial rings conflicting with the `R[i]` syntax for the i-th element
of an enumerated set `R`, and #8389 didn't cause the error, but at most
exposed it better.
--
Ticket URL: <http://trac.sagemath.org/ticket/15919>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.