[issue42535] unittest.patch confuses modules with base modules

2020-12-02 Thread Tymek Wołodźko

New submission from Tymek Wołodźko :

Nonetheless having several attempts, I wasn't able to create reproducible 
example for this bug, but I will try describing it in detail.

I have a package with multiple modules. One of the paths is like 
`mymodule.nestedmodule.io`, among other functions, this module contains 
functions `foo()` and `bar()`, where `bar()` does call `foo()`. The module 
*does not* import base python's `io` module. I have a unit test that patches:

with path('mymodule.nestedmodule.io.foo'):
bar()


The problem is, when running the test I get the following error: 
`AttributeError:  does not 
have the attribute 'foo'`. The problem is solved when I rename `io` to `myio` 
and correct all the paths to use the new name.

--
components: Library (Lib)
messages: 382303
nosy: twolodzko
priority: normal
severity: normal
status: open
title: unittest.patch confuses modules with base modules
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue42535>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance, Pearson's correlation, and simple linear regression

2020-07-11 Thread Tymek Wołodźko

Tymek Wołodźko  added the comment:

Is there anything more I should do about the PR?

Sincerely,
Tim

On Fri, May 22, 2020 at 10:45 PM Cheryl Sabella 
wrote:

>
> Cheryl Sabella  added the comment:
>
> @steven.daprano and @tim.peters, please take a look at the PR as it is
> just waiting on your approval.  Thanks!
>
> --
> nosy: +cheryl.sabella
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38490>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance, Pearson's correlation, and simple linear regression

2019-10-22 Thread Tymek Wołodźko

Change by Tymek Wołodźko :


--
title: statistics: add covariance and Pearson's correlation -> statistics: add 
covariance, Pearson's correlation, and simple linear regression

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance and Pearson's correlation

2019-10-17 Thread Tymek Wołodźko

Tymek Wołodźko  added the comment:

I expanded my PR to add simple linear regression. I also created
documentation for the new functionalities.

As about covariance, we can simply not expose it to the users, but I'm not
convinced that there is any gain in keeping it hidden from the users.

Tim

On Wed, Oct 16, 2019 at 11:25 AM Tymek Wołodźko 
wrote:

>
> Tymek Wołodźko  added the comment:
>
> In case there is agreement with Steven, I will add simple linear regression
> ( https://en.wikipedia.org/wiki/Simple_linear_regression ) in the same PR,
> since it is just:
>
> slope = correlation(x, y) * ( stdev(y) / stdev(x) )
> intercept = mean(y) - slope * mean(x)
>
> As about covariance, I see your points, but why not keeping it "because we
> can"? It can be useful for some users and the functionality still needs to
> be implemented to have correlation coefficient.
>
> On Wed, Oct 16, 2019 at 10:47 AM Steven D'Aprano 
> wrote:
>
> >
> > Steven D'Aprano  added the comment:
> >
> > I can't speak for other countries, but in Australia, secondary school
> > mathematics teaches correlation coefficient and linear regression from
> > Year 11 onwards (typically ages 16 or 17). Covariance is not itself
> > taught, and as far as I can tell neither the TI-83 nor NSpire
> > provides a built-in covariance command.
> >
> > On the other hand, other calculators such as the HP-48GX do.
> >
> > Oddly, Excel provides the population (not sample) covariance:
> >
> >
> >
> https://support.office.com/en-us/article/COVARIANCE-P-function-6F0E1E6D-956D-4E4B-9943-CFEF0BF9EDFC
> >
> > OpenOffice and LibreOffice also provide a covariance function.
> >
> > I think that supporting correlation coefficient `r` and linear
> > regression would be clear wins, from the perspective of secondary school
> > maths. But as far as covariance goes, it would help convince me if you
> > had either:
> >
> > - evidence that covariance is taught in secondary schools, or at
> >   least first year undergraduate statistics;
> >
> > - that it has use-cases beyond "helper for calculating r";
> >
> > - or that there is demand for it from people who want covariance
> >   but can't, or don't want to, use numpy/scipy.
> >
> > --
> >
> > ___
> > Python tracker 
> > <https://bugs.python.org/issue38490>
> > ___
> >
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38490>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance and Pearson's correlation

2019-10-16 Thread Tymek Wołodźko

Tymek Wołodźko  added the comment:

In case there is agreement with Steven, I will add simple linear regression
( https://en.wikipedia.org/wiki/Simple_linear_regression ) in the same PR,
since it is just:

slope = correlation(x, y) * ( stdev(y) / stdev(x) )
intercept = mean(y) - slope * mean(x)

As about covariance, I see your points, but why not keeping it "because we
can"? It can be useful for some users and the functionality still needs to
be implemented to have correlation coefficient.

On Wed, Oct 16, 2019 at 10:47 AM Steven D'Aprano 
wrote:

>
> Steven D'Aprano  added the comment:
>
> I can't speak for other countries, but in Australia, secondary school
> mathematics teaches correlation coefficient and linear regression from
> Year 11 onwards (typically ages 16 or 17). Covariance is not itself
> taught, and as far as I can tell neither the TI-83 nor NSpire
> provides a built-in covariance command.
>
> On the other hand, other calculators such as the HP-48GX do.
>
> Oddly, Excel provides the population (not sample) covariance:
>
>
> https://support.office.com/en-us/article/COVARIANCE-P-function-6F0E1E6D-956D-4E4B-9943-CFEF0BF9EDFC
>
> OpenOffice and LibreOffice also provide a covariance function.
>
> I think that supporting correlation coefficient `r` and linear
> regression would be clear wins, from the perspective of secondary school
> maths. But as far as covariance goes, it would help convince me if you
> had either:
>
> - evidence that covariance is taught in secondary schools, or at
>   least first year undergraduate statistics;
>
> - that it has use-cases beyond "helper for calculating r";
>
> - or that there is demand for it from people who want covariance
>   but can't, or don't want to, use numpy/scipy.
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38490>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance and Pearson's correlation

2019-10-16 Thread Tymek Wołodźko

Tymek Wołodźko  added the comment:

I think I see your point, that the module is intended for the most basic
features, but I would argue that correlation is one of such "most basic"
statistics.

Correlation and covariance can be thought as equivalents for standard
deviation and variance, but when we are talking about pairs of variables.
Moreover it is probably used much more often then things like geometric or
harmonic mean, that are implemented in the package. Covariance is probably
more esoteric for most non-statisticians, but in my PR (
https://github.com/python/cpython/pull/16813 ) I implemented it for
completeness and as a helper function for the correlation coefficient.

TL;DR those are basic statistics. They would make the module much more
helpful, since the basic statistics could be calculated using base python
w/o external libraries. They are also trivial to implemented (done this in
PR) and do not need much more maintenance then the other functionalities in
the module.

Tim

śr., 16 paź 2019 o 02:50 Raymond Hettinger 
napisał(a):

>
> Raymond Hettinger  added the comment:
>
> These two functions are right on the boundary edge of what the statistics
> module is trying to do, """The module is not intended to be a competitor to
> third-party libraries such as NumPy, SciPy, or proprietary full-featured
> statistics packages aimed at professional statisticians such as Minitab,
> SAS and Matlab. It is aimed at the level of graphing and scientific
> calculators."""
>
> It is debatable which side of the boundary they belong to. MS Excel has
> both of these functions, but it isn't a given that a scientific calculator
> would have them.
>
> Also, the current functions require only high-school level knowledge, but
> these two require more skill to learn, use, and interpret.
>
> --
> assignee:  -> steven.daprano
> nosy: +rhettinger, steven.daprano
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38490>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38490] statistics: add covariance and Pearson's correlation

2019-10-15 Thread Tymek Wołodźko

New submission from Tymek Wołodźko :

Covariance and Pearson's correlation are one of the most basic bivariate 
statistics.

https://en.wikipedia.org/wiki/Covariance
https://en.wikipedia.org/wiki/Pearson_correlation_coefficient

--
messages: 354754
nosy: Tymek Wołodźko
priority: normal
severity: normal
status: open
title: statistics: add covariance and Pearson's correlation
type: enhancement
versions: Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue38490>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com