Opened 8 years ago

Last modified 6 years ago

#15711 closed defect

DiscreteHiddenMarkovModel instances do not unpickle correctly — at Initial Version

Reported by: ppurka Owned by:
Priority: major Milestone: sage-6.4
Component: statistics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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)

Change History (0)

Note: See TracTickets for help on using tickets.