Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behaviour of DataSeries>>#closeTo: #208

Open
Joshua-Dias-Barreto opened this issue Mar 30, 2023 · 3 comments
Open

Weird behaviour of DataSeries>>#closeTo: #208

Joshua-Dias-Barreto opened this issue Mar 30, 2023 · 3 comments
Labels
Difficulty: Easy Novi Sad tests Yellow and red tests, badly written tests, new tests

Comments

@Joshua-Dias-Barreto
Copy link
Collaborator

Joshua-Dias-Barreto commented Mar 30, 2023

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 ] ].
@jecisc
Copy link
Member

jecisc commented Mar 30, 2023

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.

@Joshua-Dias-Barreto
Copy link
Collaborator Author

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

@olekscode
Copy link
Member

We need to write a test for this

@olekscode olekscode added tests Yellow and red tests, badly written tests, new tests Difficulty: Easy Novi Sad labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy Novi Sad tests Yellow and red tests, badly written tests, new tests
Projects
None yet
Development

No branches or pull requests

3 participants