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

Commit

Permalink
Remove import of Chart in sage.tensor.modules (#32708)
Browse files Browse the repository at this point in the history
  • Loading branch information
egourgoulhon committed Oct 17, 2021
1 parent c896669 commit 1635bd3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
32 changes: 32 additions & 0 deletions src/sage/manifolds/differentiable/tensorfield_paral.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
# *****************************************************************************

from sage.tensor.modules.free_module_tensor import FreeModuleTensor
from sage.manifolds.chart import Chart
from sage.manifolds.differentiable.tensorfield import TensorField
from sage.parallel.decorate import parallel
from sage.parallel.parallelism import Parallelism
Expand Down Expand Up @@ -727,6 +728,37 @@ def _del_derived(self, del_restrictions=True):
if del_restrictions:
self._del_restrictions()

def _preparse_display(self, basis=None, format_spec=None):
r"""
Helper function, to be used by FreeModuleTensor.display.
TESTS::
sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: t = M.tensor_field(1, 1)
sage: t._preparse_display()
(Coordinate frame (M, (∂/∂x,∂/∂y)), None)
sage: t._preparse_display(X.frame())
(Coordinate frame (M, (∂/∂x,∂/∂y)), None)
sage: t._preparse_display(X.frame(), X)
(Coordinate frame (M, (∂/∂x,∂/∂y)), Chart (M, (x, y)))
sage: t._preparse_display(X) # passing a chart instead of a frame
(Coordinate frame (M, (∂/∂x,∂/∂y)), Chart (M, (x, y)))
"""
if basis is None:
basis = self._fmodule._def_basis
elif isinstance(basis, Chart):
# a coordinate chart has been passed instead of a vector frame;
# the frame is then assumed to be the coordinate frame
# associated to the chart:
if format_spec is None:
format_spec = basis
basis = basis.frame()
return (basis, format_spec)


def _set_comp_unsafe(self, basis=None):
r"""
Return the components of the tensor field in a given vector frame
Expand Down
11 changes: 0 additions & 11 deletions src/sage/tensor/modules/free_module_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ class being:
from sage.tensor.modules.tensor_with_indices import TensorWithIndices
from sage.parallel.decorate import parallel
from sage.parallel.parallelism import Parallelism
from sage.manifolds.chart import Chart

# TODO: remove the import of Chart after _preparse_display has been redefined
# in tensor fields

class FreeModuleTensor(ModuleElementWithMutability):
r"""
Expand Down Expand Up @@ -583,13 +579,6 @@ def _preparse_display(self, basis=None, format_spec=None):
"""
if basis is None:
basis = self._fmodule._def_basis
elif isinstance(basis, Chart):
# a coordinate chart has been passed instead of a basis;
# the basis is then assumed to be the coordinate frame
# associated to the chart:
if format_spec is None:
format_spec = basis
basis = basis.frame()
return (basis, format_spec)

def display(self, basis=None, format_spec=None):
Expand Down

0 comments on commit 1635bd3

Please sign in to comment.