[sage-devel] Re: Improving rescaling of matrices
kcrisman wrote: Referring to http://trac.sagemath.org/sage_trac/ticket/3212, I have to do a little cleaning up before submitting it for review, but have some code for allowing rescaling of matrices by logical scalars not in the base ring. However, in order to do this, I need to return a copy, not modify the original, and robertwb raises the point that perhaps then rescale_row etc. should *always* return a copy, for consistency. +1 to always returning a copy. If *anything* is returned, I would expect it to be a copy. Note that one convention that I have observed in python is to return None if an object is modified by a method. You see this in the sort() method for lists, for example. We have also tried to follow this convention in the graph theory code (and we've had this discussion before when contemplating changing the graph theory code). Thanks, Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: Improving rescaling of matrices
On Mon, Jun 2, 2008 at 7:17 AM, Jason Grout [EMAIL PROTECTED] wrote: kcrisman wrote: Referring to http://trac.sagemath.org/sage_trac/ticket/3212, I have to do a little cleaning up before submitting it for review, but have some code for allowing rescaling of matrices by logical scalars not in the base ring. However, in order to do this, I need to return a copy, not modify the original, and robertwb raises the point that perhaps then rescale_row etc. should *always* return a copy, for consistency. +1 to always returning a copy. Do you have any idea what making this change is going to do to the generic echelonize() command? It's just not going to work at all or be insanely slow. If *anything* is returned, I would expect it to be a copy. Note that one convention that I have observed in python is to return None if an object is modified by a method. You see this in the sort() method for lists, for example. We have also tried to follow this convention in the graph theory code (and we've had this discussion before when contemplating changing the graph theory code). It's not just a convention. In the Python language *all* functions return a value whether you use the return command or not. If you don't they default to returning None. William --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: Improving rescaling of matrices
Maybe rescale_row and rescale_col should retain their current semantics, and we should have new methods with_rescaled_row and with_rescaled_col that always return a modified copy and never modify the original. Then rescale_row and rescale_col could catch the type error from #3212, and produce a new type error that says something like rescale_row cannot change the base ring of the matrix; try with_rescaled_row instead. +1 -- that's a great idea! Another +1, this is the best solution I've heard so far. - Robert Unless someone continues this thread, I will assume that this idea carries the day in finishing work on this ticket (which may now take a bit longer). Thanks very much for the input. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---