@@ -408,3 +408,58 @@ def test_cannot_add_new_attributes(self):
408408 # Attempting to add a new attribute should raise an error
409409 with pytest .raises (AttributeError ):
410410 circuit .new_attr = "value"
411+
412+
413+ class TestCircuitEstimate :
414+ """Test cases for Circuit.estimate method."""
415+
416+ def test_estimate_from_factory (self ):
417+ """Test that estimate works with Q# factory data."""
418+ state_prep_params = {
419+ "rowMap" : [1 , 0 ],
420+ "stateVector" : [0.6 , 0.0 , 0.0 , 0.8 ],
421+ "expansionOps" : [],
422+ "numQubits" : 2 ,
423+ }
424+ qsharp_factory = QsharpFactoryData (
425+ program = QSHARP_UTILS .StatePreparation .MakeStatePreparationCircuit ,
426+ parameter = state_prep_params ,
427+ )
428+ circuit = Circuit (qsharp_factory = qsharp_factory )
429+ result = circuit .estimate ()
430+ assert result is not None
431+ assert hasattr (result , "logical_counts" )
432+
433+ def test_estimate_from_qasm (self ):
434+ """Test that estimate works with QASM representation."""
435+ qasm_with_t = """
436+ OPENQASM 3.0;
437+ include "stdgates.inc";
438+ qubit[2] q;
439+ bit[2] c;
440+ h q[0];
441+ t q[0];
442+ cx q[0], q[1];
443+ c[0] = measure q[0];
444+ c[1] = measure q[1];
445+ """
446+ circuit = Circuit (qasm = qasm_with_t )
447+ result = circuit .estimate ()
448+ assert result is not None
449+ assert hasattr (result , "logical_counts" )
450+
451+ def test_estimate_raises_with_qir_only (self ):
452+ """Test that estimate raises when only QIR representation is available."""
453+ qir = qsharp .openqasm .compile ("""
454+ OPENQASM 3.0;
455+ include "stdgates.inc";
456+ qubit[2] q;
457+ bit[2] c;
458+ h q[0];
459+ cx q[0], q[1];
460+ c[0] = measure q[0];
461+ c[1] = measure q[1];
462+ """ )
463+ circuit = Circuit (qir = qir )
464+ with pytest .raises (RuntimeError , match = "Cannot estimate resources" ):
465+ circuit .estimate ()
0 commit comments