From: Charles R H. <cha...@gm...> - 2006-10-14 20:28:49
|
On 10/13/06, A. M. Archibald <per...@gm...> wrote: > > On 13/10/06, Tim Hochberg <tim...@ie...> wrote: > > Charles R Harris wrote: <snip> > On the other hand if error handling is set to 'raise', then a > > FloatingPointError is issued. Is a FloatingPointWarning in order to > > mirror the FloatingPointError? And if so, would it be appropriate to use > > for condition number? > > I submitted a patchto use warnings for several functions in scipy a > while ago, and the approach I took was to create a ScipyWarning, from > which more specific warnings were derived (IntegrationWarning, for > example). That was perhaps a bit short-sighted. > > I'd suggest a FloatingPointWarning as a base class, with > IllConditionedMatrix as a subclass (it should include the condition > number, but probably not the matrix itself unless it's small, as > debugging information). > Let's pin this down a bit. Numpy seems to need its own warning classes so we can control the printing of the warnings. For the polyfit function I think it should *always* warn by default because it is likely to be used interactively and one can fool around with the degree of the fit. For instance, I am now scaling the the input x vector so norm_inf(x) == 1 and this seems to work pretty well for lots of stuff with rcond=-1 (about 1e-16) and a warning on rank reduction. As long as the rank stays the same things seem to work ok, up to fits of degree 21 on the test data that started this conversation. BTW, how does one turn warnings back on? If I do a >>> warnings.simplefilter('always', mywarn) things work fine. Following this by >>> warnings.simplefilter('once', mywarn) does what is supposed to do. Once again issuing >>> warnings.simplefilter('always', mywarn) fails to have any effect. Resetwarnings doesn't help. Hmmm... Chuck |