Ticket #9086 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

LaTeX representation of negative symbolic fractions broken

Reported by: leif Owned by: burcin
Priority: blocker Milestone: sage-4.4.3
Component: symbolics Keywords: symbolic fraction, sign, minus, latex, pynac
Cc: Work issues:
Report Upstream: N/A Reviewers: Mike Hansen
Authors: William Stein Merged in: sage-4.4.3.alpha2
Dependencies: Stopgaps:

Description (last modified by leif) (diff)

When the numerator of a (negative) symbolic expression happens to be 1 (and only then), the sign is dropped in its LaTeX representation (but not its string representation):

sage: latex(-1/x) 
\frac{1}{x}
sage: latex(1/-x) 
\frac{1}{x}

Origin of the new doctest failure in sage/graphs/generic_graphy.py, introduced with Sage 4.4.3.alpha0.


Update:

Actually, though I tested many other cases, the same (still) happens if both the numerator and denominator are (symbolic) variables (see also  http://trac.sagemath.org/sage_trac/ticket/9086#comment:12):

sage: var("x y")
(x, y)
sage: latex(-x/y)
\frac{x}{y}
sage: latex(x/-y)
\frac{x}{y}

But since it was discovered after the patch that fixes the first issue had been merged, the latter bug is now  http://trac.sagemath.org/sage_trac/ticket/9314.

Attachments

trac_9086.patch Download (1.0 KB) - added by was 3 years ago.
apply to sage library
trac_9086-apply_to_pynac.patch Download (1.9 KB) - added by was 3 years ago.
apply to src/ repo in pynac spkg

Change History

comment:1 Changed 3 years ago by burcin

  • Keywords latex, pynac added; latex removed

Thanks for tracking this down. This patch is the culprit:

 http://pynac.sagemath.org/hg/rev/cbd65a7dcf6a

I will only be able to look at this after next weekend.

Changed 3 years ago by was

apply to sage library

Changed 3 years ago by was

apply to src/ repo in pynac spkg

comment:2 Changed 3 years ago by was

  • Priority changed from critical to blocker
  • Status changed from new to needs_review

The patch to the pynac spkg is long, but is logically nearly trivial. I just copied some code for printing a sign, which Burcin forgot.

The patch to the sage library is merely to test that this is fixed.

William

comment:4 Changed 3 years ago by mhansen

  • Status changed from needs_review to positive_review
  • Reviewers set to Mike Hansen
  • Authors set to William Stein

This looks good to me and fixes the issue. There was a change for #9037 that didn't get included in the spkg merged so far in 4.4.3 so I've included it at

 http://sage.math.washington.edu/home/mhansen/pynac-0.2.0.p1.spkg

which should be used instead of the above link.

comment:5 Changed 3 years ago by was

Mike, Can you give #9037 a positive review?

comment:6 Changed 3 years ago by mhansen

Positive review up at #9037.

comment:7 Changed 3 years ago by was

  • Milestone changed from sage-4.4.4 to sage-4.4.3

comment:8 Changed 3 years ago by was

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to 4.4.3.alpha2

comment:9 Changed 3 years ago by mvngu

  • Merged in changed from 4.4.3.alpha2 to sage-4.4.3.alpha2

comment:10 follow-up: ↓ 12 Changed 3 years ago by damm

  • Status changed from closed to new
  • Resolution fixed deleted
  • Description modified (diff)

comment:11 Changed 3 years ago by damm

  • Description modified (diff)

comment:12 in reply to: ↑ 10 ; follow-up: ↓ 13 Changed 3 years ago by damm

Replying to damm: Sorry, i've changed the description and couldn't revert the change.

I think the fix didn't solve all problems:

sage: var('x y')
sage: latex(-x/y) 
\frac{x}{y}

comment:13 in reply to: ↑ 12 ; follow-up: ↓ 14 Changed 3 years ago by leif

Replying to damm:

I think the fix didn't solve all problems

Indeed. Despite the ticket's name, I think this second case should be addressed on another ticket, since this one had already been merged.

comment:15 Changed 3 years ago by leif

  • Status changed from new to closed
  • Resolution set to fixed
  • Description modified (diff)
Note: See TracTickets for help on using tickets.