Coverage for navipy/scene.py : 63%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Define what a scene is """
# # Define constants # 'azimuth': 1, 'radius': 2} 'y': 1, 'z': 2} 'azimuth': 1, 'channel': 2, 'component': 3} 'channel': 1, 'component': 2} 'azimuth': 1, 'component': 2} 'component': 1}
return {'elevation': 0, 'azimuth': 1, 'radius': 2}
return {'x': 0, 'y': 1, 'z': 2}
# print("normal") raise TypeError('scene is of non numeric type') raise Exception('scene has wrong shape, must have 4 dimensions') raise Exception('scenes first dimension is empty') raise Exception('scenes second dimension is empty') raise Exception('4rd dimension of scene must be one') # assert ~(np.any(np.isNone(scene)))
raise TypeError('scene is of non numeric type') raise ValueError('scene contains nans') raise Exception('scene has wrong shape, must have 4 dimensions') raise Exception('scenes first dimension is empty') raise Exception('scenes second dimension is empty') # assert ~(np.any(np.isNone(scene))) return True
raise TypeError('viewing direction is of non numeric type') raise ValueError('viewing direction contains nans') raise Exception('viewing direction must have at least 3 dimensions') raise Exception('viewing direction has empty second dimension') raise Exception('viewing direction has empty first dimension') raise Exception(' last dimension of viewing direction must equal 2')
"""Checks if the dtype of the array is numeric.
Booleans, unsigned integer, signed integer, floats and complex are considered numeric.
:param array : `numpy.ndarray`-like The array to check. :returns: True if it is a recognized numerical and False \ if object or string. :rtype:bool """ 'u', # unsigned integer 'i', # signed integer 'f', # floats 'c'} # complex # in case it's not a numpy array it will probably have no dtype.
"""Test if a place code is image based
:param place_code: a place-code :returns: True if image based place-code :rtype: bool
""" len(__ibpc_indeces__))
"""Test if a place code is ommatidia based
:param place_code: a place-code :returns: True if ommatidia based place-code :rtype: bool
""" len(__obpc_indeces__))
"""Convert an image based scene to an ommatidium based scene.
:param scene: The scene to be converted :param eye_map: The eye_map to use :returns: (obs_scene,ommatidia_map) :rtype: (np.ndarray,np.ndarray) """ assert is_ibpc(scene),\ 'scene should be an ibs scene' assert isinstance(eye_map, np.ndarray), 'eye_map should be a numpy array' assert len(eye_map.shape) == len(__eye_indeces__),\ 'eye_map should have {} dimensions to be an ibs scene'.format( len(__eye_indeces__)) for index_name in ['elevation', 'azimuth']: index = __ibpc_indeces__[index_name] assert eye_map.shape[index] == scene.shape[index],\ 'eye_map and scene should have the same number of {}'.format( index_name) obs_size = (scene.shape[__ibpc_indeces__['elevation']] * scene.shape[__ibpc_indeces__['azimuth']], scene.shape[__ibpc_indeces__['channel']], scene.shape[__ibpc_indeces__['component']]) obs_scene = scene.reshape(obs_size) omm_size = (eye_map.shape[__ibpc_indeces__['elevation']] * eye_map.shape[__ibpc_indeces__['azimuth']], eye_map.shape[__ibpc_indeces__['component']]) ommatidia_map = eye_map.reshape(omm_size) return (obs_scene, ommatidia_map) |