Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Changed warning message to leaner version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Apr 2, 2014
1 parent d91bfab commit 8e5fe42
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 116 deletions.
5 changes: 1 addition & 4 deletions src/doc/en/reference/coercion/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,10 @@ references to the domain. Such maps should only be used internally, and so a
copy should be used instead (unless one knows what one is doing)::

sage: QQ._internal_coerce_map_from(int)
(map internal to coercion system -- copy before use)
Native morphism:
From: Set of Python objects of type 'int'
To: Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: copy(QQ._internal_coerce_map_from(int))
Native morphism:
From: Set of Python objects of type 'int'
Expand Down
28 changes: 8 additions & 20 deletions src/sage/categories/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,24 +607,18 @@ def _generic_convert_map(self, S):
Defn: Composite map:
From: Integer Ring
To: Univariate Polynomial Ring in t over Integer Ring
Defn: Polynomial base injection morphism:
Defn: (map internal to coercion system -- copy before use)
Polynomial base injection morphism:
From: Integer Ring
To: Univariate Polynomial Ring in t over Integer Ring
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
then
Ring endomorphism of Univariate Polynomial Ring in t over Integer Ring
Defn: t |--> 2*t
then
Ring morphism:
(map internal to coercion system -- copy before use)
Ring morphism:
From: Univariate Polynomial Ring in t over Integer Ring
To: Univariate Polynomial Ring in t over Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: copy(H._generic_convert_map(f.parent())(f))
Composite map:
From: Integer Ring
Expand Down Expand Up @@ -694,25 +688,19 @@ def __call__(self, x=None, y=None, check=True, **options):
Defn: Composite map:
From: Symmetric group of order 4! as a permutation group
To: Symmetric group of order 6! as a permutation group
Defn: Call morphism:
Defn: (map internal to coercion system -- copy before use)
Call morphism:
From: Symmetric group of order 4! as a permutation group
To: Symmetric group of order 5! as a permutation group
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
then
Coercion morphism:
From: Symmetric group of order 5! as a permutation group
To: Symmetric group of order 6! as a permutation group
then
Call morphism:
(map internal to coercion system -- copy before use)
Call morphism:
From: Symmetric group of order 6! as a permutation group
To: Symmetric group of order 7! as a permutation group
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
Also note that making a copy of the resulting map will automatically
make strengthened copies of the composed maps::
Expand Down
14 changes: 4 additions & 10 deletions src/sage/categories/map.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,11 @@ cdef class Map(Element):
TESTS::
sage: Q = QuadraticField(-5)
sage: phi = CDF._internal_coerce_map_from(Q); phi # indirect doctest
sage: phi = CDF._internal_coerce_map_from(Q); phi
(map internal to coercion system -- copy before use)
Composite map:
From: Number Field in a with defining polynomial x^2 + 5
To: Complex Double Field
<BLANKLINE>
WARNING: This map has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: del Q
sage: import gc
sage: _ = gc.collect()
Expand All @@ -574,11 +571,8 @@ cdef class Map(Element):
if d != '':
s += "\n Defn: %s"%('\n '.join(d.split('\n')))
else:
d = """
WARNING: This map has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy."""
s += "\n%s"%('\n '.join(d.split('\n')))
d = "(map internal to coercion system -- copy before use)"
s = d + "\n" + s
return s

def _default_repr_(self):
Expand Down
17 changes: 4 additions & 13 deletions src/sage/categories/modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,9 +1729,7 @@ def section(self):
sage: phiinv(Y.basis()[1])
Traceback (most recent call last):
...
ValueError: B[1] is not in the image of Generic morphism:
From: X
To: Free module generated by {1, 2, 3, 4, 5} over Rational Field
ValueError: B[1] is not in the image
"""
if self._inverse is not None:
return self._inverse
Expand Down Expand Up @@ -1810,18 +1808,13 @@ def preimage(self, f):
sage: phi.preimage(y[1])
Traceback (most recent call last):
...
ValueError: B[1] is not in the image of Generic morphism:
From: X
To: Free module generated by {1, 2, 3, 4, 5} over Rational Field
ValueError: B[1] is not in the image
"""
F = self.domain()
G = self.codomain()
basis_map = self._on_basis
if not f in G:
# We make a copy of self in case self is an internal coercion morphism
# because we don't want the WARNING message to be displayed
from copy import copy
raise ValueError("f(={}) must be in the codomain of the morphism (={}) to have a preimage under the latter".format(f, copy(self)))
raise ValueError("f(={}) must be in the codomain of the morphism to have a preimage under the latter".format(f))

remainder = f

Expand All @@ -1834,9 +1827,7 @@ def preimage(self, f):
else:
j_preimage = self._inverse_on_support(j)
if j_preimage is None:
# Make a copy of self for the same reason as before
from copy import copy
raise ValueError("{} is not in the image of {}".format(f, copy(self)))
raise ValueError("{} is not in the image".format(f))
s = basis_map(j_preimage)
if not j == self._dominant_item(s)[0]:
raise ValueError("The morphism (={}) is not triangular at {}, and therefore a preimage cannot be computed".format(f, s))
Expand Down
12 changes: 3 additions & 9 deletions src/sage/categories/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,10 @@ cdef class Morphism(Map):
sage: K = CyclotomicField(12)
sage: L = CyclotomicField(132)
sage: phi = L._internal_coerce_map_from(K); phi
(map internal to coercion system -- copy before use)
Generic morphism:
From: Cyclotomic Field of order 12 and degree 4
To: Cyclotomic Field of order 132 and degree 40
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: del K
sage: import gc
Expand All @@ -105,11 +102,8 @@ cdef class Morphism(Map):
if d != '':
s += "\n Defn: " + '\n '.join(d.split('\n'))
else:
d = """
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy."""
s += "\n" + '\n '.join(d.split('\n'))
d = "(map internal to coercion system -- copy before use)"
s = d + "\n" + s
return s

def _default_repr_(self):
Expand Down
4 changes: 1 addition & 3 deletions src/sage/combinat/ncsym/dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,7 @@ def _set_par_to_par(self, A):
sage: h(w[[1,3],[2]])
Traceback (most recent call last):
...
ValueError: w{{1, 3}, {2}} is not in the image of Generic morphism:
From: Symmetric Functions over Rational Field in the homogeneous basis
To: Dual symmetric functions in non-commuting variables over the Rational Field in the w basis
ValueError: w{{1, 3}, {2}} is not in the image
sage: h(w(h[2,1])) == w(h[2,1]).to_symmetric_function()
True
"""
Expand Down
16 changes: 4 additions & 12 deletions src/sage/combinat/sf/new_kschur.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ def retract(self, sym):
sage: KB.retract(s[2,1,1])
Traceback (most recent call last):
...
ValueError: s[2, 1, 1] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis also with t=1
To: Symmetric Functions over Rational Field in the Schur basis
ValueError: s[2, 1, 1] is not in the image
"""
s = self.ambient().schur()
ks = self.kschur()
Expand Down Expand Up @@ -606,9 +604,7 @@ def _mul_(self, other):
sage: ks(f)
Traceback (most recent call last):
...
ValueError: s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + (t+1)*s[4, 2] + (t+1)*s[5, 1] + t*s[6] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis
To: Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the Schur basis
ValueError: s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + (t+1)*s[4, 2] + (t+1)*s[5, 1] + t*s[6] is not in the image
sage: Sym = SymmetricFunctions(QQ)
sage: ks = Sym.kschur(3,1)
sage: f = ks[2]*ks[3,1]; f
Expand Down Expand Up @@ -714,9 +710,7 @@ def omega(self):
sage: ks[3,1,1].omega()
Traceback (most recent call last):
...
ValueError: t*s[2, 1, 1, 1] + s[3, 1, 1] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis
To: Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Schur basis
ValueError: t*s[2, 1, 1, 1] + s[3, 1, 1] is not in the image
"""
return self.parent()(self.lift().omega())

Expand Down Expand Up @@ -886,9 +880,7 @@ class kSchur(CombinatorialFreeModule):
sage: ks3(s([4]))
Traceback (most recent call last):
...
ValueError: s[4] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis
To: Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the Schur basis
ValueError: s[4] is not in the image
Note that the product of `k`-Schur functions is not guaranteed to be in the
space spanned by the `k`-Schurs. In general, we only have that a
Expand Down
8 changes: 2 additions & 6 deletions src/sage/combinat/sf/sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,7 @@ class function on the symmetric group where the elements
sage: ks(s[2,1,1])
Traceback (most recent call last):
...
ValueError: s[2, 1, 1] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis also with t=1
To: Symmetric Functions over Rational Field in the Schur basis
ValueError: s[2, 1, 1] is not in the image
The `k`-Schur functions are more generally defined with a parameter `t` and they are
a basis of the subspace spanned by the Hall-Littlewood ``Qp`` symmetric functions
Expand All @@ -613,9 +611,7 @@ class function on the symmetric group where the elements
sage: ks(ks[2,1]*ks[1,1])
Traceback (most recent call last):
...
ValueError: s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2] is not in the image of Generic morphism:
From: 3-bounded Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis
To: Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Schur basis
ValueError: s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2] is not in the image
sage: ks[2,1]*ks[1,1]
s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2]
sage: ks6 = Sym.kBoundedSubspace(6).kschur()
Expand Down
42 changes: 15 additions & 27 deletions src/sage/structure/coerce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1021,21 +1021,15 @@ cdef class CoercionModel_cache_maps(CoercionModel):
sage: f, g = cm.coercion_maps(ZZ['x'], QQ)
sage: print f
(map internal to coercion system -- copy before use)
Ring morphism:
From: Univariate Polynomial Ring in x over Integer Ring
To: Univariate Polynomial Ring in x over Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: print g
(map internal to coercion system -- copy before use)
Polynomial base injection morphism:
From: Rational Field
To: Univariate Polynomial Ring in x over Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.
sage: cm.coercion_maps(QQ, GF(7)) == None
True
Expand All @@ -1051,23 +1045,15 @@ cdef class CoercionModel_cache_maps(CoercionModel):
False
sage: cm = sage.structure.element.get_coercion_model()
sage: cm.coercion_maps(V, W)
(None,
Call morphism:
(None, (map internal to coercion system -- copy before use)
Call morphism:
From: Vector space of dimension 3 over Rational Field
To: Vector space of dimension 3 over Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.)
To: Vector space of dimension 3 over Rational Field)
sage: cm.coercion_maps(W, V)
(None,
Call morphism:
(None, (map internal to coercion system -- copy before use)
Call morphism:
From: Vector space of dimension 3 over Rational Field
To: Vector space of dimension 3 over Rational Field
<BLANKLINE>
WARNING: This morphism has apparently been used internally
in the coercion system. It may become defunct in the next
garbage collection. Please use a copy.)
To: Vector space of dimension 3 over Rational Field)
sage: v = V([1,2,3])
sage: w = W([1,2,3])
sage: parent(v+w) is V
Expand Down Expand Up @@ -1187,9 +1173,10 @@ cdef class CoercionModel_cache_maps(CoercionModel):
If there is a coercion map either direction, use that::
sage: cm.discover_coercion(ZZ, QQ)
(Natural morphism:
((map internal to coercion system -- copy before use)
Natural morphism:
From: Integer Ring
To: Rational Field..., None)
To: Rational Field, None)
sage: cm.discover_coercion(RR, QQ)
(None,
Generic map:
Expand All @@ -1199,12 +1186,13 @@ cdef class CoercionModel_cache_maps(CoercionModel):
Otherwise, try and compute an appropriate cover::
sage: cm.discover_coercion(ZZ['x,y'], RDF)
(Call morphism:
((map internal to coercion system -- copy before use)
Call morphism:
From: Multivariate Polynomial Ring in x, y over Integer Ring
To: Multivariate Polynomial Ring in x, y over Real Double Field...,
To: Multivariate Polynomial Ring in x, y over Real Double Field,
Polynomial base injection morphism:
From: Real Double Field
To: Multivariate Polynomial Ring in x, y over Real Double Field...)
To: Multivariate Polynomial Ring in x, y over Real Double Field)
Sometimes there is a reasonable "cover," but no canonical coercion::
Expand Down
Loading

0 comments on commit 8e5fe42

Please sign in to comment.