# Copyright 2018-2024 Xanadu Quantum Technologies Inc.# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at# http://www.apache.org/licenses/LICENSE-2.0# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License."""This is the top level module from which all basic functions and classes ofPennyLane can be directly imported."""frompennylane.boolean_fnimportBooleanFnimportpennylane.numpyfrompennylane.queuingimportQueuingManager,applyimportpennylane.compilerfrompennylane.compilerimportqjitimportpennylane.captureimportpennylane.control_flowfrompennylane.control_flowimportfor_loop,while_loopimportpennylane.kernelsimportpennylane.mathimportpennylane.operationimportpennylane.decompositionfrompennylane.decompositionimport(register_resources,add_decomps,list_decomps,resource_rep,)importpennylane.qnnimportpennylane.templatesimportpennylane.paulifrompennylane.pauliimportpauli_decomposefrompennylane.resourceimportspecsimportpennylane.resourceimportpennylane.qchemfrompennylane.fermiimport(FermiC,FermiA,FermiWord,FermiSentence,jordan_wigner,parity_transform,bravyi_kitaev,)frompennylane.boseimport(BoseSentence,BoseWord,binary_mapping,unary_mapping,christiansen_mapping,)frompennylane.qchemimport(taper,symmetry_generators,paulix_ops,taper_operation,import_operator,from_openfermion,to_openfermion,)frompennylane._gradimportgrad,jacobian,vjp,jvpfrompennylane._versionimport__version__frompennylane.aboutimportaboutfrompennylane.circuit_graphimportCircuitGraphfrompennylane.configurationimportConfigurationfrompennylane.trackerimportTrackerfrompennylane.registersimportregistersfrompennylane.ioimport(from_pyquil,from_qasm,from_qiskit,from_qiskit_noise,from_qiskit_op,from_quil,from_quil_file,FromBloq,bloq_registers,)frompennylane.measurementsimport(counts,density_matrix,measure,expval,probs,sample,state,var,vn_entropy,purity,mutual_info,classical_shadow,shadow_expval,)frompennylane.opsimport*frompennylane.opsimportadjoint,ctrl,cond,exp,sum,pow,prod,s_prodfrompennylane.opsimportLinearCombinationasHamiltonianfrompennylane.templatesimportlayerfrompennylane.templates.embeddingsimport*frompennylane.templates.layersimport*frompennylane.templates.tensornetworksimport*frompennylane.templates.swapnetworksimport*frompennylane.templates.state_preparationsimport*frompennylane.templates.subroutinesimport*frompennylaneimportqaoafrompennylane.workflowimportQNode,qnode,executefrompennylane.transformsimport(transform,batch_params,batch_input,batch_partial,compile,defer_measurements,dynamic_one_shot,quantum_monte_carlo,apply_controlled_Q,commutation_dag,pattern_matching,pattern_matching_optimization,clifford_t_decomposition,add_noise,)frompennylane.ops.functionsimport(dot,eigvals,equal,assert_equal,evolve,generator,is_commuting,is_hermitian,is_unitary,map_wires,matrix,simplify,iterative_qpe,commutator,comm,)frompennylane.ops.identityimportIfrompennylane.optimizeimport*frompennylane.debuggingimport(snapshots,breakpoint,debug_expval,debug_state,debug_probs,debug_tape,)frompennylane.shadowsimportClassicalShadowfrompennylane.qcutimportcut_circuit,cut_circuit_mcimportpennylane.pulseimportpennylane.fourierfrompennylane.gradientsimportmetric_tensor,adjoint_metric_tensorimportpennylane.gradients# pylint:disable=wrong-import-orderfrompennylane.drawerimportdraw,draw_mpl# pylint:disable=wrong-import-orderimportpennylane.logging# pylint:disable=wrong-import-orderimportpennylane.dataimportpennylane.noisefrompennylane.noiseimportNoiseModelfrompennylane.devices.device_constructorimportdevice,refresh_devicesimportpennylane.spinimportpennylane.liealgfrompennylane.liealgimportlie_closure,structure_constants,center# Look for an existing configuration filedefault_config=Configuration("config.toml")
[docs]classDeviceError(Exception):"""Exception raised when it encounters an illegal operation in the quantum circuit."""
[docs]classQuantumFunctionError(Exception):"""Exception raised when an illegal operation is defined in a quantum function."""
[docs]classPennyLaneDeprecationWarning(UserWarning):"""Warning raised when a PennyLane feature is being deprecated."""
[docs]classExperimentalWarning(UserWarning):"""Warning raised to indicate experimental/non-stable feature or support."""
def__getattr__(name):ifname=="plugin_devices":returnpennylane.devices.device_constructor.plugin_devicesraiseAttributeError(f"module 'pennylane' has no attribute '{name}'")
[docs]defversion():"""Returns the PennyLane version number."""return__version__