summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-11-17 14:39:57 +0100
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-11-17 14:39:57 +0100
commita28ed04da7c51df3dce4b295f603d4e972312ce7 (patch)
treeafb292a1e1f660bc5fad2df8cfd8383ab008f1ae
parentRemove UniqueRepresentation, leaving only WithEqualityById, for topological m... (diff)
parentChange function('f', x) to function('f')(x) to accomodate the deprecation war... (diff)
Morphisms of topological manifolds with the use of base_field_type()
-rw-r--r--src/sage/manifolds/chart.py28
-rw-r--r--src/sage/manifolds/coord_func_symb.py11
-rw-r--r--src/sage/manifolds/manifold.py128
-rw-r--r--src/sage/manifolds/point.py3
-rw-r--r--src/sage/manifolds/scalarfield.py11
-rw-r--r--src/sage/manifolds/scalarfield_algebra.py4
-rw-r--r--src/sage/manifolds/subset.py70
-rw-r--r--src/sage/manifolds/utilities.py32
8 files changed, 223 insertions, 64 deletions
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index f47b3de..c81e1dd 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -37,8 +37,6 @@ REFERENCES:
from sage.structure.sage_object import SageObject
from sage.misc.fast_methods import WithEqualityById
from sage.symbolic.ring import SR
-from sage.rings.all import CC
-from sage.rings.real_mpfr import RR
from sage.rings.infinity import Infinity
from sage.misc.latex import latex
from sage.manifolds.manifold import TopologicalManifold
@@ -255,7 +253,8 @@ class Chart(WithEqualityById, SageObject):
if coordinates == '':
for x in names:
coordinates += x + ' '
- self._coordinate_string = coordinates[:-1] # for pickling (cf. __reduce__)
+ coordinates = coordinates[:-1]
+ self._coordinate_string = coordinates # for pickling (cf. __reduce__)
self._manifold = domain.manifold()
self._domain = domain
# Treatment of the coordinates:
@@ -270,6 +269,15 @@ class Chart(WithEqualityById, SageObject):
# _init_coordinates, which sets self._xx and
# which may be redefined for subclasses (for instance RealChart).
self._init_coordinates(coord_list)
+ coord_string = ''
+ for x in self._xx:
+ coord_string += str(x) + ' '
+ coord_string = coord_string[:-1]
+ if coord_string in self._domain._charts_by_coord:
+ raise ValueError("the chart with coordinates " + coord_string +
+ " has already been declared on " +
+ "the {}".format(self._domain))
+ self._domain._charts_by_coord[coord_string] = self
#
# Additional restrictions on the coordinates
self._restrictions = [] # to be set with method add_restrictions()
@@ -301,11 +309,12 @@ class Chart(WithEqualityById, SageObject):
# subsets of self._domain, with the
# subsets as keys
# The null and one functions of the coordinates:
- base_field = self._domain.base_field()
- if base_field in [RR, CC]:
+ base_field_type = self._domain.base_field_type()
+ if base_field_type in ['real', 'complex']:
self._zero_function = CoordFunctionSymb(self, 0)
self._one_function = CoordFunctionSymb(self, 1)
else:
+ base_field = self._domain.base_field()
self._zero_function = CoordFunctionSymb(self, base_field.zero())
self._one_function = CoordFunctionSymb(self, base_field.one())
# Expression in self of the zero and one scalar fields of open sets
@@ -2659,9 +2668,10 @@ class CoordChange(SageObject):
"charts)")
# New symbolic variables (different from x2 to allow for a
# correct solution even when chart2 = chart1):
- if self._chart1.domain().base_field() == RR:
+ base_field = self._chart1.domain().base_field_type()
+ if base_field == 'real':
coord_domain = ['real' for i in range(n2)]
- elif self._chart1.domain().base_field() == CC:
+ elif base_field == 'complex':
coord_domain = ['complex' for i in range(n2)]
else:
coord_domain = [None for i in range(n2)]
@@ -2683,7 +2693,7 @@ class CoordChange(SageObject):
for i in range(n1)]
for transf in x2_to_x1:
try:
- if self._domain.base_field() == RR:
+ if self._domain.base_field_type() == 'real':
transf = simplify_chain_real(transf)
else:
transf = simplify_chain_generic(transf)
@@ -2699,7 +2709,7 @@ class CoordChange(SageObject):
x2_to_x1 = [sol[x1[i]].subs(substitutions) for i in range(n1)]
for transf in x2_to_x1:
try:
- if self._domain.base_field() == RR:
+ if self._domain.base_field_type() == 'real':
transf = simplify_chain_real(transf)
else:
transf = simplify_chain_generic(transf)
diff --git a/src/sage/manifolds/coord_func_symb.py b/src/sage/manifolds/coord_func_symb.py
index fe5c64c..6872152 100644
--- a/src/sage/manifolds/coord_func_symb.py
+++ b/src/sage/manifolds/coord_func_symb.py
@@ -37,7 +37,6 @@ AUTHORS:
#*****************************************************************************
from sage.symbolic.ring import SR
-from sage.rings.real_mpfr import RR
from sage.structure.element import RingElement
from sage.misc.latex import latex
from sage.manifolds.coord_func import CoordFunction, MultiCoordFunction
@@ -109,7 +108,7 @@ class CoordFunctionSymb(CoordFunction):
An unspecified coordinate function::
- sage: g = X.function(function('G', x, y))
+ sage: g = X.function(function('G')(x, y))
sage: g
G(x, y)
sage: g.display()
@@ -186,7 +185,7 @@ class CoordFunctionSymb(CoordFunction):
Another difference regards the display of partial derivatives: for callable
symbolic functions, it relies on Pynac notation ``D[0]``, ``D[1]``, etc.::
- sage: g = function('g', x, y)
+ sage: g = function('g')(x, y)
sage: f0(x,y) = diff(g, x) + diff(g, y)
sage: f0
(x, y) |--> D[0](g)(x, y) + D[1](g)(x, y)
@@ -225,10 +224,10 @@ class CoordFunctionSymb(CoordFunction):
callable symbolic expression is the possibility to switch off the display
of the arguments of unspecified functions. Consider for instance::
- sage: f = X.function(function('u', x, y) * function('v', x, y))
+ sage: f = X.function(function('u')(x, y) * function('v')(x, y))
sage: f
u(x, y)*v(x, y)
- sage: f0(x,y) = function('u', x, y) * function('v', x, y)
+ sage: f0(x,y) = function('u')(x, y) * function('v')(x, y)
sage: f0
(x, y) |--> u(x, y)*v(x, y)
@@ -292,7 +291,7 @@ class CoordFunctionSymb(CoordFunction):
self._express = SR(expression) # symbolic expression enforced
# Definition of the simplification chain to be applied in
# symbolic calculus:
- if self._chart.manifold().base_field() == RR:
+ if self._chart.manifold().base_field_type() == 'real':
self._simplify = simplify_chain_real
else:
self._simplify = simplify_chain_generic
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 2ab96ec..5427c57 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -319,9 +319,10 @@ REFERENCES:
from sage.categories.fields import Fields
from sage.categories.manifolds import Manifolds
-from sage.rings.all import CC
-from sage.rings.real_mpfr import RR
from sage.categories.homset import Hom
+from sage.rings.all import CC
+from sage.rings.real_mpfr import RR, RealField_class
+from sage.rings.complex_field import ComplexField_class
from sage.manifolds.subset import TopologicalManifoldSubset
from sage.manifolds.scalarfield_algebra import ScalarFieldAlgebra
@@ -349,8 +350,10 @@ class TopologicalManifold(TopologicalManifoldSubset):
- ``field`` -- (default: ``'real'``) field `K` on which the manifold is
defined; allowed values are
- - ``'real'`` or ``RR`` for a manifold over `\RR`
- - ``'complex'`` or ``CC`` for a manifold over `\CC`
+ - ``'real'`` or an object of type ``RealField`` (e.g. ``RR``) for a
+ manifold over `\RR`
+ - ``'complex'`` or an object of type ``ComplexField`` (e.g. ``CC``) for
+ a manifold over `\CC`
- an object in the category of topological fields (see
:class:`~sage.categories.fields.Fields` and
:class:`~sage.categories.topological_spaces.TopologicalSpaces`)
@@ -494,12 +497,20 @@ class TopologicalManifold(TopologicalManifoldSubset):
self._dim = n
if field == 'real':
self._field = RR
+ self._field_type = 'real'
elif field == 'complex':
self._field = CC
+ self._field_type = 'complex'
else:
if field not in Fields():
raise TypeError("the argument 'field' must be a field")
self._field = field
+ if isinstance(field, RealField_class):
+ self._field_type = 'real'
+ elif isinstance(field, ComplexField_class):
+ self._field_type = 'complex'
+ else:
+ self._field_type = 'neither_real_nor_complex'
if not isinstance(start_index, (int, Integer)):
raise TypeError("the starting index must be an integer")
self._sindex = start_index
@@ -519,7 +530,11 @@ class TopologicalManifold(TopologicalManifoldSubset):
self._top_charts = [] # list of charts defined on subsets of self
# that are not subcharts of charts on larger subsets
self._def_chart = None # default chart
- self._coord_changes = {} # dictionary of transition maps
+ self._charts_by_coord = {} # dictionary of charts whose domain is self
+ # (key: string formed by the coordinate
+ # symbols separated by a white space)
+ self._coord_changes = {} # dictionary of transition maps (key: pair of
+ # of charts)
# List of charts that individually cover self, i.e. whose
# domains are self (if non-empty, self is a coordinate domain):
self._covering_charts = []
@@ -563,10 +578,10 @@ class TopologicalManifold(TopologicalManifoldSubset):
"""
if self._manifold is self:
- if self._field == RR:
+ if self._field_type == 'real':
return "{}-dimensional topological manifold {}".format(
self._dim, self._name)
- elif self._field == CC:
+ elif self._field_type == 'complex':
return "Complex {}-dimensional topological manifold {}".format(
self._dim, self._name)
return "{}-dimensional topological manifold {} over the {}".format(
@@ -700,7 +715,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
return self.element_class(self)
# Attempt to construct a point in the domain of the default chart
chart = self._def_chart
- if self._field == RR:
+ if self._field_type == 'real':
coords = []
for coord_range in chart._bounds:
xmin = coord_range[0][0]
@@ -720,7 +735,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
coords = self._dim*[0]
if not chart.valid_coordinates(*coords):
# Attempt to construct a point in the domain of other charts
- if self._field == RR:
+ if self._field_type == 'real':
for ch in self._atlas:
if ch is self._def_chart:
continue # since this case has already been attempted
@@ -831,7 +846,7 @@ class TopologicalManifold(TopologicalManifoldSubset):
def base_field(self):
r"""
- Return the field on which the manifolds is defined.
+ Return the field on which the manifold is defined.
OUTPUT:
@@ -852,6 +867,34 @@ class TopologicalManifold(TopologicalManifoldSubset):
"""
return self._field
+ def base_field_type(self):
+ r"""
+ Return the type of topological field on which the manifold is defined.
+
+ OUTPUT:
+
+ - a string describing the field, with three possible values:
+
+ - ``'real'`` for the real field `\RR`
+ - ``'complex'`` for the complex field `\CC`
+ - ``'neither_real_nor_complex'`` for a field different from `\RR` and
+ `\CC`
+
+ EXAMPLES::
+
+ sage: M = Manifold(3, 'M', type='topological')
+ sage: M.base_field_type()
+ 'real'
+ sage: M = Manifold(3, 'M', type='topological', field='complex')
+ sage: M.base_field_type()
+ 'complex'
+ sage: M = Manifold(3, 'M', type='topological', field=QQ)
+ sage: M.base_field_type()
+ 'neither_real_nor_complex'
+
+ """
+ return self._field_type
+
def start_index(self):
r"""
Return the first value of the index range used on the manifold.
@@ -1477,10 +1520,67 @@ class TopologicalManifold(TopologicalManifoldSubset):
"""
from sage.manifolds.chart import Chart, RealChart
- if self._field == RR:
+ if self._field_type == 'real':
return RealChart(self, coordinates=coordinates, names=names)
return Chart(self, coordinates=coordinates, names=names)
+ def get_chart(self, coordinates, domain=None):
+ r"""
+ Get a chart from its coordinates.
+
+ The chart must have been previously created by the method
+ :meth:`chart`.
+
+ INPUT:
+
+ - ``coordinates`` -- single string composed of the coordinate symbols
+ separated by a space
+ - ``domain`` -- (default: ``None``) string containing the name of the
+ chart's domain, which must be a subset of the current manifold; if
+ ``None``, the current manifold is assumed.
+
+ OUTPUT:
+
+ - instance of
+ :class:`~sage.manifolds.chart.Chart` (or of the subclass
+ :class:`~sage.manifolds.chart.RealChart`) representing the chart
+ corresponding to the above specifications.
+
+ EXAMPLES::
+
+ sage: M = Manifold(2, 'M', type='topological')
+ sage: X.<x,y> = M.chart()
+ sage: M.get_chart('x y')
+ Chart (M, (x, y))
+ sage: M.get_chart('x y') is X
+ True
+ sage: U = M.open_subset('U', coord_def={X: (y!=0,x<0)})
+ sage: Y.<r, ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi')
+ sage: M.atlas()
+ [Chart (M, (x, y)), Chart (U, (x, y)), Chart (U, (r, ph))]
+ sage: M.get_chart('x y', domain='U')
+ Chart (U, (x, y))
+ sage: M.get_chart('x y', domain='U') is X.restrict(U)
+ True
+ sage: U.get_chart('r ph')
+ Chart (U, (r, ph))
+ sage: M.get_chart('r ph', domain='U')
+ Chart (U, (r, ph))
+ sage: M.get_chart('r ph', domain='U') is Y
+ True
+
+ """
+ if domain is None:
+ dom = self
+ else:
+ dom = self.get_subset(domain)
+ try:
+ return dom._charts_by_coord[coordinates]
+ except KeyError:
+ raise KeyError("the coordinates '{}' ".format(coordinates) +
+ "do not correspond to any chart with " +
+ "the {} as domain".format(dom))
+
def scalar_field_algebra(self):
r"""
Return the algebra of scalar fields defined the manifold.
@@ -2023,8 +2123,10 @@ def Manifold(dim, name, latex_name=None, field='real', type='smooth',
- ``field`` -- (default: ``'real'``) field `K` on which the manifold is
defined; allowed values are
- - ``'real'`` or ``RR`` for a manifold over `\RR`
- - ``'complex'`` or ``CC`` for a manifold over `\CC`
+ - ``'real'`` or an object of type ``RealField`` (e.g. ``RR``) for a
+ manifold over `\RR`
+ - ``'complex'`` or an object of type ``ComplexField`` (e.g. ``CC``) for
+ a manifold over `\CC`
- an object in the category of topological fields (see
:class:`~sage.categories.fields.Fields` and
:class:`~sage.categories.topological_spaces.TopologicalSpaces`)
diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py
index a0dd94f..b3e7674 100644
--- a/src/sage/manifolds/point.py
+++ b/src/sage/manifolds/point.py
@@ -907,9 +907,8 @@ class TopologicalManifoldPoint(Element):
from sage.plot.text import text
from sage.plot.graphics import Graphics
from sage.plot.plot3d.shapes2 import point3d, text3d
- from sage.rings.real_mpfr import RR
from sage.manifolds.chart import Chart
- if self._manifold.base_field() != RR:
+ if self._manifold.base_field_type() != 'real':
raise NotImplementedError('plot of points on manifolds over ' +
'fields different from R is not implemented')
# The ambient chart:
diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py
index e20a814..e3b80eb 100644
--- a/src/sage/manifolds/scalarfield.py
+++ b/src/sage/manifolds/scalarfield.py
@@ -36,8 +36,6 @@ REFERENCES:
from sage.structure.element import CommutativeAlgebraElement
from sage.rings.integer import Integer
-from sage.rings.all import CC
-from sage.rings.real_mpfr import RR
from sage.symbolic.expression import Expression
from sage.manifolds.coord_func import CoordFunction
@@ -178,7 +176,7 @@ class ScalarField(CommutativeAlgebraElement):
A scalar field can also be defined by some unspecified function of the
coordinates::
- sage: h = U.scalar_field(function('H', x, y), name='h') ; h
+ sage: h = U.scalar_field(function('H')(x, y), name='h') ; h
Scalar field h on the Open subset U of the 2-dimensional topological
manifold M
sage: h.display()
@@ -1370,7 +1368,7 @@ class ScalarField(CommutativeAlgebraElement):
(x, y) |--> sqrt(x + 1)
sage: latex(f.display())
\begin{array}{llcl} f:& M & \longrightarrow & \mathbb{R} \\ & \left(x, y\right) & \longmapsto & \sqrt{x + 1} \end{array}
- sage: g = M.scalar_field(function('G', x, y), name='g')
+ sage: g = M.scalar_field(function('G')(x, y), name='g')
sage: g.display()
g: M --> R
(x, y) |--> G(x, y)
@@ -1412,10 +1410,11 @@ class ScalarField(CommutativeAlgebraElement):
# Name of the base field:
field = self._domain.base_field()
- if field == RR:
+ field_type = self._domain.base_field_type()
+ if field_type == 'real':
field_name = 'R'
field_latex_name = r'\mathbb{R}'
- elif field == CC:
+ elif field_type == 'complex':
field_name = 'C'
field_latex_name = r'\mathbb{C}'
else:
diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py
index 4134848..ebafc55 100644
--- a/src/sage/manifolds/scalarfield_algebra.py
+++ b/src/sage/manifolds/scalarfield_algebra.py
@@ -35,8 +35,6 @@ from sage.structure.parent import Parent
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(WithEqualityById, Parent):
@@ -387,7 +385,7 @@ class ScalarFieldAlgebra(WithEqualityById, Parent):
"""
base_field = domain.base_field()
- if base_field in [RR, CC]:
+ if domain.base_field_type() in ['real', 'complex']:
base_field = SR
Parent.__init__(self, base=base_field,
category=CommutativeAlgebras(base_field))
diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py
index 8df3d34..8eb231f 100644
--- a/src/sage/manifolds/subset.py
+++ b/src/sage/manifolds/subset.py
@@ -560,14 +560,15 @@ class TopologicalManifoldSubset(WithEqualityById, Parent):
- ``name`` -- name given to the subset
- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the
subset; if none is provided, it is set to ``name``
- - ``is_open`` -- (default: False) if ``True``, the created subset is
- assumed to be open with respect to the manifold's topology
+ - ``is_open`` -- (default: ``False``) if ``True``, the created subset
+ is assumed to be open with respect to the manifold's topology
OUTPUT:
- the subset, as an instance of :class:`TopologicalManifoldSubset`, or
- of the derived class :class:`TopologicalManifold` if ``is_open`` is
- ``True``.
+ of the derived class
+ :class:`~sage.manifolds.manifold.TopologicalManifold` if ``is_open``
+ is ``True``.
EXAMPLES:
@@ -595,13 +596,63 @@ class TopologicalManifoldSubset(WithEqualityById, Parent):
"""
if is_open:
return self.open_subset(name, latex_name=latex_name)
- res = TopologicalManifoldSubset(self._manifold, name, latex_name=latex_name)
+ res = TopologicalManifoldSubset(self._manifold, name,
+ latex_name=latex_name)
res._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(res)
self._top_subsets.add(res)
return res
+ def get_subset(self, name):
+ r"""
+ Get a subset by its name.
+
+ The subset must have been previously created by the method
+ :meth:`subset` (or
+ :meth:`~sage.manifolds.manifold.TopologicalManifold.open_subset`)
+
+ INPUT:
+
+ - ``name`` -- (string) name of the subset
+
+ OUTPUT:
+
+ - instance of :class:`TopologicalManifoldSubset` (or
+ of the derived class
+ :class:`~sage.manifolds.manifold.TopologicalManifold` for an open
+ subset) representing the subset whose name is ``name``.
+
+ EXAMPLES::
+
+ sage: M = Manifold(4, 'M', type='topological')
+ sage: A = M.subset('A')
+ sage: B = A.subset('B')
+ sage: U = M.open_subset('U')
+ sage: M.list_of_subsets()
+ [Subset A of the 4-dimensional topological manifold M,
+ Subset B of the 4-dimensional topological manifold M,
+ 4-dimensional topological manifold M,
+ Open subset U of the 4-dimensional topological manifold M]
+ sage: M.get_subset('A')
+ Subset A of the 4-dimensional topological manifold M
+ sage: M.get_subset('A') is A
+ True
+ sage: M.get_subset('B') is B
+ True
+ sage: A.get_subset('B') is B
+ True
+ sage: M.get_subset('U')
+ Open subset U of the 4-dimensional topological manifold M
+ sage: M.get_subset('U') is U
+ True
+
+ """
+ for ss in self._subsets:
+ if ss._name == name:
+ return ss
+ raise ValueError("no subset of name '{}' found".format(name))
+
def superset(self, name, latex_name=None, is_open=False):
r"""
Create a superset of the current subset.
@@ -614,14 +665,15 @@ class TopologicalManifoldSubset(WithEqualityById, Parent):
- ``name`` -- name given to the superset
- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the
superset; if none is provided, it is set to ``name``
- - ``is_open`` -- (default: False) if ``True``, the created subset is
- assumed to be open with respect to the manifold's topology
+ - ``is_open`` -- (default: ``False``) if ``True``, the created subset
+ is assumed to be open with respect to the manifold's topology
OUTPUT:
- the superset, as an instance of :class:`TopologicalManifoldSubset` or
- of the derived class :class:`TopologicalManifold` if ``is_open`` is
- ``True``.
+ of the derived class
+ :class:`~sage.manifolds.manifold.TopologicalManifold` if ``is_open``
+ is ``True``.
EXAMPLES:
diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py
index 3a98e6b..84c0ffb 100644
--- a/src/sage/manifolds/utilities.py
+++ b/src/sage/manifolds/utilities.py
@@ -427,9 +427,9 @@ class ExpressionNice(Expression):
sage: var('x y z')
(x, y, z)
- sage: f = function('f', x, y)
+ sage: f = function('f')(x, y)
sage: g = f.diff(y).diff(x)
- sage: h = function('h', y, z)
+ sage: h = function('h')(y, z)
sage: k = h.diff(z)
sage: fun = x*g + y*(k-z)^2
@@ -453,8 +453,8 @@ class ExpressionNice(Expression):
An example when function variables are themselves functions::
- sage: f = function('f', x, y)
- sage: g = function('g', x, f) # the second variable is the function f
+ sage: f = function('f')(x, y)
+ sage: g = function('g')(x, f) # the second variable is the function f
sage: fun = (g.diff(x))*x - x^2*f.diff(x,y)
sage: fun
-x^2*D[0, 1](f)(x, y) + (D[0](f)(x, y)*D[1](g)(x, f(x, y)) + D[0](g)(x, f(x, y)))*x
@@ -513,7 +513,7 @@ class ExpressionNice(Expression):
TESTS::
- sage: f = function('f', x)
+ sage: f = function('f')(x)
sage: df = f.diff(x)
sage: df
D[0](f)(x)
@@ -535,9 +535,9 @@ class ExpressionNice(Expression):
sage: var('x y z')
(x, y, z)
- sage: f = function('f', x, y)
+ sage: f = function('f')(x, y)
sage: g = f.diff(y).diff(x)
- sage: h = function('h', y, z)
+ sage: h = function('h')(y, z)
sage: k = h.diff(z)
sage: fun = x*g + y*(k-z)^2
sage: fun
@@ -614,9 +614,9 @@ class ExpressionNice(Expression):
sage: var('x y z')
(x, y, z)
- sage: f = function('f', x, y)
+ sage: f = function('f')(x, y)
sage: g = f.diff(y).diff(x)
- sage: h = function('h', y, z)
+ sage: h = function('h')(y, z)
sage: k = h.diff(z)
sage: fun = x*g + y*(k-z)^2
sage: fun
@@ -629,14 +629,14 @@ class ExpressionNice(Expression):
Testing the behavior if no latex_name of the function is given::
- sage: f = function('f_x', x, y)
+ sage: f = function('f_x')(x, y)
sage: fun = f.diff(y)
sage: latex(ExpressionNice(fun))
\frac{\partial\,f_{x}}{\partial y}
If latex_name, it should be used in LaTeX output:
- sage: f = function('f_x', x, y, latex_name=r"{\cal F}")
+ sage: f = function('f_x', latex_name=r"{\cal F}")(x,y)
sage: fun = f.diff(y)
sage: latex(ExpressionNice(fun))
\frac{\partial\,{\cal F}}{\partial y}
@@ -730,7 +730,7 @@ def _list_derivatives(ex, list_d, exponent=0):
TESTS::
- sage: f = function('f_x', x, latex_name=r"{\cal F}")
+ sage: f = function('f_x', latex_name=r"{\cal F}")(x)
sage: df = f.diff(x)^2
sage: from sage.manifolds.utilities import _list_derivatives
sage: list_d = []
@@ -793,8 +793,8 @@ def _list_functions(ex, list_f):
sage: var('x y z')
(x, y, z)
- sage: f = function('f', x, y, latex_name=r"{\cal F}")
- sage: g = function('g_x', x, y)
+ sage: f = function('f', latex_name=r"{\cal F}")(x, y)
+ sage: g = function('g_x')(x, y)
sage: d = sin(x)*g.diff(x)*x*f - x^2*f.diff(x,y)/g
sage: from sage.manifolds.utilities import _list_functions
sage: list_f = []
@@ -847,7 +847,7 @@ def nice_derivatives(status):
sage: M = Manifold(2, 'M', type='topological')
sage: X.<x,y> = M.chart()
- sage: g = function('g', x, y)
+ sage: g = function('g')(x, y)
sage: f = X.function(diff(g, x) + diff(g, y))
sage: f
d(g)/dx + d(g)/dy
@@ -891,7 +891,7 @@ def omit_function_args(status):
TESTS::
sage: from sage.manifolds.utilities import ExpressionNice
- sage: f = function('f_x', x)
+ sage: f = function('f_x')(x)
sage: f = f*(1 + f^2)
sage: ExpressionNice(f)
(f_x(x)^2 + 1)*f_x(x)