[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] Overloading of equals method



Le 12/03/2012 14:27, carlos.marce@gmail.com a écrit :
> Hi,

Hello Carlos,

> I just realised that some classes in Orekit don't override the equals method.
> This makes difficult the comparisson of two different objects (i.e. for
> regression testing). Do you plan on adding this in the future?

It depends on the class. Typically, classes that have some primitive
double fields are difficult to compare. Any code change, regardless of
the fact it is minor or not (just think about replacing a + (b+c) by
(a+b) + c) may slightly change the least significant bits. Using exact
comparison would therefore fail despite the change should be considered
acceptable. On the other hand, using some threshold for equality is
difficult has a difference that would be considered as acceptable in one
context may be too large in another one (typically, two orbits differing
in position by 1m would be considered the same in station keeping for a
regular mission, but different for precise orbit determination
applications like altimetry missions). The equals method does not allow
user providing a threshold parameter.

So we implemented equals scarcely, in some limited cases. We implemented
it for AbsoluteDate, we did not implement it for Orbit.

For such "difficult" classes, I would recommend using something more
robust for regression testing. Equals is clearly not sufficient.

For which class would you need an equals method ?

best regards,
Luc

> Regards.
>