[SciPy-dev] stats confusion
Wed Jun 17 16:08:40 CDT 2009
OK, this is where I chime in: should the doc be clarified, or does this seem like enough of an arcane deviation from "naive" Python practice that we'll actually want to modify the code (and thus postpone modifying the doc 'til that's done)?
--- On Wed, 6/17/09, firstname.lastname@example.org <email@example.com> wrote:
> From: firstname.lastname@example.org <email@example.com>
> Subject: Re: [SciPy-dev] stats confusion
> To: "SciPy Developers List" <firstname.lastname@example.org>
> Date: Wednesday, June 17, 2009, 7:20 AM
> On Wed, Jun 17, 2009 at 9:43 AM,
> Pauli Virtanen<email@example.com> wrote:
> > Wed, 17 Jun 2009 09:37:10 -0400, josef.pktd
> > [clip]
> >> Positional arguments cannot be called as keyword
> arguments, that is
> >> standard python.
> >> (on the other hand keyword arguments can be called
> also as positional
> >> arguments.
> > Positional arguments can usually be called as keyword
> arguments in
> > standard Python.
> > def foo(a):
> > print a
> > foo(a=5)
> >> the signature and help has standard notation:
> >> eg. signature: np.maximum(x1, x2[, out])
> >>>>> np.maximum(x1=, x2=)
> >> Traceback (most recent call last):
> >> TypeError: 'x2' is an invalid keyword to maximum
> > The only exception are functions provided by C
> extension modules, and
> > functions that use *args.
> Thanks, I didn't know this is possible.
> I found the explanation in the Python Reference Manual. But
> I don't
> thinks I have ever seen it used. And it looks a bit fragile
> to me if
> you want to refactor the argument list later by adding
> *args), and I
> get easily TypeErrors when mixing positional and keyword
> arguments if
> they are in the wrong sequence.
> So, I don't see any gain using positional arguments as
> The problem in this example is that the the generic
> function cdf uses
> *args, **kwds, and checks the arguments and does the
> before dispatching to the private method _cdf.
> Calling the private method actually works with keywords
> >>> scipy.stats.chi2._cdf(1, df=2)
> >>> scipy.stats.chi2._cdf(x=1, df=2)
> I forgot to mention earlier: The generated docs are a merge
> generic and distribution specific docstrings. I never
> checked whether
> this merge is completely correct in all cases.
> > --
> > Pauli Virtanen
> Scipy-dev mailing list
More information about the Scipy-dev