<jupyter_start><jupyter_text>Parameter LabelsThis tutorials show how model parameters are labelled, and how this can be used to create more complex parameterizations for a model.<jupyter_code>import pygsti
import numpy as np
from pygsti.modelpacks import smq1Q_XY as std
from pygsti.objects import Label

mdl1 = std.target_model("H+s")  # choose a H+s model because it has a simple parameterization<jupyter_output><empty_output><jupyter_text>Getting parameter labelsA `Model`'s parameters have corresponding labels, which can be accessed in a variety of ways.  Individual operators also have labeled parameters.  An `OpModel` (e.g. an `ExplicitModel` or `ImplicitModel`) sets default parameter labels based on the parameter labels of its contained operators, but the model's parameters can vary independently.<jupyter_code># print the raw labels, straight up
mdl1.parameter_labels
# model parameters can be set to arbitrary user-defined values
mdl1.set_parameter_label(index=0, label="My favorite parameter")
# Model parameters in a nice format for printing
mdl1.parameter_labels_pretty
# For a single operator: you can get it's "local" parameter labels (in general different from the model's parameter labels)
mdl1.operations[('Gxpi2',0)].parameter_labels
# The parameters of all the operators, with mappings to non-default model parameters 
mdl1.print_parameters_by_op()<jupyter_output><empty_output><jupyter_text>Collecting parametersYou can combined multiple parameters into one using the `collect_parameters` method.  This effectively ties the values for all the original parameters together.<jupyter_code>mdl1.collect_parameters([ (('Gxpi2',0), 'X Hamiltonian error coefficient'),
                          (('Gypi2',0), 'Y Hamiltonian error coefficient')],
                        new_param_label='Over-rotation')
# Using "pretty" labels works too:
mdl1.collect_parameters(['Gxpi2:0: Y stochastic coefficient',
                         'Gxpi2:0: Z stochastic coefficient' ],
                        new_param_label='Gxpi2 off-axis stochastic')
# You can also use integer indices, and parameter labels can be tuples too.
mdl1.collect_parameters([3,4,5], new_param_label=("rho0", "common stochastic coefficient"))
# There are now fewer parameters
mdl1.parameter_labels_pretty
# And you can see how they're wired up for each op:
mdl1.print_parameters_by_op()<jupyter_output><empty_output><jupyter_text>Un-collecting parametersYou can also reverse the above process and "un-collect" a parameter so that one parameter gets replaced my multiple independent ones.<jupyter_code>mdl1.uncollect_parameters('Gxpi2 off-axis stochastic')
mdl1.print_parameters_by_op()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07543664065403195, 'fraction_numerical': 0.011519881085098476, 'mean_word_length': 5.424821002386635, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '589051', 'license': 'Apache-2.0', 'n_tokens_mistral': 765, 'n_tokens_neox': 734, 'n_words': 270, 'path': 'jupyter_notebooks/Tutorials/objects/advanced/ParameterLabels.ipynb', 'repo_name': 'colibri-coruscans/pyGSTi', 'size': '2691'}