Opened 8 years ago
Last modified 6 years ago
#15711 closed defect
DiscreteHiddenMarkovModel instances do not unpickle correctly — at Version 8
Reported by: | ppurka | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | statistics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Mark Saaltink | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | u/msaaltink/discretehiddenmarkovmodel_instances_do_not_unpickle_correctly (Commits, GitHub, GitLab) | Commit: | aff5bba2bf8fa23788a48cdf84eb4c79f9d47505 |
Dependencies: | Stopgaps: |
Description (last modified by )
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 (8)
comment:1 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:2 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:3 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:4 Changed 6 years ago by
- Branch set to u/msaaltink/discretehiddenmarkovmodel_instances_do_not_unpickle_correctly
comment:5 Changed 6 years ago by
- Commit set to aff5bba2bf8fa23788a48cdf84eb4c79f9d47505
- Status changed from new to needs_review
comment:6 Changed 6 years ago by
comment:7 Changed 6 years ago by
Btw. I could not find your name on https://trac.sagemath.org/wiki, you might want to add it there.
comment:8 Changed 6 years ago by
- Description modified (diff)
Note: See
TracTickets for help on using
tickets.
New commits:
Fixed ticket 15711, unpicking of DiscreteHiddenMarkovModel instances