Tree @015d7c02-9d75-4da2-b5a0-e0f1290dfce0/upstream/12.2.2+git20220104.1.6819ead+ds (Download .tar.gz)
- ..
- jpeg2000
- .gitignore
- add_points_without_transform.csv_expected_1
- add_points_without_transform.test.commandline
- add_points_without_transform.xml
- big_dynamic_range.csv_expected_1
- big_dynamic_range.test.commandline.inwork
- big_dynamic_range.xml
- cartesian_linear_linear.csv_expected_1
- cartesian_linear_linear.test.commandline
- cartesian_linear_linear.xml
- cartesian_linear_log.csv_expected_1
- cartesian_linear_log.test.commandline
- cartesian_linear_log.xml
- cartesian_log_linear.csv_expected_1
- cartesian_log_linear.test.commandline
- cartesian_log_linear.xml
- curve_rename.csv_expected_1
- curve_rename.test.commandline
- curve_rename.xml
- drag_and_drop_gif.csv_expected_1
- drag_and_drop_gif.gif
- drag_and_drop_gif.test.commandline
- drag_and_drop_http.csv_expected_1
- drag_and_drop_http.test.commandline
- drag_and_drop_jpg.csv_expected_1
- drag_and_drop_jpg.jpg
- drag_and_drop_jpg.test.commandline
- drag_and_drop_png.csv_expected_1
- drag_and_drop_png.png
- drag_and_drop_png.test.commandline
- DumpGraphAndScreenCoordinates_test.py
- endpoints.dig
- export.multiple.periods.csv_expected_1
- export.multiple.periods.dig
- export.multiple.periods.test.commandline
- export_empty_then_nonempty_curves.csv_expected_1
- export_empty_then_nonempty_curves.dig
- export_empty_then_nonempty_curves.test.commandline
- export_extrapolate_1_2_3_linear_smooth.csv_expected_1
- export_extrapolate_1_2_3_linear_smooth.dig
- export_extrapolate_1_2_3_linear_smooth.test.commandline
- export_extrapolate_1_2_3_linear_straight.csv_expected_1
- export_extrapolate_1_2_3_linear_straight.dig
- export_extrapolate_1_2_3_linear_straight.test.commandline
- export_extrapolate_1_2_3_log_smooth.csv_expected_1
- export_extrapolate_1_2_3_log_smooth.dig
- export_extrapolate_1_2_3_log_smooth.test.commandline
- export_extrapolate_1_2_3_log_straight.csv_expected_1
- export_extrapolate_1_2_3_log_straight.dig
- export_extrapolate_1_2_3_log_straight.test.commandline
- export_extrapolate_3_2_1_linear_smooth.csv_expected_1
- export_extrapolate_3_2_1_linear_smooth.dig
- export_extrapolate_3_2_1_linear_smooth.test.commandline
- export_extrapolate_3_2_1_linear_straight.csv_expected_1
- export_extrapolate_3_2_1_linear_straight.dig
- export_extrapolate_3_2_1_linear_straight.test.commandline
- export_extrapolate_3_2_1_log_smooth.csv_expected_1
- export_extrapolate_3_2_1_log_smooth.dig
- export_extrapolate_3_2_1_log_smooth.test.commandline
- export_extrapolate_3_2_1_log_straight.csv_expected_1
- export_extrapolate_3_2_1_log_straight.dig
- export_extrapolate_3_2_1_log_straight.test.commandline
- export_nonempty_then_empty_curves.csv_expected_1
- export_nonempty_then_empty_curves.dig
- export_nonempty_then_empty_curves.test.commandline
- export_only_all_curves_on_same_line.csv_expected_1
- export_only_all_curves_on_same_line.dig
- export_only_all_curves_on_same_line.test.commandline
- export_only_one_curve_per_line.csv_expected_1
- export_only_one_curve_per_line.dig
- export_only_one_curve_per_line.test.commandline
- export_precision_plus_0.csv_expected_1
- export_precision_plus_0.test.commandline
- export_precision_plus_0.xml
- export_precision_plus_1.csv_expected_1
- export_precision_plus_1.test.commandline
- export_precision_plus_1.xml
- export_precision_plus_2.csv_expected_1
- export_precision_plus_2.test.commandline
- export_precision_plus_2.xml
- export_relations_intervals.csv_expected_1
- export_relations_intervals.dig
- export_relations_intervals.test.commandline
- extract_image_only_1.csv_expected_1
- extract_image_only_1.dig
- extract_image_only_1.test.commandline
- extract_image_only_2.csv_expected_1
- extract_image_only_2.dig
- extract_image_only_2.test.commandline
- extrapolate_functions_smooth.csv_expected_1
- extrapolate_functions_smooth.test.commandline
- extrapolate_functions_smooth.xml
- extrapolate_functions_straight.csv_expected_1
- extrapolate_functions_straight.test.commandline
- extrapolate_functions_straight.xml
- extrapolate_relations_smooth.csv_expected_1
- extrapolate_relations_smooth.test.commandline
- extrapolate_relations_smooth.xml
- extrapolate_relations_straight.csv_expected_1
- extrapolate_relations_straight.test.commandline
- extrapolate_relations_straight.xml
- floating_axes.csv_expected_1
- floating_axes.test.commandline
- floating_axes.xml
- four_axis_point_log_x.csv_expected_1
- four_axis_point_log_x.test.commandline
- four_axis_point_log_x.xml
- four_axis_point_log_y.csv_expected_1
- four_axis_point_log_y.test.commandline
- four_axis_point_log_y.xml
- four_sides_relations.csv_expected_1
- four_sides_relations.dig
- four_sides_relations.test.commandline
- function_function.csv_expected_1
- function_function.dig
- function_function.test.commandline
- function_relation.csv_expected_1
- function_relation.dig
- function_relation.test.commandline
- gnuplot_format.csv_expected_1
- gnuplot_format.test.commandline
- gnuplot_format.xml
- guidelines_cartesian.csv_expected_1
- guidelines_cartesian.test.commandline
- guidelines_cartesian.xml
- guidelines_cartesian_log.csv_expected_1
- guidelines_cartesian_log.test.commandline
- guidelines_cartesian_log.xml
- guidelines_multiple_coordinates.csv_expected_1
- guidelines_multiple_coordinates.csv_expected_2
- guidelines_multiple_coordinates.csv_expected_3
- guidelines_multiple_coordinates.csv_expected_4
- guidelines_multiple_coordinates.csv_expected_5
- guidelines_multiple_coordinates.test.commandline
- guidelines_multiple_coordinates.xml
- guidelines_multiple_load.csv_expected_1
- guidelines_multiple_load.csv_expected_2
- guidelines_multiple_load.csv_expected_3
- guidelines_multiple_load.csv_expected_4
- guidelines_multiple_load.csv_expected_5
- guidelines_multiple_load.dig
- guidelines_multiple_load.test.commandline
- guidelines_polar.csv_expected_1
- guidelines_polar.test.commandline
- guidelines_polar.xml
- guidelines_polar_linear_shear.csv_expected_1
- guidelines_polar_linear_shear.dig
- guidelines_polar_linear_shear.test.commandline
- guidelines_polar_log.csv_expected_1
- guidelines_polar_log.test.commandline
- guidelines_polar_log.xml
- guidelines_polar_log_rotated.csv_expected_1
- guidelines_polar_log_rotated.dig
- guidelines_polar_log_rotated.test.commandline
- guidelines_undo_redo.csv_expected_1
- guidelines_undo_redo.test.commandline
- guidelines_undo_redo.xml
- huge.csv_expected_1
- huge.test.commandline
- huge.xml
- interpolation.csv_expected_1
- interpolation.dig
- interpolation.test.commandline
- log_extrapolation.csv_expected_1
- log_extrapolation.test.commandline
- log_extrapolation.xml
- log_log.csv_expected_1
- log_log.test.commandline
- log_log.xml
- multi_coord_systems_curve_rename.csv_expected_1
- multi_coord_systems_curve_rename.csv_expected_2
- multi_coord_systems_curve_rename.test.commandline
- multi_coord_systems_curve_rename.xml
- points_along_axes.csv_expected_1
- points_along_axes.test.commandline
- points_along_axes.xml
- polar_linear_linear_3curve.csv_expected_1
- polar_linear_linear_3curve.test.commandline
- polar_linear_linear_3curve.xml
- polar_linear_linear_nonzero_center.csv_expected_1
- polar_linear_linear_nonzero_center.test.commandline
- polar_linear_linear_nonzero_center.xml
- relation_relation.csv_expected_1
- relation_relation.dig
- relation_relation.test.commandline
- settings_axes_checker.csv_expected_1
- settings_axes_checker.test.commandline
- settings_axes_checker.xml
- settings_color_filter.csv_expected_1
- settings_color_filter.test.commandline
- settings_color_filter.xml
- settings_coordinates.csv_expected_1
- settings_coordinates.test.commandline
- settings_coordinates.xml
- settings_curve_list.csv_expected_1
- settings_curve_list.test.commandline
- settings_curve_list.xml
- test_segment_fill.gnuplot_expected
- testDigGenerator.py
- time_2000_years.csv_expected_1
- time_2000_years.dig
- time_2000_years.test.commandline
- time_scale.csv_expected_1
- time_scale.test.commandline
- time_scale.xml
- time_scale_64bit.csv_expected_1
- time_scale_64bit.test.commandline
- time_scale_64bit.xml
- two_bumps.csv_expected_1
- two_bumps.dig
- two_bumps.test.commandline
- undo_redo.csv_expected_1
- undo_redo.test.commandline
- undo_redo.xml
- version10_1.csv_expected_1
- version10_1.dig
- version10_1.test.commandline
- version10_7_invalid_axes_point_names.csv_expected_1
- version10_7_invalid_axes_point_names.dig
- version10_7_invalid_axes_point_names.test.commandline
- version11_1.csv_expected_1
- version11_1.dig
- version11_1.test.commandline
- version12_1.csv_expected_1
- version12_1.dig
- version12_1.test.commandline
- version13_1.csv_expected_1
- version13_1.dig
- version13_1.test.commandline
- version5_1.dig
- version5_1.test.commandline
- version5_1.xml
- version5_2.csv_expected_1
- version5_2.dig
- version5_2.test.commandline
- version5_3.csv_expected_1
- version5_3.dig
- version5_3.test.commandline
- version6_1.dig
- version6_1.test.commandline
- version6_1.xml
- version6_2.csv_expected_1
- version6_2.dig
- version6_2.test.commandline
- version7.1_1.dig
- version7.1_1.test.commandline
- version7.1_1.xml
- version7.1_2.csv_expected_1
- version7.1_2.csv_expected_2
- version7.1_2.csv_expected_3
- version7.1_2.csv_expected_4
- version7.1_2.csv_expected_5
- version7.1_2.dig
- version7.1_2.test.commandline
- version7_1.dig
- version7_1.test.commandline
- version7_1.xml
- version7_2.csv_expected_1
- version7_2.csv_expected_2
- version7_2.csv_expected_3
- version7_2.csv_expected_4
- version7_2.csv_expected_5
- version7_2.dig
- version7_2.test.commandline
- version8_1.csv_expected_1
- version8_1.dig
- version8_1.test.commandline
- version8_2.csv_expected_1
- version8_2.dig
- version8_2.test.commandline
- version9_1.csv_expected_1
- version9_1.dig
- version9_1.test.commandline
DumpGraphAndScreenCoordinates_test.py @015d7c02-9d75-4da2-b5a0-e0f1290dfce0/upstream/12.2.2+git20220104.1.6819ead+ds — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | #!/usr/bin/python3 # Script that outputs the graph and screen coordinates of each point in a DIG file. # The format is: # 1) "xGraph yGraph xScreen yScreen" on each line # 2) Between each field is the export delimiter selected in the DIG file # # Requirements: # 1) python3 (versus python2) # 2) numpy and pandas # 3) DefaultListOrderedDict.py from the Engauge scripts directory # 4) ParseDig.py from the Engauge scripts directory import faulthandler import inspect import numpy as np import pandas as pd import subprocess import sys import testDigGenerator as TDG sys.path.insert (0, '../contrib/python') from ParseDig import ParseDig DEBUG_ENABLE = True def parseDigFile (fileName): parseDig = ParseDig (fileName) curveNames = parseDig.curveNames () exportDelimiter = parseDig.exportDelimiter () try: f = open (fileName[:-4] + 'Parsed.csv', 'w') except Exception as e: f = open (fileName[:-4] + 'Parsed.csv', 'w+') for curveName in curveNames: header = ("# {}" . format (curveName)) f.write (header + exportDelimiter + exportDelimiter + exportDelimiter + '\n') curve = parseDig.curve (curveName) for row in curve: xGraph = row [0] yGraph = row [1] (xScreen, yScreen) = parseDig.transformGraphToScreen (xGraph, yGraph) dataLine = ("{}{}{}{}{}{}{}" . format (xGraph, exportDelimiter, yGraph, exportDelimiter, xScreen, exportDelimiter, yScreen)) f.write(dataLine + '\n') f.close() return pd.read_csv(fileName[:-4] + 'Parsed.csv') def showResults (testName, expected, actual): GREEN = '\033[32m' RED = '\033[31m' ENDCOLOR = '\033[0m' expected = np.array ([round (elem, 3) for elem in expected]) # Remove issues due to roundoff actual = np.array ([round (elem, 3) for elem in actual]) result = (expected == actual).all () passFail = (GREEN + "PASS" + ENDCOLOR) if result else (RED + "FAIL" + ENDCOLOR) print ('{} : {}' . format (passFail, testName)) def TestFourAxesInfiniteSlope (): xScreen = [45, 587, 45, 45] yScreen = [171, 171, 15, 327] xGraph = [0, 14, 0, 0] yGraph = [0, 0, 1.5, -1.5] xPoints = 55 yPoints = 96 title = '.TestFourAxesInfiniteSlope.dig' TDG.createTestCase(np.array ([xScreen, xGraph]), np.array ([yScreen, yGraph]), xPoints, yPoints, 'Linear', 'Linear', title) ParseDig.callEngauge (['-exportonly', title], DEBUG_ENABLE) engaugeOutput = pd.read_csv (title [:-3] + 'csv') parsedData = np.array (parseDigFile (title).iloc [:, :2])[0] testData = np.array (engaugeOutput.iloc [:, :2]) [0] for i in range (len (testData)): decimalIndex = str (testData [i]).find ('.') decimals = len (str (testData [i])) - decimalIndex - 1 parsedData[i] = np.round (parsedData [i], decimals) showResults (inspect.stack () [0] [3], testData, parsedData) def TestInfiniteSlope(): xScreen = [45, 587, 45] yScreen = [327, 171, 15] xGraph = [0, 14, 0] yGraph = [-1.5, 0, 1.5] xPoints = 55 yPoints = 96 title = '.TestInfiniteSlope.dig' TDG.createTestCase (np.array ([xScreen, xGraph]), np.array ([yScreen, yGraph]), xPoints, yPoints, 'Linear', 'Linear', title) ParseDig.callEngauge (['-exportonly', title], DEBUG_ENABLE) engaugeOutput = pd.read_csv (title [:-3] + 'csv') parsedData = np.array (parseDigFile (title).iloc [:, :2]) [0] testData = np.array (engaugeOutput.iloc [:, :2]) [0] for i in range (len (testData)): decimalIndex = str (testData[i]).find ('.') decimals = len (str (testData [i])) - decimalIndex - 1 parsedData[i] = np.round (parsedData [i], decimals) showResults (inspect.stack () [0] [3], testData, parsedData) def TestRandomSlope (): xScreen = [np.random.randint(100, 150), 587, 45] yScreen = [327, 171, 15] xGraph = [0, 14, 0] yGraph = [-1.5, 0, 1.5] xPoints = 55 yPoints = 96 title = '.TestRandomSlope.dig' TDG.createTestCase (np.array ([xScreen, xGraph]), np.array ([yScreen, yGraph]), xPoints, yPoints, 'Linear', 'Linear', title) ParseDig.callEngauge (['-exportonly', title], DEBUG_ENABLE) engaugeOutput = pd.read_csv (title [:-3] + 'csv') parsedData = np.array (parseDigFile (title).iloc [:, :2]) [0] testData = np.array (engaugeOutput.iloc [:, :2]) [0] for i in range (len (testData)): decimalIndex = str (testData[i]).find ('.') decimals = len(str (testData[i])) - decimalIndex - 1 parsedData [i] = np.round (parsedData [i], decimals) showResults (inspect.stack () [0] [3], testData, parsedData) faulthandler.enable () TestFourAxesInfiniteSlope () TestInfiniteSlope () TestRandomSlope () |