Skip to content

Commit

Permalink
Trac #24322: Use new-style GlobalOptions
Browse files Browse the repository at this point in the history
The syntax
{{{
options=GlobalOptions(...
    doc="""
    EXAMPLES::

        sage: #doctest here
    """
)
}}}
has the unfortunate effect that the doctests are not actually seen as
doctests. They are just a string, nothing more. Ticket #23238 was
created to allow a new syntax for `GlobalOptions`, which makes the
doctests actually doctests.

This ticket uses the new syntax in all cases. This enables some doctests
which were not tested before. As expected, this uncovered various
failures. Some trivial ones are fixed, others are marked as `# known
bug` with the following tickets opened: #24323, #24324, #24325. #24326

URL: https://trac.sagemath.org/24322
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Dec 11, 2017
2 parents e71dc43 + 577504b commit 2cbaa17
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 217 deletions.
16 changes: 8 additions & 8 deletions src/sage/combinat/crystals/tensor_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,17 @@ def __classcall_private__(cls, *crystals, **options):
return FullTensorProductOfCrystals(tp, cartan_type=cartan_type)

# add options to class
options=GlobalOptions('TensorProductOfCrystals',
module='sage.combinat.crystals',
doc=r"""
class options(GlobalOptions):
r"""
Sets the global options for tensor products of crystals. The default is to
use the anti-Kashiwara convention.
There are two conventions for how `e_i` and `f_i` act on tensor products,
and the difference between the two is the order of the tensor factors
are reversed. This affects both the input and output. See the example
below.
""",
end_doc=r"""
@OPTIONS@
.. NOTE::
Expand Down Expand Up @@ -443,14 +442,15 @@ def __classcall_private__(cls, *crystals, **options):
sage: T(C(2), C(1)) == elt
True
sage: crystals.TensorProduct.options._reset()
""",
convention=dict(default="antiKashiwara",
"""
NAME = 'TensorProductOfCrystals'
module = 'sage.combinat.crystals'
convention = dict(default="antiKashiwara",
description='Sets the convention used for displaying/inputting tensor product of crystals',
values=dict(antiKashiwara='use the anti-Kashiwara convention',
Kashiwara='use the Kashiwara convention'),
alias=dict(anti="antiKashiwara", opposite="antiKashiwara"),
case_sensitive=False)
)

def _element_constructor_(self, *crystalElements):
"""
Expand Down
26 changes: 14 additions & 12 deletions src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,36 +240,38 @@ def __init__(self, parent, d):
super(AbstractPartitionDiagram, self).__init__(parent, self._base_diagram)

# add options to class
options=GlobalOptions('Brauer diagram', option_class='AbstractPartitionDiagram',
module='sage.combinat.diagram_algebras',
doc=r"""
class options(GlobalOptions):
r"""
Set and display the global options for Brauer diagram (algebras). If no
parameters are set, then the function returns a copy of the options
dictionary.
The ``options`` to diagram algebras can be accessed as the method
:obj:`BrauerAlgebra.options` of :class:`BrauerAlgebra` and
related classes.
""",
end_doc=r"""
@OPTIONS@
EXAMPLES::
sage: R.<q> = QQ[]
sage: BA = BrauerAlgebra(2, q)
sage: E = BA([[1,2],[-1,-2]])
sage: E
B{{-2, -1}, {1, 2}}
sage: BrauerAlgebra.options.display="compact"
sage: E
sage: BrauerAlgebra.options.display="compact" # known bug (Trac #24323)
sage: E # known bug (Trac #24323)
B[12/12;]
sage: BrauerAlgebra.options._reset()
""",
display=dict(default="normal",
sage: BrauerAlgebra.options._reset() # known bug (Trac #24323)
"""
NAME = 'Brauer diagram'
module = 'sage.combinat.diagram_algebras'
option_class='AbstractPartitionDiagram'
display = dict(default="normal",
description='Specifies how the Brauer diagrams should be printed',
values=dict(normal="Using the normal representation",
compact="Using the compact representation"),
case_sensitive=False),
)
case_sensitive=False)

def check(self):
r"""
Expand Down
94 changes: 48 additions & 46 deletions src/sage/combinat/dyck_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -3174,72 +3174,74 @@ def __classcall_private__(cls, k1=None, k2=None, complete=True):
Element = DyckWord

# add options to class
options=GlobalOptions('DyckWords', module='sage.combinat.dyck_word',
doc=r"""
class options(GlobalOptions):
r"""
Set and display the options for Dyck words. If no parameters
are set, then the function returns a copy of the options dictionary.
The ``options`` to Dyck words can be accessed as the method
:meth:`DyckWords.options` of :class:`DyckWords` and
related parent classes.
""",
end_doc=r"""
@OPTIONS
EXAMPLES::
sage: D = DyckWord([1, 1, 0, 1, 0, 0])
sage: D
[1, 1, 0, 1, 0, 0]
sage: DyckWords.options.display="lattice"
sage: D
sage: D # known bug (Trac #24324)
___
_| x
| x .
| . .
sage: DyckWords.options(diagram_style="line")
sage: D
sage: D # known bug (Trac #24324)
/\/\
/ \
sage: DyckWords.options._reset()
""",
display=dict(default="list",
description='Specifies how Dyck words should be printed',
values=dict(list='displayed as a list',
lattice='displayed on the lattice defined by ``diagram_style``'),
case_sensitive=False),
ascii_art=dict(default="path",
description='Specifies how the ascii art of Dyck words should be printed',
values=dict(path="Using the path string",
pretty_output="Using pretty printing"),
alias=dict(pretty_print="pretty_output", path_string="path"),
case_sensitive=False),
diagram_style=dict(default="grid",
values=dict(grid='printing as paths on a grid using N and E steps',
line='printing as paths on a line using NE and SE steps',),
alias={'N-E': 'grid', 'NE-SE': 'line'},
case_sensitive=False),
latex_tikz_scale=dict(default=1,
description='The default value for the tikz scale when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_diagonal=dict(default=False,
description='The default value for displaying the diagonal when latexed',
checker=lambda x: isinstance(x, bool)),
latex_line_width_scalar=dict(default=2,
description='The default value for the line width as a'
'multiple of the tikz scale when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_color=dict(default="black",
description='The default value for the color when latexed',
checker=lambda x: isinstance(x, str)),
latex_bounce_path=dict(default=False,
description='The default value for displaying the bounce path when latexed',
checker=lambda x: isinstance(x, bool)),
latex_peaks=dict(default=False,
description='The default value for displaying the peaks when latexed',
checker=lambda x: isinstance(x, bool)),
latex_valleys=dict(default=False,
description='The default value for displaying the valleys when latexed',
checker=lambda x: isinstance(x, bool)),
)
"""
NAME = 'DyckWords'
module = 'sage.combinat.dyck_word'
display = dict(default="list",
description='Specifies how Dyck words should be printed',
values=dict(list='displayed as a list',
lattice='displayed on the lattice defined by ``diagram_style``'),
case_sensitive=False)
ascii_art = dict(default="path",
description='Specifies how the ascii art of Dyck words should be printed',
values=dict(path="Using the path string",
pretty_output="Using pretty printing"),
alias=dict(pretty_print="pretty_output", path_string="path"),
case_sensitive=False)
diagram_style = dict(default="grid",
values=dict(grid='printing as paths on a grid using N and E steps',
line='printing as paths on a line using NE and SE steps',),
alias={'N-E': 'grid', 'NE-SE': 'line'},
case_sensitive=False)
latex_tikz_scale = dict(default=1,
description='The default value for the tikz scale when latexed',
checker=lambda x: True) # More trouble than it's worth to check
latex_diagonal = dict(default=False,
description='The default value for displaying the diagonal when latexed',
checker=lambda x: isinstance(x, bool))
latex_line_width_scalar = dict(default=2,
description='The default value for the line width as a '
'multiple of the tikz scale when latexed',
checker=lambda x: True) # More trouble than it's worth to check
latex_color = dict(default="black",
description='The default value for the color when latexed',
checker=lambda x: isinstance(x, str))
latex_bounce_path = dict(default=False,
description='The default value for displaying the bounce path when latexed',
checker=lambda x: isinstance(x, bool))
latex_peaks = dict(default=False,
description='The default value for displaying the peaks when latexed',
checker=lambda x: isinstance(x, bool))
latex_valleys = dict(default=False,
description='The default value for displaying the valleys when latexed',
checker=lambda x: isinstance(x, bool))

def _element_constructor_(self, word):
"""
Expand Down
43 changes: 22 additions & 21 deletions src/sage/combinat/interval_posets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2450,52 +2450,53 @@ def __classcall_private__(cls, n=None):
return TamariIntervalPosets_size(Integer(n))

# add options to class
options = GlobalOptions('TamariIntervalPosets',
module='sage.combinat.interval_posets',
doc=r"""
class options(GlobalOptions):
r"""
Set and display the options for Tamari interval-posets. If no
parameters are set, then the function returns a copy of the options
dictionary.
The ``options`` to Tamari interval-posets can be accessed as the method
:meth:`TamariIntervalPosets.options` of :class:`TamariIntervalPosets`
and related parent classes.
""",
end_doc=r"""
@OPTIONS@
EXAMPLES::
sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)])
sage: ip.latex_options.color_decreasing
sage: ip.latex_options.color_decreasing # known bug (Trac #24326)
'red'
sage: TamariIntervalPosets.options.latex_color_decreasing='green'
sage: ip.latex_options.color_decreasing
sage: ip.latex_options.color_decreasing # known bug (Trac #24326)
'green'
sage: TamariIntervalPosets.options._reset()
sage: ip.latex_options.color_decreasing
sage: ip.latex_options.color_decreasing # known bug (Trac #24326)
'red'
""",
latex_tikz_scale=dict(default=1,
"""
NAME = 'TamariIntervalPosets'
module = 'sage.combinat.interval_posets'
latex_tikz_scale = dict(default=1,
description='the default value for the tikz scale when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_line_width_scalar=dict(default=0.5,
checker=lambda x: True) # More trouble than it's worth to check
latex_line_width_scalar = dict(default=0.5,
description='the default value for the line width as a'
'multiple of the tikz scale when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_color_decreasing=dict(default="red",
checker=lambda x: True) # More trouble than it's worth to check
latex_color_decreasing = dict(default="red",
description='the default color of decreasing relations when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_color_increasing=dict(default="blue",
checker=lambda x: True) # More trouble than it's worth to check
latex_color_increasing = dict(default="blue",
description='the default color of increasing relations when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_hspace=dict(default=1,
checker=lambda x: True) # More trouble than it's worth to check
latex_hspace = dict(default=1,
description='the default difference between horizontal'
' coordinates of vertices when latexed',
checker=lambda x: True), # More trouble than it's worth to check
latex_vspace=dict(default=1,
checker=lambda x: True) # More trouble than it's worth to check
latex_vspace = dict(default=1,
description='the default difference between vertical'
' coordinates of vertices when latexed',
checker=lambda x: True) # More trouble than it's worth to check
)

@staticmethod
def check_poset(poset):
Expand Down
33 changes: 17 additions & 16 deletions src/sage/combinat/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5184,18 +5184,18 @@ def __init__(self, is_infinite=False):
Element = Partition

# add options to class
options = GlobalOptions('Partitions',
module='sage.combinat.partition',
doc=r"""
class options(GlobalOptions):
r"""
Sets and displays the global options for elements of the partition,
skew partition, and partition tuple classes. If no parameters are
set, then the function returns a copy of the options dictionary.
The ``options`` to partitions can be accessed as the method
:obj:`Partitions.options` of :class:`Partitions` and
related parent classes.
""",
end_doc=r"""
@OPTIONS@
EXAMPLES::
sage: P = Partition([4,2,2,1])
Expand Down Expand Up @@ -5245,8 +5245,10 @@ def __init__(self, is_infinite=False):
1 2 3
4 5
sage: Partitions.options._reset()
""",
display=dict(default="list",
"""
NAME = 'Partitions'
module = 'sage.combinat.partition'
display = dict(default="list",
description='Specifies how partitions should be printed',
values=dict(list='displayed as a list',
exp_low='in exponential form (lowest first)',
Expand All @@ -5256,25 +5258,24 @@ def __init__(self, is_infinite=False):
compact_high='compact form of ``exp_high``'),
alias=dict(exp="exp_low", compact="compact_low", array="diagram",
ferrers_diagram="diagram", young_diagram="diagram"),
case_sensitive=False),
latex=dict(default="young_diagram",
case_sensitive=False)
latex = dict(default="young_diagram",
description='Specifies how partitions should be latexed',
values=dict(diagram='latex as a Ferrers diagram',
young_diagram='latex as a Young diagram',
list='latex as a list',
exp_high='latex as a list in exponential notation (highest first)',
exp_low='as a list latex in exponential notation (lowest first)'),
alias=dict(exp="exp_low", array="diagram", ferrers_diagram="diagram"),
case_sensitive=False),
diagram_str=dict(default="*",
case_sensitive=False)
diagram_str = dict(default="*",
description='The character used for the cells when printing Ferrers diagrams',
checker=lambda char: isinstance(char,str)),
latex_diagram_str=dict(default="\\ast",
checker=lambda char: isinstance(char,str))
latex_diagram_str = dict(default="\\ast",
description='The character used for the cells when latexing Ferrers diagrams',
checker=lambda char: isinstance(char,str)),
convention=dict(link_to=(tableau.Tableaux.options,'convention')),
checker=lambda char: isinstance(char,str))
convention = dict(link_to=(tableau.Tableaux.options,'convention'))
notation = dict(alt_name='convention')
)

def __reversed__(self):
"""
Expand Down

0 comments on commit 2cbaa17

Please sign in to comment.