You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My package qspray defines the qspray objects which represent polynomials.
An equality is defined for qspray objects and it is possible that qspray1 == qspray2 returns TRUE but both tests expect_identical(qspray1, qspray2) and expect_equal(qspray1, qspray2) fail.
Why? Such an object is an S4 object with two slots, powers and coeffs, the list of powers and the list of coefficients of the polynomial. It is possible that two qspray objects qspray1 and qspray2 are equal in the sense that qspray1 == qspray2 returns TRUE while they are not identical, e.g. x² + x == x + x². That's because the order of the terms of a polynomial has no importance for the equality, so in order for qspray1 == qspray2 to be TRUE, it is enough that their lists of powers and coefficients are equal up to the order. Thus expect_identical(qspray1, qspray2) fails. The same for expect_equal(qspray1, qspray2) since this test compares the slots.
So I'd like to have a test expect_equality(qspray1, qspray2) (or another name) which would do the same as expect_true(qspray1 == qspray2) but with a notable difference: expect_true(qspray1 == qspray2) does not print any useful information when it fails, whereas expect_equality(qspray1, qspray2) could print qspray1 and qspray2.
Of course, if I take the liberty to do such a feature request, that's because I think it could be useful not only for me. E.g. there are other packages dealing with polynomials, and there certainly are many packages defining the equality test == for some custom objects (e.g. the quaternions in the onion package).
Cheers.
The text was updated successfully, but these errors were encountered:
Hello,
My package qspray defines the
qspray
objects which represent polynomials.An equality is defined for
qspray
objects and it is possible thatqspray1 == qspray2
returnsTRUE
but both testsexpect_identical(qspray1, qspray2)
andexpect_equal(qspray1, qspray2)
fail.Why? Such an object is an S4 object with two slots,
powers
andcoeffs
, the list of powers and the list of coefficients of the polynomial. It is possible that twoqspray
objectsqspray1
andqspray2
are equal in the sense thatqspray1 == qspray2
returnsTRUE
while they are not identical, e.g.x² + x == x + x²
. That's because the order of the terms of a polynomial has no importance for the equality, so in order forqspray1 == qspray2
to beTRUE
, it is enough that their lists of powers and coefficients are equal up to the order. Thusexpect_identical(qspray1, qspray2)
fails. The same forexpect_equal(qspray1, qspray2)
since this test compares the slots.So I'd like to have a test
expect_equality(qspray1, qspray2)
(or another name) which would do the same asexpect_true(qspray1 == qspray2)
but with a notable difference:expect_true(qspray1 == qspray2)
does not print any useful information when it fails, whereasexpect_equality(qspray1, qspray2)
could printqspray1
andqspray2
.Of course, if I take the liberty to do such a feature request, that's because I think it could be useful not only for me. E.g. there are other packages dealing with polynomials, and there certainly are many packages defining the equality test
==
for some custom objects (e.g. the quaternions in the onion package).Cheers.
The text was updated successfully, but these errors were encountered: