| |
Methods defined here:
- __and__(self, other)
- Take a bitwise 'AND' of the bit array on which the method is
invoked with the argument bit array. Return the result as a new
bit array.
- __eq__(self, other)
- __getitem__(self, pos)
- Get the bit from the designated position
- __getslice__(self, arg1, arg2)
- A slice of a 2D array is defined as a rectangular region whose one
corner is at the (i,j) coordinates, which is represented by the
mapped integer arg1 produced by calling godel(i,j). The other
corner of the slice is at the coordinates (k,l) that is represented
by the integer arg2 produced by calling godel(k,l). The slice is
returned as a new BitArray2D instance.
- __init__(self, *args, **kwargs)
- __invert__(self)
- Invert the bits in the bit array on which the method is invoked
and return the result as a new bit array.
- __ne__(self, other)
- __or__(self, other)
- Take a bitwise 'OR' of the bit array on which the method is
invoked with the argument bit array. Return the result as a new
bit array.
- __setitem__(self, pos, item)
- This is needed for both slice assignments and for index-based
assignments. It checks the type of pos and item to see if the call
is for slice assignment. For slice assignment, the second argument
must be of type slice '[m:n]' whose two numbers m and n are
produced by calling godel() on the two corners of the rectangular
regions whose values you want to set by calling this function. So
for slice assignments, think of pos as consisting of
'[(i,j):(k,l)]' where (i,j) defines one corner of the slice and
(k,l) the other slice. As you would expect, for slice assignments,
the argument item must of type BitArray2D. For index-based
assignment, the pos consists of the tuple (i,j), the point in the
array where you want to change the value. Again, for index-based
assignment, the last argument will either be 1 or 0.
- __str__(self)
- To create a print representation
- __xor__(self, other)
- Take a bitwise 'XOR' of the bit array on which the method is
invoked with the argument bit array. Return the result as a new
bit array.
- deep_copy(self)
- Make a deep copy of a bit array
- dilate(self, m)
- erode(self, m)
- read_bit_array_from_binary_file(self, rows, columns)
- This assumes that the bit array is stored in the form of ASCII
characters 1 and 0 in a text file. We further assume that the
different rows are separated by the newline character.
- read_bit_array_from_char_file(self)
- This assumes that the bit array is stored in the form of
ASCII characters 1 and 0 in a text file. We further assume
that the different rows are separated by the newline character.
- shift(self, rowshift, colshift)
- What may make this method confusing at the beginning is the
orientation of the positive row direction and the positive
column direction. The origin of the array is at the upper
left hand corner of your display. Rows are positive going
downwards and columns are positive going rightwards:
X-----> +ve col direction
|
|
|
V
+ve row direction
So a positive value for rowshift will shift the array downwards
and a positive value for colshift will shift it rightwards.
Just remember that if you want the shifts to seem more intuitive,
use negative values for the rowshift argument.
- size(self)
- write_bit_array_to_char_file(self, file_out)
- Note that this write function for depositing a bit array into
text file uses the newline as the row delimiter.
- write_bit_array_to_packed_binary_file(self, file_out)
- This creates a packed disk storage for your bit array. But for
this to work, the total number of bits in your bit array must be a
multiple of 8 since all file I/O is byte oriented. Also note that
now you cannot use any byte as a row delimiter. So when reading
such a file back into a bit array, you have to tell the read
function how many rows and columns to create.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|