[Scipy-tickets] [SciPy] #1477: members set in scipy.stats.distributions.##._argcheck

SciPy Trac scipy-tickets@scipy....
Wed Jul 13 19:15:08 CDT 2011

#1477: members set in scipy.stats.distributions.##._argcheck
 Reporter:  jaredd  |       Owner:  somebody   
     Type:  defect  |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  0.9.0      
 Keywords:          |  
 Some distributions set instance attributes in their _argcheck functions
 that are later used in _pdf or other functions.  In particular,
 truncnorm_gen, reciprocal_gen, and planck_gen.  It seems misplaced that
 the argument check function should change the underlying instance.  Rather
 you'd expect it to only indicate which arguments are valid.

 Conventions aside, the _argcheck in calls to pdf, cdf, etc. sets instance
 attributes according to the passed parameters whereas the underlying _*
 private function is passed only those arguments that are valid (from
 goodargs).  Thus, a call like:

 > y = truncnorm.pdf(r_[-2:2:101j], r_[-ones(50),ones(51)], inf)

 will fail.  In this case, it is because truncnorm._delta is computed with
 a length 101 vector (a), but _pdf is passed a vector of only 51 elements
 (x[x>a]).  There seems to be no real computational savings by including
 the truncnorm._delta computation in truncnorm._argcheck.  Why not just
 move it to _pdf and fix this issue?  Same for reciprocal_gen.  See
 truncexpon_gen as a good example.

Ticket URL: <http://projects.scipy.org/scipy/ticket/1477>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list