Skip to content

Commit 7c83364

Browse files
authored
Merge pull request #530 from sandialabs/bugfix-pep-625-compat
PEP 503/625 compliance and various GitHub action updates, including MPI on Windows, bumping Python versions to 3.9 - 3.12, and moving to latest Mac runners.
2 parents 962216e + 206d396 commit 7c83364

21 files changed

+212
-258
lines changed

.github/workflows/beta-master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: [macos-13, ubuntu-latest, windows-latest] # TODO: Unpin mac version when cvxopt or Python 3.8 dropped
17-
python-version: [3.8, 3.9, '3.10', '3.11']
16+
os: [macos-latest, ubuntu-latest, windows-latest]
17+
python-version: [3.9, '3.10', '3.11', '3.12']
1818
use-cython: ['true', 'false']
1919
uses: ./.github/workflows/reuseable-main.yml
2020
name: Run pyGSTi tests

.github/workflows/develop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-latest, windows-latest] # No Mac
18-
python-version: [3.8, 3.9, '3.10', '3.11']
18+
python-version: [3.9, '3.10', '3.11', '3.12']
1919
use-cython: ['true', 'false']
2020
uses: ./.github/workflows/reuseable-main.yml
2121
name: Run pyGSTi tests

.github/workflows/feature-branches.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
strategy:
1919
# fail-fast: true is OK here
2020
matrix:
21-
os: [ubuntu-latest, windows-latest] # No Mac
22-
python-version: [3.8, '3.11'] # Only extremal Python versions
21+
os: [ubuntu-latest, windows-latest]
22+
python-version: [3.9, '3.12'] # Only extremal Python versions
2323
uses: ./.github/workflows/reuseable-main.yml
2424
name: Run pyGSTi tests
2525
with:
@@ -28,7 +28,7 @@ jobs:
2828
use-cython: 'true' # Only test environment with Cython
2929
run-unit-tests: 'true'
3030
run-extra-tests: 'false' # No integration tests
31-
run-notebook-tests: 'false' # No notebook tests
31+
run-notebook-tests: 'false' # No notebook tests
3232

3333

3434

.github/workflows/reuseable-main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ jobs:
3434
runs-on: ${{ inputs.os }}
3535
steps:
3636
- uses: actions/checkout@v4
37-
- name: Set up installation environment (Linux and Windows)
38-
if: ${{ inputs.os != 'macos-13' }}
37+
- name: Set up installation environment (Linux)
38+
if: ${{ inputs.os == 'ubuntu-latest' }}
3939
run: |
4040
./.github/ci-scripts/before_install.sh
4141
- name: Set up installation environment (MacOS)
42-
if: ${{ inputs.os == 'macos-13' }}
42+
if: ${{ inputs.os == 'macos-latest' }}
4343
run: |
4444
./.github/ci-scripts/before_install_macos.sh
45+
- name: Set up MPI (Windows)
46+
if: ${{ inputs.os == 'windows-latest' }}
47+
uses: mpi4py/setup-mpi@v1
48+
with:
49+
mpi: intelmpi
4550
- name: Set up Python ${{ inputs.python-version }}
4651
uses: actions/setup-python@v5
4752
with:

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include README.md CONTRIBUTING.md LICENSE
2-
include pyproject.toml pyproject.toml.no_cython
2+
include pyproject.toml
33
include install_locally.py
44
include requirements.txt
55
include optional-requirements.txt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ In particular, there are a number of characterization protocols currently implem
3636

3737
PyGSTi is designed with a modular structure so as to be highly customizable
3838
and easily integrated to new or existing python software. It runs using
39-
python 3.8 or higher. To faclilitate integration with software for running
39+
python 3.9 or higher. To faclilitate integration with software for running
4040
cloud-QIP experiments, pyGSTi `Circuit` objects can be converted to IBM's
4141
**OpenQASM** and Rigetti Quantum Computing's **Quil** circuit description languages.
4242

pygsti/baseobjs/label.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def __new__(cls, name, state_space_labels=None, time=None, args=None):
128128

129129
#print(" -> preproc with name=", name, "sslbls=", state_space_labels, "t=", time, "args=", args)
130130
if state_space_labels is None or state_space_labels in ((), (None,)):
131-
if args:
131+
if args is not None:
132132
return LabelTupWithArgs.init(name, (), time, args) # just use empty sslbls
133133
else:
134134
return LabelStr.init(name, time)
135135

136136
else:
137-
if args: return LabelTupWithArgs.init(name, state_space_labels, time, args)
137+
if args is not None: return LabelTupWithArgs.init(name, state_space_labels, time, args)
138138
else:
139139
if time == 0.0:
140140
return LabelTup.init(name, state_space_labels)

pygsti/evotypes/chp/povmreps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _run_chp_ops(self, chp_ops):
5151

5252
# Extract outputs
5353
#print("CHP program out (debug): ", out.decode('utf-8'))
54-
pattern = _re.compile('Outcome of measuring qubit (\d+): (\d)( ?\S*)')
54+
pattern = _re.compile(r'Outcome of measuring qubit (\d+): (\d)( ?\S*)')
5555
matched_values = [] # elements = (qubit_index, outcome, '(random)' or '') tuples
5656
for match in pattern.finditer(out.decode('utf-8')):
5757
matched_values.append((int(match.group(1)), match.group(2), match.group(3)))

pygsti/report/formatters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _no_format(x, specs):
6767
ebstring='%s <span class="errorbar">&plusmn; %s</span>',
6868
nmebstring='%s <span class="nmerrorbar">&plusmn; %s</span>')
6969
NormalLatex = _Formatter(latex,
70-
ebstring='$ \\begin{array}{c} %s \\\\ \pm %s \\end{array} $') # nmebstring will match
70+
ebstring='$ \\begin{array}{c} %s \\\\ \\pm %s \\end{array} $') # nmebstring will match
7171

7272
# Normal replacements
7373
format_dict['Normal'] = {
@@ -186,7 +186,7 @@ def special_convert_latex(x, specs):
186186

187187
format_dict['Vec'] = {
188188
'html': NormalHTML,
189-
'latex': _Formatter(latex, ebstring='%s $\pm$ %s'),
189+
'latex': _Formatter(latex, ebstring='%s $\\pm$ %s'),
190190
'python': _no_format}
191191

192192
format_dict['Circuit'] = {

pygsti/report/html.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ def vector(v, specs):
149149
lines.append(value(el, specs, mathmode=True))
150150
if specs['brackets']:
151151
return "$ \\begin{pmatrix}\n" + \
152-
" \\\\ \n".join(lines) + "\n \end{pmatrix} $\n"
152+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} $\n"
153153
else:
154154
return "$ \\begin{pmatrix}\n" + \
155-
" \\\\ \n".join(lines) + "\n \end{pmatrix} $\n"
155+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} $\n"
156156

157157

158158
def matrix(m, specs):
@@ -177,18 +177,18 @@ def matrix(m, specs):
177177
fontsize = specs['fontsize']
178178

179179
if fontsize is not None:
180-
prefix += "\\fontsize{%f}{%f}\selectfont " % (fontsize, fontsize * 1.2)
180+
prefix += "\\fontsize{%f}{%f}\\selectfont " % (fontsize, fontsize * 1.2)
181181

182182
for r in range(m.shape[0]):
183183
lines.append(" & ".join(
184184
[value(el, specs, mathmode=True) for el in m[r, :]]))
185185

186186
if specs['brackets']:
187187
return prefix + "$ \\begin{pmatrix}\n" + \
188-
" \\\\ \n".join(lines) + "\n \end{pmatrix} $\n"
188+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} $\n"
189189
else:
190190
return prefix + "$ \\begin{pmatrix}\n" + \
191-
" \\\\ \n".join(lines) + "\n \end{pmatrix} $\n"
191+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} $\n"
192192

193193

194194
def value(el, specs, mathmode=False):

pygsti/report/latex.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def table(custom_headings, col_headings_formatted, rows, spec):
5050
and "latex" in custom_headings:
5151
latex = custom_headings['latex']
5252
else:
53-
latex = "\\begin{%s}[l]{%s}\n\hline\n" % \
53+
latex = "\\begin{%s}[l]{%s}\n\\hline\n" % \
5454
(table, "|c" * len(col_headings_formatted) + "|")
55-
latex += ("%s \\\\ \hline\n"
55+
latex += ("%s \\\\ \\hline\n"
5656
% (" & ".join(col_headings_formatted)))
5757

5858
for formatted_rowData in rows:
@@ -82,9 +82,9 @@ def table(custom_headings, col_headings_formatted, rows, spec):
8282
# latex += "\cline{%d-%d} "%(lineStart,col-1)
8383
# latex += "\n"
8484
#else:
85-
latex += " \\\\ \hline\n"
85+
latex += " \\\\ \\hline\n"
8686

87-
latex += "\end{%s}\n" % table
87+
latex += "\\end{%s}\n" % table
8888
return {'latex': latex}
8989

9090

@@ -129,7 +129,7 @@ def list(l, specs):
129129
latex string for l.
130130
"""
131131
return "\\begin{tabular}{c}\n" + \
132-
" \\\\ \n".join(l) + "\n \end{tabular}\n"
132+
" \\\\ \n".join(l) + "\n \\end{tabular}\n"
133133

134134

135135
def vector(v, specs):
@@ -154,10 +154,10 @@ def vector(v, specs):
154154
lines.append(value(el, specs, mathmode=True))
155155
if specs['brackets']:
156156
return "\\ensuremath{ \\begin{pmatrix}\n" + \
157-
" \\\\ \n".join(lines) + "\n \end{pmatrix} }\n"
157+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} }\n"
158158
else:
159159
return "\\ensuremath{ \\begin{pmatrix}\n" + \
160-
" \\\\ \n".join(lines) + "\n \end{pmatrix} }\n"
160+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} }\n"
161161

162162

163163
def matrix(m, specs):
@@ -182,18 +182,18 @@ def matrix(m, specs):
182182
fontsize = specs['fontsize']
183183

184184
if fontsize is not None:
185-
prefix += "\\fontsize{%f}{%f}\selectfont " % (fontsize, fontsize * 1.2)
185+
prefix += "\\fontsize{%f}{%f}\\selectfont " % (fontsize, fontsize * 1.2)
186186

187187
for r in range(m.shape[0]):
188188
lines.append(" & ".join(
189189
[value(el, specs, mathmode=True) for el in m[r, :]]))
190190

191191
if specs['brackets']:
192192
return prefix + "\\ensuremath{ \\begin{pmatrix}\n" + \
193-
" \\\\ \n".join(lines) + "\n \end{pmatrix} }\n"
193+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} }\n"
194194
else:
195195
return prefix + "\\ensuremath{ \\begin{pmatrix}\n" + \
196-
" \\\\ \n".join(lines) + "\n \end{pmatrix} }\n"
196+
" \\\\ \n".join(lines) + "\n \\end{pmatrix} }\n"
197197

198198

199199
def value(el, specs, mathmode=False):
@@ -304,5 +304,5 @@ def escaped(txt, specs):
304304
-------
305305
string
306306
"""
307-
ret = txt.replace("_", "\_")
307+
ret = txt.replace("_", r"\_")
308308
return ret

pygsti/report/reportables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
used primarily in reports, so we refer to these quantities as
1616
"reportables".
1717
"""
18-
import pkgutil
18+
import importlib
1919
import warnings as _warnings
2020

2121
import numpy as _np
@@ -32,7 +32,7 @@
3232
from pygsti.models.explicitmodel import ExplicitOpModel as _ExplicitOpModel
3333

3434

35-
_CVXPY_AVAILABLE = pkgutil.find_loader('cvxpy') is not None
35+
_CVXPY_AVAILABLE = importlib.util.find_spec('cvxpy') is not None
3636

3737
FINITE_DIFF_EPS = 1e-7
3838

pygsti/report/workspacetables.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,10 +2213,10 @@ def _create(self, model, confidence_region_info, show_axis_angle_err_bars):
22132213
formatters = [None] * nCols
22142214

22152215
table = "tabular"
2216-
latex_head = "\\begin{%s}[l]{%s}\n\hline\n" % (table, "|c" * nCols + "|")
2216+
latex_head = "\\begin{%s}[l]{%s}\n\\hline\n" % (table, "|c" * nCols + "|")
22172217
latex_head += "\\multirow{2}{*}{Gate} & \\multirow{2}{*}{Angle} & " + \
2218-
"\\multicolumn{%d}{c|}{Angle between Rotation Axes} \\\\ \cline{3-%d}\n" % (len(opLabels), nCols)
2219-
latex_head += " & & %s \\\\ \hline\n" % (" & ".join(map(str, opLabels)))
2218+
"\\multicolumn{%d}{c|}{Angle between Rotation Axes} \\\\ \\cline{3-%d}\n" % (len(opLabels), nCols)
2219+
latex_head += " & & %s \\\\ \\hline\n" % (" & ".join(map(str, opLabels)))
22202220

22212221
table = _ReportTable(colHeadings, formatters,
22222222
custom_header={'latex': latex_head}, confidence_region_info=confidence_region_info)
@@ -2834,8 +2834,8 @@ def _create(self, xs, circuits_by_x, model_by_x, dataset, objfn_builder, x_label
28342834
if objfn_builder == "chi2" or (isinstance(objfn_builder, _objfns.ObjectiveFunctionBuilder)
28352835
and objfn_builder.cls_to_build == _objfns.Chi2Function):
28362836
colHeadings = {
2837-
'latex': (x_label, '$\\chi^2$', '$k$', '$\\chi^2-k$', '$\sqrt{2k}$',
2838-
'$N_\\sigma$', '$N_s$', '$N_p$', 'Rating'),
2837+
'latex': (x_label, r'$\chi^2$', '$k$', r'$\chi^2-k$', r'$\sqrt{2k}$',
2838+
r'$N_\sigma$', '$N_s$', '$N_p$', 'Rating'),
28392839
'html': (x_label, '&chi;<sup>2</sup>', 'k', '&chi;<sup>2</sup>-k',
28402840
'&radic;<span style="text-decoration:overline;">2k</span>',
28412841
'N<sub>sigma</sub>', 'N<sub>s</sub>', 'N<sub>p</sub>', 'Rating'),
@@ -2845,8 +2845,8 @@ def _create(self, xs, circuits_by_x, model_by_x, dataset, objfn_builder, x_label
28452845
elif objfn_builder == "logl" or (isinstance(objfn_builder, _objfns.ObjectiveFunctionBuilder)
28462846
and objfn_builder.cls_to_build == _objfns.PoissonPicDeltaLogLFunction):
28472847
colHeadings = {
2848-
'latex': (x_label, '$2\Delta\\log(\\mathcal{L})$', '$k$', '$2\Delta\\log(\\mathcal{L})-k$',
2849-
'$\sqrt{2k}$', '$N_\\sigma$', '$N_s$', '$N_p$', 'Rating'),
2848+
'latex': (x_label, r'$2\Delta\log(\mathcal{L})$', '$k$', r'$2\Delta\log(\mathcal{L})-k$',
2849+
r'$\sqrt{2k}$', r'$N_\sigma$', '$N_s$', '$N_p$', 'Rating'),
28502850
'html': (x_label, '2&Delta;(log L)', 'k', '2&Delta;(log L)-k',
28512851
'&radic;<span style="text-decoration:overline;">2k</span>',
28522852
'N<sub>sigma</sub>', 'N<sub>s</sub>', 'N<sub>p</sub>', 'Rating'),
@@ -2948,9 +2948,9 @@ def _create(self, circuit_lists, titles, num_cols, common_title):
29482948
else:
29492949
table = "tabular"
29502950
colHeadings = ('\\#',) + tuple(titles)
2951-
latex_head = "\\begin{%s}[l]{%s}\n\hline\n" % (table, "|c" * len(colHeadings) + "|")
2952-
latex_head += " & \multicolumn{%d}{c|}{%s} \\\\ \hline\n" % (len(colHeadings) - 1, common_title)
2953-
latex_head += "%s \\\\ \hline\n" % (" & ".join(colHeadings))
2951+
latex_head = "\\begin{%s}[l]{%s}\n\\hline\n" % (table, "|c" * len(colHeadings) + "|")
2952+
latex_head += " & \\multicolumn{%d}{c|}{%s} \\\\ \\hline\n" % (len(colHeadings) - 1, common_title)
2953+
latex_head += "%s \\\\ \\hline\n" % (" & ".join(colHeadings))
29542954

29552955
colHeadings = ('#',) + tuple(titles)
29562956
html_head = '<table class="%(tableclass)s" id="%(tableid)s" ><thead>'
@@ -3149,9 +3149,9 @@ def _create(self, metric, models, target_models, titles,
31493149
#html_head += "</thead><tbody>"
31503150

31513151
if table_title:
3152-
latex_head = "\\begin{tabular}[l]{%s}\n\hline\n" % ("|c" * nCols + "|")
3153-
latex_head += "\\multicolumn{%d}{c|}{%s} \\\\ \cline{1-%d}\n" % (nCols, table_title, nCols)
3154-
latex_head += " & ".join(colHeadings) + "\\\\ \hline\n"
3152+
latex_head = "\\begin{tabular}[l]{%s}\n\\hline\n" % ("|c" * nCols + "|")
3153+
latex_head += "\\multicolumn{%d}{c|}{%s} \\\\ \\cline{1-%d}\n" % (nCols, table_title, nCols)
3154+
latex_head += " & ".join(colHeadings) + "\\\\ \\hline\n"
31553155

31563156
html_head = '<table class="%(tableclass)s" id="%(tableid)s" ><thead>'
31573157
html_head += '<tr><th colspan="%d">%s</th></tr>\n' % (nCols, table_title)
@@ -3406,8 +3406,8 @@ def _create(self, model, params_dict):
34063406
formatters = ('Bold', 'Bold')
34073407

34083408
#custom latex header for maximum width imposed on 2nd col
3409-
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\hline\n"
3410-
latex_head += "\\textbf{Quantity} & \\textbf{Value} \\\\ \hline\n"
3409+
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\\hline\n"
3410+
latex_head += "\\textbf{Quantity} & \\textbf{Value} \\\\ \\hline\n"
34113411
table = _ReportTable(colHeadings, formatters,
34123412
custom_header={'latex': latex_head})
34133413

@@ -3513,8 +3513,8 @@ def _get_package_version(module_name):
35133513
formatters = ('Bold', 'Bold')
35143514

35153515
#custom latex header for maximum width imposed on 2nd col
3516-
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\hline\n"
3517-
latex_head += "\\textbf{Quantity} & \\textbf{Value} \\\\ \hline\n"
3516+
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\\hline\n"
3517+
latex_head += "\\textbf{Quantity} & \\textbf{Value} \\\\ \\hline\n"
35183518
table = _ReportTable(colHeadings, formatters,
35193519
custom_header={'latex': latex_head})
35203520

@@ -3583,8 +3583,8 @@ def _create(self, profiler, sort_by):
35833583
formatters = ('Bold', 'Bold')
35843584

35853585
#custom latex header for maximum width imposed on 2nd col
3586-
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\hline\n"
3587-
latex_head += "\\textbf{Label} & \\textbf{Time} (sec) \\\\ \hline\n"
3586+
latex_head = "\\begin{tabular}[l]{|c|p{3in}|}\n\\hline\n"
3587+
latex_head += "\\textbf{Label} & \\textbf{Time} (sec) \\\\ \\hline\n"
35883588
table = _ReportTable(colHeadings, formatters,
35893589
custom_header={'latex': latex_head})
35903590

pygsti/tools/optools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def unitarity(a, mx_basis="gm"):
753753
noise" NJP 17 113020 (2015). The unitarity is given by (Prop 1 in Wallman
754754
et al):
755755
756-
`u(a) = Tr( A_u^{\dagger} A_u ) / (d^2 - 1)`,
756+
`u(a) = Tr( A_u^{\\dagger} A_u ) / (d^2 - 1)`,
757757
758758
where A_u is the unital submatrix of a, and d is the dimension of
759759
the Hilbert space. When a is written in any basis for which the

0 commit comments

Comments
 (0)