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

test_division test case difference between Python and C++ #154

Open
TomyYamy opened this issue Mar 28, 2022 · 2 comments
Open

test_division test case difference between Python and C++ #154

TomyYamy opened this issue Mar 28, 2022 · 2 comments
Assignees

Comments

@TomyYamy
Copy link
Collaborator

Python

def test_division(self):
spec = rtamt.STLDiscreteTimeSpecification()
spec.declare_var('req', 'float')
spec.declare_var('gnt', 'float')
spec.declare_var('out', 'float')
spec.spec = 'out = req / gnt'
spec.parse()
out1 = spec.update(0, [('req', self.left1), ('gnt', self.right1)])
out2 = spec.update(1, [('req', self.left2), ('gnt', self.right2)])
out3 = spec.update(2, [('req', self.left3), ('gnt', self.right3)])
out4 = spec.update(3, [('req', self.left4), ('gnt', self.right4)])
out5 = spec.update(4, [('req', self.left5), ('gnt', self.right5)])
self.assertEqual(out1, 100 / 20, "input 1")
self.assertEqual(out2, -1 / -2, "input 2")
self.assertEqual(out3, -2 / 10, "input 3")
self.assertEqual(out4, 5 / 4, "input 4")
self.assertEqual(out5, -1 / -1, "input 5")

C++

def test_division(self):
spec = rtamt.StlDiscreteTimeOnlineSpecificationCpp()
spec.declare_var('req', 'float')
spec.declare_var('gnt', 'float')
spec.declare_var('out', 'float')
spec.spec = 'out = req / gnt'
spec.parse()
out1 = spec.update(0, [('req', self.left1), ('gnt', self.right1)])
out2 = spec.update(1, [('req', self.left2), ('gnt', self.right2)])
out3 = spec.update(2, [('req', self.left3), ('gnt', self.right3)])
out4 = spec.update(3, [('req', self.left4), ('gnt', self.right4)])
out5 = spec.update(4, [('req', self.left5), ('gnt', self.right5)])
self.assertEqual(out1, 100.0 / 20.0, "input 1")
self.assertEqual(out2, -1.0 / -2.0, "input 2")
self.assertEqual(out3, -2.0 / 10, "input 3")
self.assertEqual(out4, 5.0 / 4.0, "input 4")
self.assertEqual(out5, -1.0 / -1.0, "input 5")

Is that OK?

@nickovic
Copy link
Owner

Can you please check the branch 154_division? All tests pass with Python 2.7 for me.

@TomyYamy
Copy link
Collaborator Author

@nickovic The test us passed, but the problem is the test case itself different between cpp and python.

Python

     self.assertEqual(out1, 100 / 20, "input 1") 
     self.assertEqual(out2, -1 / -2, "input 2") 
     self.assertEqual(out3, -2 / 10, "input 3") 
     self.assertEqual(out4, 5 / 4, "input 4") 
     self.assertEqual(out5, -1 / -1, "input 5") 

CPP

     self.assertEqual(out1, 100.0 / 20.0, "input 1") 
     self.assertEqual(out2, -1.0 / -2.0, "input 2") 
     self.assertEqual(out3, -2.0 / 10, "input 3") 
     self.assertEqual(out4,  5.0 / 4.0, "input 4") 
     self.assertEqual(out5, -1.0 / -1.0, "input 5") 

Ideally it should be same.

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

No branches or pull requests

2 participants