Discussion:
[Erp5-dev] Dates divergency, even if dates are exact...
Łukasz Nowak
2008-03-17 09:25:23 UTC
Permalink
Hello,

I've got such situation, that sometimes in tests - not on every run -
object is divergent, and it shall not be. getDivergenceList() on such
objects returns:

tested_property 'start_date'
message 'Start Date'
prevision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
decision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
object_relative_url 'accounting_module/1/1'

tested_property 'stop_date'
message 'Stop Date'
prevision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
decision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
object_relative_url 'accounting_module/1/1'

It happens not on every test run.

What could be a problem? Is that issue known? Is that corrected
somewhere?

AFAIRC it never happened in production/development environment, only
in test runs.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Jean-Paul Smets
2008-03-17 10:14:20 UTC
Permalink
Hi,

Although this does not answer your exact question, I recommend for
divergency testing (ie. rules) to include some tolerance, both for
quantity and other values. I am not sure whether this is fully
implemented yet.

Regards,

JPS.
Post by Łukasz Nowak
Hello,
I've got such situation, that sometimes in tests - not on every run -
object is divergent, and it shall not be. getDivergenceList() on such
tested_property 'start_date'
message 'Start Date'
prevision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
decision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
object_relative_url 'accounting_module/1/1'
tested_property 'stop_date'
message 'Stop Date'
prevision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
decision_value DateTime('2008/03/17 10:14:05.434 GMT+1')
object_relative_url 'accounting_module/1/1'
It happens not on every test run.
What could be a problem? Is that issue known? Is that corrected
somewhere?
AFAIRC it never happened in production/development environment, only
in test runs.
Regards,
Luke
--
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 62 05 76 14
ERP5 Enterprise: Free / Open Source ERP for Critical Applications
http://www.erp5.com
ERP5 Express: Hosted Open Source ERP for small companies
http://www.myerp5.com
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
Łukasz Nowak
2008-03-18 08:16:27 UTC
Permalink
Hello,

On 2008-03-17, 11:14:20
Post by Jean-Paul Smets
Hi,
Although this does not answer your exact question, I recommend for
divergency testing (ie. rules) to include some tolerance, both for
quantity and other values. I am not sure whether this is fully
implemented yet.
Quite nice tip. So I shall modify code of proper AppliedRule subclass
and add some date acceptance based on assumptions?

But why is it only happens in unit tests? I wasn't able to reproduce it
in production/development system. (The only problem is that, sometimes
I've got to many test failures.) From other point of view - it only
happens in my test suites, so I might broke something myself...

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Yoshinori Okuji
2008-03-18 08:37:35 UTC
Permalink
Post by Łukasz Nowak
Hello,
On 2008-03-17, 11:14:20
Post by Jean-Paul Smets
Hi,
Although this does not answer your exact question, I recommend for
divergency testing (ie. rules) to include some tolerance, both for
quantity and other values. I am not sure whether this is fully
implemented yet.
Quite nice tip. So I shall modify code of proper AppliedRule subclass
and add some date acceptance based on assumptions?
But why is it only happens in unit tests? I wasn't able to reproduce it
in production/development system. (The only problem is that, sometimes
I've got to many test failures.) From other point of view - it only
happens in my test suites, so I might broke something myself...
Most probably, because of a round error, since DateTime uses a floating point
number internally. You should be able to see it in obj.__dict__. But if so,
this was resolved by Alexandre some months ago. Look at a DateTime patch in
ERP5Type.

YO
--
Yoshinori Okuji, Nexedi CTO
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com
ERP5 Wiki: Developer Zone for ERP5 Community
http://www.erp5.org
Łukasz Nowak
2008-03-18 08:46:07 UTC
Permalink
Hello,

On 2008-03-18, 09:37:35
Yoshinori Okuji <yo at nexedi.com> wrote:

(...)
Post by Yoshinori Okuji
Most probably, because of a round error, since DateTime uses a
floating point number internally. You should be able to see it in
obj.__dict__.
You are 99% right - in tests I'm creating dates by invoking DateTime w/o
any parameters, so I've got quite "perfect" (and not needed) timing.
Post by Yoshinori Okuji
But if so, this was resolved by Alexandre some months ago. Look at a
DateTime patch in ERP5Type.
Thanks.

Lukasz
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Łukasz Nowak
2008-03-18 08:30:15 UTC
Permalink
Hello,

On 2008-03-17, 11:14:20
Post by Jean-Paul Smets
Hi,
Although this does not answer your exact question, I recommend for
divergency testing (ie. rules) to include some tolerance, both for
quantity and other values. I am not sure whether this is fully
implemented yet.
Ok, I was too fast in previous mail. Is PropertyDivergenceTester[1]
good place to patch it for conditional (for date only) tolerance? I was
looking through *Rule*.py in ERP5/Document, but everything guide me to
generic testers. And I do not see any magic applied in
PropertyDivergenceTester.py which would allow me to configure its
behaviour on comparision.

Regards,
Luke

[1]http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PropertyDivergenceTester.py?view=markup
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Łukasz Nowak
2008-03-19 10:50:02 UTC
Permalink
Hello,

On 2008-03-17, 11:14:20
Post by Jean-Paul Smets
Hi,
Although this does not answer your exact question, I recommend for
divergency testing (ie. rules) to include some tolerance, both for
quantity and other values. I am not sure whether this is fully
implemented yet.
We've got such issues - as we are using price as divergence property,
and in our system, price is calculated from many simulation movements
to one delivery line. It is working "enough" good for us.

I'm attaching patch, which is passing our unit test suite - float
rounding on calculated prices tests are passed, and rest of test suite
is still not destroyed (this do not prove anything, I'm just proud ;) ).

Any comments, ideas, usage welcome. 6 is enough for us. Someone might
use less/more precision.

As you said - it might be quite nice to have configurable precision on
property divergence in rule definition.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PropertyDivergenceTester.py-almost-equality.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080319/57371e5f/attachment.bin>
Loading...