Source

Numpy Toy Box / carraygetwrap / use_caw.py

import numpy
from carraywrap import *

def print_2way(caw):
    print caw.nparray
    caw.print_array()

def set_range(caw):
    caw.nparray[:] = numpy.arange(
        numpy.prod(caw.nparray.shape)).reshape(caw.nparray.shape)

caw = CArrayWrap(3,3,3)

caw.nparray.fill(0)
print_2way(caw)

set_range(caw)
print_2way(caw)

caw = CArrayWrap(3,3)

caw.nparray.fill(0)
print_2way(caw)

set_range(caw)
print_2way(caw)

caw = CArrayWrap(3)

caw.nparray.fill(0)
print_2way(caw)

set_range(caw)
print_2way(caw)