def get_rep_json(): """ Gets the representative plot JSON :return: """ global current_x_axis global current_y_axis global current_category global current_dataset global current_lists global current_array_of_rows cur_x = current_x_axis cur_y = current_y_axis jsonDict = dict() current_array_of_rows = logic.make_row_objects(current_dataset['dataset'], current_x_axis, current_y_axis, current_category) some_list = [] current_lists = logic.return_sorted_list(current_array_of_rows) for row in current_lists[0]: pair = {} pair['xValue'] = row.xValue pair['category'] = row.category pair['yValue'] = row.yValue some_list.append(pair) jsonDict['datalist'] = some_list jsonDict['colNames'] = str(current_dataset['column_names']) try: jsonDict['currentX'] = cur_x except: # catch *all* exceptions e = sys.exc_info() jsonDict['currentX'] = str(e) print(e) jsonDict['currentY'] = cur_y jsonDict['currentZ'] = current_category jsonDict['cols'] = current_dataset['cols'] jsonDict['rows'] = current_dataset['rows'] jsonDict['datasetName'] = current_dataset_name jsonDict['columnNames'] = current_dataset['column_names'] return json.dumps(jsonDict)
def test_get_top_ranks(self): result = "iris-setosa" data_from_file = logic.get_data_dict(skip_header=1) dataset = data_from_file['dataset'] x_axis_number = 0 y_axis_number = 1 category_number = 4 current_array_of_rows = logic.make_row_objects(dataset, x_axis_number, y_axis_number, category_number) current_user_X_start = 2 current_user_Y_start = 0 current_user_X_end = 3 current_user_Y_end = 3 current_lists = logic.return_sorted_list(current_array_of_rows) results_tuples = logic.return_top_ranks(current_lists, current_user_X_start, current_user_X_end, current_user_Y_end, current_user_Y_start) print(results_tuples) self.assertEqual(result, "iris-setosa", "yes")