# pylint: disable=protected-access
from qiskit.circuit.library import ZZFeatureMap
from qiskit.circuit import ParameterVector

# Define a (non-parameterized) feature map from the Qiskit circuit library
fm = ZZFeatureMap(2)
input_params = fm.parameters
fm.draw()

# split params into two disjoint sets
input_params = fm.parameters[::2]
training_params = fm.parameters[1::2]
print("input_params:", input_params)
print("training_params:", training_params)

# define new parameter vectors for the input and user parameters
new_input_params = ParameterVector("x", len(input_params))
new_training_params = ParameterVector("θ", len(training_params))

# resassign the origin feature map parameters
param_reassignments = {}
for i, p in enumerate(input_params):
    param_reassignments[p] = new_input_params[i]
for i, p in enumerate(training_params):
    param_reassignments[p] = new_training_params[i]

fm.assign_parameters(param_reassignments, inplace=True)

input_params = new_input_params
training_params = new_training_params

print("input_params:", input_params)
print("training_params:", training_params)
fm.draw()

# Define two circuits
circ1 = ZZFeatureMap(2)
circ2 = ZZFeatureMap(2)
input_params = circ1.parameters
training_params = ParameterVector("θ", 2)

# Reassign new parameters to circ2 so there are no name collisions
circ2.assign_parameters(training_params, inplace=True)

# Compose to build a parameterized feature map
fm = circ2.compose(circ1)
print("input_params:", list(input_params))
print("training_params:", training_params)
fm.draw()

#import qiskit.tools.jupyter
#
#%qiskit_version_table
#%qiskit_copyright