#17058: Add abelian_vectors and abelian_complexity method to finite words
-------------------------+-------------------------------------------------
Reporter: | Owner:
slabbe | Status: needs_work
Type: | Milestone: sage-6.4
enhancement | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
combinatorics | Work issues:
Keywords: | Commit:
Authors: | 4072235c4b5b0b57d700afeecfd1da1cdf26e2c4
Report Upstream: N/A | Stopgaps:
Branch: |
u/slabbe/17058 |
Dependencies: |
-------------------------+-------------------------------------------------
Changes (by vdelecroix):
* status: needs_review => needs_work
Comment:
Hi,
I got
{{{
sage: w = Word([0,1,0])
sage: w.abelian_complexity(5)
Traceback (most recent call last):
...
StopIteration:
}}}
where I would expect a `0`.
stupid coercion is around
{{{
sage: timeit("1 < Infinity")
625 loops, best of 3: 12.6 µs per loop
sage: timeit("1 < float('inf')")
625 loops, best of 3: 803 ns per loop
}}}
but I guess it is not critical here.
What do you think of
{{{
sage: from itertools import count
sage: w = Word(count(), alphabet=NN)
sage: w[:2].abelian_vectors(2)
{(1, 1)}
sage: w[:3].abelian_vectors(2)
{(0, 1, 1), (1, 1, 0)}
sage: w[:4].abelian_vectors(2)
{(0, 0, 1, 1), (0, 1, 1, 0), (1, 1, 0, 0)}
}}}
I think this is very bad. I would rather raise an Error when the alphabet
is infinite (in the very same way `abelian_vector` does, by the way). But
at least `.abelian_complexity()` gets right.
Are you sure that the `@cached_method` is needed on `.letters()`? It seems
used only when the alphabet is infinite... in which case the user is doing
something wrong.
The convention for the header of methods is "Return bla" instead of
"Returns bla". See
[http://www.sagemath.org/doc/developer/coding_basics.html#docstring-
markup-with-rest-and-sphinx developer guide] about the header:
{{{
A one-sentence description of the function, followed by a blank line and
ending in a period. It prescribes the function or method’s effect as a
command (“Do this”, “Return that”), not as a description; e.g. don’t
write “Returns the pathname ...”.
}}}
Be careful, you introduced several trailing whitespaces.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/17058#comment:10>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.