Skip to content

Commit d85cf19

Browse files
Bruno-TTdimpase
authored andcommitted
improve imports + doc tweaks
1 parent 66ea558 commit d85cf19

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/sage/matrix/operation_table.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from sage.structure.sage_object import SageObject
1818
from matplotlib.cm import gist_rainbow, Greys
1919
from sage.plot.matrix_plot import matrix_plot
20-
from sage.matrix.constructor import Matrix
2120
from sage.plot.text import text
2221
from sage.all import copy
2322

@@ -950,11 +949,17 @@ def matrix_of_variables(self):
950949
for i in range(self._n) for j in range(self._n)]
951950
return MS(entries)
952951

952+
953+
### documentation hack ###
954+
# this code makes the docs display the default
955+
# argument of color_table as "gist_rainbow"
956+
# instead of something like
957+
# <matplotlib.colors.LinearSegmentedColormap object at 0x7fc24f7e10a0>
953958
gist_rainbow_copy=copy(gist_rainbow)
954-
class ReprOverrideLinearSegmentedColormap(gist_rainbow_copy.__class__):
959+
class _ReprOverrideLinearSegmentedColormap(gist_rainbow_copy.__class__):
955960
def __repr__(self):
956-
return "Matplotlib gist_rainbow colormap"
957-
gist_rainbow_copy.__class__=ReprOverrideLinearSegmentedColormap
961+
return "gist_rainbow"
962+
gist_rainbow_copy.__class__=_ReprOverrideLinearSegmentedColormap
958963

959964

960965
def color_table(self, element_names=True, cmap=gist_rainbow_copy, **options):
@@ -965,11 +970,12 @@ def color_table(self, element_names=True, cmap=gist_rainbow_copy, **options):
965970
966971
- ``element_names`` - (default : ``True``) Whether to display text with element names on the image
967972
968-
- ``cmap`` - (default : ``gist_rainbow``) colour map for plot, see matplotlib.cm
973+
- ``cmap`` - (default : ``gist_rainbow``) matplotlib colour map object for plot
969974
970975
- ``**options`` - passed on to matrix_plot call
971976
972977
EXAMPLES::
978+
973979
sage: from sage.matrix.operation_table import OperationTable
974980
sage: OT = OperationTable(SymmetricGroup(3), operation=operator.mul)
975981
sage: OT.color_table()
@@ -978,7 +984,7 @@ def color_table(self, element_names=True, cmap=gist_rainbow_copy, **options):
978984
"""
979985

980986
# Base matrix plot object, without text
981-
plot = matrix_plot(Matrix(self._table), cmap=cmap,
987+
plot = matrix_plot(self._table, cmap=cmap,
982988
frame=False, **options)
983989

984990
if element_names:
@@ -1009,6 +1015,13 @@ def color_table(self, element_names=True, cmap=gist_rainbow_copy, **options):
10091015
return plot
10101016

10111017
def gray_table(self, **options):
1018+
r"""
1019+
See ``color_table`` - this uses a grey colour scheme instead of a colourful one.
1020+
1021+
INPUT:
1022+
1023+
- ``**options`` - passed on to ``color_table`` call
1024+
"""
10121025
return self.color_table(cmap=Greys, **options)
10131026

10141027
def _ascii_table(self):

0 commit comments

Comments
 (0)