vprusso / toqito

|toqito> (Theory of Quantum Information Toolkit) in Python :snake:
https://toqito.readthedocs.io/en/latest/
MIT License
155 stars 61 forks source link

Installation issues #150

Closed purva-thakre closed 1 year ago

purva-thakre commented 1 year ago

Installation Instructions

I think the installation instructions for contributors are incomplete.

At this link, contributors have a link for how to clone a GitHub repo etc. But an extra line is missing for installing an editable version, i.e., using pip install -e . in the top-level directory.

I can make a PR for this if it is needed.

Installation Error

Edit : I managed to solve the python version error. But I am not sure how to install an editable version of toqito.

If I use pip install -e ., there's an error error: can not execute 'setup.py' since setuptools is not available in the build environment even though the latest version of setuptools is involved.

Installing collected packages: numpy, cvxopt, scipy, picos, scs, qdldl, ecos, osqp, cvxpy, toqito
  Running setup.py develop for toqito
    error: subprocess-exited-with-error

    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [1 lines of output]
        ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
    ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
vprusso commented 1 year ago

Hi @purva-thakre,

First, thank you for the comment and for checking out the toqito package!

With respect to your questions:

At this link, contributors have a link for how to clone a GitHub repo etc. But an extra line is missing for installing an editable version, i.e., using pip install -e . in the top-level directory.

I can make a PR for this if it is needed.

Sure, if you think that would help contributors, that would be great, thank you!

Edit : I managed to solve the python version error. But I am not sure how to install an editable version of toqito.

If I use pip install -e ., there's an error error: can not execute 'setup.py' since setuptools is not available in the build > environment even though the latest version of setuptools is involved.

Right, the reason this fails is that you are running Python 3.8, and as you correctly mentioned, the toqito project supports Python 3.9+ (as can be seen in the toml file here: https://github.com/vprusso/toqito/blob/master/pyproject.toml

Let me know if that doesn't make sense, and if you have any further questions or comments. Happy to elaborate further. Hope to see a contribution from you for toqito!

purva-thakre commented 1 year ago

Thanks! I plan to work on #141 for unitaryhack.

I was getting that error even after I managed to create a new virtualenv with Python3.9 & setuptools was installed without specifying the version (latest==67.8.0)

If I try to change the version of setuptools to what's specified in pyroject.toml, there's an error.

cvxpy 1.3.1 requires setuptools>65.5.1, but you have setuptools 57.5.0 which is incompatible.
purva-thakre commented 1 year ago

Ok. I think I managed to fix the setuptools is not available in the build environment error. Not sure why it works though because I have a surface-level understanding of how pyproject.toml works. See this comment for more.

When I used pip install -e ., setuptools was being uninstalled during the process even though it was specified in pyrpoject.toml.

If I make the following changes in lines 63 & 69, I don't get the installation error.

image

Edit:

There's also one failing test when I run pytest --cov-report term-missing --cov=toqito tests/ locally.

n = 2, a = 0.5

    @pytest.mark.parametrize("n, a", [(2, 0.5), (2, -0.5), (3, 0.5), (3, -0.5)])
    def test_s1_norm_werner(n, a):
        """Test S(1) norm of a Werner state."""
        rho = werner(n, a)
        # See:
        # N. Johnston.
        # Norms and Cones in the Theory of Quantum Entanglement.
        # PhD thesis (arXiv:1207.1479)
        # Proposition 5.2.10 and Table 5.1
        expected = (1 + abs(min(0, a))) / (n * (n - a))

        lower_bound, upper_bound = sk_operator_norm(rho, k=1)
>       np.testing.assert_equal(np.allclose(lower_bound, expected), True)
E       AssertionError: 
E       Items are not equal:
E        ACTUAL: False
E        DESIRED: True

tests/test_matrix_props/test_sk_norm.py:60: AssertionError
vprusso commented 1 year ago

Great. Happy to incorporate the setuptools change in your diff.

As for the test failure, I've opened a separate issue for that here. Thanks for catching that! https://github.com/vprusso/toqito/issues/151