Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failing, possibly because of changes to scipy optimize (?) #40

Closed
christophmark opened this issue Jun 27, 2022 · 1 comment
Closed

Comments

@christophmark
Copy link
Owner

See here:

=================================== FAILURES ===================================
_____________________ TestTwoParameterModel.test_optimize ______________________
self = <test_study.TestTwoParameterModel object at 0x7fa2fc813610>
    def test_optimize(self):
        # carry out fit
        S = bl.Study()
        S.loadData(np.array([1, 2, 3, 4, 5]))
        S.setOM(bl.om.Gaussian('mean', bl.cint(0, 6, 20), 'sigma', bl.oint(0, 2, 20), prior=lambda m, s: 1/s**3))
        T = bl.tm.CombinedTransitionModel(bl.tm.GaussianRandomWalk('sigma', 1.07, target='mean'),
                                          bl.tm.RegimeSwitch('log10pMin', -3.90))
        S.setTM(T)
        S.optimize()
        # test parameter distributions
>       np.testing.assert_allclose(S.getParameterDistributions('mean', density=False)[1][:, 5],
                                   [4.525547e-04, 1.677968e-03, 2.946498e-07, 1.499508e-08, 1.102637e-09],
                                   rtol=1e-05, err_msg='Erroneous posterior distribution values.')
E       AssertionError: 
E       Not equal to tolerance rtol=1e-05, atol=0
E       Erroneous posterior distribution values.
E       Mismatched elements: 5 / 5 (100%)
E       Max absolute difference: 6.48028681e-08
E       Max relative difference: 0.00072859
E        x: array([4.525729e-04, 1.677903e-03, 2.945258e-07, 1.498415e-08,
E              1.102384e-09])
E        y: array([4.525547e-04, 1.677968e-03, 2.946498e-07, 1.499508e-08,
E              1.102637e-09])
test_study.py:330: AssertionError
----------------------------- Captured stdout call -----------------------------
+ Created new study.
+ Successfully imported array.
+ Observation model: Gaussian observations. Parameter(s): ['mean', 'sigma']
+ Transition model: Combined transition model. Hyper-Parameter(s): ['sigma', 'log10pMin']
+ Starting optimization...
  --> All model parameters are optimized (except change/break-points).
    + Log10-evidence: -3.47897 - Parameter values: [ 1.07 -3.9 ]
    + Log10-evidence: -3.75097 - Parameter values: [ 2.07 -3.9 ]
    + Log10-evidence: -3.48400 - Parameter values: [ 1.07 -2.9 ]
    + Log10-evidence: -6.94856 - Parameter values: [ 0.07017134 -3.91851083]
    + Log10-evidence: -4.399[24](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:25) - Parameter values: [ 0.57008567 -3.909[25](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:26)542]
    + Log10-evidence: -3.52186 - Parameter values: [ 1.31999906 -3.90068388]
    + Log10-evidence: -3.47888 - Parameter values: [ 1.06965806 -4.02499953]
    + Log10-evidence: -3.59705 - Parameter values: [ 0.81965823 -4.02529235]
    + Log10-evidence: -3.49207 - Parameter values: [ 1.19465698 -4.02551875]
    + Log10-evidence: -3.48383 - Parameter values: [ 1.00715847 -4.02522561]
    + Log10-evidence: -3.47981 - Parameter values: [ 1.1009061  -4.02534994]
    + Log10-evidence: -3.47888 - Parameter values: [ 1.06948286 -4.04062355]
    + Log10-evidence: -3.48005 - Parameter values: [ 1.03823334 -4.04079793]
    + Log10-evidence: -3.47909 - Parameter values: [ 1.08510319 -4.04100528]
    + Log10-evidence: -3.47890 - Parameter values: [ 1.06167279 -4.04081835]
    + Log10-evidence: -3.47888 - Parameter values: [ 1.07332013 -4.04135437]
    + Log10-evidence: -3.47888 - Parameter values: [ 1.06911745 -4.04254219]
    + Log10-evidence: -3.47883 - Parameter values: [ 1.06570473 -4.0396313 ]
    + Log10-evidence: -3.47889 - Parameter values: [ 1.06187307 -4.03887159]
    + Log10-evidence: -3.47889 - Parameter values: [ 1.06666122 -4.03792841]
    + Log10-evidence: -3.47890 - Parameter values: [ 1.06608651 -4.04154675]
    + Log10-evidence: -3.47884 - Parameter values: [ 1.0647419  -4.03946811]
    + Log10-evidence: -3.47883 - Parameter values: [ 1.06578141 -4.04011352]
    + Log10-evidence: -3.47890 - Parameter values: [ 1.06602252 -4.04007519]
    + Log10-evidence: -3.47884 - Parameter values: [ 1.06529985 -4.0401943 ]
    + Log10-evidence: -3.47890 - Parameter values: [ 1.06602539 -4.04012232]
    + Log10-evidence: -3.47883 - Parameter values: [ 1.06568278 -4.04013005]
    + Log10-evidence: -3.47890 - Parameter values: [ 1.06578967 -4.04016284]
    + Log10-evidence: -3.47883 - Parameter values: [ 1.0657657  -4.04001477]
+ Finished optimization.
+ Started new fit:
    + Formatted data.
    + Set prior (function): <lambda>. Values have been re-normalized.
    + Finished forward pass.
    + Log10-evidence: -3.47883
    + Finished backward pass.
    + Computed mean parameter values.
----------------------------- Captured stderr call -----------------------------
  0%|          | 0/5 [00:00<?, ?it/s]
100%|██████████| 5/5 [00:00<00:00, 6[26](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:27)0.16it/s]
  0%|          | 0/5 [00:00<?, ?it/s]
100%|██████████| 5/5 [00:00<00:00, 51[32](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:33).[53](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:54)it/s]
=============================== warnings summary ===============================
../../../../../../opt/hostedtoolcache/Python/3.8.12/x[64](https://github.com/christophmark/bayesloop/runs/7068584434?check_suite_focus=true#step:5:65)/lib/python3.8/site-packages/bayesloop/core.py:23
  /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayesloop/core.py:23: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    from collections import OrderedDict, Iterable
../../../../../../opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayesloop/transitionModels.py:15
  /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayesloop/transitionModels.py:15: DeprecationWarning: Please use `gaussian_filter1d` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.
    from scipy.ndimage.filters import gaussian_filter1d
../../../../../../opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayesloop/transitionModels.py:16
  /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayesloop/transitionModels.py:16: DeprecationWarning: Please use `shift` from the `scipy.ndimage` namespace, the `scipy.ndimage.interpolation` namespace is deprecated.
    from scipy.ndimage.interpolation import shift
@christophmark
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant