Module: sage.structure.sage_object
Module-level Functions
obj) |
dumps(obj):
Dump obj to a string s. To recover obj, use loads(s).
filename) |
load(filename):
Load sage object from the file with name filename, which will have an .sobj extension added if it doesn't have one.
s) |
Recover an object x that has been dumped to a string s using s = dumps(x).
obj, filename=None) |
save(obj, filename=None):
Save obj to the file with name filename, which will have an .sobj extension added if it doesn't have one. This will emphreplace the contents of filename.
Class: SageObject
Functions: category,
db,
dump,
dumps,
Hom,
rename,
reset_name,
save,
version
self, name) |
Dumps self into the SAGE database. Use db(name) by itself to reload.
The database directory is $HOME/.sage/db
self, filename) |
Same as self.save(filename)
self) |
Dump self to a string s, which can later be reconstituted as self using loads(s).
self, codomain, cat=None) |
self.Hom(codomain, cat=None):
Return the homspace Hom(self, codomain, cat)
of all
homomorphisms from self to codomain in the category cat. The
default category is self.category()
.
sage: R, (x,y) = PolynomialRing(Q, 2, 'xy').objgens() sage: R.Hom(Q) Set of Homomorphisms from Polynomial Ring in x, y over Rational Field to Rational Field
Homspaces are defined for very general SAGE objects, even elements of familiar rings.
sage: n = 5; n.Hom(7) Set of Morphisms from 5 to 7 in Category of elements of Integer Ring sage: z=(2/3); z.Hom(8/1) Set of Morphisms from 2/3 to 8 in Category of elements of Rational Field
This example illustrates the optional third argument:
sage: QQ.Hom(ZZ, Sets()) Set of Morphisms from Rational Field to Integer Ring in Category of sets
self, x=None) |
Change self so it prints as x, where x is a string.
Note: This is only supported for Python classes that derive from SageObject.
sage: x = PolynomialRing(QQ,'x').gen() sage: g = x^3 + x - 5 sage: g x^3 + x - 5 sage: g.rename('a polynomial') sage: g a polynomial sage: g + x x^3 + 2*x - 5 sage: h = g^100 sage: str(h)[:20] 'x^300 + 100*x^298 - ' sage: h.rename('x^300 + ...') sage: h x^300 + ...
Real numbers are not Python classes, so rename is not supported:
sage: a = 3.14 sage: type(a) <type 'mpfr.RealNumber'> sage: a.rename('pi') Traceback (most recent call last): ... NotImplementedError: object does not support renaming: 3.1400000000000001
Note: The reason C-extension types are not supported is if they were then every single one would have to carry around an extra attribute, which would be slower and waste a lot of memory.
self, filename=None) |
Save self to the given filename.
sage: f = x^3 + 5 sage: f.save('file') sage: load('file') x^3 + 5
self) |
The version of SAGE.
Call this to save the version of SAGE in this object. If you then save and load this object it will know in what version of SAGE it was created.
This only works on Python classes that derive from SageObject.
Special Functions: __contains__,
__repr__,
_gap_,
_gap_init_,
_gp_,
_gp_init_,
_interface_,
_interface_is_cached_,
_kash_,
_kash_init_,
_macaulay2_,
_macaulay2_init_,
_magma_,
_magma_init_,
_maple_,
_maple_init_,
_mathematica_,
_mathematica_init_,
_maxima_,
_maxima_init_,
_octave_,
_octave_init_,
_pari_,
_pari_init_,
_plot_,
_sage_,
_singular_,
_singular_init_
self, I) |
Return coercion of self to an object of the interface I.
The result of coercion is cached, unless self is not a C extension class or codeself._interface_is_cached_() returns False.
self) |
Return True if the interface objects are cached.
If you have an object x and do gp(x), the result is cached if this function returns True.
See About this document... for information on suggesting changes.