# issue with variable assumptions

I am using sage to compute a variety of algebra, and often times, when calculating the squareroots of variables, sage gets the assumptions wrong. Here is a short example:

sage: r,M=var('r','M')

sage: assume(r>0,M>0,r>2*M)

sage: sqrt((2*M-r)^2)

2M-r

Clearly the last line is incorrect (should be r-2M), but I have no idea how to fix it. While this is a trivial example, I frequently work with equations that are many variables in length, where ensuring that the correct variables are positive is a requirement.

Edit: I found a partial solution, however it does not seem to work well with simplifying radicals. If there is an alternative to canonicalize_radical which takes assumptions into account, it would be helpful.