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

DiscreteHiddenMarkovModel instances do not unpickle correctly #15711

Closed
ppurka opened this issue Jan 22, 2014 · 11 comments
Closed

DiscreteHiddenMarkovModel instances do not unpickle correctly #15711

ppurka opened this issue Jan 22, 2014 · 11 comments

Comments

@ppurka
Copy link
Member

ppurka commented Jan 22, 2014

From the google notebook bug reports

*As you can see in the following script, even though an unpickled instance claims to be equal to the original, it behaves differently. Worse, several of the functions (e.g., M2.transition_matrix()) throw exceptions, and an exception is thrown if you just try to print the object's value. *

sage: from sage.stats.hmm.hmm import DiscreteHiddenMarkovModel
sage: M = DiscreteHiddenMarkovModel([[1.0]], [[0.1, 0.9]], [1.0])
sage: import pickle
sage: M2 = pickle.loads(pickle.dumps(M))
sage: M2 == M
True
sage: M.log_likelihood([1]*4)
-0.4214420626313051
sage: M2.log_likelihood([1]*4)
-inf
sage: M2.emission_matrix()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-24-2ee08778d25e> in <module>()
----> 1 M2.emission_matrix()

/opt/sage-5.12-linux-64bit-fedora_release_16_verne-x86_64-Linux/local/lib/python2.7/site-packages/sage/stats/hmm/hmm.so in sage.stats.hmm.hmm.DiscreteHiddenMarkovModel.emission_matrix (sage/stats/hmm/hmm.c:2760)()

/opt/sage-5.12-linux-64bit-fedora_release_16_verne-x86_64-Linux/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in _matrix_constructor(*args, **kwds)
641 raise ValueError, "entries has the wrong length"
642 elif len(args[0]) > 0:
--> 643 raise ValueError, "entries has the wrong length"
644 
645 entries = args[0]

ValueError: entries has the wrong length

sage: M2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-13669956a766> in <module>()
... (long trace deleted)

Component: statistics

Author: Mark Saaltink

Branch/Commit: ddbc327

Reviewer: Julian Rüth

Issue created by migration from https://trac.sagemath.org/ticket/15711

@ppurka ppurka added this to the sage-6.1 milestone Jan 22, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@sagetrac-msaaltink
Copy link
Mannequin

sagetrac-msaaltink mannequin commented Nov 14, 2016

@sagetrac-msaaltink
Copy link
Mannequin

sagetrac-msaaltink mannequin commented Nov 14, 2016

New commits:

aff5bbaFixed ticket 15711, unpicking of DiscreteHiddenMarkovModel instances

@sagetrac-msaaltink
Copy link
Mannequin

sagetrac-msaaltink mannequin commented Nov 14, 2016

Commit: aff5bba

@saraedum
Copy link
Member

Author: Mark Saaltink

@saraedum
Copy link
Member

comment:7

Btw. I could not find your name on https://trac.sagemath.org/wiki, you might want to add it there.

@saraedum

This comment has been minimized.

@saraedum
Copy link
Member

Changed commit from aff5bba to ddbc327

@saraedum
Copy link
Member

comment:10

I tweaked the docstring a bit. If you are fine with this, feel free to set it to positive review yourself.


New commits:

ddbc327Set indirect test in the correct lines

@saraedum
Copy link
Member

Reviewer: Julian Rüth

@vbraun
Copy link
Member

vbraun commented Nov 19, 2016

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

No branches or pull requests

3 participants