[SciPy-Dev] signature for k-sample tests ???

Ralf Gommers ralf.gommers at gmail.com
Sat Jan 4 16:18:07 EST 2014


On Fri, Jan 3, 2014 at 10:18 PM, <josef.pktd at gmail.com> wrote:

> On Fri, Jan 3, 2014 at 4:02 PM, Warren Weckesser
> <warren.weckesser at gmail.com> wrote:
> > On Fri, Jan 3, 2014 at 3:49 PM, <josef.pktd at gmail.com> wrote:
> >>
> >> I don't like it, but I don't care. Opinions please.
> >>
> >> The inherited pattern in scipy.stats for k-sample tests is to use *args
> >>
> >> anderson_ksamp(*args)
> >> f_oneway(*args)
> >> obrientransform(*args)
> >>
> >> what do we do if we want to add keyword arguments?
> >>
> >> >>> def f(*args, method='approx'):
> >> SyntaxError: invalid syntax
> >> unless this changes in newer versions of python
> >>
> >> In statsmodels I either require a tuple instead of *args, or stack the
> >> data into a long format. (I don't use *args for the main required
> >> arguments.)
> >
> >
> >
> > An option that maintains the scipy API is to define the function as
> >
> >     def f(*args, **kwargs):
> >
> > and then add code to check that any given keyword arguments are valid.
>  In
> > this case, check that the only key in kwargs is 'method'.
>
> I was thinking about that as the only solution that follows the scipy
> pattern.
>
> However, ugly and not informative.
>

Agreed.


> But I don't think that the scipy functions will get lots of keywords,
> so still bearable.
>

Bearable, but for new functions I'd rather have

    def f(arrays, kw1=None, ...)

where arrays is a sequence of arrays (or a single ndarray if that makes
sense).

These tests don't have *args uniformly now, so I don't think it's required
for anderson_ksamp to copy it.

Ralf


>
> In the anderson_ksamp case there might be "eventually" an option to
> choose the p-value calculation, which would end up in the **kwargs.
> In one of my versions of anova/f_oneway I have variance and trimming
> options IIRC.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20140104/6e6a432e/attachment.html>


More information about the SciPy-Dev mailing list