summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-11-08 22:45:44 +0100
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-11-08 22:45:44 +0100
commite2f192f483d51548cc4af460593172e1375a703d (patch)
tree02d22fe607a03044a9b611908a6e775810616e0a
parentMerge branch top_manif_basics without UniqueRepresentation into top_manif_sca... (diff)
Remove UniqueRepresentation, leaving only WithEqualityById, for scalar fields on topological manifolds
-rw-r--r--src/sage/manifolds/chart.py12
-rw-r--r--src/sage/manifolds/coord_func.py153
-rw-r--r--src/sage/manifolds/coord_func_symb.py129
-rw-r--r--src/sage/manifolds/manifold.py32
-rw-r--r--src/sage/manifolds/scalarfield.py212
-rw-r--r--src/sage/manifolds/scalarfield_algebra.py95
-rw-r--r--src/sage/manifolds/utilities.py8
7 files changed, 379 insertions, 262 deletions
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index e538800..a6ec6df 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -957,7 +957,7 @@ class Chart(WithEqualityById, SageObject):
A symbolic coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(sin(x*y))
sage: f
@@ -1002,7 +1002,7 @@ class Chart(WithEqualityById, SageObject):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: X.zero_function()
0
@@ -1018,7 +1018,7 @@ class Chart(WithEqualityById, SageObject):
Zero function on a p-adic manifold::
- sage: M = TopManifold(2, 'M', field=Qp(5)); M
+ sage: M = Manifold(2, 'M', type='topological', field=Qp(5)); M
2-dimensional topological manifold M over the 5-adic Field with
capped relative precision 20
sage: X.<x,y> = M.chart()
@@ -1056,7 +1056,7 @@ class Chart(WithEqualityById, SageObject):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: X.one_function()
1
@@ -1072,7 +1072,7 @@ class Chart(WithEqualityById, SageObject):
One function on a p-adic manifold::
- sage: M = TopManifold(2, 'M', field=Qp(5)); M
+ sage: M = Manifold(2, 'M', type='topological', field=Qp(5)); M
2-dimensional topological manifold M over the 5-adic Field with
capped relative precision 20
sage: X.<x,y> = M.chart()
@@ -1125,7 +1125,7 @@ class Chart(WithEqualityById, SageObject):
Function of two coordinates with values in `\RR^3`::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x+y, sin(x*y), x^2 + 3*y); f
Coordinate functions (x + y, sin(x*y), x^2 + 3*y) on the Chart (M, (x, y))
diff --git a/src/sage/manifolds/coord_func.py b/src/sage/manifolds/coord_func.py
index fc4def0..89551fb 100644
--- a/src/sage/manifolds/coord_func.py
+++ b/src/sage/manifolds/coord_func.py
@@ -69,7 +69,7 @@ class CoordFunction(SageObject):
TEST::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -92,7 +92,7 @@ class CoordFunction(SageObject):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(1+x+y^2)
sage: f.chart()
@@ -126,7 +126,7 @@ class CoordFunction(SageObject):
Construction of a scalar field on a 2-dimensional manifold::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: fc = c_xy.function(x+2*y^3)
sage: f = fc.scalar_field() ; f
@@ -157,7 +157,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -168,7 +168,7 @@ class CoordFunction(SageObject):
False
"""
- return not self.__eq__(other)
+ return not (self == other)
def __radd__(self, other):
r"""
@@ -185,7 +185,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -214,7 +214,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -243,7 +243,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -272,7 +272,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -301,7 +301,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -332,7 +332,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -361,7 +361,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -390,7 +390,7 @@ class CoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x*y)
@@ -417,7 +417,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -438,7 +438,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -459,7 +459,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -488,7 +488,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -521,7 +521,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -542,7 +542,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -567,7 +567,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -601,7 +601,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -630,12 +630,12 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
sage: g = CoordFunction(X)
- sage: f.__eq__(g)
+ sage: f == g
Traceback (most recent call last):
...
NotImplementedError: CoordFunction.__eq__ not implemented
@@ -656,7 +656,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -681,7 +681,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -711,7 +711,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -741,7 +741,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -771,7 +771,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -801,7 +801,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -831,7 +831,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -857,7 +857,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -889,7 +889,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -920,7 +920,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -947,7 +947,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -973,7 +973,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -999,7 +999,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1025,7 +1025,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1051,7 +1051,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1077,7 +1077,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1103,7 +1103,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1129,7 +1129,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1155,7 +1155,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1181,7 +1181,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1207,7 +1207,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1233,7 +1233,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1259,7 +1259,7 @@ class CoordFunction(SageObject):
This method must be implemented by derived classes; it is not
implemented here::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.coord_func import CoordFunction
sage: f = CoordFunction(X)
@@ -1309,7 +1309,7 @@ class MultiCoordFunction(SageObject):
A function `f: V\subset \RR^2 \longrightarrow \RR^3`::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x)*exp(y)); f
Coordinate functions (x - y, x*y, cos(x)*e^y) on the Chart (M, (x, y))
@@ -1373,7 +1373,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(3, 'M')
+ sage: M = Manifold(3, 'M', type='topological')
sage: X.<x,y,z> = M.chart()
sage: f = X.multifunction(x+y+z, x*y*z); f
Coordinate functions (x + y + z, x*y*z) on the Chart (M, (x, y, z))
@@ -1397,7 +1397,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x)*exp(y))
sage: f._repr_()
@@ -1415,7 +1415,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x)*exp(y))
sage: f._latex_()
@@ -1441,7 +1441,7 @@ class MultiCoordFunction(SageObject):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x)*exp(y))
sage: f.expr()
@@ -1467,7 +1467,7 @@ class MultiCoordFunction(SageObject):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x)*exp(y))
sage: f.chart()
@@ -1494,7 +1494,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x*y))
sage: f == X.multifunction(x-y, x*y)
@@ -1508,6 +1508,8 @@ class MultiCoordFunction(SageObject):
False
"""
+ if other is self:
+ return True
if not isinstance(other, MultiCoordFunction):
return False
if other._chart != self._chart:
@@ -1534,7 +1536,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x*y))
sage: f != X.multifunction(x-y, x*y)
@@ -1545,7 +1547,35 @@ class MultiCoordFunction(SageObject):
False
"""
- return not self.__eq__(other)
+ return not (self == other)
+
+ def _test_pickling(self, **options):
+ r"""
+ Test pickling.
+
+ This test is weaker than
+ :meth:`sage.structure.sage_object.SageObject._test_pickling` in that
+ it does not require ``loads(dumps(self)) == self``.
+ It however checks that ``loads(dumps(self))`` proceeds without any
+ error and results in an object that is a multi-coordinate function
+ of the same type as ``self`` and with the same coordinate expressions.
+
+ TEST::
+
+ sage: M = Manifold(2, 'M', type='topological')
+ sage: X.<x,y> = M.chart()
+ sage: f = X.multifunction(x-y, x*y, cos(x*y))
+ sage: f._test_pickling()
+
+ """
+ tester = self._tester(**options)
+ from sage.misc.all import loads, dumps
+ bckp = loads(dumps(self))
+ tester.assertEqual(type(bckp), type(self))
+ tester.assertEqual(bckp._nf, self._nf)
+ for i in range(self._nf):
+ tester.assertEqual(bckp._functions[i]._express,
+ self._functions[i]._express)
def __getitem__(self, index):
r"""
@@ -1561,7 +1591,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x*y))
sage: f.__getitem__(0)
@@ -1594,7 +1624,7 @@ class MultiCoordFunction(SageObject):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, cos(x*y))
sage: f.__call__(2,3)
@@ -1628,7 +1658,7 @@ class MultiCoordFunction(SageObject):
Jacobian of a set of 3 functions of 2 coordinates::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, y^3*cos(x))
sage: f.jacobian()
@@ -1648,7 +1678,7 @@ class MultiCoordFunction(SageObject):
Test with ``start_index=1``::
- sage: M = TopManifold(2, 'M', start_index=1)
+ sage: M = Manifold(2, 'M', type='topological', start_index=1)
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y, y^3*cos(x))
sage: f.jacobian()
@@ -1679,8 +1709,7 @@ class MultiCoordFunction(SageObject):
Jacobian determinant of a set of 2 functions of 2 coordinates::
- sage: M = TopManifold(3, 'M')
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.multifunction(x-y, x*y)
sage: f.jacobian_det()
@@ -1710,7 +1739,7 @@ class MultiCoordFunction(SageObject):
Jacobian determinant of a set of 3 functions of 3 coordinates::
- sage: M = TopManifold(3, 'M')
+ sage: M = Manifold(3, 'M', type='topological')
sage: X.<x,y,z> = M.chart()
sage: f = X.multifunction(x*y+z^2, z^2*x+y^2*z, (x*y*z)^3)
sage: f.jacobian_det().display()
diff --git a/src/sage/manifolds/coord_func_symb.py b/src/sage/manifolds/coord_func_symb.py
index 6463771..fe5c64c 100644
--- a/src/sage/manifolds/coord_func_symb.py
+++ b/src/sage/manifolds/coord_func_symb.py
@@ -74,7 +74,7 @@ class CoordFunctionSymb(CoordFunction):
A symbolic coordinate function associated with a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2+3*y+1)
sage: type(f)
@@ -270,7 +270,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate function on a real manifold::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(1+x*y); f
x*y + 1
@@ -280,7 +280,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate function on a complex manifold::
- sage: N = TopManifold(2, 'N', field='complex')
+ sage: N = Manifold(2, 'N', type='topological', field='complex')
sage: Y.<z,w> = N.chart()
sage: g = Y.function(i*z + 2*w); g
2*w + I*z
@@ -300,6 +300,31 @@ class CoordFunctionSymb(CoordFunction):
self._der = None # list of partial derivatives (to be set by diff()
# and unset by del_derived())
+ def _test_pickling(self, **options):
+ r"""
+ Test pickling.
+
+ This test is weaker than
+ :meth:`sage.structure.sage_object.SageObject._test_pickling` in that
+ it does not require ``loads(dumps(self)) == self``.
+ It however checks that ``loads(dumps(self))`` proceeds without any
+ error and results in an object that is a coordinate function with
+ the same coordinate expression as ``self``.
+
+ TEST::
+
+ sage: M = Manifold(2, 'M', type='topological')
+ sage: X.<x,y> = M.chart()
+ sage: f = X.function(1+x*y)
+ sage: f._test_pickling()
+
+ """
+ tester = self._tester(**options)
+ from sage.misc.all import loads, dumps
+ bckp = loads(dumps(self))
+ tester.assertEqual(type(bckp), type(self))
+ tester.assertEqual(bckp._express, self._express)
+
# -------------------------------------------------------------
# Methods to be implemented by derived classes of CoordFunction
# -------------------------------------------------------------
@@ -310,7 +335,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(1+x*y)
sage: f._repr_()
@@ -332,7 +357,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(cos(x*y/2))
sage: f._latex_()
@@ -357,7 +382,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate function on a 2-dimensional manifold::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(cos(x*y/2))
sage: f.display()
@@ -399,7 +424,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate function of a 2-dimensional manifold::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2+3*y+1)
sage: f.expr()
@@ -453,7 +478,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(sin(x*y))
sage: f.__call__(-2, 3)
@@ -492,7 +517,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate functions associated to a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2+3*y+1)
sage: f.is_zero()
@@ -522,7 +547,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = f.copy(); g
@@ -565,7 +590,7 @@ class CoordFunctionSymb(CoordFunction):
Partial derivatives of a 2-dimensional coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2+3*y+1); f
x^2 + 3*y + 1
@@ -588,7 +613,7 @@ class CoordFunctionSymb(CoordFunction):
The index range depends on the convention used on the chart's domain::
- sage: M = TopManifold(2, 'M', start_index=1)
+ sage: M = Manifold(2, 'M', type='topological', start_index=1)
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2+3*y+1)
sage: f.diff(0)
@@ -636,29 +661,29 @@ class CoordFunctionSymb(CoordFunction):
Coordinate functions associated to a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = X.function(x+y^2)
- sage: f.__eq__(g)
- True
sage: f == g
True
- sage: f.__eq__(1)
+ sage: f == 1
False
sage: h = X.function(1)
- sage: h.__eq__(1)
+ sage: h == 1
True
- sage: h.__eq__(f)
+ sage: h == f
False
- sage: h.__eq__(0)
+ sage: h == 0
False
- sage: X.function(0).__eq__(0)
+ sage: X.function(0) == 0
True
- sage: X.zero_function().__eq__(0)
+ sage: X.zero_function() == 0
True
"""
+ if other is self:
+ return True
if isinstance(other, CoordFunctionSymb):
if other._chart != self._chart:
return False
@@ -681,7 +706,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate functions associated to a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = +f; g
@@ -706,7 +731,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate functions associated to a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = -f; g
@@ -736,7 +761,7 @@ class CoordFunctionSymb(CoordFunction):
Coordinate functions associated to a 2-dimensional chart::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(1+x^2+y^2)
sage: g = f.__invert__(); g
@@ -770,7 +795,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = X.function(x+1)
@@ -824,7 +849,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y^2)
sage: g = X.function(x+1)
@@ -881,7 +906,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(x-y)
@@ -936,7 +961,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: g = X.function(1+x^2+y^2)
@@ -994,7 +1019,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: f.exp()
@@ -1026,7 +1051,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: f.log()
@@ -1059,7 +1084,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: f.__pow__(3)
@@ -1090,7 +1115,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x+y)
sage: f.sqrt()
@@ -1117,7 +1142,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.cos()
@@ -1144,7 +1169,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.sin()
@@ -1171,7 +1196,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.tan()
@@ -1198,7 +1223,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arccos()
@@ -1227,7 +1252,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arcsin()
@@ -1256,7 +1281,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arctan()
@@ -1285,7 +1310,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.cosh()
@@ -1312,7 +1337,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.sinh()
@@ -1339,7 +1364,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.tanh()
@@ -1366,7 +1391,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arccosh()
@@ -1395,7 +1420,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arcsinh()
@@ -1424,7 +1449,7 @@ class CoordFunctionSymb(CoordFunction):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x*y)
sage: f.arctanh()
@@ -1452,7 +1477,7 @@ class CoordFunctionSymb(CoordFunction):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(cos(x*y))
sage: f._der
@@ -1484,7 +1509,7 @@ class CoordFunctionSymb(CoordFunction):
Simplification of a 2-dimension coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(cos(x)^2+sin(x)^2 + sqrt(x^2))
sage: f.display()
@@ -1507,7 +1532,7 @@ class CoordFunctionSymb(CoordFunction):
Examples taking into account the declared range of a coordinate::
- sage: M = TopManifold(2, 'M_1')
+ sage: M = Manifold(2, 'M_1', type='topological')
sage: X.<x,y> = M.chart('x:(0,+oo) y')
sage: f = X.function(sqrt(x^2))
sage: f
@@ -1518,7 +1543,7 @@ class CoordFunctionSymb(CoordFunction):
::
sage: forget() # to clear the previous assumption on x
- sage: M = TopManifold(2, 'M_2')
+ sage: M = Manifold(2, 'M_2', type='topological')
sage: X.<x,y> = M.chart('x:(-oo,0) y')
sage: f = X.function(sqrt(x^2))
sage: f
@@ -1543,7 +1568,7 @@ class CoordFunctionSymb(CoordFunction):
Factorization of a 2-dimensional coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2 + 2*x*y + y^2)
sage: f.display()
@@ -1573,7 +1598,7 @@ class CoordFunctionSymb(CoordFunction):
Expanding a 2-dimensional coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function((x - y)^2)
sage: f.display()
@@ -1609,7 +1634,7 @@ class CoordFunctionSymb(CoordFunction):
Action on a 2-dimensional coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x^2*y + x*y + (x*y)^2)
sage: f.display()
@@ -1644,7 +1669,7 @@ class CoordFunctionSymb(CoordFunction):
Action on a 2-dimensional coordinate function::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = X.function(x/(x^2*y + x*y))
sage: f.display()
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 904f4e1..cc30d77 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -273,6 +273,25 @@ The following subsets and charts have been defined::
sage: M.atlas()
[Chart (U, (z,)), Chart (V, (w,)), Chart (A, (z,)), Chart (A, (w,))]
+A constant map `\CC^* \rightarrow \CC`::
+
+ sage: f = M.constant_scalar_field(3+2*I, name='f'); f
+ Scalar field f on the Complex 1-dimensional topological manifold C*
+ sage: f.display()
+ f: C* --> C
+ on U: z |--> 2*I + 3
+ on V: w |--> 2*I + 3
+ sage: f(O)
+ 2*I + 3
+ sage: f(i)
+ 2*I + 3
+ sage: f(inf)
+ 2*I + 3
+ sage: f.parent()
+ Algebra of scalar fields on the Complex 1-dimensional topological
+ manifold C*
+ sage: f.parent().category()
+ Category of commutative algebras over Symbolic Ring
AUTHORS:
@@ -1475,8 +1494,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
Scalar algebra of a 3-dimensional open subset::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(3, 'M')
+ sage: M = Manifold(3, 'M', type='topological')
sage: U = M.open_subset('U')
sage: CU = U.scalar_field_algebra() ; CU
Algebra of scalar fields on the Open subset U of the 3-dimensional topological manifold M
@@ -1534,8 +1552,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
A scalar field defined by its coordinate expression in the open
set's default chart::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(3, 'M')
+ sage: M = Manifold(3, 'M', type='topological')
sage: U = M.open_subset('U')
sage: c_xyz.<x,y,z> = U.chart()
sage: f = U.scalar_field(sin(x)*cos(y) + z, name='F'); f
@@ -1604,7 +1621,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
A constant scalar field on the 2-sphere::
- sage: M = TopManifold(2, 'M') # the 2-dimensional sphere S^2
+ sage: M = Manifold(2, 'M', type='topological') # the 2-dimensional sphere S^2
sage: U = M.open_subset('U') # complement of the North pole
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
sage: V = M.open_subset('V') # complement of the South pole
@@ -1651,8 +1668,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
EXAMPLE::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.zero_scalar_field() ; f
Scalar field zero on the 2-dimensional topological manifold M
@@ -1680,7 +1696,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.one_scalar_field(); f
Scalar field 1 on the 2-dimensional topological manifold M
diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py
index 388eb8a..e20a814 100644
--- a/src/sage/manifolds/scalarfield.py
+++ b/src/sage/manifolds/scalarfield.py
@@ -61,7 +61,7 @@ class ScalarField(CommutativeAlgebraElement):
- ``domain`` -- the topological manifold `M` on which the scalar field is
defined (must be an instance of class
- :class:`~sage.manifolds.manifold.TopManifold`)
+ :class:`~sage.manifolds.manifold.TopologicalManifold`)
- ``coord_expression`` -- (default: ``None``) coordinate expression(s) of
the scalar field; this can be either
@@ -90,7 +90,7 @@ class ScalarField(CommutativeAlgebraElement):
A scalar field on the 2-sphere::
- sage: M = TopManifold(2, 'M') # the 2-dimensional sphere S^2
+ sage: M = Manifold(2, 'M', type='topological') # the 2-dimensional sphere S^2
sage: U = M.open_subset('U') # complement of the North pole
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
sage: V = M.open_subset('V') # complement of the South pole
@@ -232,7 +232,7 @@ class ScalarField(CommutativeAlgebraElement):
on V: (u, v) |--> 2
A shortcut is to use the method
- :meth:`~sage.manifolds.manifold.TopManifold.constant_scalar_field`::
+ :meth:`~sage.manifolds.manifold.TopologicalManifold.constant_scalar_field`::
sage: c == M.constant_scalar_field(2)
True
@@ -258,7 +258,7 @@ class ScalarField(CommutativeAlgebraElement):
on V: (u, v) |--> 0
It can be obtained directly by means of the function
- :meth:`~sage.manifolds.manifold.TopManifold.zero_scalar_field`::
+ :meth:`~sage.manifolds.manifold.TopologicalManifold.zero_scalar_field`::
sage: zer is M.zero_scalar_field()
True
@@ -607,7 +607,7 @@ class ScalarField(CommutativeAlgebraElement):
TEST::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f') ; f
Scalar field f on the 2-dimensional topological manifold M
@@ -665,8 +665,7 @@ class ScalarField(CommutativeAlgebraElement):
Tests on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x*y)
sage: f.is_zero()
@@ -706,23 +705,25 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
- sage: f.__eq__(1)
+ sage: f == 1
False
- sage: f.__eq__(M.zero_scalar_field())
+ sage: f == M.zero_scalar_field()
False
sage: g = M.scalar_field({X: x+y})
- sage: f.__eq__(g)
+ sage: f == g
True
sage: h = M.scalar_field({X: 1})
- sage: h.__eq__(M.one_scalar_field())
+ sage: h == M.one_scalar_field()
True
- sage: h.__eq__(1)
+ sage: h == 1
True
"""
+ if other is self:
+ return True
if not isinstance(other, ScalarField):
# We try a conversion of other to a scalar field, except if
# other is None (since this would generate an undefined scalar
@@ -759,7 +760,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f.__ne__(1)
@@ -771,7 +772,7 @@ class ScalarField(CommutativeAlgebraElement):
False
"""
- return not self.__eq__(other)
+ return not (self == other)
def __cmp__(self, other):
r"""
@@ -781,7 +782,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f.__cmp__(1)
@@ -793,20 +794,44 @@ class ScalarField(CommutativeAlgebraElement):
0
"""
- if self.__eq__(other):
+ if self == other:
return 0
else:
return -1
####### End of required methods for an algebra element (beside arithmetic) #######
+ def _test_pickling(self, **options):
+ r"""
+ Test pickling.
+
+ This test is weaker than
+ :meth:`sage.structure.sage_object.SageObject._test_pickling` in that
+ it does not require ``loads(dumps(self)) == self``.
+ It however checks that ``loads(dumps(self))`` proceeds without any
+ error and results in an object that is a scalar field of the same type
+ as ``self``.
+
+ TEST::
+
+ sage: M = Manifold(2, 'M', type='topological')
+ sage: X.<x,y> = M.chart()
+ sage: f = M.scalar_field({X: x+y})
+ sage: f._test_pickling()
+
+ """
+ tester = self._tester(**options)
+ from sage.misc.all import loads, dumps
+ bckp = loads(dumps(self))
+ tester.assertEqual(type(bckp), type(self))
+
def _init_derived(self):
r"""
Initialize the derived quantities.
TEST::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f._init_derived()
@@ -821,7 +846,7 @@ class ScalarField(CommutativeAlgebraElement):
TEST::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: U = M.open_subset('U', coord_def={X: x>0})
@@ -845,7 +870,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f._repr_()
@@ -869,7 +894,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f._latex_()
@@ -903,7 +928,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y})
sage: f = M.scalar_field({X: x+y}); f
@@ -931,13 +956,13 @@ class ScalarField(CommutativeAlgebraElement):
OUTPUT:
- - instance of class :class:`~sage.manifolds.manifold.TopManifold`
+ - instance of class :class:`~sage.manifolds.manifold.TopologicalManifold`
representing the manifold's open subset on which the scalar field
is defined.
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x+2*y)
sage: f.domain()
@@ -958,8 +983,7 @@ class ScalarField(CommutativeAlgebraElement):
Copy on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x*y^2)
sage: g = f.copy()
@@ -973,8 +997,8 @@ class ScalarField(CommutativeAlgebraElement):
False
"""
- result = self.__class__(self._domain, name=self._name,
- latex_name=self._latex_name)
+ result = type(self)(self._domain, name=self._name,
+ latex_name=self._latex_name)
for chart, funct in self._express.iteritems():
result._express[chart] = funct.copy()
return result
@@ -1004,8 +1028,7 @@ class ScalarField(CommutativeAlgebraElement):
Coordinate function on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x*y^2)
sage: f.coord_function()
@@ -1032,8 +1055,7 @@ class ScalarField(CommutativeAlgebraElement):
Usage in a physical context (simple Lorentz transformation - boost in
x direction, with relative velocity v between o1 and o2 frames)::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: o1.<t,x> = M.chart()
sage: o2.<T,X> = M.chart()
sage: f = M.scalar_field(x^2 - t^2)
@@ -1099,7 +1121,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLE::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x*y^2)
sage: fc = f.function_chart()
@@ -1136,8 +1158,7 @@ class ScalarField(CommutativeAlgebraElement):
Expression of a scalar field on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x*y^2)
sage: f.expr()
@@ -1182,8 +1203,7 @@ class ScalarField(CommutativeAlgebraElement):
Setting scalar field expressions on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x^2 + 2*x*y +1)
sage: f._express
@@ -1231,8 +1251,7 @@ class ScalarField(CommutativeAlgebraElement):
Adding scalar field expressions on a 2-dimensional manifold::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(x^2 + 2*x*y +1)
sage: f._express
@@ -1273,7 +1292,7 @@ class ScalarField(CommutativeAlgebraElement):
Scalar field on the sphere `S^2`::
- sage: M = TopManifold(2, 'S^2')
+ sage: M = Manifold(2, 'S^2', type='topological')
sage: U = M.open_subset('U') ; V = M.open_subset('V') # the complement of resp. N pole and S pole
sage: M.declare_union(U,V) # S^2 is the union of U and V
sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() # stereographic coordinates
@@ -1343,8 +1362,7 @@ class ScalarField(CommutativeAlgebraElement):
Various displays::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: c_xy.<x,y> = M.chart()
sage: f = M.scalar_field(sqrt(x+1), name='f')
sage: f.display()
@@ -1436,7 +1454,7 @@ class ScalarField(CommutativeAlgebraElement):
INPUT:
- ``subdomain`` -- an open subset of the scalar field's domain (must
- be an instance of :class:`~sage.manifolds.manifold.TopManifold`)
+ be an instance of :class:`~sage.manifolds.manifold.TopologicalManifold`)
OUTPUT:
@@ -1448,7 +1466,7 @@ class ScalarField(CommutativeAlgebraElement):
Restriction of a scalar field defined on `\RR^2` to the unit open
disc::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart() # Cartesian coordinates
sage: U = M.open_subset('U', coord_def={X: x^2+y^2 < 1}) # U unit open disc
sage: f = M.scalar_field(cos(x*y), name='f')
@@ -1522,8 +1540,7 @@ class ScalarField(CommutativeAlgebraElement):
Search for common charts on a 2-dimensional manifold with 2
overlapping domains::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: U = M.open_subset('U')
sage: c_xy.<x,y> = U.chart()
sage: V = M.open_subset('V')
@@ -1646,7 +1663,7 @@ class ScalarField(CommutativeAlgebraElement):
INPUT:
- ``p`` -- point in the scalar field's domain (type:
- :class:`~sage.manifolds.point.TopManifoldPoint`)
+ :class:`~sage.manifolds.point.TopologicalManifoldPoint`)
- ``chart`` -- (default: ``None``) chart in which the coordinates of p
are to be considered; if none is provided, a chart in which both p's
coordinates and the expression of the scalar field are known is
@@ -1658,8 +1675,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: p = M((2,-5), name='p'); p
@@ -1736,7 +1752,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = f.__pos__(); g
@@ -1745,7 +1761,7 @@ class ScalarField(CommutativeAlgebraElement):
True
"""
- result = self.__class__(self._domain)
+ result = type(self)(self._domain)
for chart in self._express:
result._express[chart] = + self._express[chart]
if self._name is not None:
@@ -1764,8 +1780,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = f.__neg__(); g
@@ -1777,7 +1792,7 @@ class ScalarField(CommutativeAlgebraElement):
True
"""
- result = self.__class__(self._domain)
+ result = type(self)(self._domain)
for chart in self._express:
result._express[chart] = - self._express[chart]
if self._name is not None:
@@ -1804,7 +1819,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = M.scalar_field({X: x*y}, name='g')
@@ -1829,7 +1844,7 @@ class ScalarField(CommutativeAlgebraElement):
com_charts = self.common_charts(other)
if com_charts is None:
raise ValueError("no common chart for the addition")
- result = self.__class__(dom)
+ result = type(self)(dom)
for chart in com_charts:
# CoordFunction addition:
result._express[chart] = self._express[chart] + other._express[chart]
@@ -1856,7 +1871,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = M.scalar_field({X: x*y}, name='g')
@@ -1881,7 +1896,7 @@ class ScalarField(CommutativeAlgebraElement):
com_charts = self.common_charts(other)
if com_charts is None:
raise ValueError("no common chart for the subtraction")
- result = self.__class__(dom)
+ result = type(self)(dom)
for chart in com_charts:
# CoordFunction subtraction:
result._express[chart] = self._express[chart] - other._express[chart]
@@ -1909,7 +1924,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = M.scalar_field({X: x*y}, name='g')
@@ -1936,7 +1951,7 @@ class ScalarField(CommutativeAlgebraElement):
com_charts = self.common_charts(other)
if com_charts is None:
raise ValueError("no common chart for the multiplication")
- result = self.__class__(dom)
+ result = type(self)(dom)
for chart in com_charts:
# CoordFunction multiplication:
result._express[chart] = self._express[chart] * other._express[chart]
@@ -1960,7 +1975,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: g = M.scalar_field({X: x*y}, name='g')
@@ -1989,7 +2004,7 @@ class ScalarField(CommutativeAlgebraElement):
com_charts = self.common_charts(other)
if com_charts is None:
raise ValueError("no common chart for the division")
- result = self.__class__(dom)
+ result = type(self)(dom)
for chart in com_charts:
# CoordFunction division:
result._express[chart] = self._express[chart] / other._express[chart]
@@ -2018,7 +2033,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: s = f._rmul_(2); s
@@ -2041,7 +2056,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
if number == 0:
return self.parent().zero()
- result = self.__class__(self._domain)
+ result = type(self)(self._domain)
if isinstance(number, Expression):
var = number.variables() # possible symbolic variables in number
if var:
@@ -2105,7 +2120,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f')
sage: s = f._lmul_(2); s
@@ -2129,7 +2144,7 @@ class ScalarField(CommutativeAlgebraElement):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f', latex_name=r"\Phi")
sage: f._function_name("cos", r"\cos")
@@ -2165,8 +2180,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f', latex_name=r"\Phi")
sage: g = exp(f) ; g
@@ -2198,7 +2212,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("exp", r"\exp")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.exp()
return resu
@@ -2213,7 +2227,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f', latex_name=r"\Phi")
sage: g = log(f) ; g
@@ -2231,7 +2245,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("ln", r"\ln")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.log()
return resu
@@ -2251,7 +2265,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x+y}, name='f', latex_name=r'\Phi')
sage: g = f.__pow__(pi) ; g
@@ -2290,7 +2304,7 @@ class ScalarField(CommutativeAlgebraElement):
else:
latex_name = r"{" + self._latex_name + r"}^{" + \
latex(exponent) + r"}"
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.__pow__(exponent)
return resu
@@ -2305,7 +2319,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: 1+x^2+y^2}, name='f',
....: latex_name=r"\Phi")
@@ -2327,7 +2341,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("sqrt", r"\sqrt",
parentheses=False)
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.sqrt()
return resu
@@ -2342,7 +2356,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = cos(f) ; g
@@ -2362,7 +2376,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("cos", r"\cos")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.cos()
return resu
@@ -2377,7 +2391,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = sin(f) ; g
@@ -2397,7 +2411,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("sin", r"\sin")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.sin()
return resu
@@ -2412,7 +2426,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = tan(f) ; g
@@ -2434,7 +2448,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("tan", r"\tan")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.tan()
return resu
@@ -2449,7 +2463,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arccos(f) ; g
@@ -2478,7 +2492,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arccos", r"\arccos")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arccos()
return resu
@@ -2493,7 +2507,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arcsin(f) ; g
@@ -2522,7 +2536,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arcsin", r"\arcsin")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arcsin()
return resu
@@ -2537,7 +2551,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arctan(f) ; g
@@ -2566,7 +2580,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arctan", r"\arctan")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arctan()
return resu
@@ -2581,7 +2595,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = cosh(f) ; g
@@ -2599,7 +2613,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("cosh", r"\cosh")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.cosh()
return resu
@@ -2614,7 +2628,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = sinh(f) ; g
@@ -2632,7 +2646,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("sinh", r"\sinh")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.sinh()
return resu
@@ -2647,7 +2661,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = tanh(f) ; g
@@ -2667,7 +2681,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("tanh", r"\tanh")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.tanh()
return resu
@@ -2683,7 +2697,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arccosh(f) ; g
@@ -2710,7 +2724,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arccosh", r"\,\mathrm{arcosh}")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arccosh()
return resu
@@ -2726,7 +2740,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arcsinh(f) ; g
@@ -2753,7 +2767,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arcsinh", r"\,\mathrm{arsinh}")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arcsinh()
return resu
@@ -2769,7 +2783,7 @@ class ScalarField(CommutativeAlgebraElement):
EXAMPLES::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field({X: x*y}, name='f', latex_name=r"\Phi")
sage: g = arctanh(f) ; g
@@ -2798,7 +2812,7 @@ class ScalarField(CommutativeAlgebraElement):
"""
name, latex_name = self._function_name("arctanh", r"\,\mathrm{artanh}")
- resu = self.__class__(self._domain, name=name, latex_name=latex_name)
+ resu = type(self)(self._domain, name=name, latex_name=latex_name)
for chart, func in self._express.iteritems():
resu._express[chart] = func.arctanh()
return resu
diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py
index fb3efb9..4134848 100644
--- a/src/sage/manifolds/scalarfield_algebra.py
+++ b/src/sage/manifolds/scalarfield_algebra.py
@@ -32,14 +32,14 @@ REFERENCES:
#******************************************************************************
from sage.structure.parent import Parent
-from sage.structure.unique_representation import UniqueRepresentation
+from sage.misc.fast_methods import WithEqualityById
from sage.categories.commutative_algebras import CommutativeAlgebras
from sage.symbolic.ring import SR
from sage.rings.all import CC
from sage.rings.real_mpfr import RR
from sage.manifolds.scalarfield import ScalarField
-class ScalarFieldAlgebra(UniqueRepresentation, Parent):
+class ScalarFieldAlgebra(WithEqualityById, Parent):
r"""
Commutative algebra of scalar fields on a topological manifold.
@@ -63,14 +63,14 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
- ``domain`` -- the topological manifold `M` on which the scalar fields are
defined (must be an instance of class
- :class:`~sage.manifolds.manifold.TopManifold`)
+ :class:`~sage.manifolds.manifold.TopologicalManifold`)
EXAMPLES:
Algebras of scalar fields on the sphere `S^2` and on some open subsets of
it::
- sage: M = TopManifold(2, 'M') # the 2-dimensional sphere S^2
+ sage: M = Manifold(2, 'M', type='topological') # the 2-dimensional sphere S^2
sage: U = M.open_subset('U') # complement of the North pole
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
sage: V = M.open_subset('V') # complement of the South pole
@@ -183,7 +183,7 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
True
Elements can also be constructed by means of the method
- :meth:`~sage.manifolds.manifold.TopManifold.scalar_field` acting on
+ :meth:`~sage.manifolds.manifold.TopologicalManifold.scalar_field` acting on
the domain (this allows one to set the name of the scalar field at the
construction)::
@@ -374,13 +374,15 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: TopManifold._clear_cache_() # for doctests only
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
- sage: from sage.manifolds.scalarfield_algebra import ScalarFieldAlgebra
- sage: CM = ScalarFieldAlgebra(M); CM
+ sage: CM = M.scalar_field_algebra(); CM
Algebra of scalar fields on the 2-dimensional topological
manifold M
+ sage: type(CM)
+ <class 'sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra_with_category'>
+ sage: type(CM).__base__
+ <class 'sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra'>
sage: TestSuite(CM).run()
"""
@@ -432,34 +434,22 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: CM = M.scalar_field_algebra()
- sage: f = CM._element_constructor_(); f
- Scalar field on the 2-dimensional topological manifold M
- sage: f = CM._element_constructor_(coord_expression={X: x+y^2}); f
+ sage: f = CM({X: x+y^2}); f
Scalar field on the 2-dimensional topological manifold M
sage: f.display()
M --> R
(x, y) |--> y^2 + x
- sage: f = CM._element_constructor_(coord_expression={X: x+y^2},
- ....: name='f'); f
+ sage: f = CM({X: x+y^2}, name='f'); f
Scalar field f on the 2-dimensional topological manifold M
sage: f.display()
f: M --> R
(x, y) |--> y^2 + x
- sage: f1 = CM._element_constructor_(coord_expression=x+y^2,
- ....: chart=X, name='f'); f1
- Scalar field f on the 2-dimensional topological manifold M
- sage: f1 == f
- True
- sage: g = CM._element_constructor_(f); g
- Scalar field on the 2-dimensional topological manifold M
- sage: g == f
- True
sage: U = M.open_subset('U', coord_def={X: x>0})
sage: CU = U.scalar_field_algebra()
- sage: fU = CU._element_constructor_(f); fU
+ sage: fU = CU(f); fU
Scalar field on the Open subset U of the 2-dimensional topological
manifold M
sage: fU.display()
@@ -496,7 +486,7 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: CM = M.scalar_field_algebra()
sage: f = CM._an_element_(); f
@@ -516,7 +506,7 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
sage: CM = M.scalar_field_algebra()
sage: CM._coerce_map_from_(SR)
@@ -547,7 +537,7 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: CM = M.scalar_field_algebra()
sage: CM._repr_()
'Algebra of scalar fields on the 2-dimensional topological manifold M'
@@ -563,7 +553,7 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
TESTS::
- sage: M = TopManifold(2, 'M')
+ sage: M = Manifold(2, 'M', type='topological')
sage: CM = M.scalar_field_algebra()
sage: CM._latex_()
'C^0 \\left(M\\right)'
@@ -573,6 +563,49 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
"""
return r"C^0 \left(" + self._domain._latex_() + r"\right)"
+ def __reduce__(self):
+ r"""
+ Reduction function for the pickle protocole.
+
+ TEST::
+
+ sage: M = Manifold(3, 'M', type='topological')
+ sage: CM = M.scalar_field_algebra()
+ sage: CM.__reduce__()
+ (<class 'sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra'>,
+ (3-dimensional topological manifold M,))
+
+ Test of pickling::
+
+ sage: loads(dumps(CM))
+ Algebra of scalar fields on the 3-dimensional topological manifold M
+
+ """
+ return (ScalarFieldAlgebra, (self._domain,))
+
+ def _test_pickling(self, **options):
+ r"""
+ Test pickling.
+
+ This test is weaker than
+ :meth:`sage.structure.sage_object.SageObject._test_pickling` in that