{"action":"created","issue":{"url":"https://api.github.com/repos/qutip/qutip/issues/385","labels_url":"https://api.github.com/repos/qutip/qutip/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/qutip/qutip/issues/385/comments","events_url":"https://api.github.com/repos/qutip/qutip/issues/385/events","html_url":"https://github.com/qutip/qutip/issues/385","id":114100532,"number":385,"title":"Better documentation of `tensor_contract`","user":{"login":"arnelg","id":2354542,"avatar_url":"https://avatars.githubusercontent.com/u/2354542?v=3","gravatar_id":"","url":"https://api.github.com/users/arnelg","html_url":"https://github.com/arnelg","followers_url":"https://api.github.com/users/arnelg/followers","following_url":"https://api.github.com/users/arnelg/following{/other_user}","gists_url":"https://api.github.com/users/arnelg/gists{/gist_id}","starred_url":"https://api.github.com/users/arnelg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnelg/subscriptions","organizations_url":"https://api.github.com/users/arnelg/orgs","repos_url":"https://api.github.com/users/arnelg/repos","events_url":"https://api.github.com/users/arnelg/events{/privacy}","received_events_url":"https://api.github.com/users/arnelg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-29T17:14:01Z","updated_at":"2015-10-30T08:47:33Z","closed_at":null,"body":"The usage of the `tensor_contract` function is explained in [QuTiP Example: Superoperators, Pauli Basis and Channel Contraction](http://nbviewer.ipython.org/github/qutip/qutip-notebooks/blob/master/examples/example-superop-contract.ipynb).\r\n\r\nIt is explained in terms of the graphical notation in http://arxiv.org/abs/1111.6950. However, there is no figure explaining how the \"tensor wires\" are numbered. In the notebook it says \"Numbering the tensor wires from 0 to 3, this corresponds to a tensor_contract argument of (1, 3).\" But it is not clear what the convention is... does the numbering follow in an anticlockwise fashion, starting with 0 at the top left?\r\n\r\nA figure in the notebook showing the numbering convention would be extremely helpful."},"comment":{"url":"https://api.github.com/repos/qutip/qutip/issues/comments/152462241","html_url":"https://github.com/qutip/qutip/issues/385#issuecomment-152462241","issue_url":"https://api.github.com/repos/qutip/qutip/issues/385","id":152462241,"user":{"login":"cgranade","id":31516,"avatar_url":"https://avatars.githubusercontent.com/u/31516?v=3","gravatar_id":"","url":"https://api.github.com/users/cgranade","html_url":"https://github.com/cgranade","followers_url":"https://api.github.com/users/cgranade/followers","following_url":"https://api.github.com/users/cgranade/following{/other_user}","gists_url":"https://api.github.com/users/cgranade/gists{/gist_id}","starred_url":"https://api.github.com/users/cgranade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgranade/subscriptions","organizations_url":"https://api.github.com/users/cgranade/orgs","repos_url":"https://api.github.com/users/cgranade/repos","events_url":"https://api.github.com/users/cgranade/events{/privacy}","received_events_url":"https://api.github.com/users/cgranade/received_events","type":"User","site_admin":false},"created_at":"2015-10-30T08:47:33Z","updated_at":"2015-10-30T08:47:33Z","body":"Looking into the issue in more detail, I think that the documentation wasn't just misleading but wrong: because QuTiP uses the column-stacking notation, the order of ``dims`` for ``type='super'`` doesn't have the same meaning as for ``type='oper'`` or for vectors. In particular, the column-stacking basis maps |i><j| to |j> |i>, such that the order of the tensor indices for superoperators is swapped from the ordering ``[left, right]`` that is used by QuTiP's ``dims`` notation. I'll break this out into another Issue, but I think the simplest way of handling it is to keep ``dims`` the same as it is now (I don't want to break that, for crying out loud), but to transform the arguments to ``_tensor_contract_dense`` if the order of ``dims`` doesn't match the order that we need to pass to ``np.reshape``."}}