CommitLineData
fa920fb1 1# File : begin
5ae01c85 2
fa920fb1 3if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
9}
10
11# to prevent loops limit to 16 minutes
12cpulimit 1000
13
9753e6de 14# On Windows with VC, in typical configuration gl2ps is built with Release
15# mode only which will fail in Debug mode; add TODO for that case in order
16# to handle it once for all tests that can use vexport command
17if { [regexp {Debug mode} [dversion]] } {
18 puts "TODO ?#23540 windows: Error: export of image.*failed"
19 puts "TODO ?#23540 windows: Error: The file has been exported.*different size \[(\]0 "
20}
fa920fb1 21
22if { [info exists imagedir] == 0 } {
23 set imagedir .
24}
25if { [info exists test_image] == 0 } {
26 set test_image photo
27}
28
c2f5c748 29# Procedure to check equality of two reals with tolerance (relative and absolute)
91322f44 30help checkarea {shape area_expected tol_abs tol_rel}
31proc checkarea {shape area_expected tol_abs tol_rel} {
32 # compute area with half of the relative tolerance
33 # to be used in comparison; 0.001 is added to avoid zero value
34 set prop [uplevel sprops \$shape [expr 0.5 * abs(\$tol_rel) + 0.001]]
35
36 # get te value
37 if { ! [regexp {Mass\s*:\s*([0-9.e+-]+)} \$prop res area] } {
38 puts "Error: cannot get area of the shape \$shape"
39 return
40 }
f1aa2b62 41
91322f44 42 # compare with expected value
43 checkreal "area of \$shape" \$area \$area_expected \$tol_abs \$tol_rel
44}
f1aa2b62 45
deb26df7
RL
46# Procedure to check if sequence of values in listval follows linear trend
47# adding the same delta on each step.
48#
49# The function does statistical estimation of the mean variation of the
50# values of the sequence, and dispersion, and returns true only if both
51# dispersion and deviation of the mean from expected delta are within
52# specified tolerance.
53#
54# If mean variation differs from expected delta on more than two dispersions,
55# the check fails and procedure raises error with specified message.
56#
57# Otherwise the procedure returns false meaning that more iterations are needed.
58# Note that false is returned in any case if length of listval is less than 3.
59#
60# See example of use to check memory leaks in bugs/caf/bug23489
61#
62proc checktrend {listval delta tolerance message} {
63 set nbval [llength \$listval]
64 if { \$nbval < 3} {
65 return 0
66 }
fa920fb1 67
deb26df7
RL
68 # calculate mean value
69 set mean 0.
70 set prev [lindex \$listval 0]
71 foreach val [lrange \$listval 1 end] {
72 set mean [expr \$mean + (\$val - \$prev)]
73 set prev \$val
74 }
9753e6de 75 set mean [expr \$mean / (\$nbval - 1)]
fa920fb1 76
deb26df7
RL
77 # calculate dispersion
78 set sigma 0.
79 set prev [lindex \$listval 0]
80 foreach val [lrange \$listval 1 end] {
81 set d [expr (\$val - \$prev) - \$mean]
82 set sigma [expr \$sigma + \$d * \$d]
83 set prev \$val
84 }
9753e6de 85 set sigma [expr sqrt (\$sigma / (\$nbval - 2))]
fa920fb1 86
deb26df7
RL
87 puts "Checking trend: nb = \$nbval, mean delta = \$mean, sigma = \$sigma"
88
89 # check if deviation is definitely too big
9753e6de 90 if { abs (\$mean - \$delta) > \$tolerance + 2. * \$sigma } {
deb26df7 91 puts "Checking trend failed: mean delta per step = \$mean, sigma = \$sigma, expected delta = \$delta"
67a1064e 92 error "\$message"
deb26df7
RL
93 }
94
95 # check if deviation is clearly within a range
96 return [expr abs (\$mean - \$delta) <= \$sigma && \$sigma <= \$tolerance]
97}
74f764ba 98
99# Check if area of triangles is valid
100proc CheckTriArea {shape {eps 0}} {
101 upvar #0 \$shape result
102 set area [triarea result \$eps]
103 set t_area [lindex \$area 0]
104 set g_area [expr abs([lindex \$area 1])]
105 puts "area by triangles: \$t_area"
106 puts "area by geometry: \$g_area"
107 expr (\$t_area - \$g_area) / \$g_area * 100
108}
02effd35 109
110# Check if list of xdistcs-command is valid
e8feb725 111proc checkList {List Tolerance D_good Limit_Tol} {
02effd35 112 set L1 [llength \${List}]
113 set L2 10
114 set L3 5
115 set N [expr (\${L1} - \${L2})/\${L3} + 1]
116
117 for {set i 1} {\${i} <= \${N}} {incr i} {
118 set j1 [expr \${L2} + (\${i}-1)*\${L3}]
119 set j2 [expr \${j1} + 2]
120 set T [lindex \${List} \${j1}]
121 set D [lindex \${List} \${j2}]
122 #puts "i=\${i} j1=\${j1} j2=\${j2} T=\${T} D=\${D}"
123 if { [expr abs(\${D} - \${D_good})] > \${Tolerance} } {
e8feb725 124 puts "Error : T=\${T} D=\${D}"
125 }
126
127 if { \${Tolerance} > \${Limit_Tol} } {
128 if { [expr abs(\${D} - \${D_good})] > \${Limit_Tol}
129 && [expr abs(\${D} - \${D_good})] <= \${Tolerance} } {
130 puts "Attention (critical value of tolerance) : T=\${T} D=\${D}"
131 }
02effd35 132 }
133 }
134}
558e68ea 135
74da0216 136# Check expected time
137proc checktime {value expected tol_rel message} {
138 set t1 [expr \${value} - \${expected}]
139 set t2 [expr \${expected} * abs (\${tol_rel})]
140
141 if { abs (\${t1}) <= \${t2} } {
142 puts "OK. \${message}, \${value} seconds, is equal to expected time - \${expected} seconds"
143 } elseif {\${t1} > \${t2}} {
144 puts "Error. \${message}, \${value} seconds, is more than expected time - \${expected} seconds"
145 } else {
146 puts "Improvement. \${message}, \${value} seconds, is less than expected time - \${expected} seconds"
147 }
148}
{"ft_lang_label":"__label__en","ft_lang_prob":0.5374991,"math_prob":0.8885458,"size":5687,"snap":"2020-45-2020-50","text_gpt3_token_len":1962,"char_repetition_ratio":0.11719163,"word_repetition_ratio":0.023162136,"special_character_ratio":0.4448743,"punctuation_ratio":0.055555556,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9691284,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-20T21:11:11Z\",\"WARC-Record-ID\":\"<urn:uuid:3ffc72c2-4832-426c-a3fe-7093b4eef6fc>\",\"Content-Length\":\"47378\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9ff4adb2-09fc-4b12-9c1b-3f4c79d0eae8>\",\"WARC-Concurrent-To\":\"<urn:uuid:4d1ed728-ecaa-4592-b93d-15f4a5f7c4e3>\",\"WARC-IP-Address\":\"188.165.114.136\",\"WARC-Target-URI\":\"http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blame;f=tests/bugs/begin;h=8a7088ee727a6181c266d9265808638c6129c3d0;hb=59e349919f8fa8fb1f9ce6b2eeda52a4fc4d28f9\",\"WARC-Payload-Digest\":\"sha1:NOFQ3JQFHP3K6GGUR2CIHCYMQMHWMPPR\",\"WARC-Block-Digest\":\"sha1:HWMVZHAFP4AJIS3WCWQQBKMAYZDGPNM5\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107874135.2_warc_CC-MAIN-20201020192039-20201020222039-00568.warc.gz\"}"}