GNU bug report logs - #70093
Remove unnecessary `image-tests--map-equal'

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> breatheoutbreathe.in>

Date: Sat, 30 Mar 2024 19:50:01 UTC

Severity: wishlist

Tags: moreinfo, patch

To reply to this bug, email your comments to 70093 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to eliz <at> gnu.org, da_vid <at> orange.fr, bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sat, 30 Mar 2024 19:50:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
New bug report received and forwarded. Copy sent to eliz <at> gnu.org, da_vid <at> orange.fr, bug-gnu-emacs <at> gnu.org. (Sat, 30 Mar 2024 19:50:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Emacs Bugs Mailing List <bug-gnu-emacs <at> gnu.org>
Subject: Remove unnecessary `image-tests--map-equal'
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.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sat, 30 Mar 2024 22:05:01 GMT) Full text and rfc822 format available.

Message #8 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>, 70093 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Sat, 30 Mar 2024 23:04:28 +0100
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!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 31 Mar 2024 05:11:01 GMT) Full text and rfc822 format available.

Message #11 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sun, 31 Mar 2024 08:10:07 +0300
> Cc: Eli Zaretskii <eliz <at> gnu.org>, David Ponce <da_vid <at> orange.fr>
> From: Joseph Turner <joseph <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 31 Mar 2024 05:35:01 GMT) Full text and rfc822 format available.

Message #14 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sat, 30 Mar 2024 22:32:26 -0700
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: Eli Zaretskii <eliz <at> gnu.org>, David Ponce <da_vid <at> orange.fr>
>> From: Joseph Turner <joseph <at> 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.

[0001-Compare-image-maps-with-equal-in-tests.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 31 Mar 2024 07:35:01 GMT) Full text and rfc822 format available.

Message #17 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sun, 31 Mar 2024 10:33:53 +0300
> From: Joseph Turner <joseph <at> breatheoutbreathe.in>
> Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr
> Date: Sat, 30 Mar 2024 22:32:26 -0700
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Cc: Eli Zaretskii <eliz <at> gnu.org>, David Ponce <da_vid <at> orange.fr>
> >> From: Joseph Turner <joseph <at> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 31 Mar 2024 07:44:01 GMT) Full text and rfc822 format available.

Message #20 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: David Ponce <da_vid <at> orange.fr>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Sun, 31 Mar 2024 00:37:35 -0700
[Message part 1 (text/plain, inline)]
David Ponce <da_vid <at> 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

[0001-Compare-image-maps-with-equal-in-tests.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 31 Mar 2024 10:09:01 GMT) Full text and rfc822 format available.

Message #23 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Sun, 31 Mar 2024 12:08:27 +0200
On 31/03/2024 09:37, Joseph Turner wrote:
> 
> David Ponce <da_vid <at> 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!






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Tue, 02 Apr 2024 10:37:02 GMT) Full text and rfc822 format available.

Message #26 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Tue, 2 Apr 2024 12:36:31 +0200
[...]> 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))
      )
    ))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sat, 06 Apr 2024 01:53:01 GMT) Full text and rfc822 format available.

Message #29 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: David Ponce <da_vid <at> orange.fr>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Fri, 05 Apr 2024 18:50:12 -0700
David Ponce <da_vid <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 07 Apr 2024 16:02:02 GMT) Full text and rfc822 format available.

Message #32 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: *** SPAM *** bug#70093: Remove unnecessary
 `image-tests--map-equal'
Date: Sun, 7 Apr 2024 18:01:13 +0200
On 06/04/2024 03:50, Joseph Turner wrote:
> 
> David Ponce <da_vid <at> 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!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sat, 01 Mar 2025 03:00:01 GMT) Full text and rfc822 format available.

Message #35 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Fri, 28 Feb 2025 18:59:30 -0800
Joseph Turner <joseph <at> breatheoutbreathe.in> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Cc: Eli Zaretskii <eliz <at> gnu.org>, David Ponce <da_vid <at> orange.fr>
>>> From: Joseph Turner <joseph <at> 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.

Was this patch installed?  Should it be?

Thanks.




Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 01 Mar 2025 03:00:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 01 Mar 2025 03:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sat, 01 Mar 2025 09:33:02 GMT) Full text and rfc822 format available.

Message #42 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr, joseph <at> breatheoutbreathe.in
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sat, 01 Mar 2025 11:31:39 +0200
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Fri, 28 Feb 2025 18:59:30 -0800
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr
> 
> Joseph Turner <joseph <at> breatheoutbreathe.in> writes:
> 
> > Eli Zaretskii <eliz <at> gnu.org> writes:
> >
> >>> Cc: Eli Zaretskii <eliz <at> gnu.org>, David Ponce <da_vid <at> orange.fr>
> >>> From: Joseph Turner <joseph <at> 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.
> 
> Was this patch installed?

No.

> Should it be?

I'm not sure, and I said so in the discussion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 02 Mar 2025 01:06:02 GMT) Full text and rfc822 format available.

Message #45 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr, joseph <at> breatheoutbreathe.in
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sat, 1 Mar 2025 17:05:20 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Was this patch installed?
>
> No.
>
>> Should it be?
>
> I'm not sure, and I said so in the discussion.

Now I see that there were some issues with the patch reported by David
Ponce, but I see no followup to his last message from Joseph.

Joseph, do you still consider this patch a good idea?




Added tag(s) moreinfo. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 02 Mar 2025 01:06:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 02 Mar 2025 04:54:02 GMT) Full text and rfc822 format available.

Message #50 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 70093 <at> debbugs.gnu.org, da_vid <at> orange.fr, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sat, 01 Mar 2025 20:52:56 -0800
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Was this patch installed?
>>
>> No.
>>
>>> Should it be?
>>
>> I'm not sure, and I said so in the discussion.
>
> Now I see that there were some issues with the patch reported by David
> Ponce, but I see no followup to his last message from Joseph.
>
> Joseph, do you still consider this patch a good idea?

Yes.  The stricter tests which I propose in the patch all pass on my
machine.  David, are you able to reproduce this issue with emacs -Q?

Thank you!

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 02 Mar 2025 10:57:01 GMT) Full text and rfc822 format available.

Message #53 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>,
 Stefan Kangas <stefankangas <at> gmail.com>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sun, 2 Mar 2025 11:56:23 +0100
On 2025-03-02 05:52, Joseph Turner wrote:
> Stefan Kangas <stefankangas <at> gmail.com> writes:
> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> Was this patch installed?
>>>
>>> No.
>>>
>>>> Should it be?
>>>
>>> I'm not sure, and I said so in the discussion.
>>
>> Now I see that there were some issues with the patch reported by David
>> Ponce, but I see no followup to his last message from Joseph.
>>
>> Joseph, do you still consider this patch a good idea?
> 
> Yes.  The stricter tests which I propose in the patch all pass on my
> machine.  David, are you able to reproduce this issue with emacs -Q?
> 
> Thank you!
> 
> Joseph

Here here are the results of running image map tests with emacs -Q

Selector: image-create-image-with-map
Passed:  1
Failed:  0
Skipped: 0
Total:   1/1

Selector: image-transform-map
Passed:  1
Failed:  0
Skipped: 0
Total:   1/1

Selector: image--compute-map-and-original-map
Passed:  0
Failed:  1 (1 unexpected)
Skipped: 0
Total:   1/1

F image--compute-map-and-original-map
    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))

No change since my previous testing.  It is still a mystery for me why
this test consistently fails for me and not for others.

Additional info:

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.0) of 2025-03-02
Repository revision: 2ba2157a610346b56507a8ed7c771f6f57263ee6
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 40 (KDE Plasma)

Configured using:
 'configure --with-native-compilation=no
 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB

Important settings:
  value of $LC_TIME: fr_FR.utf8
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils svg dom xml
thingatpt help-fns radix-tree cl-print cl-seq time-date subr-x cl-extra
pcase cl-macs ert map byte-opt gv bytecomp byte-compile pp ewoc debug
backtrace help-mode find-func cl-loaddefs cl-lib rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames emacs)

Memory information:
((conses 16 98826 9315) (symbols 48 8089 0) (strings 32 20424 2237)
 (string-bytes 1 550226) (vectors 16 14780)
 (vector-slots 8 157482 10220) (floats 8 50 1125)
 (intervals 56 3377 14) (buffers 992 14))


 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Sun, 02 Mar 2025 19:38:01 GMT) Full text and rfc822 format available.

Message #56 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: David Ponce <da_vid <at> orange.fr>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Sun, 02 Mar 2025 11:37:17 -0800
David Ponce <da_vid <at> orange.fr> writes:

> On 2025-03-02 05:52, Joseph Turner wrote:
>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>
>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>
>>>>> Was this patch installed?
>>>>
>>>> No.
>>>>
>>>>> Should it be?
>>>>
>>>> I'm not sure, and I said so in the discussion.
>>>
>>> Now I see that there were some issues with the patch reported by David
>>> Ponce, but I see no followup to his last message from Joseph.
>>>
>>> Joseph, do you still consider this patch a good idea?
>> Yes.  The stricter tests which I propose in the patch all pass on my
>> machine.  David, are you able to reproduce this issue with emacs -Q?
>> Thank you!
>> Joseph
>
> Here here are the results of running image map tests with emacs -Q

[...]

Thank you!  In this case, I suppose we should not apply this patch until
we figure out why the generated image map varies on some machines.

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Mon, 03 Mar 2025 15:01:02 GMT) Full text and rfc822 format available.

Message #59 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Mon, 3 Mar 2025 16:00:37 +0100
On 2025-03-02 20:37, Joseph Turner wrote:
> David Ponce <da_vid <at> orange.fr> writes:
> 
>> On 2025-03-02 05:52, Joseph Turner wrote:
>>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>>
>>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>>
>>>>>> Was this patch installed?
>>>>>
>>>>> No.
>>>>>
>>>>>> Should it be?
>>>>>
>>>>> I'm not sure, and I said so in the discussion.
>>>>
>>>> Now I see that there were some issues with the patch reported by David
>>>> Ponce, but I see no followup to his last message from Joseph.
>>>>
>>>> Joseph, do you still consider this patch a good idea?
>>> Yes.  The stricter tests which I propose in the patch all pass on my
>>> machine.  David, are you able to reproduce this issue with emacs -Q?
>>> Thank you!
>>> Joseph
>>
>> Here here are the results of running image map tests with emacs -Q
> 
> [...]
> 
> Thank you!  In this case, I suppose we should not apply this patch until
> we figure out why the generated image map varies on some machines.
> 
> Joseph

Hello,

I am still trying to understand why the the rotated-map and
flipped-map cases in `image--compute-map-and-original-map' test fails
for me.

I wrote the function `svg-draw-image-map' (see below) to draw in SVG
an image map, in order to help visualize image maps (maybe a such
function could be useful to "kind of debug" image maps?).

I also adapted the code from `image--compute-map-and-original-map'
to be evaluated in the *scratch* buffer, in order to show computed
and reference image maps.

And, for me this reveals that the reference maps `flipped-map' and
`rotated-map' are not as expected, contrary to the corresponding
result of `image--compute-map' which looks as expected.  This explains
why these test case are failing for me.  But I still can't explain
why the same test cases passes for you?

Maybe could you try the code below to see if it help clarify this?

Thanks!

;; Please eval in the *scratch* buffer:

(require 'svg)

;;; Drawing image map.
;;
(defun svg-draw-image-map (svg map color)
  "In SVG, draw image MAP with COLOR."
  (pcase-dolist (`(,area _ _) map)
    (pcase-exhaustive area
      ;; Rectangle hot spot.
      (`(rect . ((,x0 . ,y0) . (,x1 . ,y1)))
       (svg-rectangle svg x0 y0 (- x1 x0) (- y1 y0)
                      :stroke-width 1
                      :stroke color
                      :fill "transparent")
       )
      ;; Circle hot spot.
      (`(circle . ((,x . ,y) . ,r))
       (svg-circle svg x y r
                   :stroke-width 1
                   :stroke color
                   :fill "transparent")
       )
      ;; Polygon hot spot.
      (`(poly . ,coords)
       (let ((i 0) (n (length coords)) points)
         ;; Convert the vector of coords [x0 y0 ...] to a list of
         ;; points ((x0 . y0) ...)
         (while (< i n)
           (let ((x (aref coords i))
                 (y (aref coords (setq i (1+ i)))))
             (push (cons x y) points))
           (setq i (1+ i)))
         (svg-polyline svg points
                       :stroke-width 1
                       :stroke color
                       :fill "transparent"))
       ))))

(let* ((svg-string "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><svg width=\"125pt\" height=\"116pt\" viewBox=\"0.00 0.00 125.00 116.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g transform=\"scale(1 1) rotate(0) translate(4 112)\"><polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-112 121,-112 121,4 -4,4\"/><a xlink:href=\"a\"><ellipse fill=\"none\" stroke=\"black\" cx=\"27\" cy=\"-90\" rx=\"18\" ry=\"18\"/><text text-anchor=\"middle\" x=\"27\" y=\"-86.3\" fill=\"#000000\">A</text></a><a xlink:href=\"b\"><polygon fill=\"none\" stroke=\"black\" points=\"54,-36 0,-36 0,0 54,0 54,-36\"/><text text-anchor=\"middle\" x=\"27\" y=\"-14.3\" fill=\"#000000\">B</text></a><a xlink:href=\"c\"><ellipse fill=\"none\" stroke=\"black\" cx=\"90\" cy=\"-90\" rx=\"27\" ry=\"18\"/><text text-anchor=\"middle\" x=\"90\" y=\"-86.3\" fill=\"#000000\">C</text></a></g></svg>")
       (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"))))
       (image (create-image svg-string 'svg t :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.
  '(should (image-tests--map-equal (image-property image :original-map)
                                   original-map))
  (or (equal (image-property image :original-map) original-map)
      (error "original-map not as expected"))

  (insert "\nScaled map computed(red) ref(grey)\n")
  (setf (image-property image :flip) nil)
  (setf (image-property image :rotation) 0)
  (setf (image-property image :scale) 2)
  (pcase-let* ((`(,w . ,h) (image-size image t))
               (svg (svg-create w h)))
    (svg-draw-image-map svg (image--compute-map image) "red")
    (svg-draw-image-map svg scaled-map "grey")
    (insert-image (svg-image svg :scale 1)))
  '(should (image-tests--map-equal (image--compute-map image)
                                   scaled-map))

  (insert "\nRotated map computed(red) ref(grey)\n")
  (setf (image-property image :scale) 1)
  (setf (image-property image :rotation) 90)
  (pcase-let* ((`(,w . ,h) (image-size image t))
               (svg (svg-create w h)))
    (svg-draw-image-map svg (image--compute-map image) "red")
    (svg-draw-image-map svg rotated-map "grey")
    (insert-image (svg-image svg :scale 1)))
  '(should (image-tests--map-equal (image--compute-map image)
                                   rotated-map))

  (insert "\nFlipped map computed(red) ref(grey)\n")
  (setf (image-property image :rotation) 0)
  (setf (image-property image :flip) t)
  (pcase-let* ((`(,w . ,h) (image-size image t))
               (svg (svg-create w h)))
    (svg-draw-image-map svg (image--compute-map image) "red")
    (svg-draw-image-map svg rotated-map "grey")
    (insert-image (svg-image svg :scale 1)))
  '(should (image-tests--map-equal (image--compute-map image)
                                   flipped-map))
    
  (insert "\nScaled Rotated Flipped map computed(red) ref(grey)\n")
  (setf (image-property image :scale) 2)
  (setf (image-property image :rotation) 90)
  (pcase-let* ((`(,w . ,h) (image-size image t))
               (svg (svg-create w h)))
    (svg-draw-image-map svg (image--compute-map image) "red")
    (svg-draw-image-map svg scaled-rotated-flipped-map "grey")
    (insert-image (svg-image svg :scale 1)))
  '(should (image-tests--map-equal (image--compute-map image)
                                   scaled-rotated-flipped-map))

  (insert "\n")
  )





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70093; Package emacs. (Mon, 03 Mar 2025 17:11:01 GMT) Full text and rfc822 format available.

Message #62 received at 70093 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: David Ponce <da_vid <at> orange.fr>
Cc: 70093 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#70093: Remove unnecessary `image-tests--map-equal'
Date: Mon, 03 Mar 2025 09:09:50 -0800
David Ponce <da_vid <at> orange.fr> writes:

> On 2025-03-02 20:37, Joseph Turner wrote:
>> David Ponce <da_vid <at> orange.fr> writes:
>>
>>> On 2025-03-02 05:52, Joseph Turner wrote:
>>>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>>>
>>>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>>>
>>>>>>> Was this patch installed?
>>>>>>
>>>>>> No.
>>>>>>
>>>>>>> Should it be?
>>>>>>
>>>>>> I'm not sure, and I said so in the discussion.
>>>>>
>>>>> Now I see that there were some issues with the patch reported by David
>>>>> Ponce, but I see no followup to his last message from Joseph.
>>>>>
>>>>> Joseph, do you still consider this patch a good idea?
>>>> Yes.  The stricter tests which I propose in the patch all pass on my
>>>> machine.  David, are you able to reproduce this issue with emacs -Q?
>>>> Thank you!
>>>> Joseph
>>>
>>> Here here are the results of running image map tests with emacs -Q
>> [...]
>> Thank you!  In this case, I suppose we should not apply this patch
>> until
>> we figure out why the generated image map varies on some machines.
>> Joseph
>
> Hello,
>
> I am still trying to understand why the the rotated-map and
> flipped-map cases in `image--compute-map-and-original-map' test fails
> for me.
>
> I wrote the function `svg-draw-image-map' (see below) to draw in SVG
> an image map, in order to help visualize image maps (maybe a such
> function could be useful to "kind of debug" image maps?).
>
> I also adapted the code from `image--compute-map-and-original-map'
> to be evaluated in the *scratch* buffer, in order to show computed
> and reference image maps.
>
> And, for me this reveals that the reference maps `flipped-map' and
> `rotated-map' are not as expected, contrary to the corresponding
> result of `image--compute-map' which looks as expected.  This explains
> why these test case are failing for me.  But I still can't explain
> why the same test cases passes for you?
>
> Maybe could you try the code below to see if it help clarify this?

[...]

The original-map generation logic is only on Emacs 30, not Emacs 29, so
I'll test this after upgrading to Emacs 30 (on the main Guix channel).

Thank you!

Joseph




Severity set to 'wishlist' from 'minor' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 04 Mar 2025 02:10:02 GMT) Full text and rfc822 format available.

This bug report was last modified 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.