#6903: Function Word currently prevent the inheritance of
Words_over_OrderedAlphabet
---------------------------+------------------------------------------------
Reporter: slabbe | Owner: mhansen
Type: defect | Status: new
Priority: major | Milestone: sage-combinat
Component: combinatorics | Keywords:
Reviewer: | Author:
Merged: |
---------------------------+------------------------------------------------
Let
{{{
sage: W = Words('ab')
}}}
In the state of sage-4.1.1, the function {{{W.__call__}}} uses the
function {{{Word}}}....but it should be the inverse. In fact, the code of
the function {{{Word}}} contains code like :
{{{
[...]
# Construct the word
if datatype == 'list':
w = FiniteWord_list(parent=parent,data=data)
elif datatype == 'str':
w = FiniteWord_str(parent=parent,data=data)
elif datatype == 'tuple':
w = FiniteWord_tuple(parent=parent,data=data)
elif datatype == 'callable':
if caching:
if length is None or length is Infinity:
cls = InfiniteWord_callable_with_caching
else:
cls = FiniteWord_callable_with_caching
else:
if length is None or length is Infinity:
cls = InfiniteWord_callable
else:
cls = FiniteWord_callable
w = cls(parent=parent,callable=data,length=length)
[...]
}}}
The problems come when someone wants to inherits the class
{{{Words_over_OrderedAlphabet}}} to create, let say, a combinatorial
classes of all paths (see #5038). Below, we would like the {{{__call__}}}
function of {{{WordPaths_all}}} to creates words paths instances and not
the usual words instances. I don't want to rewrite the {{{__call__}}}
function for {{{WordPaths_all}}} since it could be the exact same thing as
the one of {{{Words_over_OrderedAlphabet}}}.
{{{
class WordPaths_all(Words_over_OrderedAlphabet):
r"""
The combinatorial class of all paths, i.e of all words over
an alphabet where each letter is mapped to a step (a vector).
"""
def __init__(self, alphabet, steps):
r"""
INPUT:
- ``alphabet`` - an ordered alphabet
- ``steps`` - an iterable (of same length as alphabet) of ordered
vectors
EXAMPLES::
[...]
}}}
One solution is that the current code of {{{Word}}} goes to
{{{Words.__call__}}} and that the function {{{Word}}} simply creates the
parent from the input alphabet and delegates the creation to the parent.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6903>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---