def visualize_pixel_array_feature(feature, 
                                  fov_horz_span=None, fov_vert_span=None,
                                  block_index=-1, feature_index=-1, 
                                  world_name=None, save_png=False, 
                                  filename='log/feature', array_only=False):
    # Calculate the number of pixels that span the field of view
    n_pixels = feature.shape[0] / 2
    if fov_horz_span is None:
        fov_horz_span = np.sqrt(n_pixels)
        fov_vert_span = np.sqrt(n_pixels)
    if array_only:
        pixel_array = []
    else:
        block_str = str(block_index).zfill(2)
        feature_str = str(feature_index).zfill(3)
        fig_title = ' '.join(('Block', block_str, 'Feature', feature_str, 
                              'from', world_name))
        fig_name = ' '.join(('Features from ', world_name))
        fig = plt.figure(tools.str_to_int(fig_name))
        fig.clf()
    num_states = feature.shape[1]
    for state_index in range(num_states):
        feature_sensors = feature[:,state_index]
        # Maximize contrast
        feature_sensors *= 1 / (np.max(feature_sensors) + tools.EPSILON)
        pixel_values = ((feature_sensors[ 0:n_pixels] - 
                         feature_sensors[n_pixels:2 * n_pixels]) + 1.0) / 2.0
        feature_pixels = pixel_values.reshape(fov_vert_span, fov_horz_span)
        if array_only:
            pixel_array.append(feature_pixels)
        else:
            plt.gray()
            ax = fig.add_axes((float(state_index)/float(num_states), 0., 
                               1/float(num_states), 1.), frame_on=False)
            im = plt.imshow(feature_pixels, vmin=0.0, vmax=1.0, 
                            interpolation='nearest')
            plt.title(fig_title)
    if array_only:
        return pixel_array
    else:
        if save_png:
            filename = (filename + '_' + world_name  + '_' + block_str + 
                        '_' + feature_str + '.png')
            fig.savefig(filename, format='png')
        fig.show()
        fig.canvas.draw()
%get VARIABLE - get a variable from the kernel in a Python-type.
dataset/ETHPy150Open matt2000/becca/worlds/world_tools.py/visualize_pixel_array_feature--crossover with--dataset/ETHPy150Open Calysto/metakernel/metakernel/magics/get_magic.py/GetMagic.line_get