def get_shape_calculated_values(self): shapeDict = ordDict() shapeDict.setdefault(str(self.get_shape_values())) shapeDict.setdefault(str(self.calculate_area())) shapeDict.setdefault(str(self.calculate_perimeter())) shapeDict.setdefault(str(self.calculate_diagonal())) return shapeDict
def cartesian_prod_dicts_lists(the_dict): #takes a dictionary and produces a dictionary of the cartesian product of the input if not type(the_dict) is type(ordDict()): warnings.warn('An ordered dict was not used. Thus if this function is called again with the same dict it might not produce the same results.') from sklearn.utils.extmath import cartesian stim_list = [] stim_list = tuple([ list(the_dict[ key_name ]) for key_name in the_dict ]) #cartesian has the last column change the fastest, thus is like c-indexing stim_cart_array = cartesian(stim_list) cart_dict = ordDict() #load up the vectors assosciated with keys to cart_dict for key_name, key_num in zip(the_dict, range(len(the_dict))): cart_dict[key_name] = stim_cart_array[:, key_num] return cart_dict
def stim_trans_generator(shapes=None, blur=None, scale=None, x=None, y=None, amp=None, rotation=None): #takes descrptions of ranges for different transformations (start, stop, npoints) #produces a cartesian dictionary of those. stim_trans_dict = ordDict() if not shapes is None: #stim_trans_dict['shapes'] = np.array(shapes, dtype=int) stim_trans_dict['shapes'] = np.array(shapes) if not blur is None : if isinstance(blur,tuple): stim_trans_dict['blur'] = np.linspace(*blur) else: stim_trans_dict['blur'] = blur if not scale is None: if isinstance(scale, tuple): stim_trans_dict[ 'scale' ] = np.linspace(*scale) else: stim_trans_dict[ 'scale' ] = scale if not x is None : if type(x) is tuple: stim_trans_dict['x'] = np.linspace(*x) else: stim_trans_dict['x'] = np.array(x) if not y is None : if type(y) is tuple: stim_trans_dict['y'] = np.linspace(*y) else: stim_trans_dict['y'] = np.array(y) if not rotation is None : if type(rotation) is tuple: stim_trans_dict['rotation'] = np.linspace(*y) else: stim_trans_dict['rotation'] = np.array(rotation) if not amp is None: stim_trans_dict['amp'] = np.linspace(*amp) # get all dimensions, into a dict stim_trans_cart_dict = dm.cartesian_prod_dicts_lists(stim_trans_dict) #this is a hackish fix to cart from sklearn switching dtypes according to 1st element. stim_trans_cart_dict['shapes'] = stim_trans_cart_dict['shapes'].astype(int) return stim_trans_cart_dict, stim_trans_dict
# Data type: OrderedDictionary # # Key of dictionary is the category of visualized quantity # (e.g. 'Blade summary), the value is a list of tuples, # where the first element is a label of visualized q. # (e.g. 'Energy consumption [J] (Samples)') and the second one # is a unit of the quantity. # # Example: # y_label = ordDict((('Blade summary', [('Energy consumption [J] (Stats structure)', 'J')]), # ('Job info - hdeem', [('Runtime of function [s]', 's')]))) #y_label = ordDict((('Blade summary', [('Average energy consumption [J]', 'J')]), # ('Job info - hdeem', [('Average runtime of function [s]', 's')]))) y_label = ordDict((('COUNTERS - RAPL:', [ ('AVG Energy summary [J]', 'J') ]), ('Job info - RAPL', [('AVG Runtime of function [s]', 's')]))) # Time and energy variable # # Data type: Dictionary/None # # When used, than reports will contain information about # run-time change for energetically-optimal settings # # Example: # 1) time_energy_vars = None # 2) time_energy_vars = {'time': ('Job info - hdeem', 'Runtime of function [s]'), # 'energy': ('Blade summary', 'Energy consumption [J] (Samples)')} #time_energy_vars = {'time': ('Job info - hdeem', 'Average runtime of function [s]'), # 'energy': ('Blade summary', 'Average energy consumption [J]')}
# Listing of visualized quantities/variables # # Data type: OrderedDictionary # # Key of dictionary is the category of visualized quantity # (e.g. 'Blade summary), the value is a list of tuples, # where the first element is a label of visualized q. # (e.g. 'Energy consumption [J] (Samples)') and the second one # is a unit of the quantity. # # Example: # y_label = ordDict((('Blade summary', [('Energy consumption [J] (Stats structure)', 'J')]), # ('Job info - hdeem', [('Runtime of function [s]', 's')]))) y_label = ordDict((('Blade summary', [ ('Average energy consumption [J]', 'J') ]), ('Job info - hdeem', [('Average runtime of function [s]', 's')]))) # Time and energy variable # # Data type: Dictionary/None # # When used, than reports will contain information about # run-time change for energetically-optimal settings # # Example: # 1) time_energy_vars = None # 2) time_energy_vars = {'time': ('Job info - hdeem', 'Runtime of function [s]'), # 'energy': ('Blade summary', 'Energy consumption [J] (Samples)')} time_energy_vars = { 'time': ('Job info - hdeem', 'Average runtime of function [s]'),