Skip to content

Weird behaviour of DataSeries>>#closeTo: #208

Open

Description

@Joshua-Dias-Barreto
ds:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(1.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Returns true

ds:= DataSeries withKeys: #(1 2 3 4) values:#(5 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(5.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Also returns true.
However,

ds:= DataSeries withKeys: #(1 2 3 4) values:#(2 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(2.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Returns false.

With certain numbers, it allows the default precision of 0.0001 ( 1, 4.....31, 256.......2047, 8192.....16383 )
And with the other numbers, it returns false.

This code can be used to see at which numbers it returns true ( set the range accordingly, the current range is 1 to 100):

ds:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
1 to: 100 do: [ :x |
	ds at: 1 put: x.
	ds1 at: 1 put: x + 0.0001.
	(ds closeTo: ds1) = true ifTrue: [ Transcript crShow: x ] ].

Activity

  1. jecisc commented on Mar 30, 2023

    @jecisc
    Member

    Hi,

    What version of Pharo are you using? We probably rely on the #closeTo: of Pharo and I found a bug in it that I fixed in the latest Pharo 11. Maybe this is related.

  2. Joshua-Dias-Barreto commented on Mar 30, 2023

    @Joshua-Dias-Barreto
    CollaboratorAuthor

    I use Pharo 11. You are right it is related, because I tested it on Pharo 10 now and #closeTo: works just fine.

  3. olekscode commented on Apr 23, 2024

    @olekscode
    Member

    We need to write a test for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions