From fbb817a3da88635892c88dae847ea00484d2b78e Mon Sep 17 00:00:00 2001 From: Rish001 Date: Tue, 30 Jun 2020 13:59:37 +0530 Subject: [PATCH 01/15] 3962 issue fixed --- pymc3/distributions/distribution.py | 6 ++++-- pymc3/distributions/timeseries.py | 12 ++++++++++-- pymc3/sampling.py | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pymc3/distributions/distribution.py b/pymc3/distributions/distribution.py index 7176fb47add..3e7500b536a 100644 --- a/pymc3/distributions/distribution.py +++ b/pymc3/distributions/distribution.py @@ -559,6 +559,7 @@ def draw_values(params, point=None, size=None): # draw_values in the context of sample_posterior_predictive ppc_sampler = vectorized_ppc.get(None) if ppc_sampler is not None: + # this is being done inside new, vectorized sample_posterior_predictive return ppc_sampler(params, trace=point, samples=size) @@ -592,7 +593,6 @@ def draw_values(params, point=None, size=None): else: # param still needs to be drawn symbolic_params.append((i, p)) - if not symbolic_params: # We only need to enforce the correct order if there are symbolic # params that could be drawn in variable order @@ -818,6 +818,7 @@ def _draw_value(param, point=None, givens=None, size=None): if point and hasattr(param, 'model') and param.name in point: return point[param.name] elif hasattr(param, 'random') and param.random is not None: + print(point) return param.random(point=point, size=size) elif (hasattr(param, 'distribution') and hasattr(param.distribution, 'random') and @@ -995,7 +996,7 @@ def generate_samples(generator, *args, **kwargs): else: samples = generator(size=size_tup + dist_bcast_shape, *args, **kwargs) samples = np.asarray(samples) - + # reshape samples here if samples.ndim > 0 and samples.shape[0] == 1 and size_tup == (1,): if (len(samples.shape) > len(dist_shape) and @@ -1009,4 +1010,5 @@ def generate_samples(generator, *args, **kwargs): size_tup == (1,)) ): samples = samples.reshape(samples.shape[:-1]) + print("samples:",samples) return np.asarray(samples) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index 56351a53c25..92fff99a0ee 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -17,6 +17,7 @@ from scipy import stats import theano.tensor as tt from theano import scan +import numpy as np from pymc3.util import get_variable_name from .continuous import get_tau_sigma, Normal, Flat @@ -293,6 +294,7 @@ def random(self, point=None, size=None): sigma, mu = distribution.draw_values( [self.sigma, self.mu], point=point, size=size ) + return distribution.generate_samples( self._random, sigma=sigma, @@ -309,8 +311,14 @@ def _random(self, sigma, mu, size, sample_shape): else: axis = 0 rv = stats.norm(mu, sigma) - data = rv.rvs(size).cumsum(axis=axis) - data = data - data[0] # TODO: this should be a draw from `init`, if available + if len(size) == 1: + data = rv.rvs(size).cumsum(axis=axis) + data = data - data[0] # TODO: this should be a draw from `init`, if available + else: + data = np.empty(size) + for i in range(size[0]): + data[i]=rv.rvs((size[1],)).cumsum(axis=axis) + data[i]=data[i] - data[i][0] return data def _repr_latex_(self, name=None, dist=None): diff --git a/pymc3/sampling.py b/pymc3/sampling.py index 4b76cb8184b..21ae36c457d 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -1825,6 +1825,7 @@ def sample_prior_predictive( samples. """ model = modelcontext(model) + if vars is None and var_names is None: prior_pred_vars = model.observed_RVs @@ -1842,15 +1843,17 @@ def sample_prior_predictive( else: raise ValueError("Cannot supply both vars and var_names arguments.") vars = cast(TIterable[str], vars) # tell mypy that vars cannot be None here. + if random_seed is not None: np.random.seed(random_seed) names = get_default_varnames(vars_, include_transformed=False) # draw_values fails with auto-transformed variables. transform them later! values = draw_values([model[name] for name in names], size=samples) + data = {k: v for k, v in zip(names, values)} - if data is None: + if data is None: raise AssertionError("No variables sampled: attempting to sample %s" % names) prior = {} # type: Dict[str, np.ndarray] From fbcf9e5bdada4838e41a81c1a61fc8545befc5ac Mon Sep 17 00:00:00 2001 From: Rish001 Date: Thu, 2 Jul 2020 09:29:58 +0530 Subject: [PATCH 02/15] Scaled ._random() to more than 2 dim --- pymc3/distributions/timeseries.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index 92fff99a0ee..2d318a2e209 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -311,14 +311,20 @@ def _random(self, sigma, mu, size, sample_shape): else: axis = 0 rv = stats.norm(mu, sigma) - if len(size) == 1: + if size is None: + data = rv.rvs(size).cumsum(axis=axis) + data = data - data[0] # TODO: this should be a draw from `init`, if available + elif len(size) == 1: data = rv.rvs(size).cumsum(axis=axis) data = data - data[0] # TODO: this should be a draw from `init`, if available else: data = np.empty(size) + list_of_size = list(size) + size_inner_matrix = list_of_size[1:] + size_inner_matrix_tuple = tuple(size_inner_matrix) for i in range(size[0]): - data[i]=rv.rvs((size[1],)).cumsum(axis=axis) - data[i]=data[i] - data[i][0] + data[i]=rv.rvs(size_inner_matrix_tuple).cumsum(axis=axis) + data[i]=data[i] - data[i][0] # TODO: this should be a draw from `init`, if available return data def _repr_latex_(self, name=None, dist=None): From 1218f26a583ff39d214e63d0e01e94a59a654628 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 10:02:58 +0530 Subject: [PATCH 03/15] Fixed the remaining failed testcase --- pymc3/distributions/timeseries.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index 2d318a2e209..a66ab830275 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -317,11 +317,21 @@ def _random(self, sigma, mu, size, sample_shape): elif len(size) == 1: data = rv.rvs(size).cumsum(axis=axis) data = data - data[0] # TODO: this should be a draw from `init`, if available + elif len(size) == 2: + data = np.empty(size) + for i in range(size[0]): + # np.reshape() has been introduced to circumvent the failing test case + # test_distributions_random.py::TestGuassianRandomWalk::test_ + # parameters_1d_shape[5] + # Otherwise, data[i] = rv.rvs((size[1],)).cumsum(axis = axis) works fine. + data[i]=np.reshape(rv.rvs((size[1],1)).cumsum(axis=axis),(size[1])) + data[i]=data[i] - data[i][0] else: data = np.empty(size) list_of_size = list(size) size_inner_matrix = list_of_size[1:] size_inner_matrix_tuple = tuple(size_inner_matrix) + print(size_inner_matrix_tuple) for i in range(size[0]): data[i]=rv.rvs(size_inner_matrix_tuple).cumsum(axis=axis) data[i]=data[i] - data[i][0] # TODO: this should be a draw from `init`, if available From f72626cd00af6881d47795cf19e913fb86d058fa Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 18:33:44 +0530 Subject: [PATCH 04/15] Update pymc3/distributions/distribution.py Co-authored-by: Alexandre ANDORRA --- pymc3/distributions/distribution.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pymc3/distributions/distribution.py b/pymc3/distributions/distribution.py index 3e7500b536a..0abeeb85f71 100644 --- a/pymc3/distributions/distribution.py +++ b/pymc3/distributions/distribution.py @@ -1010,5 +1010,4 @@ def generate_samples(generator, *args, **kwargs): size_tup == (1,)) ): samples = samples.reshape(samples.shape[:-1]) - print("samples:",samples) return np.asarray(samples) From ed6be5861ce05dceff9082081cc29a40b2661bff Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 18:34:20 +0530 Subject: [PATCH 05/15] Update pymc3/distributions/distribution.py Co-authored-by: Alexandre ANDORRA --- pymc3/distributions/distribution.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pymc3/distributions/distribution.py b/pymc3/distributions/distribution.py index 0abeeb85f71..892a6a910c2 100644 --- a/pymc3/distributions/distribution.py +++ b/pymc3/distributions/distribution.py @@ -818,7 +818,6 @@ def _draw_value(param, point=None, givens=None, size=None): if point and hasattr(param, 'model') and param.name in point: return point[param.name] elif hasattr(param, 'random') and param.random is not None: - print(point) return param.random(point=point, size=size) elif (hasattr(param, 'distribution') and hasattr(param.distribution, 'random') and From 8317554411b6589c60da985f27626cf977458eb8 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 18:35:18 +0530 Subject: [PATCH 06/15] Update pymc3/distributions/timeseries.py Co-authored-by: Alexandre ANDORRA --- pymc3/distributions/timeseries.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index a66ab830275..8c96bcdb9a2 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -311,10 +311,7 @@ def _random(self, sigma, mu, size, sample_shape): else: axis = 0 rv = stats.norm(mu, sigma) - if size is None: - data = rv.rvs(size).cumsum(axis=axis) - data = data - data[0] # TODO: this should be a draw from `init`, if available - elif len(size) == 1: + if (size is None) or (len(size) == 1): data = rv.rvs(size).cumsum(axis=axis) data = data - data[0] # TODO: this should be a draw from `init`, if available elif len(size) == 2: From 5aaa0e17d99f8e95e92e8300cc81addb798ac580 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 19:43:57 +0530 Subject: [PATCH 07/15] Formatting issues fixed --- pymc3/distributions/timeseries.py | 7 ++++++- pymc3/sampling.py | 5 +---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index 8c96bcdb9a2..f85526ca842 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -311,6 +311,12 @@ def _random(self, sigma, mu, size, sample_shape): else: axis = 0 rv = stats.norm(mu, sigma) + # On invoking .rvs(size) method where size is a 2 dimensional + # tuple like (500,10), the individual instantiations of the + # resultant matrix of random variables depict strange correlation + # instead of being random. + # Ref: https://github.com/scipy/scipy/issues/12482 + if (size is None) or (len(size) == 1): data = rv.rvs(size).cumsum(axis=axis) data = data - data[0] # TODO: this should be a draw from `init`, if available @@ -328,7 +334,6 @@ def _random(self, sigma, mu, size, sample_shape): list_of_size = list(size) size_inner_matrix = list_of_size[1:] size_inner_matrix_tuple = tuple(size_inner_matrix) - print(size_inner_matrix_tuple) for i in range(size[0]): data[i]=rv.rvs(size_inner_matrix_tuple).cumsum(axis=axis) data[i]=data[i] - data[i][0] # TODO: this should be a draw from `init`, if available diff --git a/pymc3/sampling.py b/pymc3/sampling.py index 21ae36c457d..4b76cb8184b 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -1825,7 +1825,6 @@ def sample_prior_predictive( samples. """ model = modelcontext(model) - if vars is None and var_names is None: prior_pred_vars = model.observed_RVs @@ -1843,17 +1842,15 @@ def sample_prior_predictive( else: raise ValueError("Cannot supply both vars and var_names arguments.") vars = cast(TIterable[str], vars) # tell mypy that vars cannot be None here. - if random_seed is not None: np.random.seed(random_seed) names = get_default_varnames(vars_, include_transformed=False) # draw_values fails with auto-transformed variables. transform them later! values = draw_values([model[name] for name in names], size=samples) - data = {k: v for k, v in zip(names, values)} - if data is None: + if data is None: raise AssertionError("No variables sampled: attempting to sample %s" % names) prior = {} # type: Dict[str, np.ndarray] From 89ff0405dbdf3cc002455442bdf8ba3160fb47fa Mon Sep 17 00:00:00 2001 From: Rish001 Date: Sat, 4 Jul 2020 23:52:37 +0530 Subject: [PATCH 08/15] handled value of axis to fix the bug --- pymc3/distributions/timeseries.py | 33 +++++++------------------------ 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index f85526ca842..ae58ca74343 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -309,34 +309,15 @@ def _random(self, sigma, mu, size, sample_shape): if size[len(sample_shape)] == sample_shape: axis = len(sample_shape) else: - axis = 0 + axis = len(size) - 1 rv = stats.norm(mu, sigma) - # On invoking .rvs(size) method where size is a 2 dimensional - # tuple like (500,10), the individual instantiations of the - # resultant matrix of random variables depict strange correlation - # instead of being random. - # Ref: https://github.com/scipy/scipy/issues/12482 - - if (size is None) or (len(size) == 1): - data = rv.rvs(size).cumsum(axis=axis) - data = data - data[0] # TODO: this should be a draw from `init`, if available - elif len(size) == 2: - data = np.empty(size) - for i in range(size[0]): - # np.reshape() has been introduced to circumvent the failing test case - # test_distributions_random.py::TestGuassianRandomWalk::test_ - # parameters_1d_shape[5] - # Otherwise, data[i] = rv.rvs((size[1],)).cumsum(axis = axis) works fine. - data[i]=np.reshape(rv.rvs((size[1],1)).cumsum(axis=axis),(size[1])) - data[i]=data[i] - data[i][0] + data = rv.rvs(size).cumsum(axis=axis) + data = np.array(data) + if len(data.shape)>1: + for i in range(data.shape[0]): + data[i] = data[i] - data[i][0] else: - data = np.empty(size) - list_of_size = list(size) - size_inner_matrix = list_of_size[1:] - size_inner_matrix_tuple = tuple(size_inner_matrix) - for i in range(size[0]): - data[i]=rv.rvs(size_inner_matrix_tuple).cumsum(axis=axis) - data[i]=data[i] - data[i][0] # TODO: this should be a draw from `init`, if available + data = data - data[0] return data def _repr_latex_(self, name=None, dist=None): From c8dfd3da3efb08ffd1894c227a528870781825d8 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Tue, 14 Jul 2020 11:15:09 +0530 Subject: [PATCH 09/15] Documented the change in Release-Notes --- docs/release-notes/pymc3-3.0.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/pymc3-3.0.md b/docs/release-notes/pymc3-3.0.md index 8b137891791..02f72fb98b6 100644 --- a/docs/release-notes/pymc3-3.0.md +++ b/docs/release-notes/pymc3-3.0.md @@ -1 +1,2 @@ - +Changed _random() method of pymc3/distributions.py :: GaussianandomWalk classto fix #3962 +It is temporary fix to be amended in #4010 \ No newline at end of file From d3780a942bce799a1f202f94ff9b7da9b2b37af6 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Tue, 14 Jul 2020 20:00:34 +0530 Subject: [PATCH 10/15] Documented RELEASENOTES --- RELEASE-NOTES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 2f4b7db46b4..b2d282c4098 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,6 +9,7 @@ - Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)). - Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). - Require ArviZ >= 0.9.0 (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). +- Temporarily fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Furthur testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) _NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._ @@ -54,6 +55,8 @@ Though we had to temporarily remove the `docs/*` folder from the tarball due to - Forced the `Beta` distribution's `random` method to generate samples that are in the open interval $(0, 1)$, i.e. no value can be equal to zero or equal to one (issue [#3898](https://github.com/pymc-devs/pymc3/issues/3898) fixed by [#3924](https://github.com/pymc-devs/pymc3/pull/3924)). - Fixed an issue that happened on Windows, that was introduced by the clipped beta distribution rvs function ([#3924](https://github.com/pymc-devs/pymc3/pull/3924)). Windows does not support the `float128` dtype, but we had assumed that it had to be available. The solution was to only support `float128` on Linux and Darwin systems (see issue [#3929](https://github.com/pymc-devs/pymc3/issues/3849) fixed by [#3930](https://github.com/pymc-devs/pymc3/pull/3930)). + + ### Deprecations - Remove `sample_ppc` and `sample_ppc_w` that were deprecated in 3.6. - Deprecated `sd` has been replaced by `sigma` (already in version 3.7) in continuous, mixed and timeseries distributions and now raises `DeprecationWarning` when `sd` is used. (see [#3837](https://github.com/pymc-devs/pymc3/pull/3837) and [#3688](https://github.com/pymc-devs/pymc3/issues/3688)). From ef64f7922791346118791ffaf304842bbdfd64e6 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Wed, 15 Jul 2020 21:12:26 +0530 Subject: [PATCH 11/15] removed text from the docs/release-notes.md/pymc3-3.0.md --- docs/release-notes/pymc3-3.0.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/release-notes/pymc3-3.0.md b/docs/release-notes/pymc3-3.0.md index 02f72fb98b6..e69de29bb2d 100644 --- a/docs/release-notes/pymc3-3.0.md +++ b/docs/release-notes/pymc3-3.0.md @@ -1,2 +0,0 @@ -Changed _random() method of pymc3/distributions.py :: GaussianandomWalk classto fix #3962 -It is temporary fix to be amended in #4010 \ No newline at end of file From a660f3206fb2c32ba3f3217375e5bddad32b1725 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Fri, 24 Jul 2020 19:17:55 +0530 Subject: [PATCH 12/15] Fix typo in release notes and line changes --- RELEASE-NOTES.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index b2d282c4098..0ce876ae878 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,7 +9,7 @@ - Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)). - Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). - Require ArviZ >= 0.9.0 (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). -- Temporarily fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Furthur testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) +- Temporarily fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Further testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) _NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._ @@ -55,8 +55,6 @@ Though we had to temporarily remove the `docs/*` folder from the tarball due to - Forced the `Beta` distribution's `random` method to generate samples that are in the open interval $(0, 1)$, i.e. no value can be equal to zero or equal to one (issue [#3898](https://github.com/pymc-devs/pymc3/issues/3898) fixed by [#3924](https://github.com/pymc-devs/pymc3/pull/3924)). - Fixed an issue that happened on Windows, that was introduced by the clipped beta distribution rvs function ([#3924](https://github.com/pymc-devs/pymc3/pull/3924)). Windows does not support the `float128` dtype, but we had assumed that it had to be available. The solution was to only support `float128` on Linux and Darwin systems (see issue [#3929](https://github.com/pymc-devs/pymc3/issues/3849) fixed by [#3930](https://github.com/pymc-devs/pymc3/pull/3930)). - - ### Deprecations - Remove `sample_ppc` and `sample_ppc_w` that were deprecated in 3.6. - Deprecated `sd` has been replaced by `sigma` (already in version 3.7) in continuous, mixed and timeseries distributions and now raises `DeprecationWarning` when `sd` is used. (see [#3837](https://github.com/pymc-devs/pymc3/pull/3837) and [#3688](https://github.com/pymc-devs/pymc3/issues/3688)). From 710692a7b567b25b1764bc3d2c6acfefff260d00 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Fri, 24 Jul 2020 19:41:57 +0530 Subject: [PATCH 13/15] Fixed the typos in Release notes. Added comments in timeseries.py and fixed the line changes in distributions.py --- pymc3/distributions/distribution.py | 2 +- pymc3/distributions/timeseries.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pymc3/distributions/distribution.py b/pymc3/distributions/distribution.py index 892a6a910c2..1fb199125ca 100644 --- a/pymc3/distributions/distribution.py +++ b/pymc3/distributions/distribution.py @@ -559,7 +559,6 @@ def draw_values(params, point=None, size=None): # draw_values in the context of sample_posterior_predictive ppc_sampler = vectorized_ppc.get(None) if ppc_sampler is not None: - # this is being done inside new, vectorized sample_posterior_predictive return ppc_sampler(params, trace=point, samples=size) @@ -593,6 +592,7 @@ def draw_values(params, point=None, size=None): else: # param still needs to be drawn symbolic_params.append((i, p)) + if not symbolic_params: # We only need to enforce the correct order if there are symbolic # params that could be drawn in variable order diff --git a/pymc3/distributions/timeseries.py b/pymc3/distributions/timeseries.py index ae58ca74343..d5d836b4655 100644 --- a/pymc3/distributions/timeseries.py +++ b/pymc3/distributions/timeseries.py @@ -294,7 +294,6 @@ def random(self, point=None, size=None): sigma, mu = distribution.draw_values( [self.sigma, self.mu], point=point, size=size ) - return distribution.generate_samples( self._random, sigma=sigma, @@ -305,7 +304,11 @@ def random(self, point=None, size=None): ) def _random(self, sigma, mu, size, sample_shape): - """Implement a Gaussian random walk as a cumulative sum of normals.""" + """Implement a Gaussian random walk as a cumulative sum of normals. + axis = len(size) - 1 denotes the axis along which cumulative sum would be calculated. + This might need to be corrected in future when issue #4010 is fixed. + Lines 318-322 ties the starting point of each instance of random walk to 0" + """ if size[len(sample_shape)] == sample_shape: axis = len(sample_shape) else: From 531091fa47a4ba6c384b4d43527d7d82d51f7cf8 Mon Sep 17 00:00:00 2001 From: Rish001 Date: Fri, 24 Jul 2020 21:26:38 +0530 Subject: [PATCH 14/15] Removed temporary from release notes. fixed the line changes --- RELEASE-NOTES.md | 2 +- pymc3/distributions/distribution.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 0ce876ae878..f41b837666b 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,7 +9,7 @@ - Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)). - Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). - Require ArviZ >= 0.9.0 (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). -- Temporarily fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Further testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) +- Fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Further testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) _NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._ diff --git a/pymc3/distributions/distribution.py b/pymc3/distributions/distribution.py index 1fb199125ca..7176fb47add 100644 --- a/pymc3/distributions/distribution.py +++ b/pymc3/distributions/distribution.py @@ -592,7 +592,7 @@ def draw_values(params, point=None, size=None): else: # param still needs to be drawn symbolic_params.append((i, p)) - + if not symbolic_params: # We only need to enforce the correct order if there are symbolic # params that could be drawn in variable order @@ -995,7 +995,7 @@ def generate_samples(generator, *args, **kwargs): else: samples = generator(size=size_tup + dist_bcast_shape, *args, **kwargs) samples = np.asarray(samples) - + # reshape samples here if samples.ndim > 0 and samples.shape[0] == 1 and size_tup == (1,): if (len(samples.shape) > len(dist_shape) and From 8e2bb932446aff6e549626079f17d3e4f3398dc4 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Fri, 24 Jul 2020 18:23:08 +0200 Subject: [PATCH 15/15] Update RELEASE-NOTES.md --- RELEASE-NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f41b837666b..8dccec79378 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,7 +9,7 @@ - Pass the `tune` argument from `sample` when using `advi+adapt_diag_grad` (see issue [#3965](https://github.com/pymc-devs/pymc3/issues/3965), fixed by [#3979](https://github.com/pymc-devs/pymc3/pull/3979)). - Add simple test case for new coords and dims feature in `pm.Model` (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). - Require ArviZ >= 0.9.0 (see [#3977](https://github.com/pymc-devs/pymc3/pull/3977)). -- Fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985].Further testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) +- Fixed issue [#3962](https://github.com/pymc-devs/pymc3/issues/3962) by making change in the `_random()` method of `GaussianRandomWalk` class, refer to PR [#3985]. Further testing revealed a new issue which is being tracked [#4010](https://github.com/pymc-devs/pymc3/issues/4010) _NB: The `docs/*` folder is still removed from the tarball due to an upload size limit on PyPi._