# Ticket #10340: trac_10340_error_msg.patch

File trac_10340_error_msg.patch, 3.5 KB (added by malb, 11 years ago)
• ## sage/rings/polynomial/pbori.pyx

```# HG changeset patch
# User Martin Albrecht <martinralbrecht@googlemail.com>
# Date 1290787554 0
# Node ID 22ffe975998711fec1272491c3c8cf5dcd40e7a1
# Parent  cc8a8137a48d9920e744c5a4accf46a151db04f1
fixing the error message if a boolean polynomial ring with zero variables is created (#10340)

diff -r cc8a8137a48d -r 22ffe9759987 sage/rings/polynomial/pbori.pyx```
 a sage: R Boolean PolynomialRing in x, y, z :: sage: p = x*y + x*z + y*z sage: x*p x*y*z + x*y + x*z :: sage: R.term_order() Lexicographic term order :: sage: R = BooleanPolynomialRing(5,'x',order='deglex(3),deglex(2)') sage: R.term_order() deglex(3),deglex(2) term order :: sage: R = BooleanPolynomialRing(3,'x',order='degrevlex') sage: R.term_order() Degree reverse lexicographic term order sage: R = BooleanPolynomialRing(0,'x',order='degrevlex') Traceback (most recent call last): ... ValueError: Number of variables must be greater than or equal to 1. TESTS:: sage: P. = BooleanPolynomialRing(2,order='degrevlex') sage: x > y True :: sage: P. = BooleanPolynomialRing(4,order='degrevlex(2),degrevlex(2)') sage: x0 > x1 True cdef Py_ssize_t i, j, bstart, bsize if names is None: raise TypeError, "You must specify the names of the variables." raise TypeError("You must specify the names of the variables.") if n is None: if PY_TYPE_CHECK(names, tuple) or PY_TYPE_CHECK(names, list): try: n = int(n) except TypeError, msg: raise TypeError, "Number of variables must be an integer" raise TypeError("Number of variables must be an integer") if n < 1: raise ValueError, "Number of variables must be greater than 1." raise ValueError("Number of variables must be greater than or equal to 1.") self.pbind = sage_malloc(n*sizeof(Py_ssize_t)) cdef char *_n try: pb_order_code = order_mapping[order[0].singular_str()] except KeyError: raise ValueError, "Only lex, deglex, degrevlex orders are supported." raise ValueError("Only lex, deglex, degrevlex orders are supported.") if len(order.blocks) > 1: if pb_order_code is pblp: raise ValueError, "Only deglex and degrevlex are supported for block orders." raise ValueError("Only deglex and degrevlex are supported for block orders.") elif pb_order_code is pbdlex: pb_order_code = pbblock_dlex elif pb_order_code is pbdp_asc: pb_order_code = pbblock_dp_asc for i in range(1, len(order.blocks)): if order[0] != order[i]: raise ValueError, "Each block must have the same order type (deglex or degrevlex) for block orderings." raise ValueError("Each block must have the same order type (deglex or degrevlex) for block orderings.") if (pb_order_code is pbdlex) or (pb_order_code is pblp) or \ (pb_order_code is pbblock_dlex):