autowisp.light_curves.hashable_array module — AutoWISP documentation

# autowisp.light_curves.hashable_array module

## Class Inheritance Diagram

Define a Hashable wrapper for ndarray objects.

class autowisp.light_curves.hashable_array.HashableArray(wrapped, tight=False)

  Bases: `object`

  Hashable wrapper for ndarray objects

  Copied from: http://stackoverflow.com/questions/1939228/constructing-a-python-set-from-a-numpy-matrix

  Instances of ndarray are not hashable, meaning they cannot be added to sets, nor used as keys in dictionaries. This is by design - ndarray objects are mutable, and therefore cannot reliably implement the __hash__() method.

  The hashable class allows a way around this limitation. It implements the required methods for hashable objects in terms of an encapsulated ndarray object. This can be either a copied instance (which is safer) or the original object (which requires the user to be careful enough not to modify it).

  __init__(wrapped, tight=False)

    Creates a new hashable object encapsulating an ndarray.

    Parameters:

      - wrapped (-) – The wrapped ndarray.

      - tight (-) – If True, a copy of the input ndaray is created.

  unwrap()

    Return the encapsulated ndarray.

    If the wrapper is “tight”, a copy of the encapsulated ndarray is returned. Otherwise, the encapsulated ndarray itself is returned.