Error when performing sampling algorithm

Hey! I am trying to run torontonian_sample_graph(An,q, cutoff=3) (where An is my adjacency matrix and q is my mean photon number) but getting this error “TypeError: torontonian_sample_graph() got an unexpected keyword argument ‘cutoff’”.

Apart from that, I tried hafnian_sample_graph but got this error “IndexError: index 1 is out of bounds for axis 0 with size 1”

Hi @MUSHKAN_SUREKA, I think the issue is the version of TheWalrus that you’re using.

Version 0.19 doesn’t include cutoff as an argument while the development version (0.20) does.

Since you need to include the cutoff you should use the development version, although your code may break somewhere else since this isn’t the latest stable version.

As per your second question I think the issue may again ve the version you’re using.

I hope this helps!

Hey! How to update my version to the development one?

I ran !pip install thewalrus and it only installs 0.19 :confused:

Hi @MUSHKAN_SUREKA,

You can compile the latest development version by cloning the git repository, and installing using pip in development mode.

git clone https://github.com/XanaduAI/thewalrus.git
cd thewalrus && python -m pip install -e . 

You can find the development version of the documentation at
https://the-walrus.readthedocs.io/en/latest/

Please let me know if you have any trouble or if this works for you!

when I run the 2nd line, I get No such file or directory: ‘thewalrus && python -m pip install -e’
/Users/Mushkan/Desktop

when I run both commands separately, I get- File “”, line 1

  • python -m pip install -e*
  •          ^*
    

SyntaxError: invalid syntax

Hey @MUSHKAN_SUREKA! Make sure you include the period:

python -m pip install -e .

got it! Running setup.py develop for thewalrus
Successfully installed thewalrus

I got this but now if I run print(thewalrus.version) it still shows 0.19.0

still getting TypeError: torontonian_sample_graph() got an unexpected keyword argument ‘cutoff’ but I guess the version is still 0.19.0 I dont know why :confused:

Hi @MUSHKAN_SUREKA

This pip install git+https://github.com/XanaduAI/thewalrus.git will do the trick.

Then as a sanity check open an interpreter and execute

import thewalrus as tw
tw.about()

and check if the correct version is installed.

still getting 0.19.0 :confused:

ImportError: cannot import name ‘coo_array’ from ‘scipy.sparse’ (/Users/Mushkan/opt/anaconda3/lib/python3.8/site-packages/scipy/sparse/init.py)

this error

okay it is working now! thanks!

I’m glad this is working now @MUSHKAN_SUREKA!