#8127: Wraps string features into WordDatatypes
---------------------------------+------------------------------------------
Reporter: vdelecroix | Owner: vdelecroix
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.3.2
Component: algebra | Keywords: string, word
Author: Vincent Delecroix | Upstream: N/A
Reviewer: Sébastien Labbé | Merged:
Work_issues: |
---------------------------------+------------------------------------------
Changes (by newvalueoldvalue):
* cc: fsaliola (removed)
* cc: saliola (added)
* reviewer: => Sébastien Labbé
* status: needs_review => needs_work
* author: vdelecroix => Vincent Delecroix
Comment:
I just tested the patch. All test passed. Not tested the sphinx docbuild
because the affected file is not part of the doc (maybe it should?). But I
wonder if no blank line before the INPUT: line could raise a error in the
docbuild process. I think the patch needs work for the reasons explained
below.
The `string_rep()` output depends on the current state of the truncate
length :
{{{
sage: u = Word('abcdbruitbruit01234...ababbruitbruit01234...abababab')
sage: u.string_rep()
'abcdbruitbruit01234...ababbruitbruit0123...'
}}}
which leads to the following bug :
{{{
sage: w = Word(range(20))
sage: u.split(w)
[word: abcdbruitbruit01234...ababbruitbruit0123...]
sage: WordOptions(truncate_length=5)
sage: u.split(w)
[word: abcdb..., word: ababb..., word: ababa...]
}}}
To correct this, I suggest that the function `split` be supported only for
str and `WordDatatype_str` object.
Same suggestion for partition function:
{{{
sage: u = Word('abcdbruitbruit01234...ababbruitbruit01234...abababab')
sage: w = Word(range(20))
sage: u.partition(w)
[word: abcdbruitbruit01234...ababbruitbruit0123..., word: , word: ]
sage: WordOptions(truncate_length=5)
sage: u.partition(w)
[word: abcdb..., word: 01234..., word: ababb...]
}}}
I think split should follow the behavior of the python split for str, i.e
works for no input given :
{{{
sage: s = 'absdg asdfas asdfa'
sage: s.split()
['absdg', 'asdfas', 'asdfa']
sage: s.split(' ')
['absdg', 'asdfas', 'asdfa']
sage: s.split(None)
['absdg', 'asdfas', 'asdfa']
sage: w = Word(s)
sage: w.split()
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'string_rep'
sage: w.split(' ')
[word: absdg, word: asdfas, word: asdfa]
sage: w.split(None)
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'string_rep'
}}}
The INPUT block of `split` should mention the part `(optional, default:
None)` for both arguments.
For both functions, I suggest to move the `..notes` block after the OUTPUT
block.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8127#comment:3>
Sage <http://www.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.