# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1294788504 28800
# Node ID 9f650a053251fc954d2e6e26843c8e9a0795ead5
# Parent 3b5f79f2d47e5ec182180673a97a3e7bd4fdefb1
10595: vector constructor defaults to ZZ with empty list
diff r 3b5f79f2d47e r 9f650a053251 sage/modules/free_module_element.pyx
a

b


346  346  (1, 2, 3) 
347  347  sage: parent(v) 
348  348  Ambient free module of rank 3 over the principal ideal domain Integer Ring 
 349  
 350  Am empty list, without a ring given, will default to the integers. :: 
 351  
 352  sage: x = vector([]); x 
 353  () 
 354  sage: x.parent() 
 355  Ambient free module of rank 0 over the principal ideal domain Integer Ring 
349  356  """ 
350  357  if hasattr(arg0, '_vector_'): 
351  358  return arg0._vector_(arg1) 
… 
… 

448  455  the entries in the list. If ``R`` is given, the entries 
449  456  are coerced in. Otherwise a common ring is found. For 
450  457  more details, see the 
451   :class:`~sage.structure.sequence.Sequence` object. 
 458  :class:`~sage.structure.sequence.Sequence` object. When ``v`` 
 459  has no elements and ``R`` is ``None``, the ring returned is 
 460  the integers. 
452  461  
453  462  
454  463  EXAMPLES:: 
… 
… 

477  486  ... 
478  487  TypeError: unable to find a common ring for all elements 
479  488  
 489  This checks a bug listed at Trac #10595. Without good evidence for a ring, the default 
 490  is the integers. 
 491  
 492  sage: prepare([], None) 
 493  ([], Integer Ring) 
480  494  """ 
481  495  if isinstance(v, dict): 
482  496  # convert to a list 
… 
… 

485  499  X[key] = value 
486  500  v = X 
487  501  # convert to a Sequence over common ring 
 502  # default to ZZ on an empty list 
 503  if len(v) == 0 and R == None: 
 504  R = sage.rings.integer_ring.IntegerRing() 
488  505  v = Sequence(v, universe=R, use_sage_types=True) 
489  506  ring = v.universe() 
490  507  if not is_Ring(ring): 