Opened 12 years ago
Closed 12 years ago
#10841 closed defect (fixed)
piecewise integrals of 0 fail
Reported by: | D.S. McNeil | Owned by: | Burcin Erocal |
---|---|---|---|
Priority: | minor | Milestone: | sage-4.7 |
Component: | symbolics | Keywords: | |
Cc: | Karl-Dieter Crisman | Merged in: | sage-4.7.alpha3 |
Authors: | Douglas McNeil | Reviewers: | David Joyner, Karl-Dieter Crisman |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
As reported in a sage-support thread, in 4.6.1 we see that
sage: # succeeds sage: f = Piecewise([[(0,1),1]]) sage: f.integral(x,0,1) 1 sage: # fails sage: f = Piecewise([[(0,1),0]]) sage: f.integral(x,0,1) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /Applications/sage/local/lib/python2.6/site-packages/sage/all_cmdline.pyc in <module>() /Applications/sage/local/lib/python2.6/site-packages/sage/functions/piecewise.pyc in integral(self, x, a, b, definite) 789 """ 790 if a != None and b != None: --> 791 F = self.integral(x) 792 return F(b) - F(a) 793 /Applications/sage/local/lib/python2.6/site-packages/sage/functions/piecewise.pyc in integral(self, x, a, b, definite) 831 if definite or end != infinity: 832 area += fun.integral(x, start, end) --> 833 new_pieces.append([(start, end), fun_integrated.function(x)]) 834 835 if definite: /Applications/sage/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2666)() /Applications/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2840)() /Applications/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2611)() AttributeError: 'sage.rings.integer.Integer' object has no attribute 'function'
ultimately because 0 is special-cased:
sage: type(SR(0).integral(x)) <type 'sage.rings.integer.Integer'> sage: type(SR(1).integral(x)) <type 'sage.symbolic.expression.Expression'>
and the code path for a zero in PiecewisePolynomial?.integral never coerces to SR, so .function fails.
Apply only trac_10841_fix_piecewise_integrals_of_zero.2.patch
Attachments (2)
Change History (15)
comment:1 Changed 12 years ago by
Component: | PLEASE CHANGE → symbolics |
---|---|
Owner: | changed from tbd to Burcin Erocal |
Priority: | major → minor |
Type: | PLEASE CHANGE → defect |
Changed 12 years ago by
Attachment: | trac_10841_fix_piecewise_integrals_of_zero.patch added |
---|
comment:2 Changed 12 years ago by
Description: | modified (diff) |
---|
comment:3 follow-up: 4 Changed 12 years ago by
Cc: | Karl-Dieter Crisman added |
---|
comment:4 Changed 12 years ago by
Status: | new → needs_review |
---|
Replying to kcrisman:
I don't have time to review this now, but hopefully not too long. Do all long tests pass with this change?
Also, you should feel free to ask the webmaster (Harald Schilly) to add you to http://www.sagemath.org/development-map.html.
I've tested this on one machine on an older version of Sage and sage -testall passed, except for failing the (presumably unrelated) R-interface file. Also, the code looks good, has the appropriate doctests and seems to do what is claimed. I want to test it on one more machine before giving it a positive review though.
comment:5 Changed 12 years ago by
Status: | needs_review → positive_review |
---|
This applies fine to 4.6.2.rc0 and passes sage -testall -long. Patch reads okay and does what it claims to do.
Thanks very much for making the patch!
comment:6 Changed 12 years ago by
Authors: | → Douglas McNeil |
---|---|
Milestone: | → sage-4.7 |
Reviewers: | → David Joyner |
comment:7 Changed 12 years ago by
Status: | positive_review → needs_work |
---|
Problems while building the documentation:
dochtml.log:/mnt/usb1/scratch/jdemeyer/merger/sage-4.7.alpha3/local/lib/python2.6/site-packages/sage/functions/piecewise.py:docstring of sage.functions.piecewise.PiecewisePolynomial.integral:83: (WARNING/2) Literal block expected; none found.
Changed 12 years ago by
Attachment: | trac_10841_fix_piecewise_integrals_of_zero.2.patch added |
---|
Apply only this patch
comment:8 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Status: | needs_work → needs_review |
This should fix the problem.
comment:9 Changed 12 years ago by
Reviewers: | David Joyner → David Joyner, Karl-Dieter Crisman |
---|---|
Status: | needs_review → positive_review |
Yes, it does.
Note to DSM: it turns out that you only need the double colon in front of doctests. So if there is verbiage between the EXAMPLES
or TESTS
and the actual indented tests, you only use a single colon there.
comment:10 Changed 12 years ago by
Okay, so just so I'm clear: you must use only one colon after EXAMPLE[S] or TESTS if you're going to follow it with text at the indentation level of EXAMPLES and TESTS and not a more deeply indented code section. If you use two colons, then what comes after *must* be an indented code section, whether you've used "EXAMPLES::" or "EXAMPLE:" and then text and then a bare "::" on a line.
[update: just read kcrisman's explanation. `:^)`]
So does this mean that the merger of my patch for trac #10088 broke the docs?
comment:11 Changed 12 years ago by
Well, you'd think so, but it didn't - here's why. It doesn't 'break' them, just causes a warning. And if they aren't in the reference manual - as that file apparently isn't - it won't break them, since there is no warning, since they are never actually built.
comment:12 Changed 12 years ago by
That's not to say such things shouldn't be fixed eventually. But that would happen when such files are put into the reference manual; even I wouldn't do a ticket for something that trivial.
comment:13 Changed 12 years ago by
Merged in: | → sage-4.7.alpha3 |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
I don't have time to review this now, but hopefully not too long. Do all long tests pass with this change?
Also, you should feel free to ask the webmaster (Harald Schilly) to add you to http://www.sagemath.org/development-map.html.