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

tooledit: Fix rounding issue #2601

Closed
wants to merge 1 commit into from

Conversation

d2inventory
Copy link
Contributor

A tool length of 123.4567 would be rounded to 123.457
This commit allows for 9 digits instead of the default 6 digits.

Fixes issue #2593

@petterreinholdtsen
Copy link
Collaborator

Is it possible to add some script in tests/ verifying this change work as intended?

@d2inventory
Copy link
Contributor Author

d2inventory commented Jul 29, 2023

I added a test.

Test:

puts [ format "%.9g" 123]
puts [ format "%.9g" 123.0]
puts [ format "%.9g" 123.000]
puts [ format "%.9g" 123.456]
puts [ format "%.9g" 0.1]
puts [ format "%.9g" 0.001]
puts [ format "%.9g" 0.0001]
puts [ format "%.9g" 0.00001]
puts [ format "%.9g" 0.000001]
puts [ format "%.9g" 12345.6789]
puts [ format "%.9g" 12345.0]
puts [ format "%.9g" 1234.123456]
puts [ format "%.9g" 12345.123456]
puts [ format "%.9g" 123456.123456]
puts [ format "%.9g" 1234567.123456]
puts [ format "%.9g" 12345678.123456]
puts [ format "%.9g" 123456789.123456]

Result:

123
123
123
123.456
0.1
0.001
0.0001
1e-05           <---- issue I mentioned
1e-06           <---- issue I mentioned
12345.6789
12345
1234.12346      <---- rounded
12345.1235      <---- rounded
123456.123      <---- rounded
1234567.12      <---- rounded
12345678.1      <---- rounded
123456789

@petterreinholdtsen
Copy link
Collaborator

Why did you change sim_mm.tbl? The test seem to test tcl more than tooledit. Is there no way to test the tooledit output non-interactively?

@d2inventory
Copy link
Contributor Author

I changed it because I tested it locally by running linuxcnc and edititing the tool lengths and then fucked up when commiting to git.

I guess we could start tooledit with a tool table that has length with lots of digits and then make it save somehow but I don't know.

But I think this is all a bit of an overkill. This is simply changing the default 6 digits of %g to 9 digits.

@smoe
Copy link
Contributor

smoe commented Aug 7, 2023

@petterreinholdtsen recently introduced the extra automated testing and I agree that this looks a bit like an opportunity for it. My hunch is that he is looking after something like

source ./tcl/tooledit.tcl

set ::te(fmt,dummy) real
set ::te(dummy) 0.12345678901234567890
puts $::te(dummy)

exit

Just hat I am somewhat not capable to get this right. :)

@d2inventory
Copy link
Contributor Author

d2inventory commented Aug 21, 2023

I updated the test to use a test.tbl that is loaded with tooledit.tcl and then saved again.

While doing this I ran into an issue with the comments, which were converted in a strange way.
(the ä in schaftfräser was always different on saving)
This made me realise that tooledit always converts every line to lower case, which I think is bad as comments should be left as is.
So I made a slight change to tooledit.tcl to fix this issue and convert the lines to lower after the comment has been extracted.
This commit also contains a small fix that messed up syntax highlighting and was an error anyway (but I guess this code path is just never hit so nobody ever encountered the error).

@andypugh
Copy link
Collaborator

It looks like the tooledit test is now failing?

@d2inventory
Copy link
Contributor Author

Yeah, I have to figure out why because it works locally for me.

Maybe because there is no display available on the server side testing?

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Aug 21, 2023 via email

@andypugh
Copy link
Collaborator

I am starting to think that the amount of work being demanded for a test of this simple change is rather disproportionate.

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Aug 22, 2023 via email

@d2inventory
Copy link
Contributor Author

@petterreinholdtsen

I highly doubt that xvfb is installed on the build servers. I set up a test environment locally with a minimal debian12 install and can reproduce the error.
If I install xvfb and use it as you suggested the test runs through successfully.

Let's see if it works if I just use xvfb-run ...

@d2inventory
Copy link
Contributor Author

d2inventory commented Aug 22, 2023

Well, looks like I was very wrong and using xvfb-run solved the problem 😄

EDIT:
nvm, seems like some have xvfb installed and others dont :-/

@d2inventory
Copy link
Contributor Author

@petterreinholdtsen

How should I proceed now?

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Aug 24, 2023 via email

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Aug 27, 2023 via email

@d2inventory
Copy link
Contributor Author

@petterreinholdtsen

it's passing all the tests now.

@petterreinholdtsen
Copy link
Collaborator

petterreinholdtsen commented Sep 8, 2023 via email

A tool length of 123.4567 would be rounded to 123.457
This commit allows for 9 digits instead of the default 6 digits.
@d2inventory
Copy link
Contributor Author

@petterreinholdtsen

I squashed it all into one commit.

@petterreinholdtsen
Copy link
Collaborator

I cherry-picked this commit into the 2.9 branch and merged 2.9 into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants