#15820: Implement sequences of bounded integers
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.4
      Component:  algebra            |   Resolution:
       Keywords:  sequence bounded   |    Merged in:
  integer                            |    Reviewers:  Jeroen Demeyer, Simon
        Authors:  Simon King,        |  King
  Jeroen Demeyer                     |  Work issues:  interrupt handling
Report Upstream:  N/A                |       Commit:
         Branch:                     |  1560ce8dff16ed1fceabcc5656312f718d874211
  u/jdemeyer/ticket/15820            |     Stopgaps:
   Dependencies:  #17195, #17196     |
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Since yesterday evening, I tried for about 20 times to push my changes
 (implementing interrupt stuff). But it doesn't work. Any idea why?

 As usual, the error message is not very helpful:
 {{{
 > git trac push 15820
 Pushing to Trac #15820...
 Guessed remote branch: u/SimonKing/ticket/15820
 Enter passphrase for key '/home/king/.ssh/id_rsa':
 Traceback (most recent call last):
   File "/home/king/bin/git-trac", line 18, in <module>
     cmdline.launch()
   File "/home/king/Sage/git/git-trac-command/git_trac/cmdline.py", line
 210, in launch
     app.push(ticket_number, remote=args.remote, force=args.force)
   File "/home/king/Sage/git/git-trac-command/git_trac/app.py", line 194,
 in push
     self.repo.push(remote, force)
   File "/home/king/Sage/git/git-trac-command/git_trac/git_repository.py",
 line 181, in push
     self.git.echo.push('trac', refspec)
   File "/home/king/Sage/git/git-trac-command/git_trac/git_interface.py",
 line 341, in meth
     return self.execute(git_cmd, *args, **kwds)
   File "/home/king/Sage/git/git-trac-command/git_trac/git_interface.py",
 line 98, in execute
     popen_stderr=subprocess.PIPE)
   File "/home/king/Sage/git/git-trac-command/git_trac/git_interface.py",
 line 263, in _run
     raise GitError(result)
 git_trac.git_error.GitError
 }}}
 Is that a problem on my side, or on trac?

 Anyway, the diff would be
 {{{
 #!diff
 diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx
 b/src/sage/data_structures/bounded_integer_sequences.pyx
 index 7f5e632..ccda54c 100644
 --- a/src/sage/data_structures/bounded_integer_sequences.pyx
 +++ b/src/sage/data_structures/bounded_integer_sequences.pyx
 @@ -124,7 +124,9 @@ cdef bint biseq_init(biseq_t R, mp_size_t l,
 mp_bitcnt_t itemsize) except -1:
          totalbitsize = l * itemsize
      else:
          totalbitsize = 1
 +    sig_on()
      bitset_init(R.data, totalbitsize)
 +    sig_off()
      R.length = l
      R.itembitsize = itemsize
      R.mask_item = limb_lower_bits_up(itemsize)
 @@ -140,7 +142,9 @@ cdef bint biseq_init_copy(biseq_t R, biseq_t S) except
 -1:
      Initialize ``R`` as a copy of ``S``.
      """
      biseq_init(R, S.length, S.itembitsize)
 +    sig_on()
      bitset_copy(R.data, S.data)
 +    sig_off()

  #
  # Conversion
 @@ -162,6 +166,7 @@ cdef bint biseq_init_list(biseq_t R, list data, size_t
 bound) except -1:

      biseq_init(R, len(data), BIT_COUNT(bound|<size_t>1))

 +    sig_check()
      for item in data:
          item_c = item
          if item_c > bound:
 @@ -187,8 +192,10 @@ cdef bint biseq_init_concat(biseq_t R, biseq_t S1,
 biseq_t S2) except -1:
      The result is written into ``R``, which must not be initialised
      """
      biseq_init(R, S1.length + S2.length, S1.itembitsize)
 +    sig_on()
      bitset_lshift(R.data, S2.data, S1.length * S1.itembitsize)
      bitset_or(R.data, R.data, S1.data)
 +    sig_off()


  cdef inline bint biseq_startswith(biseq_t S1, biseq_t S2) except -1:
 @@ -207,6 +214,7 @@ cdef inline bint biseq_startswith(biseq_t S1, biseq_t
 S2) except -1:
          return False
      if S2.length == 0:
          return True
 +    sig_check()
      return mpn_equal_bits(S1.data.bits, S2.data.bits, S2.data.size)


 @@ -304,7 +312,9 @@ cdef bint biseq_init_slice(biseq_t R, biseq_t S,
 mp_size_t start, mp_size_t stop

      if step == 1:
          # Slicing essentially boils down to a shift operation.
 +        sig_on()
          bitset_rshift(R.data, S.data, start*S.itembitsize)
 +        sig_off()
          return 0

      # In the general case, we move item by item.
 @@ -340,6 +350,7 @@ cdef mp_size_t biseq_contains(biseq_t S1, biseq_t S2,
 mp_size_t start) except -2
      if S2.length == 0:
          return start
      cdef mp_size_t index
 +    sig_check()
      for index from start <= index <= S1.length-S2.length:
          if mpn_equal_bits_shifted(S2.data.bits, S1.data.bits,
                  S2.length*S2.itembitsize, index*S2.itembitsize):
 @@ -373,6 +384,7 @@ cdef mp_size_t biseq_startswith_tail(biseq_t S1,
 biseq_t S2, mp_size_t start) ex
      if S1.length < S2.length - start:
          start = S2.length - S1.length
      cdef mp_size_t index
 +    sig_check()
      for index from start <= index < S2.length:
          if mpn_equal_bits_shifted(S1.data.bits, S2.data.bits,
                  (S2.length - index)*S2.itembitsize,
 index*S2.itembitsize):
 @@ -1335,7 +1347,9 @@ cpdef BoundedIntegerSequence NewBISEQ(tuple
 bitset_data, mp_bitcnt_t itembitsize
      cdef BoundedIntegerSequence out =
 BoundedIntegerSequence.__new__(BoundedIntegerSequence)
      # bitset_unpickle assumes that out.data.data is initialised.
      biseq_init(out.data, length, itembitsize)
 +    sig_on()
      bitset_unpickle(out.data.data, bitset_data)
 +    sig_off()
      return out

  def _biseq_stresstest():
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15820#comment:369>
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.

Reply via email to