If the two printers share a lot in common one of them could subclass
the other, or they could share a common superclass. If it's just this
one method, I would just copy the code.

It's hard to say without seeing the actual code. I will say that
usually this sort of thing is handled in the pretty printers by making
correct use of the prettyform class.

Aaron Meurer

On Sun, Apr 2, 2023 at 2:33 PM Pedro Xavier <[email protected]> wrote:
>
> I'm trying to close issue #12157 through the PR #25012.
>
> In summary, the issue comes from the physics dyadic 
> (sympy/physics/vector/dyadic.py) printing method not properly accounting for 
> expressions with large width such as fractions and powers. However, as it was 
> discussed in the issue, the printing routine for dyadic objects from the 
> vector package (sympy/vector/dyadic.py) correctly handles the formatting. I 
> should note that this routine is very similar to the non-working dedicated 
> one for the physics dyadic
>
> I've found two ways of solving the issue. One of them takes a hacky approach 
> to reroute the printing routine for the physics dyadic so it can use the same 
> routine as the vector's dyadic. This prevents copying code across files and 
> is a much smaller change, but it involves writing hacky methods for the 
> physics dyadic class so that the printing routine can work properly.
>
> The other way updates the current dedicated printing method present in the 
> physics dyadic class, which itself is very similar to the working printing 
> routine and probably was the basis for it. It's a much longer change and 
> based of off the currently working printing routine for the vector's dyadic.
>
> since the physics dyadic and the vector's dyadic have very different 
> implementations from what I've seen, those seem the best options to deal with 
> the issue without completely rewriting the physics vector and physics dyadic 
> classes. But I'm unsure which one is considered "best practices".
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/c9cc47fd-5a55-4838-8948-1d9b7289df01n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JOUx1nrpLoaam1cY4Q4_2NZks%2Bb%2BwFvNg4femr-E-KBw%40mail.gmail.com.

Reply via email to