#24425 closed defect (fixed)
Fix inherently failing random_expr doctest
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  symbolics  Keywords:  
Cc:  Merged in:  
Authors:  Ralf Stephan  Reviewers:  Marc Mezzarobba 
Report Upstream:  N/A  Work issues:  
Branch:  a17755c (Commits)  Commit:  
Dependencies:  Stopgaps: 
Description (last modified by )
The docs for random_expr
read:
This function will often raise an error because it tries to create an erroneous expression (such as a division by zero).
It has the following doctest:
sage: from sage.symbolic.random_tests import * sage: set_random_seed(53) sage: random_expr(50, nvars=3, coeff_generator=CDF.random_element) # random (v1^(0.97134084277 + 0.195868299334*I)/csc(pi + v1^2 + v3) + sgn(1/ ...
Despite having a random seed the test run changes with every new builtin function introduced in sage/functions
because the global function list changes. That's why the test was marked random. The problem however is that the test can even raise an error, as the docs state above. The"random
" keyword does not catch this, and it would make the test useless anyway.
Tests are meant to test the functionality of the associated code so the test and perhaps random_expr
should be rewritten such that it allows a test that does not change with a changed global function list.
Change History (8)
comment:1 Changed 22 months ago by
comment:2 Changed 22 months ago by
 Description modified (diff)
 Summary changed from random_expr changes behaviour when unrelated code is changed to Minimize random_expr's raising exceptions
comment:3 Changed 22 months ago by
 Description modified (diff)
 Summary changed from Minimize random_expr's raising exceptions to Fix inherently failing random_expr doctest
comment:4 Changed 22 months ago by
 Branch set to u/rws/fix_inherently_failing_random_expr_doctest
comment:5 Changed 22 months ago by
 Commit set to a17755c56a524033d3075a737f4a08facd012dbb
 Status changed from new to needs_review
New commits:
a17755c  24425: Fix inherently failing random_expr doctest

comment:6 Changed 17 months ago by
 Reviewers set to Marc Mezzarobba
 Status changed from needs_review to positive_review
I don't fully understand the context, but the change looks reasonable and really unlikely to break anything—and this ticket has been languishing for months.
comment:7 Changed 17 months ago by
 Branch changed from u/rws/fix_inherently_failing_random_expr_doctest to a17755c56a524033d3075a737f4a08facd012dbb
 Resolution set to fixed
 Status changed from positive_review to closed
comment:8 Changed 17 months ago by
 Commit a17755c56a524033d3075a737f4a08facd012dbb deleted
Thanks. Oddly enough, #24212 depends on this.
The lazy_import is not even necessary for trigger.