* bug#70093: Remove unnecessary `image-tests--map-equal' @ 2024-03-30 19:44 Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-30 22:04 ` bug#70093: *** SPAM *** " David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 5:10 ` Eli Zaretskii 0 siblings, 2 replies; 10+ messages in thread From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-30 19:44 UTC (permalink / raw) To: 70093; +Cc: Eli Zaretskii, David Ponce With the resolution of bug#69992, it may be possible to remove the `image-tests--map-equal' equality predicate from lisp/image-tests.el. Eli and David, would you please apply the attached patch and then run the tests to see if we still need to allow for tolerances in `image--compute-map-and-original-map'? The tests pass for me, but then again, they never failed on my machine... Thank you!! I'm grateful for this fun collaboration. :) Joseph ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-30 19:44 bug#70093: Remove unnecessary `image-tests--map-equal' Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-30 22:04 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 7:37 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 5:10 ` Eli Zaretskii 1 sibling, 1 reply; 10+ messages in thread From: David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-30 22:04 UTC (permalink / raw) To: Joseph Turner, 70093; +Cc: Eli Zaretskii On 30/03/2024 20:44, Joseph Turner wrote: > With the resolution of bug#69992, it may be possible to remove the > `image-tests--map-equal' equality predicate from lisp/image-tests.el. > > Eli and David, would you please apply the attached patch and then run > the tests to see if we still need to allow for tolerances in > `image--compute-map-and-original-map'? > > The tests pass for me, but then again, they never failed on my machine... > > Thank you!! I'm grateful for this fun collaboration. :) > > Joseph > > Hi Joseph, Did you forget to attach the patch? I cannot find it. Anyway, I don't think the resolution of bug#69992 changed anything regarding the test `image--compute-map-and-original-map'. And to be honest I don't understand why it gives a different result on our configurations. To test, I also eval the following simple code in *scratch* buffer, which gives me consistent results on my laptop: (let* ((svg (svg-create 200 100)) (omap `(((rect . ((0 . 0) . (50 . 50))) rect-test (help-echo "rect-test")) ((circle . ((85 . 55) . 25)) circle-test (help-echo "circle-test")) ((poly . [100 0 125 0 170 50 125 50]) poly-test (help-echo "poly-test"))))) (svg-rectangle svg 0 0 50 50 :stroke-width 0 :fill "red") (svg-circle svg 85 55 25 :stroke-width 0 :fill "green") (svg-polyline svg '((100 . 0) (125 . 0) (170 . 50) (125 . 50)) :stroke-width 0 :fill "blue") (let ((image (svg-image svg :original-map omap :scale nil ;; vary scale test :rotation nil ;; vary rotation test :flip nil ;; vary flip test ))) ;; Must see the pointer and help-echo change when mouse hovers the ;; rect, circle and poly hot spots. (insert-image image) (insert ?\n) ;; Must see the same original map. (image--compute-original-map image))) Thanks! ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-30 22:04 ` bug#70093: *** SPAM *** " David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 7:37 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 10:08 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 10+ messages in thread From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 7:37 UTC (permalink / raw) To: David Ponce; +Cc: 70093, Eli Zaretskii [-- Attachment #1: Type: text/plain, Size: 2698 bytes --] David Ponce <da_vid@orange.fr> writes: > On 30/03/2024 20:44, Joseph Turner wrote: >> With the resolution of bug#69992, it may be possible to remove the >> `image-tests--map-equal' equality predicate from lisp/image-tests.el. >> Eli and David, would you please apply the attached patch and then >> run >> the tests to see if we still need to allow for tolerances in >> `image--compute-map-and-original-map'? >> The tests pass for me, but then again, they never failed on my >> machine... >> Thank you!! I'm grateful for this fun collaboration. :) >> Joseph >> > > Hi Joseph, > > Did you forget to attach the patch? I cannot find it. Apologies. Here it is. (This is the same patch as in my response to Eli) > Anyway, I don't think the resolution of bug#69992 changed anything > regarding the test `image--compute-map-and-original-map'. And to > be honest I don't understand why it gives a different result on our > configurations. I thought perhaps calculating scale with (/ (float (car size)) (car (image-size (image--image-without-parameters image) t))) instead of (or (image-property image :scale) 1) would fix the variations on our machines. > To test, I also eval the following simple code in *scratch* buffer, > which gives me consistent results on my laptop: > > (let* ((svg (svg-create 200 100)) > (omap `(((rect . ((0 . 0) . (50 . 50))) > rect-test (help-echo "rect-test")) > ((circle . ((85 . 55) . 25)) > circle-test (help-echo "circle-test")) > ((poly . [100 0 125 0 170 50 125 50]) > poly-test (help-echo "poly-test"))))) > (svg-rectangle svg 0 0 50 50 > :stroke-width 0 :fill "red") > (svg-circle svg 85 55 25 > :stroke-width 0 :fill "green") > (svg-polyline svg '((100 . 0) (125 . 0) (170 . 50) (125 . 50)) > :stroke-width 0 :fill "blue") > (let ((image (svg-image svg > :original-map omap > :scale nil ;; vary scale test > :rotation nil ;; vary rotation test > :flip nil ;; vary flip test > ))) > ;; Must see the pointer and help-echo change when mouse hovers the > ;; rect, circle and poly hot spots. > (insert-image image) > (insert ?\n) > ;; Must see the same original map. > (image--compute-original-map image))) This manual test also works on my machine. I had been doing something similar; I like your use of svg-create :) Let me know if the unit tests pass with this patch applied. Thank you! Joseph [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Compare-image-maps-with-equal-in-tests.patch --] [-- Type: text/x-diff, Size: 4386 bytes --] From e85fd88a2943fa95d2d7eea3a542308adaa81582 Mon Sep 17 00:00:00 2001 From: Joseph Turner <joseph@breatheoutbreathe.in> Date: Sat, 30 Mar 2024 12:38:52 -0700 Subject: [PATCH] Compare image maps with `equal' in tests With the fixes to image map transformation introduced in cc212ea314d, the tests should now exactly predict calculated image maps. * test/lisp/image-tests.el (image-tests--map-equal): Remove function. (image--compute-map-and-original-map): Use equal to compare image maps. --- test/lisp/image-tests.el | 46 +++++----------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el index 020781eff50..41b87b8d337 100644 --- a/test/lisp/image-tests.el +++ b/test/lisp/image-tests.el @@ -178,37 +178,6 @@ image-create-image-with-map (got-original-map (image-property image :original-map))) (should (equal got-original-map original-map-other))))) -(defun image-tests--map-equal (a b &optional tolerance) - "Return t if maps A and B have the same coordinates within TOLERANCE. -Since image sizes calculations vary on different machines, this function -allows for each image map coordinate in A to be within TOLERANCE to the -corresponding coordinate in B. When nil, TOLERANCE defaults to 5." - (unless tolerance (setq tolerance 5)) - (catch 'different - (cl-labels ((check-tolerance - (coord-a coord-b) - (unless (>= tolerance (abs (- coord-a coord-b))) - (throw 'different nil)))) - (dotimes (i (length a)) - (pcase-let ((`((,type-a . ,coords-a) ,_id ,_plist) (nth i a)) - (`((,type-b . ,coords-b) ,_id ,_plist) (nth i b))) - (unless (eq type-a type-b) - (throw 'different nil)) - (pcase-exhaustive type-a - ('rect - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cadr coords-a) (cadr coords-b)) - (check-tolerance (cddr coords-a) (cddr coords-b))) - ('circle - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b))) - ('poly - (dotimes (i (length coords-a)) - (check-tolerance (aref coords-a i) (aref coords-b i)))))))) - t)) - (ert-deftest image--compute-map-and-original-map () "Test `image--compute-map' and `image--compute-original-map'." (skip-unless (display-images-p)) @@ -237,25 +206,20 @@ image--compute-map-and-original-map :scale 2 :rotation 90 :flip t))) ;; Test that `image--compute-original-map' correctly generates ;; original-map when creating an already transformed image. - (should (image-tests--map-equal (image-property image :original-map) - original-map)) + (should (equal (image-property image :original-map) original-map)) (setf (image-property image :flip) nil) (setf (image-property image :rotation) 0) (setf (image-property image :scale) 2) - (should (image-tests--map-equal (image--compute-map image) - scaled-map)) + (should (equal (image--compute-map image) scaled-map)) (setf (image-property image :scale) 1) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - rotated-map)) + (should (equal (image--compute-map image) rotated-map)) (setf (image-property image :rotation) 0) (setf (image-property image :flip) t) - (should (image-tests--map-equal (image--compute-map image) - flipped-map)) + (should (equal (image--compute-map image) flipped-map)) (setf (image-property image :scale) 2) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - scaled-rotated-flipped-map)) + (should (equal (image--compute-map image) scaled-rotated-flipped-map)) ;; Uncomment to test manually by interactively transforming the ;; image and checking the map boundaries by hovering them. -- 2.41.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-31 7:37 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 10:08 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-02 10:36 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 10+ messages in thread From: David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 10:08 UTC (permalink / raw) To: Joseph Turner; +Cc: 70093, Eli Zaretskii On 31/03/2024 09:37, Joseph Turner wrote: > > David Ponce <da_vid@orange.fr> writes: > >> On 30/03/2024 20:44, Joseph Turner wrote: >>> With the resolution of bug#69992, it may be possible to remove the >>> `image-tests--map-equal' equality predicate from lisp/image-tests.el. >>> Eli and David, would you please apply the attached patch and then >>> run >>> the tests to see if we still need to allow for tolerances in >>> `image--compute-map-and-original-map'? >>> The tests pass for me, but then again, they never failed on my >>> machine... >>> Thank you!! I'm grateful for this fun collaboration. :) >>> Joseph >>> >> >> Hi Joseph, >> >> Did you forget to attach the patch? I cannot find it. > > Apologies. Here it is. (This is the same patch as in my response to Eli) > >> Anyway, I don't think the resolution of bug#69992 changed anything >> regarding the test `image--compute-map-and-original-map'. And to >> be honest I don't understand why it gives a different result on our >> configurations. > > I thought perhaps calculating scale with > > (/ (float (car size)) > (car (image-size > (image--image-without-parameters image) t))) > > instead of > > (or (image-property image :scale) 1) > > would fix the variations on our machines. > >> To test, I also eval the following simple code in *scratch* buffer, >> which gives me consistent results on my laptop: >> >> (let* ((svg (svg-create 200 100)) >> (omap `(((rect . ((0 . 0) . (50 . 50))) >> rect-test (help-echo "rect-test")) >> ((circle . ((85 . 55) . 25)) >> circle-test (help-echo "circle-test")) >> ((poly . [100 0 125 0 170 50 125 50]) >> poly-test (help-echo "poly-test"))))) >> (svg-rectangle svg 0 0 50 50 >> :stroke-width 0 :fill "red") >> (svg-circle svg 85 55 25 >> :stroke-width 0 :fill "green") >> (svg-polyline svg '((100 . 0) (125 . 0) (170 . 50) (125 . 50)) >> :stroke-width 0 :fill "blue") >> (let ((image (svg-image svg >> :original-map omap >> :scale nil ;; vary scale test >> :rotation nil ;; vary rotation test >> :flip nil ;; vary flip test >> ))) >> ;; Must see the pointer and help-echo change when mouse hovers the >> ;; rect, circle and poly hot spots. >> (insert-image image) >> (insert ?\n) >> ;; Must see the same original map. >> (image--compute-original-map image))) > > This manual test also works on my machine. I had been doing something > similar; I like your use of svg-create :) > > Let me know if the unit tests pass with this patch applied. > > Thank you! > > Joseph > Hello, With the patch applied the test fails the same for me: _______________________________________________________________ Selector: image--compute-map-and-original-map Passed: 0 Failed: 1 (1 unexpected) Skipped: 0 Total: 1/1 Started at: 2024-03-31 11:17:56+0200 Finished. Finished at: 2024-03-31 11:17:56+0200 F F image--compute-map-and-original-map Test ‘image--compute-map’ and ‘image--compute-original-map’. (ert-test-failed ((should (equal (image--compute-map image) rotated-map)) :form (equal (((circle ... . 24) "a" (help-echo "A")) ((rect ... 127 . 77) "b" (help-echo "B")) ((poly . [199 161 206 160 213 154 218 146 221 136 ...]) "c" (help-echo "C"))) (((circle ... . 24) "a" (help-echo "A")) ((rect ... 54 . 77) "b" (help-echo "B")) ((poly . [126 161 133 160 140 154 145 146 148 136 ...]) "c" (help-echo "C")))) :value nil :explanation (list-elt 0 (list-elt 0 (cdr (car ...)))))) _______________________________________________________________ More in detail, these 3 tests pass: 1. (should (equal (image-property image :original-map) original-map)) 2. (setf (image-property image :flip) nil) (setf (image-property image :rotation) 0) (setf (image-property image :scale) 2) (should (equal (image--compute-map image) scaled-map)) 3. (setf (image-property image :scale) 2) (setf (image-property image :rotation) 90) (should (equal (image--compute-map image) scaled-rotated-flipped-map)) But these 2 tests fails: 1. (setf (image-property image :scale) 1) (setf (image-property image :rotation) 90) (should (equal (image--compute-map image) rotated-map)) ;; Return ((((circle (199 . 41) . 24) "a" (help-echo "A")) ((rect (79 . 5) 127 . 77) "b" (help-echo "B")) ((poly . [199 161 206 160 213 154 218 146 221 136 223 125 221 114 218 104 213 96 206 91 199 89 191 91 185 96 179 104 176 114 175 125 176 136 179 146 185 154 191 160]) "c" (help-echo "C"))) ;; Instead of (((circle (126 . 41) . 24) "a" (help-echo "A")) ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) ((poly . [126 161 133 160 140 154 145 146 148 136 150 125 148 114 145 104 140 96 133 91 126 89 118 91 112 96 106 104 103 114 102 125 103 136 106 146 112 154 118 160]) "c" (help-echo "C")))) ;; All the result X coords are different, but Y coords are expected. 2. (setf (image-property image :rotation) 0) (setf (image-property image :flip) t) (should (equal (image--compute-map image) flipped-map)) ;; Return ((((circle (205 . 29) . 24) "a" (help-echo "A")) ((rect (169 . 101) 241 . 149) "b" (help-echo "B")) ((poly . [85 29 86 22 92 15 100 10 110 7 121 5 132 7 142 10 150 15 155 22 157 29 155 37 150 43 142 49 132 52 121 53 110 52 100 49 92 43 86 37]) "c" (help-echo "C"))) ;; Instead of (((circle (125 . 29) . 24) "a" (help-echo "A")) ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) ((poly . [5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 75 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 20 49 12 43 6 37]) "c" (help-echo "C")))) ;; All the result X coords are different, but Y coords are expected. On my laptop: (image-size (image--image-without-parameters image) t) => (228 . 246) Hope it will help to understand the reason. Thanks! ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-31 10:08 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-02 10:36 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-06 1:50 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 10+ messages in thread From: David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-02 10:36 UTC (permalink / raw) To: Joseph Turner; +Cc: 70093, Eli Zaretskii [...]> But these 2 tests fails: > > 1. > (setf (image-property image :scale) 1) > (setf (image-property image :rotation) 90) > (should (equal (image--compute-map image) > rotated-map)) > > ;; Return > ((((circle (199 . 41) . 24) "a" (help-echo "A")) > ((rect (79 . 5) 127 . 77) "b" (help-echo "B")) > ((poly . [199 161 206 160 213 154 218 146 221 136 223 125 221 114 218 104 213 96 206 91 199 89 191 91 185 96 179 104 176 114 175 125 176 136 179 146 185 154 191 160]) "c" (help-echo "C"))) > ;; Instead of > (((circle (126 . 41) . 24) "a" (help-echo "A")) > ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) > ((poly . [126 161 133 160 140 154 145 146 148 136 150 125 148 114 145 104 140 96 133 91 126 89 118 91 112 96 106 104 103 114 102 125 103 136 106 146 112 154 118 160]) "c" (help-echo "C")))) > ;; All the result X coords are different, but Y coords are expected. > > 2. > (setf (image-property image :rotation) 0) > (setf (image-property image :flip) t) > (should (equal (image--compute-map image) > flipped-map)) > > ;; Return > ((((circle (205 . 29) . 24) "a" (help-echo "A")) > ((rect (169 . 101) 241 . 149) "b" (help-echo "B")) > ((poly . [85 29 86 22 92 15 100 10 110 7 121 5 132 7 142 10 150 15 155 22 157 29 155 37 150 43 142 49 132 52 121 53 110 52 100 49 92 43 86 37]) "c" (help-echo "C"))) > ;; Instead of > (((circle (125 . 29) . 24) "a" (help-echo "A")) > ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) > ((poly . [5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 75 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 20 49 12 43 6 37]) "c" (help-echo "C")))) > ;; All the result X coords are different, but Y coords are expected. > > On my laptop: > > (image-size (image--image-without-parameters image) t) => (228 . 246) > > Hope it will help to understand the reason. [...] Hello, I am still trying to understand why the 2 tests above fails with my configuration. From the test `image--compute-map-and-original-map' I wrote the below equivalent code to be evaled in the *scratch* buffer, in order to observe and analyze the results interactively. The shapes are derived from the hot spots coordinates to ensure a strict visual correspondance between a shape and its hot spot. On my configuration, all the computed map from the different image variations are correct. You can test it by hovering the different produced colored shapes with the mouse, and observe the mouse pointer and help-echo changes. My conclusion at this point is that the values of `flipped-map' and `rotated-map' are not correct for my configuration, but I don't know why. If you can try the below code and observe the result on your configuration, maybe could we get a better understanding of what is happening for the 2 tests that fail? Thanks! ______________________________________________________________________________ (let* ((svg (svg-create "125pt" "116pt")) ;; 246px X 228px on my conf. (original-map '(((circle (41 . 29) . 24) "a" (help-echo "A")) ((rect (5 . 101) 77 . 149) "b" (help-echo "B")) ((poly . [ 161 29 160 22 154 15 146 10 136 7 125 5 114 7 104 10 96 15 91 22 89 29 91 37 96 43 104 49 114 52 125 53 136 52 146 49 154 43 160 37]) "c" (help-echo "C")))) (scaled-map '(((circle (82 . 58) . 48) "a" (help-echo "A")) ((rect (10 . 202) 154 . 298) "b" (help-echo "B")) ((poly . [ 322 58 320 44 308 30 292 20 272 14 250 10 228 14 208 20 192 30 182 44 178 58 182 74 192 86 208 98 228 104 250 106 272 104 292 98 308 86 320 74]) "c" (help-echo "C")))) (flipped-map '(((circle (125 . 29) . 24) "a" (help-echo "A")) ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) ((poly . [ 5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 75 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 20 49 12 43 6 37]) "c" (help-echo "C")))) (rotated-map '(((circle (126 . 41) . 24) "a" (help-echo "A")) ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) ((poly . [ 126 161 133 160 140 154 145 146 148 136 150 125 148 114 145 104 140 96 133 91 126 89 118 91 112 96 106 104 103 114 102 125 103 136 106 146 112 154 118 160]) "c" (help-echo "C")))) (scaled-rotated-flipped-map '(((circle (58 . 82) . 48) "a" (help-echo "A")) ((rect (202 . 10) 298 . 154) "b" (help-echo "B")) ((poly . [ 58 322 44 320 30 308 20 292 14 272 10 250 14 228 20 208 30 192 44 182 58 178 74 182 86 192 98 208 104 228 106 250 104 272 98 292 86 308 74 320]) "c" (help-echo "C")))) ) (svg-rectangle svg 5 101 (- 77 5) (- 149 101) :stroke-width 0 :fill "red") (svg-circle svg 41 29 24 :stroke-width 0 :fill "green") (svg-polyline svg '((161 . 29) (160 . 22) (154 . 15) (146 . 10) (136 . 7) (125 . 5) (114 . 7) (104 . 10) (96 . 15) (91 . 22) (89 . 29) (91 . 37) (96 . 43) (104 . 49) (114 . 52) (125 . 53) (136 . 52) (146 . 49) (154 . 43) (160 . 37)) :stroke-width 0 :fill "blue") (let ((image (svg-image svg :map scaled-rotated-flipped-map :scale 2 :rotation 90 :flip t))) ;; Test that `image--compute-original-map' correctly generates ;; original-map when creating an already transformed image. (insert (format "\n:flip %s :rotation %s :scale %s (equal :original-map original-map)=>%s" (image-property image :flip) (image-property image :rotation) (image-property image :scale) (equal (image-property image :original-map) original-map))) (print image) (insert-image image) (setf (image-property image :flip) nil) (setf (image-property image :rotation) 0) (setf (image-property image :scale) 2) (let ((map (image--compute-map image))) (insert (format "\n:flip %s :rotation %s :scale %s (equal map scaled-map)=>%s" (image-property image :flip) (image-property image :rotation) (image-property image :scale) (equal map scaled-map))) (setf (image-property image :map) map) (print image) ;; insert a new image in current buffer. (insert-image (copy-tree image t)) ) (setf (image-property image :scale) 1) (setf (image-property image :rotation) 90) (let ((map (image--compute-map image))) (insert (format "\n:flip %s :rotation %s :scale %s (equal map rotated-map)=>%s" (image-property image :flip) (image-property image :rotation) (image-property image :scale) (equal map rotated-map))) (setf (image-property image :map) map) (print image) ;; insert a new image in current buffer. (insert-image (copy-tree image t)) ) (setf (image-property image :rotation) 0) (setf (image-property image :flip) t) (let ((map (image--compute-map image))) (insert (format "\n:flip %s :rotation %s :scale %s (equal map flipped-map)=>%s" (image-property image :flip) (image-property image :rotation) (image-property image :scale) (equal map flipped-map))) (setf (image-property image :map) map) (print image) ;; insert a new image in current buffer. (insert-image (copy-tree image t)) ) (setf (image-property image :scale) 2) (setf (image-property image :rotation) 90) (let ((map (image--compute-map image))) (insert (format "\n:flip %s :rotation %s :scale %s (equal map scaled-rotated-flipped-map)=>%s" (image-property image :flip) (image-property image :rotation) (image-property image :scale) (equal map scaled-rotated-flipped-map))) (setf (image-property image :map) map) (print image) ;; insert a new image in current buffer. (insert-image (copy-tree image t)) ) )) ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-04-02 10:36 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-06 1:50 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-07 16:01 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 10+ messages in thread From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-06 1:50 UTC (permalink / raw) To: David Ponce; +Cc: 70093, Eli Zaretskii David Ponce <da_vid@orange.fr> writes: > [...]> But these 2 tests fails: >> 1. >> (setf (image-property image :scale) 1) >> (setf (image-property image :rotation) 90) >> (should (equal (image--compute-map image) >> rotated-map)) >> ;; Return >> ((((circle (199 . 41) . 24) "a" (help-echo "A")) >> ((rect (79 . 5) 127 . 77) "b" (help-echo "B")) >> ((poly . [199 161 206 160 213 154 218 146 221 136 223 125 221 >> 114 218 104 213 96 206 91 199 89 191 91 185 96 179 104 176 114 175 >> 125 176 136 179 146 185 154 191 160]) "c" (help-echo "C"))) >> ;; Instead of >> (((circle (126 . 41) . 24) "a" (help-echo "A")) >> ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) >> ((poly . [126 161 133 160 140 154 145 146 148 136 150 125 148 >> 114 145 104 140 96 133 91 126 89 118 91 112 96 106 104 103 114 102 >> 125 103 136 106 146 112 154 118 160]) "c" (help-echo "C")))) >> ;; All the result X coords are different, but Y coords are expected. >> 2. >> (setf (image-property image :rotation) 0) >> (setf (image-property image :flip) t) >> (should (equal (image--compute-map image) >> flipped-map)) >> ;; Return >> ((((circle (205 . 29) . 24) "a" (help-echo "A")) >> ((rect (169 . 101) 241 . 149) "b" (help-echo "B")) >> ((poly . [85 29 86 22 92 15 100 10 110 7 121 5 132 7 142 10 >> 150 15 155 22 157 29 155 37 150 43 142 49 132 52 121 53 110 52 100 >> 49 92 43 86 37]) "c" (help-echo "C"))) >> ;; Instead of >> (((circle (125 . 29) . 24) "a" (help-echo "A")) >> ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) >> ((poly . [5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 75 >> 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 20 49 12 43 6 37]) "c" >> (help-echo "C")))) >> ;; All the result X coords are different, but Y coords are expected. >> On my laptop: >> (image-size (image--image-without-parameters image) t) => (228 . >> 246) >> Hope it will help to understand the reason. > [...] > > Hello, > > I am still trying to understand why the 2 tests above fails with my configuration. > From the test `image--compute-map-and-original-map' I wrote the below equivalent > code to be evaled in the *scratch* buffer, in order to observe and analyze the > results interactively. The shapes are derived from the hot spots coordinates to > ensure a strict visual correspondance between a shape and its hot spot. > > On my configuration, all the computed map from the different image variations are > correct. You can test it by hovering the different produced colored shapes with > the mouse, and observe the mouse pointer and help-echo changes. > > My conclusion at this point is that the values of `flipped-map' and `rotated-map' > are not correct for my configuration, but I don't know why. > > If you can try the below code and observe the result on your configuration, maybe > could we get a better understanding of what is happening for the 2 tests that fail? > > Thanks! > > ______________________________________________________________________________ > > (let* ((svg (svg-create "125pt" "116pt")) ;; 246px X 228px on my conf. > (original-map > '(((circle (41 . 29) . 24) "a" (help-echo "A")) > ((rect (5 . 101) 77 . 149) "b" (help-echo "B")) > ((poly . [ 161 29 160 22 154 15 146 10 136 7 125 5 114 7 > 104 10 96 15 91 22 89 29 91 37 96 43 104 49 > 114 52 125 53 136 52 146 49 154 43 160 37]) > "c" (help-echo "C")))) > (scaled-map > '(((circle (82 . 58) . 48) "a" (help-echo "A")) > ((rect (10 . 202) 154 . 298) "b" (help-echo "B")) > ((poly . [ 322 58 320 44 308 30 292 20 272 14 250 10 228 14 > 208 20 192 30 182 44 178 58 182 74 192 86 208 98 > 228 104 250 106 272 104 292 98 308 86 320 74]) > "c" (help-echo "C")))) > (flipped-map > '(((circle (125 . 29) . 24) "a" (help-echo "A")) > ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) > ((poly . [ 5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 > 75 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 > 20 49 12 43 6 37]) > "c" (help-echo "C")))) > (rotated-map > '(((circle (126 . 41) . 24) "a" (help-echo "A")) > ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) > ((poly . [ 126 161 133 160 140 154 145 146 148 136 150 125 > 148 114 145 104 140 96 133 91 126 89 118 91 > 112 96 106 104 103 114 102 125 103 136 106 146 > 112 154 118 160]) > "c" (help-echo "C")))) > (scaled-rotated-flipped-map > '(((circle (58 . 82) . 48) "a" (help-echo "A")) > ((rect (202 . 10) 298 . 154) "b" (help-echo "B")) > ((poly . [ 58 322 44 320 30 308 20 292 14 272 10 250 14 228 > 20 208 30 192 44 182 58 178 74 182 86 192 98 208 > 104 228 106 250 104 272 98 292 86 308 74 320]) > "c" (help-echo "C")))) > ) > (svg-rectangle svg 5 101 (- 77 5) (- 149 101) > :stroke-width 0 :fill "red") > (svg-circle svg 41 29 24 > :stroke-width 0 :fill "green") > (svg-polyline svg '((161 . 29) (160 . 22) (154 . 15) (146 . 10) > (136 . 7) (125 . 5) (114 . 7) (104 . 10) > (96 . 15) (91 . 22) (89 . 29) (91 . 37) > (96 . 43) (104 . 49) (114 . 52) (125 . 53) > (136 . 52) (146 . 49) (154 . 43) (160 . 37)) > :stroke-width 0 :fill "blue") > (let ((image (svg-image svg :map scaled-rotated-flipped-map > :scale 2 :rotation 90 :flip t))) > ;; Test that `image--compute-original-map' correctly generates > ;; original-map when creating an already transformed image. > (insert > (format > "\n:flip %s :rotation %s :scale %s (equal :original-map original-map)=>%s" > (image-property image :flip) > (image-property image :rotation) > (image-property image :scale) > (equal (image-property image :original-map) > original-map))) > (print image) > (insert-image image) > (setf (image-property image :flip) nil) > (setf (image-property image :rotation) 0) > (setf (image-property image :scale) 2) > (let ((map (image--compute-map image))) > (insert > (format > "\n:flip %s :rotation %s :scale %s (equal map scaled-map)=>%s" > (image-property image :flip) > (image-property image :rotation) > (image-property image :scale) > (equal map scaled-map))) > (setf (image-property image :map) map) > (print image) > ;; insert a new image in current buffer. > (insert-image (copy-tree image t)) > ) > > (setf (image-property image :scale) 1) > (setf (image-property image :rotation) 90) > (let ((map (image--compute-map image))) > (insert > (format > "\n:flip %s :rotation %s :scale %s (equal map rotated-map)=>%s" > (image-property image :flip) > (image-property image :rotation) > (image-property image :scale) > (equal map rotated-map))) > (setf (image-property image :map) map) > (print image) > ;; insert a new image in current buffer. > (insert-image (copy-tree image t)) > ) > > (setf (image-property image :rotation) 0) > (setf (image-property image :flip) t) > (let ((map (image--compute-map image))) > (insert > (format > "\n:flip %s :rotation %s :scale %s (equal map flipped-map)=>%s" > (image-property image :flip) > (image-property image :rotation) > (image-property image :scale) > (equal map flipped-map))) > (setf (image-property image :map) map) > (print image) > ;; insert a new image in current buffer. > (insert-image (copy-tree image t)) > ) > > (setf (image-property image :scale) 2) > (setf (image-property image :rotation) 90) > (let ((map (image--compute-map image))) > (insert > (format > "\n:flip %s :rotation %s :scale %s (equal map scaled-rotated-flipped-map)=>%s" > (image-property image :flip) > (image-property image :rotation) > (image-property image :scale) > (equal map scaled-rotated-flipped-map))) > (setf (image-property image :map) map) > (print image) > ;; insert a new image in current buffer. > (insert-image (copy-tree image t)) > ) > )) When I evaluate this block and hover over the various shapes, the help-echo pop-ups appear at the correct boundaries. Are you able to reproduce this issue with my patch with emacs -Q? Without the patch? Thank you! Joseph ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: *** SPAM *** bug#70093: Remove unnecessary `image-tests--map-equal' 2024-04-06 1:50 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-07 16:01 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 0 replies; 10+ messages in thread From: David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-07 16:01 UTC (permalink / raw) To: Joseph Turner; +Cc: 70093, Eli Zaretskii On 06/04/2024 03:50, Joseph Turner wrote: > > David Ponce <da_vid@orange.fr> writes: > >> [...]> But these 2 tests fails: >>> 1. >>> (setf (image-property image :scale) 1) >>> (setf (image-property image :rotation) 90) >>> (should (equal (image--compute-map image) >>> rotated-map)) >>> ;; Return >>> ((((circle (199 . 41) . 24) "a" (help-echo "A")) >>> ((rect (79 . 5) 127 . 77) "b" (help-echo "B")) >>> ((poly . [199 161 206 160 213 154 218 146 221 136 223 125 221 >>> 114 218 104 213 96 206 91 199 89 191 91 185 96 179 104 176 114 175 >>> 125 176 136 179 146 185 154 191 160]) "c" (help-echo "C"))) >>> ;; Instead of >>> (((circle (126 . 41) . 24) "a" (help-echo "A")) >>> ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) >>> ((poly . [126 161 133 160 140 154 145 146 148 136 150 125 148 >>> 114 145 104 140 96 133 91 126 89 118 91 112 96 106 104 103 114 102 >>> 125 103 136 106 146 112 154 118 160]) "c" (help-echo "C")))) >>> ;; All the result X coords are different, but Y coords are expected. >>> 2. >>> (setf (image-property image :rotation) 0) >>> (setf (image-property image :flip) t) >>> (should (equal (image--compute-map image) >>> flipped-map)) >>> ;; Return >>> ((((circle (205 . 29) . 24) "a" (help-echo "A")) >>> ((rect (169 . 101) 241 . 149) "b" (help-echo "B")) >>> ((poly . [85 29 86 22 92 15 100 10 110 7 121 5 132 7 142 10 >>> 150 15 155 22 157 29 155 37 150 43 142 49 132 52 121 53 110 52 100 >>> 49 92 43 86 37]) "c" (help-echo "C"))) >>> ;; Instead of >>> (((circle (125 . 29) . 24) "a" (help-echo "A")) >>> ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) >>> ((poly . [5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 75 >>> 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 20 49 12 43 6 37]) "c" >>> (help-echo "C")))) >>> ;; All the result X coords are different, but Y coords are expected. >>> On my laptop: >>> (image-size (image--image-without-parameters image) t) => (228 . >>> 246) >>> Hope it will help to understand the reason. >> [...] >> >> Hello, >> >> I am still trying to understand why the 2 tests above fails with my configuration. >> From the test `image--compute-map-and-original-map' I wrote the below equivalent >> code to be evaled in the *scratch* buffer, in order to observe and analyze the >> results interactively. The shapes are derived from the hot spots coordinates to >> ensure a strict visual correspondance between a shape and its hot spot. >> >> On my configuration, all the computed map from the different image variations are >> correct. You can test it by hovering the different produced colored shapes with >> the mouse, and observe the mouse pointer and help-echo changes. >> >> My conclusion at this point is that the values of `flipped-map' and `rotated-map' >> are not correct for my configuration, but I don't know why. >> >> If you can try the below code and observe the result on your configuration, maybe >> could we get a better understanding of what is happening for the 2 tests that fail? >> >> Thanks! >> >> ______________________________________________________________________________ >> >> (let* ((svg (svg-create "125pt" "116pt")) ;; 246px X 228px on my conf. >> (original-map >> '(((circle (41 . 29) . 24) "a" (help-echo "A")) >> ((rect (5 . 101) 77 . 149) "b" (help-echo "B")) >> ((poly . [ 161 29 160 22 154 15 146 10 136 7 125 5 114 7 >> 104 10 96 15 91 22 89 29 91 37 96 43 104 49 >> 114 52 125 53 136 52 146 49 154 43 160 37]) >> "c" (help-echo "C")))) >> (scaled-map >> '(((circle (82 . 58) . 48) "a" (help-echo "A")) >> ((rect (10 . 202) 154 . 298) "b" (help-echo "B")) >> ((poly . [ 322 58 320 44 308 30 292 20 272 14 250 10 228 14 >> 208 20 192 30 182 44 178 58 182 74 192 86 208 98 >> 228 104 250 106 272 104 292 98 308 86 320 74]) >> "c" (help-echo "C")))) >> (flipped-map >> '(((circle (125 . 29) . 24) "a" (help-echo "A")) >> ((rect (89 . 101) 161 . 149) "b" (help-echo "B")) >> ((poly . [ 5 29 6 22 12 15 20 10 30 7 41 5 52 7 62 10 70 15 >> 75 22 77 29 75 37 70 43 62 49 52 52 41 53 30 52 >> 20 49 12 43 6 37]) >> "c" (help-echo "C")))) >> (rotated-map >> '(((circle (126 . 41) . 24) "a" (help-echo "A")) >> ((rect (6 . 5) 54 . 77) "b" (help-echo "B")) >> ((poly . [ 126 161 133 160 140 154 145 146 148 136 150 125 >> 148 114 145 104 140 96 133 91 126 89 118 91 >> 112 96 106 104 103 114 102 125 103 136 106 146 >> 112 154 118 160]) >> "c" (help-echo "C")))) >> (scaled-rotated-flipped-map >> '(((circle (58 . 82) . 48) "a" (help-echo "A")) >> ((rect (202 . 10) 298 . 154) "b" (help-echo "B")) >> ((poly . [ 58 322 44 320 30 308 20 292 14 272 10 250 14 228 >> 20 208 30 192 44 182 58 178 74 182 86 192 98 208 >> 104 228 106 250 104 272 98 292 86 308 74 320]) >> "c" (help-echo "C")))) >> ) >> (svg-rectangle svg 5 101 (- 77 5) (- 149 101) >> :stroke-width 0 :fill "red") >> (svg-circle svg 41 29 24 >> :stroke-width 0 :fill "green") >> (svg-polyline svg '((161 . 29) (160 . 22) (154 . 15) (146 . 10) >> (136 . 7) (125 . 5) (114 . 7) (104 . 10) >> (96 . 15) (91 . 22) (89 . 29) (91 . 37) >> (96 . 43) (104 . 49) (114 . 52) (125 . 53) >> (136 . 52) (146 . 49) (154 . 43) (160 . 37)) >> :stroke-width 0 :fill "blue") >> (let ((image (svg-image svg :map scaled-rotated-flipped-map >> :scale 2 :rotation 90 :flip t))) >> ;; Test that `image--compute-original-map' correctly generates >> ;; original-map when creating an already transformed image. >> (insert >> (format >> "\n:flip %s :rotation %s :scale %s (equal :original-map original-map)=>%s" >> (image-property image :flip) >> (image-property image :rotation) >> (image-property image :scale) >> (equal (image-property image :original-map) >> original-map))) >> (print image) >> (insert-image image) >> (setf (image-property image :flip) nil) >> (setf (image-property image :rotation) 0) >> (setf (image-property image :scale) 2) >> (let ((map (image--compute-map image))) >> (insert >> (format >> "\n:flip %s :rotation %s :scale %s (equal map scaled-map)=>%s" >> (image-property image :flip) >> (image-property image :rotation) >> (image-property image :scale) >> (equal map scaled-map))) >> (setf (image-property image :map) map) >> (print image) >> ;; insert a new image in current buffer. >> (insert-image (copy-tree image t)) >> ) >> >> (setf (image-property image :scale) 1) >> (setf (image-property image :rotation) 90) >> (let ((map (image--compute-map image))) >> (insert >> (format >> "\n:flip %s :rotation %s :scale %s (equal map rotated-map)=>%s" >> (image-property image :flip) >> (image-property image :rotation) >> (image-property image :scale) >> (equal map rotated-map))) >> (setf (image-property image :map) map) >> (print image) >> ;; insert a new image in current buffer. >> (insert-image (copy-tree image t)) >> ) >> >> (setf (image-property image :rotation) 0) >> (setf (image-property image :flip) t) >> (let ((map (image--compute-map image))) >> (insert >> (format >> "\n:flip %s :rotation %s :scale %s (equal map flipped-map)=>%s" >> (image-property image :flip) >> (image-property image :rotation) >> (image-property image :scale) >> (equal map flipped-map))) >> (setf (image-property image :map) map) >> (print image) >> ;; insert a new image in current buffer. >> (insert-image (copy-tree image t)) >> ) >> >> (setf (image-property image :scale) 2) >> (setf (image-property image :rotation) 90) >> (let ((map (image--compute-map image))) >> (insert >> (format >> "\n:flip %s :rotation %s :scale %s (equal map scaled-rotated-flipped-map)=>%s" >> (image-property image :flip) >> (image-property image :rotation) >> (image-property image :scale) >> (equal map scaled-rotated-flipped-map))) >> (setf (image-property image :map) map) >> (print image) >> ;; insert a new image in current buffer. >> (insert-image (copy-tree image t)) >> ) >> )) > > When I evaluate this block and hover over the various shapes, the > help-echo pop-ups appear at the correct boundaries. > > Are you able to reproduce this issue with my patch with emacs -Q? > > Without the patch? > > Thank you! > > Joseph Hello, On my laptop, running emacs -Q, the tests give the same results with and without the patch: Test with patch without patch ------------------------------------------------------------- image-create-image-with-map OK OK image-transform-map OK OK image--compute-map-and-original-map Fail (1) Fail (2) (1) Test ‘image--compute-map’ and ‘image--compute-original-map’. (ert-test-failed ((should (equal (image--compute-map image) rotated-map)) :form (equal (((circle ... . 24) "a" (help-echo "A")) ((rect ... 127 . 77) "b" (help-echo "B")) ((poly . [199 161 206 160 213 154 218 146 221 136 ...]) "c" (help-echo "C"))) (((circle ... . 24) "a" (help-echo "A")) ((rect ... 54 . 77) "b" (help-echo "B")) ((poly . [126 161 133 160 140 154 145 146 148 136 ...]) "c" (help-echo "C")))) :value nil :explanation (list-elt 0 (list-elt 0 (cdr (car ...)))))) (2) Test ‘image--compute-map’ and ‘image--compute-original-map’. (ert-test-failed ((should (image-tests--map-equal (image--compute-map image) rotated-map)) :form (image-tests--map-equal (((circle ... . 24) "a" (help-echo "A")) ((rect ... 127 . 77) "b" (help-echo "B")) ((poly . [199 161 206 160 213 154 218 146 221 136 ...]) "c" (help-echo "C"))) (((circle ... . 24) "a" (help-echo "A")) ((rect ... 54 . 77) "b" (help-echo "B")) ((poly . [126 161 133 160 140 154 145 146 148 136 ...]) "c" (help-echo "C")))) :value nil)) Thanks! ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-30 19:44 bug#70093: Remove unnecessary `image-tests--map-equal' Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-30 22:04 ` bug#70093: *** SPAM *** " David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 5:10 ` Eli Zaretskii 2024-03-31 5:32 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2024-03-31 5:10 UTC (permalink / raw) To: Joseph Turner; +Cc: 70093, da_vid > Cc: Eli Zaretskii <eliz@gnu.org>, David Ponce <da_vid@orange.fr> > From: Joseph Turner <joseph@breatheoutbreathe.in> > Date: Sat, 30 Mar 2024 12:44:14 -0700 > > With the resolution of bug#69992, it may be possible to remove the > `image-tests--map-equal' equality predicate from lisp/image-tests.el. Why is it a good idea to remove tests? If the test tests some of our code which should work as the test assumes, we should not remove it. > Eli and David, would you please apply the attached patch and then run > the tests to see if we still need to allow for tolerances in > `image--compute-map-and-original-map'? ENOPATCH ^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-31 5:10 ` Eli Zaretskii @ 2024-03-31 5:32 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 7:33 ` Eli Zaretskii 0 siblings, 1 reply; 10+ messages in thread From: Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 5:32 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 70093, da_vid [-- Attachment #1: Type: text/plain, Size: 878 bytes --] Eli Zaretskii <eliz@gnu.org> writes: >> Cc: Eli Zaretskii <eliz@gnu.org>, David Ponce <da_vid@orange.fr> >> From: Joseph Turner <joseph@breatheoutbreathe.in> >> Date: Sat, 30 Mar 2024 12:44:14 -0700 >> >> With the resolution of bug#69992, it may be possible to remove the >> `image-tests--map-equal' equality predicate from lisp/image-tests.el. > > Why is it a good idea to remove tests? If the test tests some of our > code which should work as the test assumes, we should not remove it. Not removing tests, but rather making the tests more strict (if possible). >> Eli and David, would you please apply the attached patch and then run >> the tests to see if we still need to allow for tolerances in >> `image--compute-map-and-original-map'? > > ENOPATCH Sorry about that. Please check if the tests still pass on your machine when we use `equal' to compare image maps. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Compare-image-maps-with-equal-in-tests.patch --] [-- Type: text/x-diff, Size: 4386 bytes --] From e85fd88a2943fa95d2d7eea3a542308adaa81582 Mon Sep 17 00:00:00 2001 From: Joseph Turner <joseph@breatheoutbreathe.in> Date: Sat, 30 Mar 2024 12:38:52 -0700 Subject: [PATCH] Compare image maps with `equal' in tests With the fixes to image map transformation introduced in cc212ea314d, the tests should now exactly predict calculated image maps. * test/lisp/image-tests.el (image-tests--map-equal): Remove function. (image--compute-map-and-original-map): Use equal to compare image maps. --- test/lisp/image-tests.el | 46 +++++----------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el index 020781eff50..41b87b8d337 100644 --- a/test/lisp/image-tests.el +++ b/test/lisp/image-tests.el @@ -178,37 +178,6 @@ image-create-image-with-map (got-original-map (image-property image :original-map))) (should (equal got-original-map original-map-other))))) -(defun image-tests--map-equal (a b &optional tolerance) - "Return t if maps A and B have the same coordinates within TOLERANCE. -Since image sizes calculations vary on different machines, this function -allows for each image map coordinate in A to be within TOLERANCE to the -corresponding coordinate in B. When nil, TOLERANCE defaults to 5." - (unless tolerance (setq tolerance 5)) - (catch 'different - (cl-labels ((check-tolerance - (coord-a coord-b) - (unless (>= tolerance (abs (- coord-a coord-b))) - (throw 'different nil)))) - (dotimes (i (length a)) - (pcase-let ((`((,type-a . ,coords-a) ,_id ,_plist) (nth i a)) - (`((,type-b . ,coords-b) ,_id ,_plist) (nth i b))) - (unless (eq type-a type-b) - (throw 'different nil)) - (pcase-exhaustive type-a - ('rect - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cadr coords-a) (cadr coords-b)) - (check-tolerance (cddr coords-a) (cddr coords-b))) - ('circle - (check-tolerance (caar coords-a) (caar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b)) - (check-tolerance (cdar coords-a) (cdar coords-b))) - ('poly - (dotimes (i (length coords-a)) - (check-tolerance (aref coords-a i) (aref coords-b i)))))))) - t)) - (ert-deftest image--compute-map-and-original-map () "Test `image--compute-map' and `image--compute-original-map'." (skip-unless (display-images-p)) @@ -237,25 +206,20 @@ image--compute-map-and-original-map :scale 2 :rotation 90 :flip t))) ;; Test that `image--compute-original-map' correctly generates ;; original-map when creating an already transformed image. - (should (image-tests--map-equal (image-property image :original-map) - original-map)) + (should (equal (image-property image :original-map) original-map)) (setf (image-property image :flip) nil) (setf (image-property image :rotation) 0) (setf (image-property image :scale) 2) - (should (image-tests--map-equal (image--compute-map image) - scaled-map)) + (should (equal (image--compute-map image) scaled-map)) (setf (image-property image :scale) 1) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - rotated-map)) + (should (equal (image--compute-map image) rotated-map)) (setf (image-property image :rotation) 0) (setf (image-property image :flip) t) - (should (image-tests--map-equal (image--compute-map image) - flipped-map)) + (should (equal (image--compute-map image) flipped-map)) (setf (image-property image :scale) 2) (setf (image-property image :rotation) 90) - (should (image-tests--map-equal (image--compute-map image) - scaled-rotated-flipped-map)) + (should (equal (image--compute-map image) scaled-rotated-flipped-map)) ;; Uncomment to test manually by interactively transforming the ;; image and checking the map boundaries by hovering them. -- 2.41.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#70093: Remove unnecessary `image-tests--map-equal' 2024-03-31 5:32 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-31 7:33 ` Eli Zaretskii 0 siblings, 0 replies; 10+ messages in thread From: Eli Zaretskii @ 2024-03-31 7:33 UTC (permalink / raw) To: Joseph Turner; +Cc: 70093, da_vid > From: Joseph Turner <joseph@breatheoutbreathe.in> > Cc: 70093@debbugs.gnu.org, da_vid@orange.fr > Date: Sat, 30 Mar 2024 22:32:26 -0700 > > Eli Zaretskii <eliz@gnu.org> writes: > > >> Cc: Eli Zaretskii <eliz@gnu.org>, David Ponce <da_vid@orange.fr> > >> From: Joseph Turner <joseph@breatheoutbreathe.in> > >> Date: Sat, 30 Mar 2024 12:44:14 -0700 > >> > >> With the resolution of bug#69992, it may be possible to remove the > >> `image-tests--map-equal' equality predicate from lisp/image-tests.el. > > > > Why is it a good idea to remove tests? If the test tests some of our > > code which should work as the test assumes, we should not remove it. > > Not removing tests, but rather making the tests more strict (if possible). > > >> Eli and David, would you please apply the attached patch and then run > >> the tests to see if we still need to allow for tolerances in > >> `image--compute-map-and-original-map'? > > > > ENOPATCH > > Sorry about that. Please check if the tests still pass on your machine > when we use `equal' to compare image maps. They pass, thanks. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-04-07 16:01 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-03-30 19:44 bug#70093: Remove unnecessary `image-tests--map-equal' Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-30 22:04 ` bug#70093: *** SPAM *** " David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 7:37 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 10:08 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-02 10:36 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-06 1:50 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-04-07 16:01 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 5:10 ` Eli Zaretskii 2024-03-31 5:32 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-03-31 7:33 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).