Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add computation of longest commons extensions in a word #23131

Closed
enadeau opened this issue Jun 2, 2017 · 32 comments
Closed

Add computation of longest commons extensions in a word #23131

enadeau opened this issue Jun 2, 2017 · 32 comments

Comments

@enadeau
Copy link

enadeau commented Jun 2, 2017

Add two methods to compute the longest commons extensions in forward and backward direction in a word.

Component: combinatorics

Keywords: words, days88, IMA coding sprints

Author: Émile Nadeau

Branch/Commit: 7ee5699

Reviewer: Travis Scrimshaw, Franco Saliola

Issue created by migration from https://trac.sagemath.org/ticket/23131

@enadeau enadeau added this to the sage-8.0 milestone Jun 2, 2017
@enadeau
Copy link
Author

enadeau commented Aug 1, 2017

@enadeau
Copy link
Author

enadeau commented Aug 1, 2017

New commits:

182d7d3Trac #23131: Add methods to compute longest common extension in words.

@enadeau
Copy link
Author

enadeau commented Aug 1, 2017

Commit: 182d7d3

@enadeau enadeau modified the milestones: sage-8.0, sage-8.1 Aug 2, 2017
@tscrim
Copy link
Collaborator

tscrim commented Aug 2, 2017

comment:4

You should put spaces between your operators (e.g., =, ==, +=, etc.) and after commas to be PEP8 compliant. You should make your variables in code format in your doc, e.g., ``y``. Also, do these changes in your methods:

-        INPUTS:
{        INPUT:
 
-            x,y - positions in self
+        - ``x``, ``y`` -- positions in ``self``
 
-        EXAMPLES:
+        EXAMPLES::

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 3, 2017

Changed commit from 182d7d3 to 788470c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 3, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

788470cTrac #23131: Correct code and doc formating

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 16, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

adae40dTrac #23131: Correct formating of code and doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 16, 2017

Changed commit from 788470c to adae40d

@tscrim
Copy link
Collaborator

tscrim commented Aug 17, 2017

comment:7

Three additional comments, but once addressed, then this will be ready for a positive review.

  • Translation needed le -> the.
  • - ``x``, ``y`` - positions in ``self`` should be - ``x``, ``y`` -- positions in ``self`` in longest_backward_extension.
  • I think if x and y are invalid positions, then the method should raise a ValueError instead of returning 0 as it is invalid input.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 21, 2017

Changed commit from adae40d to c992563

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 21, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

c992563Trac #23131: Minor correction and add a valueError for invalid

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

Changed commit from c992563 to 8d3d3fa

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

comment:9

I have made a last few little changes to the doc and made the doctests pass (specifically, indices are 0-based). If you agree with my changes, then positive review.


New commits:

52ff453Merge branch 'u/enadeau/add_computation_of_longest_commons_extensions_in_a_word' of trac.sagemath.org:sage into public/combinat/words/longest_common_extension-23131
8d3d3faSome last little doc fixes.

@kevindilks
Copy link
Mannequin

kevindilks mannequin commented Aug 21, 2017

comment:10

Would it be worth the effort to modify the code to allow negative positions, indicating distance from the end of the word (the way that Python lists work) ?

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

comment:11

I think that would complicate things, but I don't have uses for this code, so I have fundamentally no position on the matter. However, it would be consistent with words, e.g., w[-1] gets the last letter.

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

Changed keywords from words to words, days88, IMA coding sprints

@kevindilks
Copy link
Mannequin

kevindilks mannequin commented Aug 21, 2017

comment:13
if not (abs(x) < length and abs(y) < length):
            raise ValueError("x and y must be valid positions in self")
if x<0:
    x=length-x
if y<0:
    y=length-y

should work, right?

@kevindilks
Copy link
Mannequin

kevindilks mannequin commented Aug 21, 2017

Changed keywords from words, days88, IMA coding sprints to words

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

Changed keywords from words to words, days88, IMA coding sprints

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

comment:14

No, you need -len(w):

sage: w = Word('123')
sage: w[-3]
'1'

So you need to be slightly more careful.

@kevindilks
Copy link
Mannequin

kevindilks mannequin commented Aug 21, 2017

comment:15
if not (-length<= x < length and -length <= y < length):
            raise ValueError("x and y must be valid positions in self")
if x<0:
    x=length-x
if y<0:
    y=length-y

should work, right?

@tscrim
Copy link
Collaborator

tscrim commented Aug 21, 2017

comment:16

I think that should work.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 25, 2017

Changed commit from 8d3d3fa to d17e0c8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

d17e0c8Merge branch 'public/combinat/words/longest_common_extension-23131' of git://trac.sagemath.org/sage into t/23131/public/combinat/words/longest_common_extension-23131

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 25, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

7ee5699trac 23131: allow negative positions

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 25, 2017

Changed commit from d17e0c8 to 7ee5699

@saliola
Copy link

saliola commented Aug 25, 2017

comment:19

I implemented Kevin's suggestion (except that I used x = length + x instead of x = length - x since x is negative in this case). If you are OK with my changes, then set this to positive review.

@tscrim
Copy link
Collaborator

tscrim commented Aug 25, 2017

Changed reviewer from Travis Scrimshaw to Travis Scrimshaw, Franco Saliola

@tscrim
Copy link
Collaborator

tscrim commented Aug 25, 2017

comment:20

LGTM.

@vbraun
Copy link
Member

vbraun commented Oct 5, 2017

Changed branch from public/combinat/words/longest_common_extension-23131 to 7ee5699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants