<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> __authors__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __credits__ = __authors__ . split ( "<STR_LIT>" ) <EOL> __license__ = "<STR_LIT>" <EOL> __maintainer__ = "<STR_LIT>" <EOL> __email__ = "<STR_LIT>" <EOL> import os <EOL> import copy <EOL> import gzip <EOL> import bz2 <EOL> import warnings <EOL> import functools <EOL> import numpy <EOL> import theano <EOL> from pylearn2 . utils import safe_zip , string_utils <EOL> from pylearn2 . datasets . dense_design_matrix import DenseDesignMatrix <EOL> from pylearn2 . space import VectorSpace , Conv2DSpace , CompositeSpace <EOL> from pylearn2 . datasets . filetensor import read_header <EOL> class NORB ( DenseDesignMatrix ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , which_norb , which_set , image_dtype = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if which_norb not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % str ( which_norb ) ) <EOL> if which_set not in ( '<STR_LIT:test>' , '<STR_LIT:train>' , '<STR_LIT>' ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % str ( which_set ) ) <EOL> image_dtype = numpy . dtype ( image_dtype ) <EOL> self . label_index_to_name = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> if which_norb == '<STR_LIT>' : <EOL> self . label_index_to_name = ( self . label_index_to_name + <EOL> ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> self . label_name_to_index = { } <EOL> for index , name in enumerate ( self . label_index_to_name ) : <EOL> self . label_name_to_index [ name ] = index <EOL> self . label_to_value_funcs = ( get_category_value , <EOL> get_instance_value , <EOL> get_elevation_value , <EOL> get_azimuth_value , <EOL> get_lighting_value ) <EOL> if which_norb == '<STR_LIT>' : <EOL> self . label_to_value_funcs = ( self . label_to_value_funcs + <EOL> ( get_horizontal_shift_value , <EOL> get_vertical_shift_value , <EOL> get_lumination_change_value , <EOL> get_contrast_change_value , <EOL> get_scale_change_value , <EOL> get_rotation_change_value ) ) <EOL> image_length = <NUM_LIT> if which_norb == '<STR_LIT>' else <NUM_LIT> <EOL> def read_norb_files ( norb_files , output ) : <EOL> """<STR_LIT>""" <EOL> def read_norb_file ( norb_file_path , debug = False ) : <EOL> """<STR_LIT>""" <EOL> if not ( norb_file_path . endswith ( "<STR_LIT>" ) or <EOL> norb_file_path . endswith ( "<STR_LIT>" ) ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % norb_file_path ) <EOL> if not os . path . isfile ( norb_file_path ) : <EOL> raise IOError ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> reversed ( os . path . split ( norb_file_path ) ) ) <EOL> file_handle = ( gzip . open ( norb_file_path ) <EOL> if norb_file_path . endswith ( '<STR_LIT>' ) <EOL> else open ( norb_file_path ) ) <EOL> def readNums ( file_handle , num_type , count ) : <EOL> """<STR_LIT>""" <EOL> num_bytes = count * numpy . dtype ( num_type ) . itemsize <EOL> string = file_handle . read ( num_bytes ) <EOL> return numpy . fromstring ( string , dtype = num_type ) <EOL> ( elem_type , <EOL> elem_size , <EOL> _num_dims , <EOL> shape , <EOL> num_elems ) = read_header ( file_handle , debug ) <EOL> del _num_dims <EOL> beginning = file_handle . tell ( ) <EOL> result = None <EOL> if isinstance ( file_handle , ( gzip . GzipFile , bz2 . BZ2File ) ) : <EOL> result = readNums ( file_handle , <EOL> elem_type , <EOL> num_elems * elem_size ) . reshape ( shape ) <EOL> else : <EOL> result = numpy . fromfile ( file_handle , <EOL> dtype = elem_type , <EOL> count = num_elems ) . reshape ( shape ) <EOL> return result <EOL> row_index = <NUM_LIT:0> <EOL> for norb_file in norb_files : <EOL> print ( "<STR_LIT>" % os . path . split ( norb_file ) [ <NUM_LIT:1> ] ) <EOL> norb_data = read_norb_file ( norb_file ) <EOL> norb_data = norb_data . reshape ( - <NUM_LIT:1> , output . shape [ <NUM_LIT:1> ] ) <EOL> end_row = row_index + norb_data . shape [ <NUM_LIT:0> ] <EOL> output [ row_index : end_row , : ] = norb_data <EOL> row_index = end_row <EOL> assert end_row == output . shape [ <NUM_LIT:0> ] <EOL> if which_norb == '<STR_LIT>' : <EOL> training_set_size = <NUM_LIT> <EOL> testing_set_size = <NUM_LIT> <EOL> else : <EOL> assert which_norb == '<STR_LIT>' <EOL> num_rows_per_file = <NUM_LIT> <EOL> training_set_size = num_rows_per_file * <NUM_LIT:10> <EOL> testing_set_size = num_rows_per_file * <NUM_LIT:2> <EOL> def load_images ( which_norb , which_set , dtype ) : <EOL> """<STR_LIT>""" <EOL> assert type ( dtype ) == numpy . dtype <EOL> memmap_path = get_memmap_path ( which_norb , '<STR_LIT>' % str ( dtype ) ) <EOL> row_size = <NUM_LIT:2> * ( image_length ** <NUM_LIT:2> ) <EOL> shape = ( training_set_size + testing_set_size , row_size ) <EOL> def make_memmap ( ) : <EOL> dat_files = get_norb_file_paths ( which_norb , '<STR_LIT>' , '<STR_LIT>' ) <EOL> memmap_dir = os . path . split ( memmap_path ) [ <NUM_LIT:0> ] <EOL> if not os . path . isdir ( memmap_dir ) : <EOL> os . mkdir ( memmap_dir ) <EOL> print ( "<STR_LIT>" % memmap_path ) <EOL> writeable_memmap = numpy . memmap ( filename = memmap_path , <EOL> dtype = dtype , <EOL> mode = '<STR_LIT>' , <EOL> shape = shape ) <EOL> read_norb_files ( dat_files , writeable_memmap ) <EOL> if not os . path . isfile ( memmap_path ) : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> make_memmap ( ) <EOL> images = numpy . memmap ( filename = memmap_path , <EOL> dtype = dtype , <EOL> mode = '<STR_LIT:r>' , <EOL> shape = shape ) <EOL> if which_set == '<STR_LIT:train>' : <EOL> images = images [ : training_set_size , : ] <EOL> elif which_set == '<STR_LIT:test>' : <EOL> images = images [ training_set_size : , : ] <EOL> return images <EOL> def load_labels ( which_norb , which_set ) : <EOL> """<STR_LIT>""" <EOL> memmap_path = get_memmap_path ( which_norb , '<STR_LIT>' ) <EOL> dtype = numpy . dtype ( '<STR_LIT>' ) <EOL> row_size = <NUM_LIT:5> if which_norb == '<STR_LIT>' else <NUM_LIT:11> <EOL> shape = ( training_set_size + testing_set_size , row_size ) <EOL> def make_memmap ( ) : <EOL> cat_files , info_files = [ get_norb_file_paths ( which_norb , <EOL> '<STR_LIT>' , <EOL> x ) <EOL> for x in ( '<STR_LIT>' , '<STR_LIT:info>' ) ] <EOL> memmap_dir = os . path . split ( memmap_path ) [ <NUM_LIT:0> ] <EOL> if not os . path . isdir ( memmap_dir ) : <EOL> os . mkdir ( memmap_dir ) <EOL> print ( "<STR_LIT>" ) <EOL> writeable_memmap = numpy . memmap ( filename = memmap_path , <EOL> dtype = dtype , <EOL> mode = '<STR_LIT>' , <EOL> shape = shape ) <EOL> print ( "<STR_LIT>" ) <EOL> cat_memmap = writeable_memmap [ : , : <NUM_LIT:1> ] <EOL> info_memmap = writeable_memmap [ : , <NUM_LIT:1> : ] <EOL> for norb_files , memmap in safe_zip ( ( cat_files , info_files ) , <EOL> ( cat_memmap , info_memmap ) ) : <EOL> read_norb_files ( norb_files , memmap ) <EOL> if not os . path . isfile ( memmap_path ) : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" % memmap_path ) <EOL> make_memmap ( ) <EOL> labels = numpy . memmap ( filename = memmap_path , <EOL> dtype = dtype , <EOL> mode = '<STR_LIT:r>' , <EOL> shape = shape ) <EOL> if which_set == '<STR_LIT:train>' : <EOL> labels = labels [ : training_set_size , : ] <EOL> elif which_set == '<STR_LIT:test>' : <EOL> labels = labels [ training_set_size : , : ] <EOL> return labels <EOL> def get_norb_dir ( which_norb ) : <EOL> datasets_dir = os . getenv ( '<STR_LIT>' ) <EOL> if datasets_dir is None : <EOL> raise RuntimeError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if not os . path . isdir ( datasets_dir ) : <EOL> raise IOError ( "<STR_LIT>" <EOL> "<STR_LIT>" % datasets_dir ) <EOL> return os . path . join ( datasets_dir , <EOL> '<STR_LIT>' if which_norb == '<STR_LIT>' <EOL> else '<STR_LIT>' ) <EOL> norb_dir = get_norb_dir ( which_norb ) <EOL> def get_memmap_path ( which_norb , file_basename ) : <EOL> assert which_norb in ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert ( file_basename == '<STR_LIT>' or <EOL> file_basename . startswith ( '<STR_LIT>' ) ) , file_basename <EOL> memmap_dir = os . path . join ( norb_dir , '<STR_LIT>' ) <EOL> return os . path . join ( memmap_dir , "<STR_LIT>" % file_basename ) <EOL> def get_norb_file_paths ( which_norb , which_set , norb_file_type ) : <EOL> """<STR_LIT>""" <EOL> assert which_set in ( '<STR_LIT:train>' , '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> if which_set == '<STR_LIT>' : <EOL> return ( get_norb_file_paths ( which_norb , <EOL> '<STR_LIT:train>' , <EOL> norb_file_type ) + <EOL> get_norb_file_paths ( which_norb , <EOL> '<STR_LIT:test>' , <EOL> norb_file_type ) ) <EOL> norb_file_types = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:info>' ) <EOL> if norb_file_type not in norb_file_types : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( str ( norb_file_types ) , <EOL> norb_file_type ) ) <EOL> instance_list = '<STR_LIT>' if which_set == '<STR_LIT:test>' else '<STR_LIT>' <EOL> if which_norb == '<STR_LIT>' : <EOL> templates = [ '<STR_LIT>' % <EOL> ( instance_list , which_set ) ] <EOL> else : <EOL> numbers = range ( <NUM_LIT:1> , <NUM_LIT:3> if which_set == '<STR_LIT:test>' else <NUM_LIT:11> ) <EOL> templates = [ '<STR_LIT>' % <EOL> ( instance_list , which_set , n ) for n in numbers ] <EOL> original_files_dir = os . path . join ( norb_dir , '<STR_LIT>' ) <EOL> return [ os . path . join ( original_files_dir , t % norb_file_type ) <EOL> for t in templates ] <EOL> def make_view_converter ( which_norb , which_set ) : <EOL> image_length = <NUM_LIT> if which_norb == '<STR_LIT>' else <NUM_LIT> <EOL> datum_shape = ( <NUM_LIT:2> , <EOL> image_length , <EOL> image_length , <EOL> <NUM_LIT:1> ) <EOL> axes = ( '<STR_LIT:b>' , '<STR_LIT:s>' , <NUM_LIT:0> , <NUM_LIT:1> , '<STR_LIT:c>' ) <EOL> return StereoViewConverter ( datum_shape , axes ) <EOL> images = load_images ( which_norb , which_set , image_dtype ) <EOL> labels = load_labels ( which_norb , which_set ) <EOL> view_converter = make_view_converter ( which_norb , which_set ) <EOL> super ( NORB , self ) . __init__ ( X = images , <EOL> y = labels , <EOL> y_labels = numpy . max ( labels ) + <NUM_LIT:1> , <EOL> view_converter = view_converter ) <EOL> self . X_memmap_info = None <EOL> self . y_memmap_info = None <EOL> @ functools . wraps ( DenseDesignMatrix . get_topological_view ) <EOL> def get_topological_view ( self , mat = None , single_tensor = False ) : <EOL> """<STR_LIT>""" <EOL> result = super ( NORB , self ) . get_topological_view ( mat ) <EOL> if single_tensor : <EOL> if '<STR_LIT:s>' not in self . view_converter . axes : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % str ( self . view_converter . axes ) ) <EOL> assert isinstance ( result , tuple ) <EOL> assert len ( result ) == <NUM_LIT:2> <EOL> axes = list ( self . view_converter . axes ) <EOL> s_index = axes . index ( '<STR_LIT:s>' ) <EOL> assert axes . index ( '<STR_LIT:b>' ) == <NUM_LIT:0> <EOL> num_image_pairs = result [ <NUM_LIT:0> ] . shape [ <NUM_LIT:0> ] <EOL> shape = ( num_image_pairs , ) + self . view_converter . shape <EOL> mono_shape = shape [ : s_index ] + ( <NUM_LIT:1> , ) + shape [ ( s_index + <NUM_LIT:1> ) : ] <EOL> result = tuple ( t . reshape ( mono_shape ) for t in result ) <EOL> result = numpy . concatenate ( result , axis = s_index ) <EOL> return result <EOL> def __getstate__ ( self ) : <EOL> """<STR_LIT>""" <EOL> _check_pickling_support ( ) <EOL> result = copy . copy ( self . __dict__ ) <EOL> assert isinstance ( self . X , numpy . memmap ) , ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> str ( type ( self . X ) ) ) <EOL> assert isinstance ( self . y , numpy . memmap ) , ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> str ( type ( self . y ) ) ) <EOL> del result [ '<STR_LIT:X>' ] <EOL> del result [ '<STR_LIT:y>' ] <EOL> def get_memmap_info ( memmap ) : <EOL> assert isinstance ( memmap , numpy . memmap ) <EOL> if not isinstance ( memmap . filename , str ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( type ( memmap . filename ) , str ( memmap . filename ) ) ) <EOL> result = { } <EOL> def get_relative_path ( full_path ) : <EOL> """<STR_LIT>""" <EOL> data_dir = string_utils . preprocess ( '<STR_LIT>' ) <EOL> if not memmap . filename . startswith ( data_dir ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( data_dir , memmap . filename ) ) <EOL> return os . path . relpath ( full_path , data_dir ) <EOL> return { '<STR_LIT:filename>' : get_relative_path ( memmap . filename ) , <EOL> '<STR_LIT>' : memmap . dtype , <EOL> '<STR_LIT>' : memmap . shape , <EOL> '<STR_LIT>' : memmap . offset , <EOL> '<STR_LIT>' : '<STR_LIT>' if memmap . mode in ( '<STR_LIT>' , '<STR_LIT>' ) else '<STR_LIT:r>' } <EOL> result [ '<STR_LIT>' ] = get_memmap_info ( self . X ) <EOL> result [ '<STR_LIT>' ] = get_memmap_info ( self . y ) <EOL> for memmap in ( self . X , self . y ) : <EOL> memmap . flush ( ) <EOL> memmap . setflags ( write = False ) <EOL> return result <EOL> def __setstate__ ( self , state ) : <EOL> """<STR_LIT>""" <EOL> _check_pickling_support ( ) <EOL> X_info = state [ '<STR_LIT>' ] <EOL> y_info = state [ '<STR_LIT>' ] <EOL> del state [ '<STR_LIT>' ] <EOL> del state [ '<STR_LIT>' ] <EOL> self . __dict__ . update ( state ) <EOL> def load_memmap_from_info ( info ) : <EOL> data_dir = string_utils . preprocess ( '<STR_LIT>' ) <EOL> info [ '<STR_LIT:filename>' ] = os . path . join ( data_dir , info [ '<STR_LIT:filename>' ] ) <EOL> shape = info [ '<STR_LIT>' ] <EOL> offset = info [ '<STR_LIT>' ] <EOL> if offset == <NUM_LIT:0> : <EOL> del info [ '<STR_LIT>' ] <EOL> return numpy . memmap ( ** info ) <EOL> else : <EOL> del info [ '<STR_LIT>' ] <EOL> result = numpy . memmap ( ** info ) <EOL> return result . reshape ( shape ) <EOL> self . X = load_memmap_from_info ( X_info ) <EOL> self . y = load_memmap_from_info ( y_info ) <EOL> class StereoViewConverter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , shape , axes = None ) : <EOL> """<STR_LIT>""" <EOL> shape = tuple ( shape ) <EOL> if not all ( isinstance ( s , int ) for s in shape ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if len ( shape ) != <NUM_LIT:4> : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> shape ) <EOL> datum_axes = list ( axes ) <EOL> datum_axes . remove ( '<STR_LIT:b>' ) <EOL> if shape [ datum_axes . index ( '<STR_LIT:s>' ) ] != <NUM_LIT:2> : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( shape [ datum_axes . index ( '<STR_LIT:s>' ) ] , <EOL> axes , <EOL> shape ) ) <EOL> self . shape = shape <EOL> self . set_axes ( axes ) <EOL> def make_conv2d_space ( shape , axes ) : <EOL> shape_axes = list ( axes ) <EOL> shape_axes . remove ( '<STR_LIT:b>' ) <EOL> image_shape = tuple ( shape [ shape_axes . index ( axis ) ] <EOL> for axis in ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> conv2d_axes = list ( axes ) <EOL> conv2d_axes . remove ( '<STR_LIT:s>' ) <EOL> return Conv2DSpace ( shape = image_shape , <EOL> num_channels = shape [ shape_axes . index ( '<STR_LIT:c>' ) ] , <EOL> axes = conv2d_axes , <EOL> dtype = None ) <EOL> conv2d_space = make_conv2d_space ( shape , axes ) <EOL> self . topo_space = CompositeSpace ( ( conv2d_space , conv2d_space ) ) <EOL> self . storage_space = VectorSpace ( dim = numpy . prod ( shape ) ) <EOL> def get_formatted_batch ( self , batch , space ) : <EOL> """<STR_LIT>""" <EOL> return self . storage_space . np_format_as ( batch , space ) <EOL> def design_mat_to_topo_view ( self , design_mat ) : <EOL> """<STR_LIT>""" <EOL> return self . storage_space . np_format_as ( design_mat , self . topo_space ) <EOL> def design_mat_to_weights_view ( self , design_mat ) : <EOL> """<STR_LIT>""" <EOL> return self . design_mat_to_topo_view ( design_mat ) <EOL> def topo_view_to_design_mat ( self , topo_batch ) : <EOL> """<STR_LIT>""" <EOL> return self . topo_space . np_format_as ( topo_batch , self . storage_space ) <EOL> def view_shape ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . shape <EOL> def weights_view_shape ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . view_shape ( ) <EOL> def set_axes ( self , axes ) : <EOL> """<STR_LIT>""" <EOL> axes = tuple ( axes ) <EOL> if len ( axes ) != <NUM_LIT:5> : <EOL> raise ValueError ( "<STR_LIT>" % str ( axes ) ) <EOL> for required_axis in ( '<STR_LIT:b>' , '<STR_LIT:s>' , <NUM_LIT:0> , <NUM_LIT:1> , '<STR_LIT:c>' ) : <EOL> if required_axis not in axes : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % str ( axes ) ) <EOL> if axes . index ( '<STR_LIT:b>' ) != <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> str ( axes ) ) <EOL> def remove_b_axis ( axes ) : <EOL> axes = list ( axes ) <EOL> axes . remove ( '<STR_LIT:b>' ) <EOL> return tuple ( axes ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> assert hasattr ( self , '<STR_LIT>' ) <EOL> old_axes = remove_b_axis ( self . axes ) <EOL> new_axes = remove_b_axis ( axes ) <EOL> new_shape = tuple ( self . shape [ old_axes . index ( a ) ] for a in new_axes ) <EOL> self . shape = new_shape <EOL> self . axes = axes <EOL> def _check_is_integral ( name , label ) : <EOL> if not numpy . issubdtype ( type ( label ) , numpy . integer ) : <EOL> raise TypeError ( "<STR_LIT>" % <EOL> ( name , type ( label ) ) ) <EOL> def _check_range ( name , label , min_label , max_label ) : <EOL> if label < min_label or label > max_label : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( name , min_label , max_label , str ( label ) ) ) <EOL> def _get_array_element ( name , label , array ) : <EOL> _check_is_integral ( name , label ) <EOL> _check_range ( name , label , <NUM_LIT:0> , len ( array ) - <NUM_LIT:1> ) <EOL> return array [ label ] <EOL> def get_category_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _get_array_element ( '<STR_LIT>' , label , ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:blank>' ) ) <EOL> def _check_range_and_return ( name , <EOL> label , <EOL> min_label , <EOL> max_label , <EOL> none_label = None ) : <EOL> _check_is_integral ( name , label ) <EOL> _check_range ( name , label , min_label , max_label ) <EOL> return None if label == none_label else label <EOL> def get_instance_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT:1> , <NUM_LIT:9> , - <NUM_LIT:1> ) <EOL> def get_elevation_value ( label ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> _check_is_integral ( name , label ) <EOL> _check_range ( name , label , - <NUM_LIT:1> , <NUM_LIT:8> ) <EOL> if label == - <NUM_LIT:1> : <EOL> return None <EOL> else : <EOL> return label * <NUM_LIT:5> + <NUM_LIT:30> <EOL> def get_azimuth_value ( label ) : <EOL> """<STR_LIT>""" <EOL> _check_is_integral ( '<STR_LIT>' , label ) <EOL> if label == - <NUM_LIT:1> : <EOL> return None <EOL> else : <EOL> if ( label % <NUM_LIT:2> ) != <NUM_LIT:0> or label < <NUM_LIT:0> or label > <NUM_LIT> : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> str ( label ) ) <EOL> return label * <NUM_LIT:10> <EOL> def get_lighting_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT:1> , <NUM_LIT:5> , - <NUM_LIT:1> ) <EOL> def get_horizontal_shift_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> def get_vertical_shift_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> def get_lumination_change_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT> , <NUM_LIT> ) <EOL> def get_contrast_change_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _get_array_element ( '<STR_LIT>' , label , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> def get_scale_change_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _get_array_element ( '<STR_LIT>' , label , ( <NUM_LIT> , <NUM_LIT:1.0> ) ) <EOL> def get_rotation_change_value ( label ) : <EOL> """<STR_LIT>""" <EOL> return _check_range_and_return ( '<STR_LIT>' , label , - <NUM_LIT:4> , <NUM_LIT:4> ) <EOL> def _check_pickling_support ( ) : <EOL> version = float ( '<STR_LIT:.>' . join ( numpy . version . version . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:2> ] ) ) <EOL> if version < <NUM_LIT> : <EOL> msg = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> raise NotImplementedError ( msg ) </s>
