sandialabs / pyGSTi

A python implementation of Gate Set Tomography
http://www.pygsti.info
Apache License 2.0
132 stars 55 forks source link

Docstring for QuditProcessorSpec has mistake for "availability" #400

Open rileyjmurray opened 5 months ago

rileyjmurray commented 5 months ago

Describe the bug The docstring for QuditProcessorSpec has a mistake for the "availability" keyword argument. The existing code is ...

https://github.com/sandialabs/pyGSTi/blob/2d4fe845fca84bc10adc2625947ddd3679abece2/pygsti/processors/processorspec.py#L85-L94

The relevant substring in the docstring is

   If a gate name is not present in `availability`, the default is `"all-permutations"`.  So, the availability of a gate
   only needs to be specified when it cannot act in every valid way on the qubits (e.g., the device does not have
   all-to-all connectivity).

I'm not sure what the actual behavior is, but I've given code below which shows that the behavior is different from the docstring.

To Reproduce

import numpy as np
import pygsti as pg
from pygsti.processors import QuditProcessorSpec
from pygsti.models import create_explicit_model
import scipy

gate_names=['Gxpi2', 'Gypi2']
Uxpi2 = np.asarray(np.bmat([[scipy.linalg.expm(-1j/2 * np.pi/2 * pg.sigmax),np.zeros((2,1))],
                 [np.zeros((1,2)),np.array([[1]])]]))
Uypi2 = np.asarray(np.bmat([[scipy.linalg.expm(-1j/2 * np.pi/2 * pg.sigmay),np.zeros((2,1))],
                 [np.zeros((1,2)),np.array([[1]])]]))

qps = QuditProcessorSpec(
    qudit_labels=[0], 
    qudit_udims=[3],
    gate_names=['Gxpi2', 'Gypi2'],
    nonstd_gate_unitaries={'Gxpi2':Uxpi2,'Gypi2':Uypi2}
    #,availability={'Gxpi2':[0], 'Gypi2':[0]} 
)
# the next line errors if (and only if) you keep the "availability" keyword arg commented out
model = create_explicit_model(qps,  ideal_spam_type='full pure',  ideal_gate_type='full TP', basis='gm')

Expected behavior The behavior described in the docstring.

sserita commented 3 months ago

@rileyjmurray What version of pyGSTi were you running this on? I'm trying to reproduce on current develop and failing to do so (both commenting/uncommenting the availability line succeed).

rileyjmurray commented 2 months ago

Sorry for the slow response, @sserita.

I used a permalink to the version of the code I was running. It points to a specific commit on develop. Here's a permalink to the state of the whole pyGSTi repo at the relevant commit https://github.com/sandialabs/pyGSTi/tree/690542693c4fe23afb1d7995058660ed9e989457.