Regarding deprecation of a property

163 views
Skip to first unread message

Ruchit Jagodara

unread,
Jan 10, 2024, 2:49:37 AM1/10/24
to sage-devel
Currently, the PolynomialSequence.coefficient_matrix() function returns a matrix of monomials as the second element of a tuple. However, as discussed in issue [#37027](https://github.com/sagemath/sage/issues/37027), it has been suggested that returning a vector of monomials would be more logical. I am uncertain about the correct approach to deprecate the current behavior. I have submitted a pull request with the proposed changes at PR [#37035](https://github.com/sagemath/sage/pull/37035), but I would appreciate guidance on whether this is the appropriate way to deprecate the property.

Nils Bruin

unread,
Jan 10, 2024, 3:06:36 AM1/10/24
to sage-devel
deprecation in a way that allows code to be adapted gradually would mean:
 - introduce a new method with a different name that implements the desired behaviour
 - deprecate old method
 - after appropriate deprecation period remove old method
 - possibly, at this point introduce the now-vacated name as a synonym for the method with the desired method.
Quite frankly I think "coefficient_matrix" is the wrong name anyway: I'd expect such a method to return a matrix, but it returns a tuple (both in the old and the new version). So I think step 4 can be skipped in this case.

Note that often deprecation remains the state for very long: the motivation for actually removing functionality is pretty minimal.

Martin R

unread,
Jan 10, 2024, 6:03:09 AM1/10/24
to sage-devel
I like this idea much better!  What would be a good name?  Brainstorming: `coefficient_system`, `coefficients`, `coefficients_monomials`, `coefficient_matrix_monomial_vector`...

Lorenz Panny

unread,
Jan 10, 2024, 8:31:09 AM1/10/24
to sage-devel

How about .linearize()?

(I think this method should also optionally take a list
of monomials as an argument, since there are situations
in which users would like to force their own ordering.
Returning the same monomial vector again would then of
course be redundant, so in that case the method could
really return just the matrix.)


On Wed, 10 Jan 2024 12:03:09 +0100, 'Martin R' via sage-devel <sage-...@googlegroups.com> wrote:
> I like this idea much better! What would be a good name? Brainstorming:
> `coefficient_system`, `coefficients`, `coefficients_monomials`,
> `coefficient_matrix_monomial_vector`...
>
> On Wednesday 10 January 2024 at 09:06:36 UTC+1 Nils Bruin wrote:
> deprecation in a way that allows code to be adapted gradually would mean:
> - introduce a new method with a different name that implements the desired
> behaviour
> - deprecate old method
> - after appropriate deprecation period remove old method
> - possibly, at this point introduce the now-vacated name as a synonym for
> the method with the desired method. Quite frankly I think
> "coefficient_matrix" is the wrong name anyway: I'd expect such a method to
> return a matrix, but it returns a tuple (both in the old and the new
> version). So I think step 4 can be skipped in this case.
>
> Note that often deprecation remains the state for very long: the motivation
> for actually removing functionality is pretty minimal.
>
>
> On Tuesday 9 January 2024 at 23:49:37 UTC-8 Ruchit Jagodara wrote:
> Currently, the PolynomialSequence.coefficient_matrix() function returns a
> matrix of monomials as the second element of a tuple. However, as discussed
> in issue
> [#37027](https://github.com/sagemath/sage/issues/37027<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsagemath%2Fsage%2Fissues%2F37027&data=05%7C02%7C%7C063dfadc5a71420af4e508dc11cbbe94%7Ccc7df24760ce4a0f9d75704cf60efc64%7C0%7C0%7C638404813986242357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DPIIhBlboqhbMioFvG1N4GtlhtOY3Z%2FVdeiSldRFFhs%3D&reserved=0>),
> it has been suggested that returning a vector of monomials would be more
> logical. I am uncertain about the correct approach to deprecate the current
> behavior. I have submitted a pull request with the proposed changes at PR
> [#37035](https://github.com/sagemath/sage/pull/37035<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsagemath%2Fsage%2Fpull%2F37035&data=05%7C02%7C%7C063dfadc5a71420af4e508dc11cbbe94%7Ccc7df24760ce4a0f9d75704cf60efc64%7C0%7C0%7C638404813986242357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CW88u4zndEZ8Z3RIl0D7%2F82wM8MhkdjG1%2BcsZnvq0MM%3D&reserved=0>),
> but I would appreciate guidance on whether this is the appropriate way to
> deprecate the property.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group. To unsubscribe from this group and stop receiving emails
> from it, send an email to
> sage-devel+...@googlegroups.com<mailto:sage-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/00253792-8260-43aa-b449-4a04de540ad8n%40googlegroups.com<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fsage-devel%2F00253792-8260-43aa-b449-4a04de540ad8n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C02%7C%7C063dfadc5a71420af4e508dc11cbbe94%7Ccc7df24760ce4a0f9d75704cf60efc64%7C0%7C0%7C638404813986398591%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=VsrgBEL8xnVCbpI7wSD9QFLAMnKvFS1m4wthu0jqDyc%3D&reserved=0>.

Nils Bruin

unread,
Jan 10, 2024, 9:46:25 AM1/10/24
to sage-devel
On Wednesday 10 January 2024 at 03:03:09 UTC-8 Martin R wrote:
... What would be a good name?  Brainstorming: `coefficient_system`, `coefficients`, `coefficients_monomials`, `coefficient_matrix_monomial_vector`...

I think coefficients_monomials() is the most descriptive, as it tells you what you get back and in what order.

C, m = PS.coefficients_monomials()
assert PolynomialSequence(C*m) == PS

(incidentally, the assert also holds true with the return values of coefficient_matrix)

Also, thinking about whether C should be transposed: I think it's logical that the rows of C are the coefficients of members of the sequence (since matrices are closest to sequences of rows in sage), so C is already correct in that sense. Therefore, m should indeed be a "column" vector, but sage is ambivalent about whether vectors are rows or columns and therefore we can safely return it as a vector.

Ruchit Jagodara

unread,
Jan 12, 2024, 2:50:54 PM1/12/24
to sage-devel
Okay, so I will make a new function named coefficient_monomials and will implement the functionality that Lorenz Panny suggested.
Thank you for your help : ) .

Nils Bruin

unread,
Jan 12, 2024, 3:52:51 PM1/12/24
to sage-devel
On Friday 12 January 2024 at 14:50:54 UTC-5 Ruchit Jagodara wrote:
Okay, so I will make a new function named coefficient_monomials and will implement the functionality that Lorenz Panny suggested.
Thank you for your help : ) .

I think "coefficients_monomials" is a little clearer. ( coefficient_monomials could be interpreted as "monomials of the coefficient", which wouldn't make sense).

Ruchit Jagodara

unread,
Jan 13, 2024, 2:57:52 AM1/13/24
to sage-devel
Okay.
Reply all
Reply to author
Forward
0 new messages