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

Failing unit tests test_ZeigerEvalHybrid and in suite test_cnnflowcontroll #2753

Closed
rainman110 opened this issue Dec 21, 2023 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@rainman110
Copy link
Contributor

rainman110 commented Dec 21, 2023

The Problem

The unit test test_ ZeigerEvalHybrid is failing. In particular, three assertions fail:

// the 5.7 and no previous should trunc to 5
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1));

(returns 5 instead)

// the 5.8 and no previous should round up to 6
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.8, 0, -1));

(returns 5 instead)

// the 5.3 with previous and the previous >=9.5 should reduce to 4
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(5.3, 9.6, 9));

(returns 5 instead)

Also, multiple assertions are raised in the suite test_cnnflowcontroll.

Version

Git rev 02138c4 (from 2023/11/22)

Logfile

The log from the unit tests.


PointerEvalHybridNew(5.7, 0, -1)
DEBUG - [CNN]:PointerEvalHybridNew - No predecessor - Result = 5 number: 5.700000 number_of_predecessors = 0.000000 eval_predecessors = -1 Digital_Uncertainty = 0.200000
C:\src\3rdparty\AI-on-the-edge-device\code\test\components\jomjol-flowcontroll\test_cnnflowcontroll.cpp(58): error: Expected equality of these values:
  6
  undertest.PointerEvalHybridNew(5.7, 0, -1)
    Which is: 5

PointerEvalHybridNew(5.8, 0, -1)
DEBUG - [CNN]:PointerEvalHybridNew - No predecessor - Result = 5 number: 5.800000 number_of_predecessors = 0.000000 eval_predecessors = -1 Digital_Uncertainty = 0.200000
C:\src\3rdparty\AI-on-the-edge-device\code\test\components\jomjol-flowcontroll\test_cnnflowcontroll.cpp(62): error: Expected equality of these values:
  6
  undertest.PointerEvalHybridNew(5.8, 0, -1)
    Which is: 5

DEBUG - [CNN]:PointerEvalHybridNew - O analogue predecessor, >= 9.5 --> no zero crossing yet = 5 number: 5.300000 number_of_predecessors = 9.600000 eval_predecessors = 9 Digital_Uncertainty = 0.200000 result_after_decimal_point = 3
C:\src\3rdparty\AI-on-the-edge-device\code\test\components\jomjol-flowcontroll\test_cnnflowcontroll.cpp(74): error: Expected equality of these values:
  4
  undertest.PointerEvalHybridNew(5.3, 9.6, 9)
    Which is: 5

Log of test_doFlowPP1:
test_doFlowPP1.txt

Log of test_doFlowPP2:
test_doFlowPP2.txt

Expected Behavior

No test failures.

Screenshots

No response

Additional Context

Note. I did not run the code natively on the esp but ported to post processing code to PC to be able to understand and debug the code. Later, I intend to improve issues, when the analog and digital counters are out of sync, but I'd like to have a solid test bed first.

@rainman110 rainman110 added the bug Something isn't working label Dec 21, 2023
@rainman110 rainman110 changed the title Failing unit tests test_ZeigerEvalHybrid Failing unit tests test_ZeigerEvalHybrid and in suite test_cnnflowcontroll Dec 21, 2023
@Slider0007
Copy link
Collaborator

Slider0007 commented Dec 24, 2023

// the 5.7 and no previous should trunc to 5
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1));
(returns 5 instead)

5 is correct. (Changed result due to PR #2466)

// the 5.8 and no previous should round up to 6
TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.8, 0, -1));
(returns 5 instead)

5 is correct. (Changed result due to PR #2466)

It seems test cases (also in test_cnnflowcontroll) needs to be adapted to follow actual implementation changed by PR #2466.

@Slider0007
Copy link
Collaborator

@rainman110:

to be able to understand and debug the code

A while ago I refactord some parts of the code to get better understanding how it works. Maybe this could be helpful for your analysis somehow, otherwise just ignore my comment.
Be aware: The logic is in principle identical, but the code is slighly different. Main difference: pure INT handling to avoid rounding issues.

e.g. https://github.com/Slider0007/AI-on-the-edge-device/blob/develop/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp#L44

😺 Happy Christmas to everybody! 😺

@haverland
Copy link
Collaborator

// the 5.7 and no previous should trunc to 5 TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1)); (returns 5 instead)

5 is correct. (Changed result due to PR #2466)

// the 5.8 and no previous should round up to 6 TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.8, 0, -1)); (returns 5 instead)

5 is correct. (Changed result due to PR #2466)

It seems test cases (also in test_cnnflowcontroll) needs to be adapted to follow actual implementation changed by PR #2466.

I think @Slider0007 is right. Maybe I didn't fixed the unit tests.

Will have a deeper look on it the next days.

@haverland
Copy link
Collaborator

// the 5.7 and no previous should trunc to 5 TEST_ASSERT_EQUAL(6, undertest.PointerEvalHybridNew(5.7, 0, -1)); (returns 5 instead)

undertest.PointerEvalHybridNew has now 5 parameters.

After the rewrite the tests are not fixed any more.

First, in most cases we truncate instead of rounding. It's mostly the better way.

But the early transition not working any more. (higher digit = 5.3 and lower digit is 9.7. Here the 9.7 => 9 and the 5.3 is an early transition and must be reduced to 4.)

Will fix it the next days and rewrite the tests.

@caco3 caco3 closed this as completed Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants