Opened 8 years ago

Closed 8 years ago

#8233 closed enhancement (fixed)

concatenation of words should preserve the data type represention when possible

Reported by: slabbe Owned by: sage-combinat
Priority: major Milestone: sage-4.3.4
Component: combinatorics Keywords: word, concatenation
Cc: abmasse Merged in: sage-4.3.4.alpha1
Authors: Sébastien Labbé Reviewers: Alexandre Blondin Massé
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by slabbe)

This concerns word represented by str, tuple and list.

  1. We want the representation of a concatenation of two words u and v to be preserved when u and v are of the same data type.

ACTUAL BEHAVIOR:

sage: u = Word(range(10))
sage: type(u)
<class 'sage.combinat.words.word.FiniteWord_list'>
sage: type(u*u)
<class 'sage.combinat.words.word.FiniteWord_callable_with_caching'>
sage: v = Word('asdgadsf')
sage: type(v)
<class 'sage.combinat.words.word.FiniteWord_str'>
sage: type(v*v)
<class 'sage.combinat.words.word.FiniteWord_callable_with_caching'>
sage: v = Word((2,3,5,21,34,6))
sage: type(v)
<class 'sage.combinat.words.word.FiniteWord_tuple'>
sage: type(v*v)
<class 'sage.combinat.words.word.FiniteWord_callable_with_caching'>
  1. Moreover, the empty word could be ignored for concatenation :

ACTUAL BEHAVIOR:

sage: type(Word([]) * Word('asdga'))
<class 'sage.combinat.words.word.FiniteWord_callable_with_caching'>

INTENDED BEHAVIOR:

sage: type(Word([]) * Word('asdga'))
<class 'sage.combinat.words.word.FiniteWord_str'>

Attachments (2)

trac_8233_word_concatenation-sl.2.patch (5.9 KB) - added by slabbe 8 years ago.
Forget about this patch!
trac_8233_word_concatenation-sl.patch (5.2 KB) - added by slabbe 8 years ago.
Depends on #7619.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 years ago by slabbe

  • Description modified (diff)
  • Status changed from new to needs_review

Changed 8 years ago by slabbe

Forget about this patch!

Changed 8 years ago by slabbe

Depends on #7619.

comment:2 Changed 8 years ago by slabbe

  • Cc abmasse added

comment:3 Changed 8 years ago by abmasse

  • Authors set to Sébastien Labbé
  • Keywords word concatenation added
  • Reviewers set to Alexandre Blondin Massé
  • Status changed from needs_review to positive_review

Tested on sage-4.3.3 after having applied ticket #7619. All tests passed, looking at the documentation with browse_sage_doc reveals nothing to be corrected. The improvement seems very reasonable and the code looks fine. Positive review !

comment:4 Changed 8 years ago by mhansen

  • Merged in set to sage-4.3.4.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.