@@ -525,15 +525,48 @@ def _repr_(self):
525
525
sage: c._repr_()
526
526
'2-indices components w.r.t. [1, 2, 3]'
527
527
528
+ sage: from sage.tensor.modules.comp import CompWithSym
529
+ sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1))
530
+ 4-indices components w.r.t. [1, 2, 3],
531
+ with symmetry on the index positions (0, 1)
532
+ sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1), antisym=(2,3))
533
+ 4-indices components w.r.t. [1, 2, 3],
534
+ with symmetry on the index positions (0, 1),
535
+ with antisymmetry on the index positions (2, 3)
536
+
537
+ sage: from sage.tensor.modules.comp import CompFullySym
538
+ sage: CompFullySym(ZZ, (1,2,3), 4)
539
+ Fully symmetric 4-indices components w.r.t. (1, 2, 3)
540
+
541
+ sage: from sage.tensor.modules.comp import CompFullyAntiSym
542
+ sage: CompFullyAntiSym(ZZ, (1,2,3), 4)
543
+ Fully antisymmetric 4-indices components w.r.t. (1, 2, 3)
528
544
"""
529
- description = str (self ._nid )
545
+ prefix , suffix = self ._repr_symmetry ()
546
+ description = prefix
547
+ description += str (self ._nid )
530
548
if self ._nid == 1 :
531
549
description += "-index"
532
550
else :
533
551
description += "-indices"
534
552
description += " components w.r.t. " + str (self ._frame )
553
+ description += suffix
535
554
return description
536
555
556
+ def _repr_symmetry (self ):
557
+ r"""
558
+ Return a prefix and a suffix string describing the symmetry of ``self``.
559
+
560
+ EXAMPLES::
561
+
562
+ sage: from sage.tensor.modules.comp import Components
563
+ sage: c = Components(ZZ, [1,2,3], 2)
564
+ sage: c._repr_symmetry()
565
+ ('', '')
566
+
567
+ """
568
+ return "" , ""
569
+
537
570
def _new_instance (self ):
538
571
r"""
539
572
Creates a :class:`Components` instance of the same number of indices
@@ -3128,35 +3161,29 @@ def _canonicalize_sym_antisym(nb_indices, sym=None, antisym=None):
3128
3161
"index position appears more than once" )
3129
3162
return result_sym , result_antisym
3130
3163
3131
- def _repr_ (self ):
3164
+ def _repr_symmetry (self ):
3132
3165
r"""
3133
- Return a string representation of ``self``.
3166
+ Return a prefix and a suffix string describing the symmetry of ``self``.
3134
3167
3135
3168
EXAMPLES::
3136
3169
3137
3170
sage: from sage.tensor.modules.comp import CompWithSym
3138
- sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1))
3139
- 4-indices components w.r.t. [1, 2, 3],
3140
- with symmetry on the index positions (0, 1)
3141
- sage: CompWithSym(ZZ, [1,2,3], 4, sym=(0,1), antisym=(2,3))
3142
- 4-indices components w.r.t. [1, 2, 3],
3143
- with symmetry on the index positions (0, 1),
3144
- with antisymmetry on the index positions (2, 3)
3145
-
3171
+ sage: cp = CompWithSym(QQ, [1,2,3], 4, sym=(0,1))
3172
+ sage: cp._repr_symmetry()
3173
+ ('', ', with symmetry on the index positions (0, 1)')
3174
+ sage: cp = CompWithSym(QQ, [1,2,3], 4, sym=((0,1),), antisym=((2,3),))
3175
+ sage: cp._repr_symmetry()
3176
+ ('',
3177
+ ', with symmetry on the index positions (0, 1), with antisymmetry on the index positions (2, 3)')
3146
3178
"""
3147
- description = str (self ._nid )
3148
- if self ._nid == 1 :
3149
- description += "-index"
3150
- else :
3151
- description += "-indices"
3152
- description += " components w.r.t. " + str (self ._frame )
3179
+ description = ""
3153
3180
for isym in self ._sym :
3154
3181
description += ", with symmetry on the index positions " + \
3155
3182
str (tuple (isym ))
3156
3183
for isym in self ._antisym :
3157
3184
description += ", with antisymmetry on the index positions " + \
3158
3185
str (tuple (isym ))
3159
- return description
3186
+ return "" , description
3160
3187
3161
3188
def _new_instance (self ):
3162
3189
r"""
@@ -4824,19 +4851,19 @@ def __init__(self, ring, frame, nb_indices, start_index=0,
4824
4851
CompWithSym .__init__ (self , ring , frame , nb_indices , start_index ,
4825
4852
output_formatter , sym = range (nb_indices ))
4826
4853
4827
- def _repr_ (self ):
4854
+ def _repr_symmetry (self ):
4828
4855
r"""
4829
- Return a string representation of ``self``.
4856
+ Return a prefix and a suffix string describing the symmetry of ``self``.
4830
4857
4831
4858
EXAMPLES::
4832
4859
4833
4860
sage: from sage.tensor.modules.comp import CompFullySym
4834
- sage: CompFullySym(ZZ, (1,2,3), 4)
4835
- Fully symmetric 4-indices components w.r.t. (1, 2, 3)
4861
+ sage: c = CompFullySym(ZZ, (1,2,3), 4)
4862
+ sage: c._repr_symmetry()
4863
+ ('Fully symmetric ', '')
4836
4864
4837
4865
"""
4838
- return "Fully symmetric " + str (self ._nid ) + "-indices" + \
4839
- " components w.r.t. " + str (self ._frame )
4866
+ return "Fully symmetric " , ""
4840
4867
4841
4868
def _new_instance (self ):
4842
4869
r"""
@@ -5283,19 +5310,19 @@ def __init__(self, ring, frame, nb_indices, start_index=0,
5283
5310
CompWithSym .__init__ (self , ring , frame , nb_indices , start_index ,
5284
5311
output_formatter , antisym = range (nb_indices ))
5285
5312
5286
- def _repr_ (self ):
5313
+ def _repr_symmetry (self ):
5287
5314
r"""
5288
- Return a string representation of ``self``.
5315
+ Return a prefix and a suffix string describing the symmetry of ``self``.
5289
5316
5290
5317
EXAMPLES::
5291
5318
5292
5319
sage: from sage.tensor.modules.comp import CompFullyAntiSym
5293
- sage: CompFullyAntiSym(ZZ, (1,2,3), 4)
5294
- Fully antisymmetric 4-indices components w.r.t. (1, 2, 3)
5320
+ sage: c = CompFullyAntiSym(ZZ, (1,2,3), 4)
5321
+ sage: c._repr_symmetry()
5322
+ ('Fully antisymmetric ', '')
5295
5323
5296
5324
"""
5297
- return "Fully antisymmetric " + str (self ._nid ) + "-indices" + \
5298
- " components w.r.t. " + str (self ._frame )
5325
+ return "Fully antisymmetric " , ""
5299
5326
5300
5327
def _new_instance (self ):
5301
5328
r"""
0 commit comments