Closed ihincks closed 8 years ago
62 files changed 95 commits
Great work on the PR Ian. Ian has made fairly reasonable arguments to me that these changes should be included in V1.0
On Tue, Aug 16, 2016 at 5:53 PM, Steven Casagrande <notifications@github.com
wrote:
62 files changed 95 commits
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/QInfer/python-qinfer/pull/71#issuecomment-240251337, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe1tqbKQujPtyeumVjwCLcg9Jm8XzMyks5qgjFMgaJpZM4Jly8n .
Now that I'm back from travel, trying to catch up on PRs, I apologize for the delay and thank you for your wonderful contribution. master
should now be much more up to date after merging in the other PRs; could you please merge those in? Thank you again! ♥
Thanks Chris! Hopefully this won't be too painful. I'll get on it.
git merge upstream/master
crosses fingers
Oh, that was actually pretty easy. The tests seem to be failing because qutip isn't being imported in one of the new tomography model tests and so what should be the qutip module is actually None
. I don't presently know enough about how these tests work to fix this...they pass on my computer.
This PR should probably also include a guide on outcomes. I was pretty careful going through inline documentation making sure it still made sense, but it's possible some of the examples or guides need to deal with outcomes.
@whitewhim2718 pointed out that in tomography
, version >=3.1
of qutip was required. However, in version 3.1, functions like rand_dm_ginibre
do not exist. The newest commit demands qutip version >=3.2
across the board for use with tomography.
I'm not sure if this is the right thing to do because 3.1 is the highest official release of qutip, though it is quite old (2014).
This fix is independent of travis-ci not having qutip at all.
I think depending on QuTiP 3.2 prereleases is fine, since as you point out, it is quite old, and as the official 3.2 is scheduled to come out very soon. In particular, many of the features such as rand_dm_ginibre
were contributed to QuTiP precisely for QInfer tomography support.
After thinking on it for the weekend, I think the best way forward with this PR is for me to git cherry-pick
the QuTiP CI configuration and 3.2 requirements into a separate PR so that I can test them separately. If that works, that will make the rest of the PR much easier to merge in.
Okay, added a skipIf
to the TestTomographyModel
. Thanks for pointing out this feature, @cgranade .
I think this looks really good! Thanks for everything with this PR. I want to go through in a bit more detail, as well as discuss w/ @csferrie, but I think this is nearly ready to merge in.
Looking in more detail, I had a bit of confusion about the roles of the new properties and methods (in particular, domain
) in relation to previous interfaces (e.g.: n_outcomes
). Would you be willing to add a bit to doc/guide/models.rst
describing the changed interfaces? If not, I'm also happy to work my way through it and write said docs. Thanks for the huge contribution!
The role of n_outcomes
is definitely something that deserves attention. In this PR, n_outcomes
is completely independent of domain
. I will explain in detail later. In short, part of the problem is wanting to keep a property called n_outcomes
in the new system that means for FiniteOutcomeModel
what it did for Model
before this PR. For finite-outcome models, it will typically hold that n_outcomes(expparam)=domain(expparam).n_members
. For models with an infinite number of outcomes (or a very large number of outcomes such that enumerating them is painful), n_members
is not defined, but n_outcomes
sort of refers to "enough outcomes" to make estimates of properties like Bayes' risk.
(But yes, I will add to the guide)
Ah, that makes a lot more sense, then. Thank you for the explanation, and for all the help!
Py2.7 is having a problem due to the print
statement that I have commented on. Conda 3.5 has an issue with the doctests.
As a reminder though for everyone, a PR of this magnitude is impossible to code review (and thus, I haven't looked over the actual implementation). Future work should be done in as small of chunks as possible. It keeps thing reviewable, reduces churn, and helps prevent the problem where peoples' local code branches too heavily from master, creating massive merge conflicts.
Thanks for catching that forgotten print statement @scasagrande.
I agree that this PR is big. At the same time, it really does affect all of these files: if you add some methods and properties to a fundamental abstract class, you gotta fix everything that inherits from it. And then I introduced more than 100 tests involving all inheriting classes to try to minimize errors.
There is always ways to split the work up, and part of learning to work on a code base with a team is submitting code-review-able PRs. This might involve a number of PRs merged into a staging branch before merging into a primary branch.
Some ideas on how to slice large base changes like this:
To give you an idea, at work, the worst case we had was when we had to rewrite this massive file. It was pure refactoring work, but had to be done so that our actual work could be implemented (so one degree of PR-splitting already). We had to change it from being some all-knowing god-object into using proper dependency injection. We split it as much as we could (one PR for new tests, one for the refactoring) but it was still ugly to review.
This is a beefy PR addressing issue #66. The nutshell improvement is that we want experiment outcomes to be able to have fancy data types (like expparams), and to be compatible with future improvements that lift the constraint that any experiment must have a finite number of possible outcomes (this constraint comes in the form of some methods like bayes_risk enumurating over all possible outcomes).
This is handled as follows:
Domains
, not much to it, just tells you stuff like whether it's finite and is able to spit out values in the domain. This comes with obvious subclasses likeIntegerDomain
andRealDomain
.domain(self, expparam)
ofSimulateable
, returning aDomain
for every set of expparms.FiniteOutcomeModel
ofModel
which can have outcome-enumerating methodsare_expparam_dtypes_consistent
tells you if all the expparams correspond to the same datatype)Handling breaking changes:
There are two breaking changes, and they're both very easy to fix on existing models. You need to inherit from
FiniteOutcomeModel
instead ofModel
, and you need to implement thedomain
method, returning for exampleIntegerDomain(min=0, max=1)
for a two outcome model. Another thing that comes up is thatModel.pr0_to_likelihood_array
is moved toFiniteOutcomeModel.pr0_to_likelihood_array
.New Features
MultinomialModel
(which requires fancy outcome data type which is a tuple of results) which generalizesBinomialModel
.TODO
NOTES
I pulled in the feature-improved-docs because it would be confusing for me not to.