summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-10-02 00:11:11 +0200
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2015-10-02 00:11:11 +0200
commit9977194c487d29f8796b27d189260d384eaa80e4 (patch)
tree3a82ca6e8ab45df7fd116a985d469665a00f399d
parentImprovement in simplify_sqrt_real() and in the documentation. (diff)
Minor improvements in the doc of top manifolds (scalar fields part)
-rw-r--r--src/sage/manifolds/chart.py80
-rw-r--r--src/sage/manifolds/coord_func.py3
-rw-r--r--src/sage/manifolds/manifold.py108
-rw-r--r--src/sage/manifolds/point.py60
-rw-r--r--src/sage/manifolds/scalarfield.py243
-rw-r--r--src/sage/manifolds/scalarfield_algebra.py87
-rw-r--r--src/sage/manifolds/subset.py78
-rw-r--r--src/sage/manifolds/utilities.py31
8 files changed, 408 insertions, 282 deletions
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index bc1b8e7..15bd851 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -45,9 +45,9 @@ class Chart(UniqueRepresentation, SageObject):
Chart on a topological manifold.
Given a topological manifold `M` of dimension `n` over a topological field
- `K`, a *chart* is a pair `(U,\varphi)`, where `U` is an open subset of `M`
- and `\varphi: U \rightarrow V \subset K^n` is a homeomorphism from `U` to
- an open subset `V` of `K^n`.
+ `K`, a *chart* on `M` is a pair `(U,\varphi)`, where `U` is an open subset
+ of `M` and `\varphi: U \rightarrow V \subset K^n` is a homeomorphism from
+ `U` to an open subset `V` of `K^n`.
The components `(x^1,\ldots,x^n)` of `\varphi`, defined by
`\varphi(p) = (x^1(p),\ldots,x^n(p))\in K^n` for any point `p\in U`,
@@ -55,7 +55,8 @@ class Chart(UniqueRepresentation, SageObject):
INPUT:
- - ``domain`` -- open subset `U` on which the chart is defined
+ - ``domain`` -- open subset `U` on which the chart is defined (must be
+ an instance of :class:`~sage.manifolds.manifold.TopManifold`)
- ``coordinates`` -- (default: '' (empty string)) single string defining
the coordinate symbols, with ' ' (whitespace) as a separator; each item
has at most two fields, separated by ':':
@@ -72,7 +73,7 @@ class Chart(UniqueRepresentation, SageObject):
used via Sage preparser (see examples below)
- ``names`` -- (default: ``None``) unused argument, except if
``coordinates`` is not provided; it must then be a tuple containing
- the coordinate symbols (this is guaranted if the shortcut operator
+ the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used).
EXAMPLES:
@@ -547,21 +548,22 @@ class Chart(UniqueRepresentation, SageObject):
def restrict(self, subset, restrictions=None):
r"""
- Return the restriction of ``self`` to some subset.
+ Return the restriction of the chart to some open subset of its domain.
- If ``self`` is the chart `(U,\varphi)`, a restriction (or subchart)
+ If the current chart is `(U,\varphi)`, a *restriction* (or *subchart*)
is a chart `(V,\psi)` such that `V\subset U` and `\psi = \varphi |_V`.
If such subchart has not been defined yet, it is constructed here.
The coordinates of the subchart bare the same names as the coordinates
- of the mother chart.
+ of the current chart.
INPUT:
- - ``subset`` -- open subset `V` of the chart domain `U`
- - ``restrictions`` -- (default: ``None``) list of coordinate restrictions
- defining the subset `V`.
+ - ``subset`` -- open subset `V` of the chart domain `U` (must be an
+ instance of :class:`~sage.manifolds.manifold.TopManifold`)
+ - ``restrictions`` -- (default: ``None``) list of coordinate
+ restrictions defining the subset `V`.
A restriction can be any symbolic equality or
inequality involving the coordinates, such as x>y or x^2+y^2 != 0.
The items of the list ``restrictions`` are combined with the ``and``
@@ -595,8 +597,8 @@ class Chart(UniqueRepresentation, SageObject):
return self
if subset not in self._dom_restrict:
if not subset.is_subset(self._domain):
- raise ValueError("The specified subset is not a subset " +
- "of the domain of definition of the chart.")
+ raise ValueError("the specified subset is not a subset " +
+ "of the domain of definition of the chart")
coordinates = ""
for coord in self._xx:
coordinates += repr(coord) + ' '
@@ -1045,8 +1047,8 @@ class RealChart(Chart):
r"""
Chart on a topological manifold over `\RR`.
- Given a topological manifold `M` of dimension `n` over `\RR`, a *chart* is
- a pair `(U,\varphi)`, where `U` is an open subset of `M` and
+ Given a topological manifold `M` of dimension `n` over `\RR`, a *chart*
+ on `M` is a pair `(U,\varphi)`, where `U` is an open subset of `M` and
`\varphi: U \rightarrow V \subset \RR^n` is a homeomorphism from `U` to
an open subset `V` of `\RR^n`.
@@ -1083,7 +1085,7 @@ class RealChart(Chart):
shortcut operator ``<,>`` is used via Sage preparser (see examples below)
- ``names`` -- (default: ``None``) unused argument, except if
``coordinates`` is not provided; it must then be a tuple containing
- the coordinate symbols (this is guaranted if the shortcut operator
+ the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used).
EXAMPLES:
@@ -1441,8 +1443,8 @@ class RealChart(Chart):
INPUT:
- ``xx`` -- (default: ``None``) symbolic expression corresponding to a
- coordinate of ``self``; if ``None``, the ranges of all coordinates
- are displayed.
+ coordinate of the current chart; if ``None``, the ranges of all
+ coordinates are displayed.
EXAMPLES:
@@ -1628,21 +1630,22 @@ class RealChart(Chart):
def restrict(self, subset, restrictions=None):
r"""
- Return the restriction of ``self`` to some subset.
+ Return the restriction of the chart to some open subset of its domain.
- If ``self`` is the chart `(U,\varphi)`, a restriction (or subchart)
+ If the current chart is `(U,\varphi)`, a *restriction* (or *subchart*)
is a chart `(V,\psi)` such that `V\subset U` and `\psi = \varphi |_V`.
If such subchart has not been defined yet, it is constructed here.
The coordinates of the subchart bare the same names as the coordinates
- of the mother chart.
+ of the current chart.
INPUT:
- - ``subset`` -- open subset `V` of the chart domain `U`
- - ``restrictions`` -- (default: ``None``) list of coordinate restrictions
- defining the subset `V`.
+ - ``subset`` -- open subset `V` of the chart domain `U` (must be an
+ instance of :class:`~sage.manifolds.manifold.TopManifold`)
+ - ``restrictions`` -- (default: ``None``) list of coordinate
+ restrictions defining the subset `V`.
A restriction can be any symbolic equality or
inequality involving the coordinates, such as x>y or x^2+y^2 != 0.
The items of the list ``restrictions`` are combined with the ``and``
@@ -1658,7 +1661,7 @@ class RealChart(Chart):
OUTPUT:
- - chart `(V,\psi)`, as an instance of :class:`Chart`.
+ - chart `(V,\psi)`, as an instance of :class:`RealChart`.
EXAMPLES:
@@ -1691,8 +1694,8 @@ class RealChart(Chart):
return self
if subset not in self._dom_restrict:
if not subset.is_subset(self._domain):
- raise ValueError("The specified subset is not a subset " +
- "of the domain of definition of the chart.")
+ raise ValueError("the specified subset is not a subset " +
+ "of the domain of definition of the chart")
coordinates = ""
for coord in self._xx:
coordinates += repr(coord) + ' '
@@ -1809,7 +1812,6 @@ class RealChart(Chart):
# All tests have been passed:
return True
-
#*****************************************************************************
class CoordChange(SageObject):
@@ -1964,7 +1966,7 @@ class CoordChange(SageObject):
OUTPUT:
- an instance of :class:`CoordChange` representing the inverse of
- ``self``.
+ the current coordinate transformation.
EXAMPLES:
@@ -2001,9 +2003,9 @@ class CoordChange(SageObject):
n1 = self._n1
n2 = self._n2
if n1 != n2:
- raise TypeError("the change of coordinates is not invertible " +
- "(different number of coordinates in the two " +
- "charts)")
+ raise ValueError("the change of coordinates is not invertible " +
+ "(different number of coordinates in the two " +
+ "charts)")
# New symbolic variables (different from x2 to allow for a
# correct solution even when chart2 = chart1):
if self._chart1.domain().base_field() == 'real':
@@ -2073,7 +2075,7 @@ class CoordChange(SageObject):
r"""
Sets the inverse of the coordinate transformation.
- This is usefull when the automatic computation via :meth:`inverse()`
+ This is useful when the automatic computation via :meth:`inverse()`
fails.
INPUT:
@@ -2082,7 +2084,7 @@ class CoordChange(SageObject):
list of the expressions of the "old" coordinates in terms of the
"new" ones
- ``kwds`` -- keyword arguments: only ``check=True`` (default) or
- ``check=False`` are meaningfull; it determines whether the provided
+ ``check=False`` are meaningful; it determines whether the provided
transformations are checked to be indeed the inverse coordinate
transformations.
@@ -2201,9 +2203,18 @@ class CoordChange(SageObject):
u = x + y
v = x - y
+ The result is cached::
+
+ sage: X_to_Y.restrict(U) is X_to_Y_U
+ True
+
"""
if dom2 is None:
dom2 = dom1
+ ch1 = self._chart1.restrict(dom1)
+ ch2 = self._chart2.restrict(dom2)
+ if (ch1, ch2) in dom1.coord_changes():
+ return dom1.coord_changes()[(ch1,ch2)]
return self.__class__(self._chart1.restrict(dom1),
self._chart2.restrict(dom2), *(self._transf.expr()))
@@ -2259,4 +2270,3 @@ class CoordChange(SageObject):
return FormattedExpansion(rtxt, rlatex)
disp = display
-
diff --git a/src/sage/manifolds/coord_func.py b/src/sage/manifolds/coord_func.py
index c66964d..767f17a 100644
--- a/src/sage/manifolds/coord_func.py
+++ b/src/sage/manifolds/coord_func.py
@@ -502,7 +502,7 @@ class CoordFunction(SageObject):
def __call__(self, *coords, **options):
r"""
- Computes the value of the function at specified coordinates.
+ Compute the value of the function at specified coordinates.
INPUT:
@@ -1760,4 +1760,3 @@ class MultiCoordFunction(SageObject):
self.jacobian() # forces the computation of self._jacob
self._jacob_det = simple_determinant(self._jacob)
return self._jacob_det
-
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 31521f0..883f415 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -159,6 +159,27 @@ Similarly::
sage: stereoN(S)
(0, 0)
+A continuous map `S^2\rightarrow \RR` (scalar field)::
+
+ sage: f = M.scalar_field({stereoN: atan(x^2+y^2), stereoS: pi/2-atan(u^2+v^2)},
+ ....: name='f')
+ sage: f
+ Scalar field f on the 2-dimensional topological manifold S^2
+ sage: f.display()
+ f: S^2 --> R
+ on U: (x, y) |--> arctan(x^2 + y^2)
+ on V: (u, v) |--> 1/2*pi - arctan(u^2 + v^2)
+ sage: f(p)
+ arctan(5)
+ sage: f(N)
+ 1/2*pi
+ sage: f(S)
+ 0
+ sage: f.parent()
+ Algebra of scalar fields on the 2-dimensional topological manifold S^2
+ sage: f.parent().category()
+ Category of commutative algebras over Symbolic Ring
+
.. RUBRIC:: Example 2: the Riemann sphere as a topological manifold of
dimension 1 over `\CC`
@@ -312,7 +333,7 @@ class TopManifold(TopManifoldSubset):
- ``start_index`` -- (default: 0) integer; lower value of the range of
indices used for "indexed objects" on the manifold, e.g. coordinates
in a chart
- - ``category`` -- (default: ``None``) to specify the categeory; the
+ - ``category`` -- (default: ``None``) to specify the category; the
default being ``Sets()`` (``Manifolds()`` after :trac:`18175` is
implemented)
- ``ambient_manifold`` -- (default: ``None``) if not ``None``, the created
@@ -457,7 +478,7 @@ class TopManifold(TopManifoldSubset):
ambient_manifold = self
elif not isinstance(ambient_manifold, TopManifold):
raise TypeError("the argument 'ambient_manifold' must be " +
- " a topological manifold")
+ "a topological manifold")
# Initialization as a subset of the ambient manifold (possibly itself):
TopManifoldSubset.__init__(self, ambient_manifold, name,
latex_name=latex_name, category=category)
@@ -476,8 +497,6 @@ class TopManifold(TopManifoldSubset):
self._zero_scalar_field = self.scalar_field_algebra().zero()
# The unit scalar field:
self._one_scalar_field = self.scalar_field_algebra().one()
- # The identity map on self:
- #*# self._identity_map = Hom(self, self).one()
def _repr_(self):
r"""
@@ -899,12 +918,12 @@ class TopManifold(TopManifoldSubset):
def top_charts(self):
r"""
- Return the list of charts defined on subsets of the current set
+ Return the list of charts defined on subsets of the current manifold
that are not subcharts of charts on larger subsets.
OUTPUT:
- - list of charts defined on open subsets of ``self`` but not on
+ - list of charts defined on open subsets of the manifold but not on
larger subsets
EXAMPLES:
@@ -986,14 +1005,14 @@ class TopManifold(TopManifoldSubset):
"""
from chart import Chart
if not isinstance(chart, Chart):
- raise TypeError(str(chart) + " is not a chart.")
+ raise TypeError("{} is not a chart".format(chart))
if chart._domain is not self:
if self.is_manifestly_coordinate_domain():
- raise TypeError("The chart domain must coincide with the " +
- str(self) + ".")
+ raise TypeError("the chart domain must coincide with " +
+ "the {}".format(self))
if chart not in self._atlas:
- raise ValueError("The chart must be defined on the " +
- str(self))
+ raise ValueError("the chart must be defined on the " +
+ "{}".format(self))
self._def_chart = chart
def coord_change(self, chart1, chart2):
@@ -1030,9 +1049,9 @@ class TopManifold(TopManifoldSubset):
"""
if (chart1, chart2) not in self._coord_changes:
- raise TypeError("The change of coordinates from " + str(chart1) +
- " to " + str(chart2) + " has not been " +
- "defined on the " + str(self))
+ raise TypeError("the change of coordinates from " +
+ "{} to {}".format(chart1, chart2) + " has not " +
+ "been defined on the {}".format(self))
return self._coord_changes[(chart1, chart2)]
@@ -1089,7 +1108,7 @@ class TopManifold(TopManifoldSubset):
def is_manifestly_coordinate_domain(self):
r"""
- Returns ``True`` if the manifold is known to be the domain of some
+ Return ``True`` if the manifold is known to be the domain of some
coordinate chart and ``False`` otherwise.
If ``False`` is returned, either the manifold cannot be the domain of
@@ -1128,8 +1147,8 @@ class TopManifold(TopManifoldSubset):
subset; if none is provided, it is set to ``name``
- ``coord_def`` -- (default: {}) definition of the subset in
terms of coordinates; ``coord_def`` must a be dictionary with keys
- charts on ``self`` and values the symbolic expressions formed by the
- coordinates to define the subset.
+ charts on the manifold and values the symbolic expressions formed by
+ the coordinates to define the subset.
OUTPUT:
@@ -1137,16 +1156,16 @@ class TopManifold(TopManifoldSubset):
EXAMPLES:
- Creating an open subset of a manifold::
+ Creating an open subset of a 2-dimensional manifold::
sage: TopManifold._clear_cache_() # for doctests only
sage: M = TopManifold(2, 'M')
sage: A = M.open_subset('A'); A
Open subset A of the 2-dimensional topological manifold M
- As an open subset of a topological manifold, A is itself a topological
- manifold, on the same topological field and of the same dimension a
- M::
+ As an open subset of a topological manifold, ``A`` is itself a
+ topological manifold, on the same topological field and of the same
+ dimension as ``M``::
sage: isinstance(A, TopManifold)
True
@@ -1155,7 +1174,7 @@ class TopManifold(TopManifoldSubset):
sage: dim(A) == dim(M)
True
- Creating an open subset of A::
+ Creating an open subset of ``A``::
sage: B = A.open_subset('B'); B
Open subset B of the 2-dimensional topological manifold M
@@ -1178,9 +1197,9 @@ class TopManifold(TopManifoldSubset):
sage: U = M.open_subset('U', coord_def={c_cart: x^2+y^2<1}); U
Open subset U of the 2-dimensional topological manifold R^2
- Since the argument ``coord_def`` has been set, U is automatically
+ Since the argument ``coord_def`` has been set, ``U`` is automatically
provided with a chart, which is the restriction of the Cartesian one
- to U::
+ to ``U``::
sage: U.atlas()
[Chart (U, (x, y))]
@@ -1199,15 +1218,30 @@ class TopManifold(TopManifoldSubset):
field=self._field, start_index=self._sindex,
category=self.category(),
ambient_manifold=self._manifold)
+ #!# NB: the above could have been
+ # resu = type(self).__base__(...) instead of resu = TopManifold(...)
+ # to allow for open_subset() of derived classes to call first this
+ # version,
+ # but, because of the category framework, it could NOT have been
+ # resu = self.__class__(...)
+ # cf. the discussion in
+ # https://groups.google.com/forum/#!topic/sage-devel/jHlFxhMDf3Y
resu._supersets.update(self._supersets)
for sd in self._supersets:
sd._subsets.add(resu)
self._top_subsets.add(resu)
+ # Charts on the result from the coordinate definition:
for chart, restrictions in coord_def.iteritems():
if chart not in self._atlas:
- raise ValueError("The " + str(chart) + "does not belong to " +
- "the atlas of " + str(self))
+ raise ValueError("the {} does not belong to ".format(chart) +
+ "the atlas of {}".format(self))
chart.restrict(resu, restrictions)
+ # Transition maps on the result inferred from those of self:
+ for chart1 in coord_def:
+ for chart2 in coord_def:
+ if chart2 != chart1:
+ if (chart1, chart2) in self._coord_changes:
+ self._coord_changes[(chart1, chart2)].restrict(resu)
return resu
def chart(self, coordinates='', names=None):
@@ -1257,7 +1291,7 @@ class TopManifold(TopManifoldSubset):
below)
- ``names`` -- (default: ``None``) unused argument, except if
``coordinates`` is not provided; it must then be a tuple containing
- the coordinate symbols (this is guaranted if the shortcut operator
+ the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used).
OUTPUT:
@@ -1366,8 +1400,8 @@ class TopManifold(TopManifoldSubset):
r"""
Define a scalar field on the manifold.
- See :class:`~sage.manifolds.scalarfield.ScalarField` for a
- complete documentation.
+ See :class:`~sage.manifolds.scalarfield.ScalarField` for a complete
+ documentation.
INPUT:
@@ -1447,7 +1481,7 @@ class TopManifold(TopManifoldSubset):
# check validity of entry
for chart in coord_expression:
if not chart._domain.is_subset(self):
- raise ValueError("the {} is not defined ".formart(chart) +
+ raise ValueError("the {} is not defined ".format(chart) +
"on some subset of the " + str(self))
return self.scalar_field_algebra().element_class(self,
coord_expression=coord_expression,
@@ -1515,6 +1549,11 @@ class TopManifold(TopManifoldSubset):
r"""
Return the zero scalar field defined on the manifold.
+ OUTPUT:
+
+ - instance of :class:`~sage.manifolds.scalarfield.ScalarField`
+ representing the constant scalar field with value 0.
+
EXAMPLE::
sage: TopManifold._clear_cache_() # for doctests only
@@ -1535,7 +1574,14 @@ class TopManifold(TopManifoldSubset):
def one_scalar_field(self):
r"""
- Return the constant scalar field one defined on the manifold.
+ Return the constant scalar field with value the unit element of the
+ manifold's base field.
+
+ OUTPUT:
+
+ - instance of :class:`~sage.manifolds.scalarfield.ScalarField`
+ representing the constant scalar field with value the unit element
+ of the manifold's base field.
EXAMPLE::
diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py
index 997250d..3e4ce31 100644
--- a/src/sage/manifolds/point.py
+++ b/src/sage/manifolds/point.py
@@ -84,11 +84,11 @@ class TopManifoldPoint(Element):
- ``coords`` -- (default: ``None``) the point coordinates (as a tuple or a
list) in the chart ``chart``
- ``chart`` -- (default: ``None``) chart in which the coordinates are given;
- if none is provided, the coordinates are assumed
- to refer to the subset's default chart
+ if ``None``, the coordinates are assumed to refer to the subset's
+ default chart
- ``name`` -- (default: ``None``) name given to the point
- - ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the point; if
- none is provided, the LaTeX symbol is set to ``name``
+ - ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the point;
+ if ``None``, the LaTeX symbol is set to ``name``
- ``check_coords`` -- (default: ``True``) determines whether ``coords`` are
valid coordinates for the chart ``chart``; for symbolic coordinates, it
is recommended to set ``check_coords`` to ``False``.
@@ -173,18 +173,18 @@ class TopManifoldPoint(Element):
# charts, with the charts as keys
if coords is not None:
if len(coords) != self._manifold._dim:
- raise ValueError("The number of coordinates must be equal" +
- " to the manifold dimension.")
+ raise ValueError("the number of coordinates must be equal " +
+ "to the manifold's dimension")
if chart is None:
chart = self._subset._def_chart
elif self._subset._is_open:
if chart not in self._subset._atlas:
- raise ValueError("The " + str(chart) +
- " has not been defined on the " + str(self._subset))
+ raise ValueError("the {}".format(chart) + " has not " +
+ "been defined on the {}".format(self._subset))
if check_coords:
if not chart.valid_coordinates(*coords):
- raise ValueError("The coordinates " + str(coords) +
- " are not valid on the " + str(chart))
+ raise ValueError("the coordinates {}".format(coords) +
+ " are not valid on the {}".format(chart))
for schart in chart._supercharts:
self._coordinates[schart] = tuple(coords)
for schart in chart._subcharts:
@@ -249,10 +249,10 @@ class TopManifoldPoint(Element):
def containing_set(self):
r"""
- Return a manifold subset that contains ``self``.
+ Return a manifold subset that contains the point.
A priori, this method returns the manifold subset (possibly the
- manifold itself) in which the point ``self`` has been defined.
+ manifold itself) in which the point has been defined.
OUTPUT:
@@ -305,9 +305,9 @@ class TopManifoldPoint(Element):
- ``chart`` -- (default: ``None``) chart in which the coordinates are
given; if none is provided, the coordinates are assumed to refer to
the subset's default chart
- - ``old_chart`` -- (default: ``None``) chart from which the coordinates in
- ``chart`` are to be computed. If ``None``, a chart in which the point's
- coordinates are already known will be picked, priveleging the
+ - ``old_chart`` -- (default: ``None``) chart from which the coordinates
+ in ``chart`` are to be computed. If ``None``, a chart in which the
+ point's coordinates are already known will be picked, privileging the
subset's default chart.
EXAMPLES:
@@ -332,7 +332,8 @@ class TopManifoldPoint(Element):
Computing the Cartesian coordinates from the spherical ones::
sage: c_cart.<x,y,z> = M.chart() # Cartesian coordinates
- sage: c_spher.transition_map(c_cart, [r*sin(th)*cos(ph), r*sin(th)*sin(ph), r*cos(th)])
+ sage: c_spher.transition_map(c_cart, [r*sin(th)*cos(ph),
+ ....: r*sin(th)*sin(ph), r*cos(th)])
Change of coordinates from Chart (M, (r, th, ph)) to Chart (M, (x, y, z))
sage: p.coord(c_cart) # the computation is performed by means of the above change of coordinates
(-1, 0, 0)
@@ -373,7 +374,8 @@ class TopManifoldPoint(Element):
(a^3 - 3*a^2*b + 3*a*b^2 - b^3, a^3 + 3*a^2*b + 3*a*b^2 + b^3)
sage: p._coordinates # random (dictionary output)
{Chart (M, (u, v)): (a - b, a + b),
- Chart (M, (w, z)): (a^3 - 3*a^2*b + 3*a*b^2 - b^3, a^3 + 3*a^2*b + 3*a*b^2 + b^3)}
+ Chart (M, (w, z)): (a^3 - 3*a^2*b + 3*a*b^2 - b^3,
+ a^3 + 3*a^2*b + 3*a*b^2 + b^3)}
"""
if chart is None:
@@ -384,8 +386,8 @@ class TopManifoldPoint(Element):
dom = chart._domain
def_chart = dom._def_chart
if self not in dom:
- raise ValueError("The point does not belong to the domain " +
- "of " + str(chart))
+ raise ValueError("the point does not belong to the domain " +
+ "of {}".format(chart))
if chart not in self._coordinates:
# Check whether chart corresponds to a superchart of a chart
# in which the coordinates are known:
@@ -432,9 +434,9 @@ class TopManifoldPoint(Element):
if old_chart is not None:
break
if old_chart is None:
- raise ValueError("The coordinates of " + str(self) + \
- " in the " + str(chart) + " cannot be computed" + \
- " by means of known changes of charts.")
+ raise ValueError("the coordinates of {}".format(self) +
+ " in the {}".format(chart) + " cannot be computed " +
+ "by means of known changes of charts.")
else:
chcoord = dom._coord_changes[(s_old_chart, s_chart)]
self._coordinates[chart] = \
@@ -504,7 +506,7 @@ class TopManifoldPoint(Element):
.. WARNING::
If the point has already coordinates in other charts, it
- is the user's responsability to make sure that the coordinates
+ is the user's responsibility to make sure that the coordinates
to be added are consistent with them.
EXAMPLES:
@@ -541,14 +543,14 @@ class TopManifoldPoint(Element):
"""
if len(coords) != self._manifold._dim:
- raise ValueError("The number of coordinates must be equal " +
- "to the manifold dimension.")
+ raise ValueError("the number of coordinates must be equal to " +
+ "the manifold's dimension.")
if chart is None:
chart = self._subset._def_chart
else:
if chart not in self._subset._atlas:
- raise ValueError("The " + str(chart) +
- " has not been defined on the " + str(self._subset))
+ raise ValueError("the {}".format(chart) + " has not been " +
+ "defined on the {}".format(self._subset))
self._coordinates[chart] = coords
def __eq__(self, other):
@@ -631,8 +633,8 @@ class TopManifoldPoint(Element):
if common_chart is None:
return False
#!# Another option would be:
- # raise ValueError("No common chart has been found to compare " +
- # str(self) + " and " + str(other))
+ # raise ValueError("no common chart has been found to compare " +
+ # "{} and {}".format(self, other))
return self._coordinates[common_chart] == \
other._coordinates[common_chart]
diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py
index d589a5c..8ebd39a 100644
--- a/src/sage/manifolds/scalarfield.py
+++ b/src/sage/manifolds/scalarfield.py
@@ -1,14 +1,13 @@
r"""
Scalar fields
-Given a topological manifold `M` over a topological field `K`, a *scalar field*
-on `M` is a continuous map
+Given a topological manifold `M` over a topological field `K` (in most
+applications, `K = \RR` or `K = \CC`), a *scalar field* on `M` is a continuous
+map
.. MATH::
- f: U\subset M \longrightarrow K
-
-where `U` is an open subset of `M`.
+ f: M \longrightarrow K
Scalar fields are implemented by the class :class:`ScalarField`.
@@ -18,11 +17,10 @@ AUTHORS:
REFERENCES:
+- J.M. Lee : *Introduction to Topological Manifolds*, 2nd ed., Springer (New
+ York) (2011)
- S. Kobayashi & K. Nomizu : *Foundations of Differential Geometry*, vol. 1,
Interscience Publishers (New York) (1963)
-- J.M. Lee : *Introduction to Smooth Manifolds*, 2nd ed., Springer (New York)
- (2013)
-- B O'Neill : *Semi-Riemannian Geometry*, Academic Press (San Diego) (1983)
"""
@@ -45,21 +43,21 @@ class ScalarField(CommutativeAlgebraElement):
r"""
Scalar field on a topological manifold.
- Given a topological manifold `M` over a topological field `K`
- and an open subset `U` of `M`, a *scalar field* defined on `U` is a
+ Given a topological manifold `M` over a topological field `K` (in most
+ applications, `K = \RR` or `K = \CC`), a *scalar field on* `M` is a
continuous map
.. MATH::
- f: U\subset M \longrightarrow K .
+ f: M \longrightarrow K .
The class :class:`ScalarField` inherits from the class :class:`~sage.structure.element.CommutativeAlgebraElement`, a scalar field
- on `U` being an element of the commutative algebra `C^0(U)` (see
+ on `M` being an element of the commutative algebra `C^0(M)` (see
:class:`~sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra`).
INPUT:
- - ``domain`` -- the manifold open subset `U` on which the scalar field is
+ - ``domain`` -- the topological manifold `M` on which the scalar field is
defined (must be an instance of class
:class:`~sage.manifolds.manifold.TopManifold`)
- ``coord_expression`` -- (default: ``None``) coordinate expression(s) of
@@ -113,18 +111,21 @@ class ScalarField(CommutativeAlgebraElement):
can be passed instead of the dictionary over the charts::
sage: g = U.scalar_field(x*y, chart=c_xy, name='g') ; g
- Scalar field g on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field g on the Open subset U of the 2-dimensional topological
+ manifold M
The above is indeed equivalent to::
sage: g = U.scalar_field({c_xy: x*y}, name='g') ; g
- Scalar field g on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field g on the Open subset U of the 2-dimensional topological
+ manifold M
Since ``c_xy`` is the default chart of ``U``, the argument ``chart`` can
be skipped::
sage: g = U.scalar_field(x*y, name='g') ; g
- Scalar field g on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field g on the Open subset U of the 2-dimensional topological
+ manifold M
The scalar field `g` is defined on `U` and has an expression in terms of
the coordinates `(u,v)` on `W=U\cap V`::
@@ -176,7 +177,8 @@ class ScalarField(CommutativeAlgebraElement):
coordinates::
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
+ Scalar field h on the Open subset U of the 2-dimensional topological
+ manifold M
sage: h.display()
h: U --> R
(x, y) |--> H(x, y)
@@ -339,7 +341,8 @@ class ScalarField(CommutativeAlgebraElement):
sage: f.parent() is M.scalar_field_algebra()
True
sage: g.parent()
- Algebra of scalar fields on the Open subset U of the 2-dimensional topological manifold M
+ Algebra of scalar fields on the Open subset U of the 2-dimensional
+ topological manifold M
sage: g.parent() is U.scalar_field_algebra()
True
@@ -416,13 +419,15 @@ class ScalarField(CommutativeAlgebraElement):
sage: g.domain()
Open subset U of the 2-dimensional topological manifold M
sage: s = f + g ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.domain()
Open subset U of the 2-dimensional topological manifold M
sage: s.display()
U --> R
(x, y) |--> (x*y^3 + (x^3 + x)*y + 1)/(x^2 + y^2 + 1)
- on W: (u, v) |--> (u^6 + 3*u^4*v^2 + 3*u^2*v^4 + v^6 + u*v^3 + (u^3 + u)*v)/(u^6 + v^6 + (3*u^2 + 1)*v^4 + u^4 + (3*u^4 + 2*u^2)*v^2)
+ on W: (u, v) |--> (u^6 + 3*u^4*v^2 + 3*u^2*v^4 + v^6 + u*v^3
+ + (u^3 + u)*v)/(u^6 + v^6 + (3*u^2 + 1)*v^4 + u^4 + (3*u^4 + 2*u^2)*v^2)
The operation actually performed is `f|_U + g`::
@@ -496,9 +501,11 @@ class ScalarField(CommutativeAlgebraElement):
sage: s.display()
f*f: M --> R
on U: (x, y) |--> 1/(x^4 + y^4 + 2*(x^2 + 1)*y^2 + 2*x^2 + 1)
- on V: (u, v) |--> (u^4 + 2*u^2*v^2 + v^4)/(u^4 + v^4 + 2*(u^2 + 1)*v^2 + 2*u^2 + 1)
+ on V: (u, v) |--> (u^4 + 2*u^2*v^2 + v^4)/(u^4 + v^4 + 2*(u^2 + 1)*v^2
+ + 2*u^2 + 1)
sage: s = g*h ; s
- Scalar field g*h on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field g*h on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
g*h: U --> R
(x, y) |--> x*y*H(x, y)
@@ -513,7 +520,8 @@ class ScalarField(CommutativeAlgebraElement):
(2-dimensional topological manifold M,
Open subset U of the 2-dimensional topological manifold M)
sage: s = f*g ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> x*y/(x^2 + y^2 + 1)
@@ -530,13 +538,15 @@ class ScalarField(CommutativeAlgebraElement):
on U: (x, y) |--> 1/(a*x^2 + a*y^2 + a)
on V: (u, v) |--> (u^2 + v^2)/(a*u^2 + a*v^2 + a)
sage: s = g/h ; s
- Scalar field g/h on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field g/h on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
g/h: U --> R
(x, y) |--> x*y/H(x, y)
on W: (u, v) |--> u*v/((u^4 + 2*u^2*v^2 + v^4)*H(u/(u^2 + v^2), v/(u^2 + v^2)))
sage: s = f/g ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> 1/(x*y^3 + (x^3 + x)*y)
@@ -548,7 +558,8 @@ class ScalarField(CommutativeAlgebraElement):
arithmetics with symbolic expressions involving the chart coordinates::
sage: s = g + x^2 - y ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> x^2 + (x - 1)*y
@@ -557,7 +568,8 @@ class ScalarField(CommutativeAlgebraElement):
::
sage: s = g*x ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> x^2*y
@@ -566,13 +578,15 @@ class ScalarField(CommutativeAlgebraElement):
::
sage: s = g/x ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> y
on W: (u, v) |--> v/(u^2 + v^2)
sage: s = x/g ; s
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: s.display()
U --> R
(x, y) |--> 1/y
@@ -599,14 +613,14 @@ class ScalarField(CommutativeAlgebraElement):
sage: isinstance(f, ScalarField)
True
sage: f.parent()
- Algebra of scalar fields on the 2-dimensional topological manifold M
+ Algebra of scalar fields on the 2-dimensional topological
+ manifold M
sage: TestSuite(f).run()
"""
CommutativeAlgebraElement.__init__(self, domain.scalar_field_algebra())
self._manifold = domain._manifold
self._domain = domain
- self._tensor_type = (0,0)
self._is_zero = False # a priori, may be changed below or via
# method __nonzero__()
self._name = name
@@ -810,9 +824,12 @@ class ScalarField(CommutativeAlgebraElement):
sage: f = M.scalar_field({X: x+y})
sage: U = M.open_subset('U', coord_def={X: x>0})
sage: f.restrict(U)
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: f._restrictions
- {Open subset U of the 2-dimensional topological manifold M: Scalar field on the Open subset U of the 2-dimensional topological manifold M}
+ {Open subset U of the 2-dimensional topological manifold M:
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M}
sage: f._del_derived()
sage: f._restrictions # restrictions are derived quantities
{}
@@ -822,7 +839,7 @@ class ScalarField(CommutativeAlgebraElement):
def _repr_(self):
r"""
- String representation of ``self``.
+ String representation of the object.
TESTS::
@@ -846,7 +863,7 @@ class ScalarField(CommutativeAlgebraElement):
def _latex_(self):
r"""
- LaTeX representation of ``self``.
+ LaTeX representation of the object.
TESTS::
@@ -872,7 +889,7 @@ class ScalarField(CommutativeAlgebraElement):
def set_name(self, name=None, latex_name=None):
r"""
- Set (or change) the text name and LaTeX name of ``self``.
+ Set (or change) the text name and LaTeX name of the scalar field.
INPUT:
@@ -931,25 +948,9 @@ class ScalarField(CommutativeAlgebraElement):
"""
return self._domain
- def tensor_type(self):
- r"""
- Return the tensor type of ``self``, i.e. (0,0), when ``self`` is
- considered as a tensor field on the manifold.
-
- EXAMPLE::
-
- sage: M = TopManifold(2, 'M')
- sage: c_xy.<x,y> = M.chart()
- sage: f = M.scalar_field(x+2*y)
- sage: f.tensor_type()
- (0, 0)
-
- """
- return self._tensor_type
-
def copy(self):
r"""
- Return an exact copy of ``self``.
+ Return an exact copy of the scalar field.
EXAMPLES:
@@ -985,10 +986,11 @@ class ScalarField(CommutativeAlgebraElement):
- ``chart`` -- (default: ``None``) chart with respect to which the
coordinate expression is to be returned; if ``None``, the
- default chart of the domain of ``self`` will be used
+ default chart of the scalar field's domain will be used
- ``from_chart`` -- (default: ``None``) chart from which the
required expression is computed if it is not known already in the
- chart ``chart``; if ``None``, a chart is picked in ``self._express``
+ chart ``chart``; if ``None``, a chart is picked in the known
+ expressions.
OUTPUT:
@@ -1077,7 +1079,7 @@ class ScalarField(CommutativeAlgebraElement):
break
if not found:
raise ValueError("no starting chart could be found to " +
- "compute the expression in the {}".format(chart))
+ "compute the expression in the {}".format(chart))
change = self._domain._coord_changes[(chart, from_chart)]
# old coordinates expressed in terms of the new ones:
coords = [ change._transf._functions[i]._express
@@ -1087,6 +1089,27 @@ class ScalarField(CommutativeAlgebraElement):
self._del_derived()
return self._express[chart]
+ def function_chart(self, chart=None, from_chart=None):
+ r"""
+ Deprecated.
+
+ Use :meth:`coord_function` instead.
+
+ EXAMPLE::
+
+ sage: M = TopManifold(2, 'M')
+ sage: c_xy.<x,y> = M.chart()
+ sage: f = M.scalar_field(x*y^2)
+ sage: fc = f.function_chart()
+ doctest:...: DeprecationWarning: Use coord_function() instead.
+ See http://trac.sagemath.org/18640 for details.
+ sage: fc
+ x*y^2
+
+ """
+ from sage.misc.superseded import deprecation
+ deprecation(18640, 'Use coord_function() instead.')
+ return self.coord_function(chart=chart, from_chart=from_chart)
def expr(self, chart=None, from_chart=None):
r"""
@@ -1097,7 +1120,7 @@ class ScalarField(CommutativeAlgebraElement):
- ``chart`` -- (default: ``None``) chart with respect to which the
coordinate expression is required; if ``None``, the default
- chart of the domain of ``self`` will be used
+ chart of the scalar field's domain will be used
- ``from_chart`` -- (default: ``None``) chart from which the
required expression is computed if it is not known already in the
chart ``chart``; if ``None``, a chart is picked in ``self._express``
@@ -1149,9 +1172,9 @@ class ScalarField(CommutativeAlgebraElement):
INPUT:
- ``coord_expression`` -- coordinate expression of the scalar field
- - ``chart`` -- (default: ``None``) chart in which ``coord_expression`` is
- defined; if ``None``, the default chart of the domain of ``self`` is
- assumed
+ - ``chart`` -- (default: ``None``) chart in which ``coord_expression``
+ is defined; if ``None``, the default chart of the scalar field's
+ domain is assumed
EXAMPLES:
@@ -1193,13 +1216,13 @@ class ScalarField(CommutativeAlgebraElement):
- ``coord_expression`` -- coordinate expression of the scalar field
- ``chart`` -- (default: ``None``) chart in which ``coord_expression``
- is defined; if ``None``, the default chart of the domain of ``self`` is
- assumed
+ is defined; if ``None``, the default chart of the scalar field's
+ domain is assumed
.. WARNING::
If the scalar field has already expressions in other charts, it
- is the user's responsability to make sure that the expression
+ is the user's responsibility to make sure that the expression
to be added is consistent with them.
EXAMPLES:
@@ -1252,9 +1275,9 @@ class ScalarField(CommutativeAlgebraElement):
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
- sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)), \
- intersection_name='W', restrictions1= x^2+y^2!=0, \
- restrictions2= u^2+v^2!=0)
+ sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
+ ....: intersection_name='W', restrictions1= x^2+y^2!=0,
+ ....: restrictions2= u^2+v^2!=0)
sage: uv_to_xy = xy_to_uv.inverse()
sage: W = U.intersection(V) # S^2 minus the two poles
sage: f = M.scalar_field(atan(x^2+y^2), chart=c_xy, name='f')
@@ -1359,10 +1382,11 @@ class ScalarField(CommutativeAlgebraElement):
result._latex += " & "
else:
result._txt += "on " + chart._domain._name + ": "
- result._latex += r"\mbox{on}\ " + latex(chart._domain) + r": & "
+ result._latex += r"\mbox{on}\ " + latex(chart._domain) + \
+ r": & "
result._txt += repr(coords) + " |--> " + repr(expression) + "\n"
result._latex += latex(coords) + r"& \longmapsto & " + \
- latex(expression) + r"\\"
+ latex(expression) + r"\\"
except (TypeError, ValueError):
pass
@@ -1404,18 +1428,18 @@ class ScalarField(CommutativeAlgebraElement):
def restrict(self, subdomain):
r"""
- Restriction of the scalar field to a subdomain of its domain of
+ Restriction of the scalar field to an open subset of its domain of
definition.
INPUT:
- - ``subdomain`` -- the subdomain (instance of
- :class:`~sage.manifolds.manifold.TopManifold`)
+ - ``subdomain`` -- an open subset of the scalar field's domain (must
+ be an instance of :class:`~sage.manifolds.manifold.TopManifold`)
OUTPUT:
- instance of :class:`ScalarField` representing the restriction of
- ``self`` to ``subdomain``.
+ the scalar field to ``subdomain``.
EXAMPLE:
@@ -1427,14 +1451,17 @@ class ScalarField(CommutativeAlgebraElement):
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')
sage: f_U = f.restrict(U) ; f_U
- Scalar field f on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field f on the Open subset U of the 2-dimensional
+ topological manifold M
sage: f_U.display()
f: U --> R
(x, y) |--> cos(x*y)
sage: f.parent()
- Algebra of scalar fields on the 2-dimensional topological manifold M
+ Algebra of scalar fields on the 2-dimensional topological
+ manifold M
sage: f_U.parent()
- Algebra of scalar fields on the Open subset U of the 2-dimensional topological manifold M
+ Algebra of scalar fields on the Open subset U of the 2-dimensional
+ topological manifold M
The restriction to the whole domain is the identity::
@@ -1446,7 +1473,8 @@ class ScalarField(CommutativeAlgebraElement):
Restriction of the zero scalar field::
sage: M.zero_scalar_field().restrict(U)
- Scalar field zero on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field zero on the Open subset U of the 2-dimensional
+ topological manifold M
sage: M.zero_scalar_field().restrict(U) is U.zero_scalar_field()
True
@@ -1455,9 +1483,8 @@ class ScalarField(CommutativeAlgebraElement):
return self
if subdomain not in self._restrictions:
if not subdomain.is_subset(self._domain):
- raise ValueError("the specified domain is not a subset " +
- "of the domain of definition of the scalar " +
- "field")
+ raise ValueError("the specified domain is not a subset of " +
+ "the domain of definition of the scalar field")
# Special case of the zero scalar field:
if self._is_zero:
return subdomain._zero_scalar_field
@@ -1476,7 +1503,8 @@ class ScalarField(CommutativeAlgebraElement):
def common_charts(self, other):
r"""
- Find common charts for the expressions of ``self`` and ``other``.
+ Find common charts for the expressions of the scalar field and
+ ``other``.
INPUT:
@@ -1517,7 +1545,8 @@ class ScalarField(CommutativeAlgebraElement):
sage: trans = c_xy.transition_map(c_uv, (x+y, x-y), 'W', x<0, u+v<0)
sage: M.atlas()
- [Chart (U, (x, y)), Chart (V, (u, v)), Chart (W, (x, y)), Chart (W, (u, v))]
+ [Chart (U, (x, y)), Chart (V, (u, v)), Chart (W, (x, y)),
+ Chart (W, (u, v))]
sage: c_xy_W = M.atlas()[2]
sage: c_uv_W = M.atlas()[3]
sage: trans.inverse()
@@ -1535,14 +1564,16 @@ class ScalarField(CommutativeAlgebraElement):
sage: f.expr(c_uv_W)
1/4*u^2 + 1/2*u*v + 1/4*v^2
sage: f._express # random (dictionary output)
- {Chart (U, (x, y)): x^2, Chart (W, (x, y)): x^2, Chart (W, (u, v)): 1/4*u^2 + 1/2*u*v + 1/4*v^2}
+ {Chart (U, (x, y)): x^2, Chart (W, (x, y)): x^2,
+ Chart (W, (u, v)): 1/4*u^2 + 1/2*u*v + 1/4*v^2}
sage: g._express # random (dictionary output)
{Chart (U, (x, y)): x + y, Chart (V, (u, v)): u}
sage: f.common_charts(g)
[Chart (U, (x, y)), Chart (W, (u, v))]
sage: # the expressions have been updated on the subcharts
sage: g._express # random (dictionary output)
- {Chart (U, (x, y)): x + y, Chart (V, (u, v)): u, Chart (W, (u, v)): u}
+ {Chart (U, (x, y)): x + y, Chart (V, (u, v)): u,
+ Chart (W, (u, v)): u}
Common charts found by computing some coordinate changes::
@@ -1556,13 +1587,14 @@ class ScalarField(CommutativeAlgebraElement):
sage: f.common_charts(g)
[Chart (W, (u, v)), Chart (W, (x, y))]
sage: f._express # random (dictionary output)
- {Chart (W, (u, v)): 1/4*u^2 + 1/2*u*v + 1/4*v^2, Chart (W, (x, y)): x^2}
+ {Chart (W, (u, v)): 1/4*u^2 + 1/2*u*v + 1/4*v^2,
+ Chart (W, (x, y)): x^2}
sage: g._express # random (dictionary output)
{Chart (W, (u, v)): u + 1, Chart (W, (x, y)): x + y + 1}
"""
if not isinstance(other, ScalarField):
- raise TypeError("The second argument must be a scalar field.")
+ raise TypeError("the second argument must be a scalar field")
dom1 = self._domain
dom2 = other._domain
coord_changes = self._manifold._coord_changes
@@ -1612,11 +1644,11 @@ class ScalarField(CommutativeAlgebraElement):
INPUT:
- ``p`` -- point in the scalar field's domain (type:
- :class:`~sage.manifolds.point.ManifoldPoint`)
+ :class:`~sage.manifolds.point.TopManifoldPoint`)
- ``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 ``self`` are known is searched,
- starting from the default chart of self._domain
+ coordinates and the expression of the scalar field are known is
+ searched, starting from the default chart of self._domain
OUTPUT:
@@ -1654,8 +1686,8 @@ class ScalarField(CommutativeAlgebraElement):
#!# it should be "if p not in self_domain:" instead, but this test is
# skipped for efficiency
if p not in self._manifold:
- raise ValueError("the point " + str(p) +
- " does not belong to the " + str(self._manifold))
+ raise ValueError("the {} ".format(p) + "does not belong " +
+ "to the {}".format(self._manifold))
if self._is_zero:
return 0
if chart is None:
@@ -1698,7 +1730,7 @@ class ScalarField(CommutativeAlgebraElement):
OUTPUT:
- - an exact copy of ``self``
+ - an exact copy of the scalar field
TESTS::
@@ -1726,7 +1758,7 @@ class ScalarField(CommutativeAlgebraElement):
OUTPUT:
- - the negative of ``self``
+ - the negative of the scalar field
TESTS::
@@ -2021,10 +2053,26 @@ class ScalarField(CommutativeAlgebraElement):
if chart_var:
# Some symbolic variables in number are chart coordinates
for chart, expr in self._express.iteritems():
- # The multiplication is performed only if all the
- # symbolic variables involved in number are chart
- # coordinates:
- if all(s in chart[:] for s in var):
+ # The multiplication is performed only if
+ # either
+ # (i) all the symbolic variables in number are
+ # coordinates of this chart
+ # or (ii) no symbolic variable in number belongs to a
+ # different chart
+ chart_coords = chart[:]
+ var_not_in_chart = [s for s in var
+ if not s in chart_coords]
+ any_in_other_chart = False
+ if var_not_in_chart != []:
+ for other_chart in self._domain.atlas():
+ other_chart_coords = other_chart[:]
+ for s in var_not_in_chart:
+ if s in other_chart_coords:
+ any_in_other_chart = True
+ break
+ if any_in_other_chart:
+ break
+ if not any_in_other_chart:
result._express[chart] = number * expr
return result
# General case: the multiplication is performed on all charts:
@@ -2257,7 +2305,8 @@ class ScalarField(CommutativeAlgebraElement):
sage: M = TopManifold(2, 'M')
sage: X.<x,y> = M.chart()
- sage: f = M.scalar_field({X: 1+x^2+y^2}, name='f', latex_name=r"\Phi")
+ sage: f = M.scalar_field({X: 1+x^2+y^2}, name='f',
+ ....: latex_name=r"\Phi")
sage: g = sqrt(f) ; g
Scalar field sqrt(f) on the 2-dimensional topological manifold M
sage: latex(g)
diff --git a/src/sage/manifolds/scalarfield_algebra.py b/src/sage/manifolds/scalarfield_algebra.py
index a8f8e25..07132f1 100644
--- a/src/sage/manifolds/scalarfield_algebra.py
+++ b/src/sage/manifolds/scalarfield_algebra.py
@@ -2,10 +2,10 @@ r"""
Scalar field algebra
The class :class:`ScalarFieldAlgebra` implements the commutative algebra
-`C^0(U)` of scalar fields on some open subset `U` of a
-topological manifold `M` over a topological field `K`. By *scalar field*, it
-is meant a continuous function `U\rightarrow K`.
-`C^0(U)` is an algebra over `K`, whose ring product is the pointwise
+`C^0(M)` of scalar fields on a topological manifold `M` over a topological
+field `K`. By *scalar field*, it
+is meant a continuous function `M\rightarrow K`. The set
+`C^0(M)` is an algebra over `K`, whose ring product is the pointwise
multiplication of `K`-valued functions, which is clearly commutative.
AUTHORS:
@@ -14,11 +14,10 @@ AUTHORS:
REFERENCES:
+- J.M. Lee : *Introduction to Topological Manifolds*, 2nd ed., Springer (New
+ York) (2011)
- S. Kobayashi & K. Nomizu : *Foundations of Differential Geometry*, vol. 1,
Interscience Publishers (New York) (1963)
-- J.M. Lee : *Introduction to Smooth Manifolds*, 2nd ed., Springer (New York)
- (2013)
-- B O'Neill : *Semi-Riemannian Geometry*, Academic Press (San Diego) (1983)
"""
@@ -40,19 +39,17 @@ from sage.manifolds.scalarfield import ScalarField
class ScalarFieldAlgebra(UniqueRepresentation, Parent):
r"""
- Commutative algebra of scalar fields on some open subset of a
- topological manifold.
+ Commutative algebra of scalar fields on a topological manifold.
- If `M` is a topological manifold over a topological field `K` and `U`
- an open subset of `M`, the commutative algebra of scalar fields on `U`
- is the set `C^0(U)` of all continuous maps `U\rightarrow K`.
- `C^0(U)` is an algebra over `K`, whose ring product is the pointwise
- multiplication of `K`-valued functions, which is clearly commutative.
+ If `M` is a topological manifold over a topological field `K`, the
+ commutative algebra of scalar fields on `M` is the set `C^0(M)` of all
+ continuous maps `M\rightarrow K`. The set `C^0(M)` is an algebra over `K`,
+ whose ring product is the pointwise multiplication of `K`-valued functions,
+ which is clearly commutative.
If `K = \RR` or `K = \CC`, the field `K` over which the
- albegra `C^0(U)` is constructed,
- is represented by Sage's Symbolic Ring SR, since there is no exact
- representation of `\RR` nor `\CC` in Sage.
+ algebra `C^0(M)` is constructed is represented by Sage's Symbolic Ring
+ ``SR``, since there is no exact representation of `\RR` nor `\CC` in Sage.
The class :class:`ScalarFieldAlgebra` inherits from
:class:`~sage.structure.parent.Parent`, with the category set to
@@ -62,13 +59,14 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
INPUT:
- - ``domain`` -- the manifold open subset `U` on which the scalar fields are
+ - ``domain`` -- the topological manifold `M` on which the scalar fields are
defined (must be an instance of class
:class:`~sage.manifolds.manifold.TopManifold`)
EXAMPLES:
- Algebras of scalar fields on the sphere `S^2` and on some subdomain of it::
+ 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: U = M.open_subset('U') # complement of the North pole
@@ -76,15 +74,16 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
sage: V = M.open_subset('V') # complement of the South pole
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
sage: M.declare_union(U,V) # S^2 is the union of U and V
- sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)), \
- intersection_name='W', restrictions1= x^2+y^2!=0, \
- restrictions2= u^2+v^2!=0)
+ sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
+ ....: intersection_name='W', restrictions1= x^2+y^2!=0,
+ ....: restrictions2= u^2+v^2!=0)
sage: uv_to_xy = xy_to_uv.inverse()
sage: CM = M.scalar_field_algebra() ; CM
Algebra of scalar fields on the 2-dimensional topological manifold M
sage: W = U.intersection(V) # S^2 minus the two poles
sage: CW = W.scalar_field_algebra() ; CW
- Algebra of scalar fields on the Open subset W of the 2-dimensional topological manifold M
+ Algebra of scalar fields on the Open subset W of the 2-dimensional
+ topological manifold M
`C^0(M)` and `C^0(W)` belong to the category of commutative
algebras over `\RR` (represented here by Sage's Symbolic Ring)::
@@ -110,7 +109,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
Those of `C^0(W)` are scalar fields on `W`::
sage: CW.an_element()
- Scalar field on the Open subset W of the 2-dimensional topological manifold M
+ Scalar field on the Open subset W of the 2-dimensional topological
+ manifold M
sage: CW.an_element().display() # this sample element is a constant field
W --> R
(x, y) |--> 2
@@ -128,7 +128,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
::
sage: CW.zero()
- Scalar field zero on the Open subset W of the 2-dimensional topological manifold M
+ Scalar field zero on the Open subset W of the 2-dimensional
+ topological manifold M
sage: CW.zero().display()
zero: W --> R
(x, y) |--> 0
@@ -146,15 +147,16 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
::
sage: CW.one()
- Scalar field 1 on the Open subset W of the 2-dimensional topological manifold M
+ Scalar field 1 on the Open subset W of the 2-dimensional topological
+ manifold M
sage: CW.one().display()
1: W --> R
(x, y) |--> 1
(u, v) |--> 1
A generic element can be constructed as for any parent in Sage, namely
- by means of the ``__call__`` operator on the parent (here with the dictionary
- of the coordinate expressions defining the scalar field)::
+ by means of the ``__call__`` operator on the parent (here with the
+ dictionary of the coordinate expressions defining the scalar field)::
sage: f = CM({c_xy: atan(x^2+y^2), c_uv: pi/2 - atan(u^2+v^2)}); f
Scalar field on the 2-dimensional topological manifold M
@@ -182,7 +184,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
the domain (this allows one to set the name of the scalar field at the
construction)::
- sage: f1 = M.scalar_field({c_xy: atan(x^2+y^2), c_uv: pi/2 - atan(u^2+v^2)}, name='f')
+ sage: f1 = M.scalar_field({c_xy: atan(x^2+y^2), c_uv: pi/2 - atan(u^2+v^2)},
+ ....: name='f')
sage: f1.parent()
Algebra of scalar fields on the 2-dimensional topological manifold M
sage: f1 == f
@@ -205,7 +208,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
on `M`::
sage: fW = CW(f) ; fW
- Scalar field on the Open subset W of the 2-dimensional topological manifold M
+ Scalar field on the Open subset W of the 2-dimensional topological
+ manifold M
sage: fW.display()
W --> R
(x, y) |--> arctan(x^2 + y^2)
@@ -222,7 +226,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
sage: s = fW + f
sage: s.parent()
- Algebra of scalar fields on the Open subset W of the 2-dimensional topological manifold M
+ Algebra of scalar fields on the Open subset W of the 2-dimensional
+ topological manifold M
sage: s.display()
W --> R
(x, y) |--> 2*arctan(x^2 + y^2)
@@ -289,7 +294,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
sage: f/fW == CW.one()
True
sage: s = f*fW ; s
- Scalar field on the Open subset W of the 2-dimensional topological manifold M
+ Scalar field on the Open subset W of the 2-dimensional topological
+ manifold M
sage: s.display()
W --> R
(x, y) |--> arctan(x^2 + y^2)^2
@@ -342,7 +348,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
sage: X.<x,y> = M.chart()
sage: from sage.manifolds.scalarfield_algebra import ScalarFieldAlgebra
sage: CM = ScalarFieldAlgebra(M); CM
- Algebra of scalar fields on the 2-dimensional topological manifold M
+ Algebra of scalar fields on the 2-dimensional topological
+ manifold M
sage: TestSuite(CM).run()
"""
@@ -404,12 +411,14 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
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._element_constructor_(coord_expression={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
+ 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
@@ -420,7 +429,8 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
sage: U = M.open_subset('U', coord_def={X: x>0})
sage: CU = U.scalar_field_algebra()
sage: fU = CU._element_constructor_(f); fU
- Scalar field on the Open subset U of the 2-dimensional topological manifold M
+ Scalar field on the Open subset U of the 2-dimensional topological
+ manifold M
sage: fU.display()
U --> R
(x, y) |--> y^2 + x
@@ -438,8 +448,9 @@ class ScalarFieldAlgebra(UniqueRepresentation, Parent):
coord_expression=sexpress, name=name,
latex_name=latex_name)
else:
- raise TypeError("Cannot coerce the " + str(coord_expression) +
- "to a scalar field on the " + str(self._domain))
+ raise TypeError("cannot convert the " +
+ "{} to a scalar ".format(coord_expression) +
+ "field on the {}".format(self._domain))
else:
# generic constructor:
resu = self.element_class(self._domain,
diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py
index 781b980..b88e1e5 100644
--- a/src/sage/manifolds/subset.py
+++ b/src/sage/manifolds/subset.py
@@ -1,8 +1,8 @@
r"""
Subsets of topological manifolds
-The class :class:`TopManifoldSubset` implements generic subsets of a topological
-manifold. Open subsets are implemented by the class
+The class :class:`TopManifoldSubset` implements generic subsets of a
+topological manifold. Open subsets are implemented by the class
:class:`~sage.manifolds.manifold.TopManifold` (since an open subset of a
manifold is a manifold by itself), which inherits from
:class:`TopManifoldSubset`.
@@ -181,7 +181,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
Parent.__init__(self, category=category, facade=manifold)
for dom in manifold._subsets:
if name == dom._name:
- raise ValueError("The name '" + name +
+ raise ValueError("the name '" + name +
"' is already used for another " +
"subset of the {}".format(manifold))
manifold._subsets.add(self)
@@ -260,14 +260,15 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
Point on the 2-dimensional topological manifold M
sage: Y(p)
(0, 1/2)
- sage: p = A._element_constructor_((0,1/2), chart=Y, check_coords=False); p
+ sage: p = A._element_constructor_((0,1/2), chart=Y,
+ ....: check_coords=False); p
Point on the 2-dimensional topological manifold M
sage: Y(p)
(0, 1/2)
sage: p = A._element_constructor_((3,1/2), chart=Y)
Traceback (most recent call last):
...
- ValueError: The coordinates (3, 1/2) are not valid on the Chart (M, (u, v))
+ ValueError: the coordinates (3, 1/2) are not valid on the Chart (M, (u, v))
Specifying the name of the point::
@@ -300,7 +301,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def _an_element_(self):
r"""
- Construct some point in ``self``.
+ Construct some point in the subset.
EXAMPLES::
@@ -320,7 +321,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def _repr_(self):
r"""
- String representation of ``self``.
+ String representation of the object.
TESTS::
@@ -336,7 +337,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def _latex_(self):
r"""
- LaTeX representation of ``self``.
+ LaTeX representation of the object.
TESTS::
@@ -355,7 +356,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def manifold(self):
r"""
- Return the manifold of which ``self`` is a subset.
+ Return the manifold of which the current object is a subset.
EXAMPLES::
@@ -375,12 +376,12 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def subsets(self):
r"""
- Return the set of subsets that have been defined on ``self``.
+ Return the set of subsets that have been defined on the current subset.
OUTPUT:
- A Python set containing all the subsets that have been defined on
- ``self``.
+ the current subset.
.. NOTE::
@@ -425,7 +426,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
OUTPUT:
- A list containing all the subsets that have been defined on
- ``self``.
+ the current subset.
.. NOTE::
@@ -457,7 +458,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def subset(self, name, latex_name=None, is_open=False):
r"""
- Create a subset of ``self``.
+ Create a subset of the current subset.
INPUT:
@@ -508,9 +509,10 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def superset(self, name, latex_name=None, is_open=False):
r"""
- Create a superset of ``self``.
+ Create a superset of the current subset.
- A *superset* is a manifold subset in which ``self`` is included.
+ A *superset* is a manifold subset in which the current subset is
+ included.
INPUT:
@@ -573,7 +575,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def intersection(self, other, name=None, latex_name=None):
r"""
- Return the intersection of ``self`` with another subset.
+ Return the intersection of the current subset with another subset.
INPUT:
@@ -588,7 +590,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
OUTPUT:
- instance of :class:`TopManifoldSubset` representing the subset that
- is the intersection of ``self`` with ``other``
+ is the intersection of the current subset with ``other``
EXAMPLES:
@@ -631,8 +633,8 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
"""
if other._manifold != self._manifold:
- raise TypeError(
- "The two subsets do not belong to the same manifold.")
+ raise ValueError(
+ "the two subsets do not belong to the same manifold")
# Particular cases:
if self is self._manifold:
return other
@@ -669,7 +671,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def union(self, other, name=None, latex_name=None):
r"""
- Return the union of ``self`` with another subset.
+ Return the union of the current subset with another subset.
INPUT:
@@ -684,7 +686,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
OUTPUT:
- instance of :class:`TopManifoldSubset` representing the subset that
- is the union of ``self`` with ``other``
+ is the union of the current subset with ``other``
EXAMPLES:
@@ -727,8 +729,8 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
"""
if other._manifold != self._manifold:
- raise TypeError(
- "The two subsets do not belong to the same manifold.")
+ raise ValueError(
+ "the two subsets do not belong to the same manifold")
# Particular cases:
if (self is self._manifold) or (other is self._manifold):
return self._manifold
@@ -770,14 +772,14 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def declare_union(self, dom1, dom2):
r"""
- Declare that ``self`` is the union of two subsets, i.e.
+ Declare that the current subset is the union of two subsets, i.e.
that
.. MATH::
U = U_1 \cup U_2
- where `U` is ``self``, `U_1\subset U` and `U_2\subset U`.
+ where `U` is the current subset, `U_1\subset U` and `U_2\subset U`.
INPUT:
@@ -795,21 +797,21 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
"""
if not dom1.is_subset(self):
- raise TypeError("The " + str(dom1) + " is not a subset of " +
- "the " + str(self) + ".")
+ raise TypeError("the {} is not a subset of ".format(dom1) +
+ "the {}".format(self))
if not dom2.is_subset(self):
- raise TypeError("The " + str(dom2) + " is not a subset of " +
- "the " + str(self) + ".")
+ raise TypeError("the {} is not a subset of ".format(dom2) +
+ "the {}".format(self))
dom1._unions[dom2._name] = self
dom2._unions[dom1._name] = self
def is_subset(self, other):
r"""
- Return ``True`` iff ``self`` is included in ``other``.
+ Return ``True`` iff the current subset is included in ``other``.
EXAMPLES:
- Subsubsets on a 2-dimensional manifold::
+ Subsets on a 2-dimensional manifold::
sage: M = TopManifold(2, 'M')
sage: a = M.subset('A')
@@ -831,7 +833,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def __contains__(self, point):
r"""
- Check whether a point is contained in ``self``.
+ Check whether a point is contained in the current subset.
TESTS::
@@ -863,7 +865,7 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
def point(self, coords=None, chart=None, name=None, latex_name=None):
r"""
- Define a point in ``self``.
+ Define a point in the subset.
See :class:`~sage.manifolds.point.TopManifoldPoint` for a
complete documentation.
@@ -872,12 +874,12 @@ class TopManifoldSubset(UniqueRepresentation, Parent):
- ``coords`` -- the point coordinates (as a tuple or a list) in the
chart specified by ``chart``
- - ``chart`` -- (default: ``None``) chart in which the point coordinates are
- given; if none is provided, the coordinates are assumed to refer to
- the default chart of ``self``
+ - ``chart`` -- (default: ``None``) chart in which the point coordinates
+ are given; if ``None``, the coordinates are assumed to refer to
+ the default chart of the current subset
- ``name`` -- (default: ``None``) name given to the point
- - ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the point;
- if none is provided, the LaTeX symbol is set to ``name``
+ - ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the
+ point; if ``None``, the LaTeX symbol is set to ``name``
OUTPUT:
diff --git a/src/sage/manifolds/utilities.py b/src/sage/manifolds/utilities.py
index 27bb85c..3ce51b4 100644
--- a/src/sage/manifolds/utilities.py
+++ b/src/sage/manifolds/utilities.py
@@ -242,7 +242,7 @@ def simplify_abs_trig(expr):
def simplify_chain_real(expr):
r"""
- Apply a chain of simplications to a symbolic expression, assuming the
+ Apply a chain of simplifications to a symbolic expression, assuming the
real domain.
This is the simplification chain used in calculus involving coordinate
@@ -344,7 +344,7 @@ def simplify_chain_real(expr):
def simplify_chain_generic(expr):
r"""
- Apply a chain of simplications to a symbolic expression
+ Apply a chain of simplifications to a symbolic expression.
This is the simplification chain used in calculus involving coordinate
functions on manifolds over fields different from `\RR`, as implemented in
@@ -451,7 +451,7 @@ class ExpressionNice(Expression):
y {\left(z - \frac{\partial\,h}{\partial z}\right)}^{2}
+ x \frac{\partial^2\,f}{\partial x\partial y}
- An example when function variables are themselve functions::
+ 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
@@ -489,7 +489,7 @@ class ExpressionNice(Expression):
\left(\frac{\partial\,f}{\partial y}\right)^{2}
The explicit mention of function arguments can be omitted for the sake of
- brievety::
+ brevity::
sage: fun = fun*f
sage: ExpressionNice(fun)
@@ -574,10 +574,13 @@ class ExpressionNice(Expression):
variables = m[4]
# dictionary to group multiple occurences of differentiation: d/dxdx -> d/dx^2 etc.
- occ = dict((i, str(variables[i]) + "^" + str(diffargs.count(i)) if(diffargs.count(i)>1) else str(variables[i])) for i in diffargs)
+ occ = dict((i, str(variables[i]) + "^" + str(diffargs.count(i))
+ if (diffargs.count(i)>1) else str(variables[i]))
+ for i in diffargs)
# re.sub for removing the brackets of possible composite variables
- res = "d" + str(numargs) + "(" + str(funcname) + ")/d" + "d".join([re.sub("\(.*?\)","", i) for i in occ.values()])
+ res = "d" + str(numargs) + "(" + str(funcname) + ")/d" + "d".join(
+ [re.sub("\(.*?\)","", i) for i in occ.values()])
# str representation of the operator
s = self._parent._repr_element_(m[0])
@@ -669,9 +672,13 @@ class ExpressionNice(Expression):
variables = m[4]
# dictionary to group multiple occurences of differentiation: d/dxdx -> d/dx^2 etc.
- occ = dict((i, str(variables[i]) + "^" + str(diffargs.count(i)) if(diffargs.count(i)>1) else str(variables[i])) for i in diffargs)
+ occ = dict((i, str(variables[i]) + "^" + str(diffargs.count(i))
+ if (diffargs.count(i)>1) else str(variables[i]))
+ for i in diffargs)
- res = "\\frac{\partial" + numargs + "\," + funcname + "}{\partial " + "\partial ".join([re.sub("\(.*?\)", "", i) for i in occ.values()]) + "}"
+ res = "\\frac{\partial" + numargs + "\," + funcname + \
+ "}{\partial " + "\partial ".join(
+ [re.sub("\(.*?\)", "", i) for i in occ.values()]) + "}"
# representation of the operator
s = self._parent._latex_element_(m[0])
@@ -700,7 +707,7 @@ class ExpressionNice(Expression):
def _list_derivatives(ex, list_d, exponent=0):
r"""
- Function to find the occurences of FDerivativeOperator in a symbolic
+ Function to find the occurrences of FDerivativeOperator in a symbolic
expression; inspired by http://ask.sagemath.org/question/10256/how-can-extract-different-terms-from-a-symbolic-expression/?answer=26136#post-id-26136
INPUT:
@@ -755,7 +762,8 @@ def _list_derivatives(ex, list_d, exponent=0):
if function == latex_function:
latex_function = latex_variable_name(str(op.function()))
- list_d.append((ex, function, latex_function, parameter_set, operands, exponent))
+ list_d.append((ex, function, latex_function, parameter_set,
+ operands, exponent))
for operand in operands:
_list_derivatives(operand, list_d, exponent)
@@ -763,7 +771,7 @@ def _list_derivatives(ex, list_d, exponent=0):
def _list_functions(ex, list_f):
r"""
- Function to find the occurences of symbolic functions in a symbolic
+ Function to find the occurrences of symbolic functions in a symbolic
expression.
INPUT:
@@ -902,4 +910,3 @@ def omit_function_args(status):
if not isinstance(status, bool):
raise TypeError("the argument must be a boolean")
CoordFunctionSymb._omit_fargs = status
-