Skip to content

Coherence of the module #16

Description

I write here because the original bitarray is dead ()

I know that is outside the spec but is a strange behaviour

In : bitarray([True, False])
Out: bitarray('10')

In : bitarray('1') + bitarray('0')
Out: bitarray('10')

In : bitarray('1') + True
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-93-3d90d100a032> in <module>()
----> 1 bitarray('1') + True

TypeError: could not extend bitarray

In : bitarray(True)   # here it interprets True as the integer 1  => int(True)
Out: bitarray('1')

In : bitarray(False)
Out: bitarray()

In : a = 2 * bitarray('1') + 2 * bitarray('0') + 2 * bitarray('1') + bitarray(False) + bitarray(True)
In : a
Out: bitarray('1100111')
# it misses the false because it evaluate as bitarray() -> zero length

also

a = 10 * bitarray('1')

In : a
Out: bitarray('1111111111')

In : a[5] = '0'

In : a
Out: bitarray('1111111111')

another 'strange' behaviour

a = 10 * bitarray('0')

In [116]: a
Out[116]: bitarray('0000000000')

In [117]: a[5:6] = 10 * bitarray('1')   # is normal to extend by default?? this is like an oveflow??)

In [118]: a
Out[118]: bitarray('0000011111111110000')

another thing why have a length property when you can use the buildin len() function?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions