This file is indexed.

/usr/share/pyshared/HTSeq/StepVector.py is in python-htseq 0.5.4p3-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.10
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.



from sys import version_info
if version_info >= (2,6,0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_StepVector', [dirname(__file__)])
        except ImportError:
            import _StepVector
            return _StepVector
        if fp is not None:
            try:
                _mod = imp.load_module('_StepVector', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _StepVector = swig_import_helper()
    del swig_import_helper
else:
    import _StepVector
del version_info
try:
    _swig_property = property
except NameError:
    pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
    if (name == "thisown"): return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name,None)
    if method: return method(self,value)
    if (not static):
        self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)

def _swig_setattr(self,class_type,name,value):
    return _swig_setattr_nondynamic(self,class_type,name,value,0)

def _swig_getattr(self,class_type,name):
    if (name == "thisown"): return self.this.own()
    method = class_type.__swig_getmethods__.get(name,None)
    if method: return method(self)
    raise AttributeError(name)

def _swig_repr(self):
    try: strthis = "proxy of " + self.this.__repr__()
    except: strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object : pass
    _newclass = 0


class _Pair_int_float(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _Pair_int_float, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _Pair_int_float, name)
    __repr__ = _swig_repr
    __swig_setmethods__["first"] = _StepVector._Pair_int_float_first_set
    __swig_getmethods__["first"] = _StepVector._Pair_int_float_first_get
    if _newclass:first = _swig_property(_StepVector._Pair_int_float_first_get, _StepVector._Pair_int_float_first_set)
    __swig_setmethods__["second"] = _StepVector._Pair_int_float_second_set
    __swig_getmethods__["second"] = _StepVector._Pair_int_float_second_get
    if _newclass:second = _swig_property(_StepVector._Pair_int_float_second_get, _StepVector._Pair_int_float_second_set)
    def __init__(self, *args): 
        this = _StepVector.new__Pair_int_float(*args)
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _StepVector.delete__Pair_int_float
    __del__ = lambda self : None;
_Pair_int_float_swigregister = _StepVector._Pair_int_float_swigregister
_Pair_int_float_swigregister(_Pair_int_float)

class _StepVector_Iterator_float(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_Iterator_float, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_Iterator_float, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _StepVector.new__StepVector_Iterator_float(*args)
        try: self.this.append(this)
        except: self.this = this
    def next(self): return _StepVector._StepVector_Iterator_float_next(self)
    def __iter__(self): return _StepVector._StepVector_Iterator_float___iter__(self)
    __swig_destroy__ = _StepVector.delete__StepVector_Iterator_float
    __del__ = lambda self : None;
_StepVector_Iterator_float_swigregister = _StepVector._StepVector_Iterator_float_swigregister
_StepVector_Iterator_float_swigregister(_StepVector_Iterator_float)

class _StepVector_float(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_float, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_float, name)
    __repr__ = _swig_repr
    def __init__(self): 
        this = _StepVector.new__StepVector_float()
        try: self.this.append(this)
        except: self.this = this
    def set_value(self, *args): return _StepVector._StepVector_float_set_value(self, *args)
    def add_value(self, *args): return _StepVector._StepVector_float_add_value(self, *args)
    def get_all_values_pystyle(self): return _StepVector._StepVector_float_get_all_values_pystyle(self)
    def get_values_pystyle(self, *args): return _StepVector._StepVector_float_get_values_pystyle(self, *args)
    def num_values(self): return _StepVector._StepVector_float_num_values(self)
    __swig_destroy__ = _StepVector.delete__StepVector_float
    __del__ = lambda self : None;
_StepVector_float_swigregister = _StepVector._StepVector_float_swigregister
_StepVector_float_swigregister(_StepVector_float)
cvar = _StepVector.cvar
_StepVector_float.min_index = _StepVector.cvar._StepVector_float_min_index
_StepVector_float.max_index = _StepVector.cvar._StepVector_float_max_index

class _Pair_int_int(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _Pair_int_int, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _Pair_int_int, name)
    __repr__ = _swig_repr
    __swig_setmethods__["first"] = _StepVector._Pair_int_int_first_set
    __swig_getmethods__["first"] = _StepVector._Pair_int_int_first_get
    if _newclass:first = _swig_property(_StepVector._Pair_int_int_first_get, _StepVector._Pair_int_int_first_set)
    __swig_setmethods__["second"] = _StepVector._Pair_int_int_second_set
    __swig_getmethods__["second"] = _StepVector._Pair_int_int_second_get
    if _newclass:second = _swig_property(_StepVector._Pair_int_int_second_get, _StepVector._Pair_int_int_second_set)
    def __init__(self, *args): 
        this = _StepVector.new__Pair_int_int(*args)
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _StepVector.delete__Pair_int_int
    __del__ = lambda self : None;
_Pair_int_int_swigregister = _StepVector._Pair_int_int_swigregister
_Pair_int_int_swigregister(_Pair_int_int)

class _StepVector_Iterator_int(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_Iterator_int, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_Iterator_int, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _StepVector.new__StepVector_Iterator_int(*args)
        try: self.this.append(this)
        except: self.this = this
    def next(self): return _StepVector._StepVector_Iterator_int_next(self)
    def __iter__(self): return _StepVector._StepVector_Iterator_int___iter__(self)
    __swig_destroy__ = _StepVector.delete__StepVector_Iterator_int
    __del__ = lambda self : None;
_StepVector_Iterator_int_swigregister = _StepVector._StepVector_Iterator_int_swigregister
_StepVector_Iterator_int_swigregister(_StepVector_Iterator_int)

class _StepVector_int(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_int, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_int, name)
    __repr__ = _swig_repr
    def __init__(self): 
        this = _StepVector.new__StepVector_int()
        try: self.this.append(this)
        except: self.this = this
    def set_value(self, *args): return _StepVector._StepVector_int_set_value(self, *args)
    def add_value(self, *args): return _StepVector._StepVector_int_add_value(self, *args)
    def get_all_values_pystyle(self): return _StepVector._StepVector_int_get_all_values_pystyle(self)
    def get_values_pystyle(self, *args): return _StepVector._StepVector_int_get_values_pystyle(self, *args)
    def num_values(self): return _StepVector._StepVector_int_num_values(self)
    __swig_destroy__ = _StepVector.delete__StepVector_int
    __del__ = lambda self : None;
_StepVector_int_swigregister = _StepVector._StepVector_int_swigregister
_StepVector_int_swigregister(_StepVector_int)
_StepVector_int.min_index = _StepVector.cvar._StepVector_int_min_index
_StepVector_int.max_index = _StepVector.cvar._StepVector_int_max_index

class _Pair_int_bool(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _Pair_int_bool, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _Pair_int_bool, name)
    __repr__ = _swig_repr
    __swig_setmethods__["first"] = _StepVector._Pair_int_bool_first_set
    __swig_getmethods__["first"] = _StepVector._Pair_int_bool_first_get
    if _newclass:first = _swig_property(_StepVector._Pair_int_bool_first_get, _StepVector._Pair_int_bool_first_set)
    __swig_setmethods__["second"] = _StepVector._Pair_int_bool_second_set
    __swig_getmethods__["second"] = _StepVector._Pair_int_bool_second_get
    if _newclass:second = _swig_property(_StepVector._Pair_int_bool_second_get, _StepVector._Pair_int_bool_second_set)
    def __init__(self, *args): 
        this = _StepVector.new__Pair_int_bool(*args)
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _StepVector.delete__Pair_int_bool
    __del__ = lambda self : None;
_Pair_int_bool_swigregister = _StepVector._Pair_int_bool_swigregister
_Pair_int_bool_swigregister(_Pair_int_bool)

class _StepVector_Iterator_bool(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_Iterator_bool, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_Iterator_bool, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _StepVector.new__StepVector_Iterator_bool(*args)
        try: self.this.append(this)
        except: self.this = this
    def next(self): return _StepVector._StepVector_Iterator_bool_next(self)
    def __iter__(self): return _StepVector._StepVector_Iterator_bool___iter__(self)
    __swig_destroy__ = _StepVector.delete__StepVector_Iterator_bool
    __del__ = lambda self : None;
_StepVector_Iterator_bool_swigregister = _StepVector._StepVector_Iterator_bool_swigregister
_StepVector_Iterator_bool_swigregister(_StepVector_Iterator_bool)

class _StepVector_bool(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_bool, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_bool, name)
    __repr__ = _swig_repr
    def __init__(self): 
        this = _StepVector.new__StepVector_bool()
        try: self.this.append(this)
        except: self.this = this
    def set_value(self, *args): return _StepVector._StepVector_bool_set_value(self, *args)
    def add_value(self, *args): return _StepVector._StepVector_bool_add_value(self, *args)
    def get_all_values_pystyle(self): return _StepVector._StepVector_bool_get_all_values_pystyle(self)
    def get_values_pystyle(self, *args): return _StepVector._StepVector_bool_get_values_pystyle(self, *args)
    def num_values(self): return _StepVector._StepVector_bool_num_values(self)
    __swig_destroy__ = _StepVector.delete__StepVector_bool
    __del__ = lambda self : None;
_StepVector_bool_swigregister = _StepVector._StepVector_bool_swigregister
_StepVector_bool_swigregister(_StepVector_bool)
_StepVector_bool.min_index = _StepVector.cvar._StepVector_bool_min_index
_StepVector_bool.max_index = _StepVector.cvar._StepVector_bool_max_index

class _Pair_int_obj(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _Pair_int_obj, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _Pair_int_obj, name)
    __repr__ = _swig_repr
    __swig_setmethods__["first"] = _StepVector._Pair_int_obj_first_set
    __swig_getmethods__["first"] = _StepVector._Pair_int_obj_first_get
    if _newclass:first = _swig_property(_StepVector._Pair_int_obj_first_get, _StepVector._Pair_int_obj_first_set)
    __swig_setmethods__["second"] = _StepVector._Pair_int_obj_second_set
    __swig_getmethods__["second"] = _StepVector._Pair_int_obj_second_get
    if _newclass:second = _swig_property(_StepVector._Pair_int_obj_second_get, _StepVector._Pair_int_obj_second_set)
    def __init__(self, *args): 
        this = _StepVector.new__Pair_int_obj(*args)
        try: self.this.append(this)
        except: self.this = this
    __swig_destroy__ = _StepVector.delete__Pair_int_obj
    __del__ = lambda self : None;
_Pair_int_obj_swigregister = _StepVector._Pair_int_obj_swigregister
_Pair_int_obj_swigregister(_Pair_int_obj)

class _StepVector_Iterator_obj(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_Iterator_obj, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_Iterator_obj, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _StepVector.new__StepVector_Iterator_obj(*args)
        try: self.this.append(this)
        except: self.this = this
    def next(self): return _StepVector._StepVector_Iterator_obj_next(self)
    def __iter__(self): return _StepVector._StepVector_Iterator_obj___iter__(self)
    __swig_destroy__ = _StepVector.delete__StepVector_Iterator_obj
    __del__ = lambda self : None;
_StepVector_Iterator_obj_swigregister = _StepVector._StepVector_Iterator_obj_swigregister
_StepVector_Iterator_obj_swigregister(_StepVector_Iterator_obj)

class _StepVector_obj(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, _StepVector_obj, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, _StepVector_obj, name)
    __repr__ = _swig_repr
    def __init__(self): 
        this = _StepVector.new__StepVector_obj()
        try: self.this.append(this)
        except: self.this = this
    def set_value(self, *args): return _StepVector._StepVector_obj_set_value(self, *args)
    def add_value(self, *args): return _StepVector._StepVector_obj_add_value(self, *args)
    def get_all_values_pystyle(self): return _StepVector._StepVector_obj_get_all_values_pystyle(self)
    def get_values_pystyle(self, *args): return _StepVector._StepVector_obj_get_values_pystyle(self, *args)
    def num_values(self): return _StepVector._StepVector_obj_num_values(self)
    __swig_destroy__ = _StepVector.delete__StepVector_obj
    __del__ = lambda self : None;
_StepVector_obj_swigregister = _StepVector._StepVector_obj_swigregister
_StepVector_obj_swigregister(_StepVector_obj)
_StepVector_obj.min_index = _StepVector.cvar._StepVector_obj_min_index
_StepVector_obj.max_index = _StepVector.cvar._StepVector_obj_max_index

import sys

class StepVector( object ):

   """A step vector is a vector with integer indices that is able to store
   data efficiently if it is piece-wise constant, i.e., if the values change
   in "steps". So, if a number of adjacent vectort elements have the same
   value, this values will be stored only once.
   
   The data can be either one of a number of elementary types, or any object.
   
   Usage example:
   
   >>> sv = StepVector.StepVector( 20 )
   >>> sv[5:17] = 13
   >>> sv[12]
   13.0
   >>> list( sv )
   [0.0, 0.0, 0.0, 0.0, 0.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 0.0, 0.0, 0.0]
   >>> list( sv.get_steps() )
   [(0, 5, 0.0), (5, 17, 13.0), (17, 20, 0.0)]

   """

   @classmethod
   def create( cls, length = sys.maxint, typecode = 'd', start_index = 0 ):
      """Construct a StepVector of the given length, with indices starting
      at the given start_index and counting up to (but not including)
      start_index + length.
      
      The typecode may be:
        'd' for float values (C type 'double'),
        'i' for int values,
        'b' for Boolean values,
        'O' for arbitrary Python objects as value.
   
      The vector is initialized with the value zero (or, for typecode 'O',
      with None).
      """
      if typecode == 'd':
         swigclass = _StepVector_float
      elif typecode == 'i':
         swigclass = _StepVector_int
      elif typecode == 'b':
         swigclass = _StepVector_bool
      elif typecode == 'O':
         swigclass = _StepVector_obj
      else:
         raise ValueError, "unsupported typecode"
      obj = cls()
      obj._typecode = typecode
      obj._swigobj = swigclass( )    
      obj.start = start_index
      obj.stop = start_index + length
      return obj
     
   def __setitem__( self, index, value ):
      """To set element i of StepVector sv to the value v, write
         sv[i] = v
      If you want to set a whole step, say, all values from i to j (not
      including j), write
         sv[i:j] = v
      Note that the StepVector class will only notice that all the values
      from i to j are equal if you assign them in this fashion. Assigning each
      item individually in a loop from i to j will result in the value v being
      stored many times.
      """
      if isinstance( value, StepVector ):
         if self._swigobj is value._swigobj and \
               value.start == index.start and value.stop == index.stop:
            return
         else:
            raise NotImplemented, "Stepvector-to-Stepvector assignment still missing"
      if isinstance( index, slice ):
         if index.step is not None and index.step != 1:
             raise ValueError, "Striding slices (i.e., step != 1) are not supported"
         if index.start is None:
            start = self.start
         else:
            if index.start < self.start:
               raise IndexError, "start too small"
            start = index.start
         if index.stop is None:
            stop = self.stop
         else:
            if index.stop > self.stop:
               raise IndexError, "stop too large"
            stop = index.stop
         self._swigobj.set_value( start, stop-1, value )
         # Note the "-1": The C++ object uses closed intervals, but we follow
         # Python convention here and use half-open ones.
      else:
         self._swigobj.set_value( index, index, value )
    
   def get_steps( self, values_only = False, merge_steps=True ):
      """To get a succinct representation of the StepVector's content, call
      the 'get_steps' method. It returns an iterator that generates triples
      of values. Each triple contains one step, giving first the start index
      of the step, then the stop index (i.e., one more than the index of the 
      last element), and as third element the value of the step.
      
      If you want to see only a part of the StepVector, use the 'start' and
      'stop' parameters of 'get_steps' to specify a window.
      
      Sometimes, one might only be interested in the values, not the step
      boundaries. Then, set 'values_only' to true, and the iterator generates
      only the values insted of the triples.
      """
      startvals = self._swigobj.get_values_pystyle( self.start )
      prevstart = self.start
      prevval = startvals.next().second
      for pair in startvals:
         stepstart, value = pair.first, pair.second
         if merge_steps and value == prevval:
            continue
         if self.stop is not None and stepstart >= self.stop:
            if not values_only:
               yield prevstart, self.stop, prevval
            else:
               yield prevval
            return
         if not values_only:
            yield prevstart, stepstart, prevval
         else:
            yield prevval
         prevstart, prevval = stepstart, value
      else:
         if not values_only:
            yield prevstart, min( self.stop, self._swigobj.max_index+1), prevval
         else:
            yield prevval

   def __getitem__( self, index ):
      """Given a StepVector sv, writing sv[i] returns sv's element i (where i
      is an integer). 
      
      If you use a slice, i.e., 'sv[i:j]', you get a view on the StepVector,
      i.e., the same data, but changed boundaries.
      """
      if isinstance( index, slice ):
         if index.step is not None and index.step != 1:
             raise ValueError, "Striding slices (i.e., step != 1) are not supported"
         if index.start is None:
            start = self.start
         else:
            if index.start < self.start:
               raise IndexError, "start too small"
            start = index.start
         if index.stop is None:
            stop = self.stop
         else:
            if index.stop > self.stop:
               raise IndexError, "stop too large"
            stop = index.stop
         res = self.__class__()
         res._typecode = self.typecode
         res._swigobj = self._swigobj
         res.start = start
         res.stop = stop
         return res
      else:
         return self._swigobj.get_values_pystyle( index ).next().second
      
   def __iter__( self ):
      """When asked to provide an iterator, a StepVector will yield all its
      value, repeating each value according to the length of the step.
      Hence, calling, e.g., 'list( sv )' will transform the StepVector 'sv'
      into an ordinary list.
      """
      for start, stop, value in self.get_steps():
         for i in xrange( start, stop ):
            yield value
       
   def __repr__( self ):
      if self.start == -sys.maxint - 1:
         start_s = "-inf"
      else:
         start_s = str( self.start )
      if self.stop == sys.maxint:
         stop_s = "inf"
      else:
         stop_s = str( self.stop )
      return "<%s object, type '%s', index range %s:%s, %d step(s)>" % (
         self.__class__.__name__, self.typecode(), start_s,
         stop_s, self.num_steps() )
       
   def typecode( self ):
      "Returns the typecode."
      return self._typecode
      
   def __len__( self ):
      """The length of a StepVector is defined by its index range, not by
      the number of steps.
      """
      return self.stop - self.start
      
   def num_steps( self ):
      """Returns the number of steps, i.e., the number of triples that get_steps
      returns.
      """
      return self._swigobj.num_values()
      
   def __eq__( self, other ):
      """StepVectors can be compared for equality. This is conceptually done
      element for element, but, for performance, taking steps in one go.
      """
      if self.start_index() != other.start_index() or len(self) != len(other) or \
            self.typecode() != other.typecode():
         print "Mark A"
         return False
      selfsteps = self.get_steps()
      othrsteps = other.get_steps()
      selfstart, selfstop, selfval = selfsteps.next()
      othrstart, othrstop, othrval = othrsteps.next()
      while selfstop < self.start_index() + len(self) and \
            othrstop < other.start_index() + len(other):
         assert selfstart < othrstop and othrstart < selfstop
         if not( selfval == othrval ):
            return False
         if selfstop < othrstop:
            selfstart, selfstop, selfval = selfsteps.next()
         elif othrstop < selfstop:
            othrstart, othrstop, othrval = othrsteps.next()
         else:
            selfstart, selfstop, selfval = selfsteps.next()
            othrstart, othrstop, othrval = othrsteps.next()
      return True
      
   def __neq__( self, other ):
      return not ( self == other )
      
   def __reduce__( self ):
      if self.__class__ is not StepVector:
         raise NotImplemented, "Attempting to pickle a subclass of StepVector without redefined __reduce__."
      return ( 
         _StepVector_unpickle, 
         ( self.stop - self.start, self._typecode, self.start ),
         None,
         None,
         ( ( slice( start, stop ), val ) for start, stop, val in self.get_steps() ) )
    
   def __iadd__( self, value ):
      self._swigobj.add_value( self.start, self.stop-1, value )
      return self
    
   def apply( self, func, start = None, stop = None ):
      # TODO: check!
      for stepstart, stepstop, value in self.get_steps( start, stop ):
         self[ stepstart : stepstop ] = func( value )
      
def _StepVector_unpickle( length, typecode, start ):
   return StepVector.create( length, typecode, start )
    

# This file is compatible with both classic and new-style classes.