Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 2c290ba

Browse files
author
Raphael Koh
committed
Make ResetAll a composite operation
1 parent 08ae4a4 commit 2c290ba

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/Simulation/QsharpCore/Intrinsic.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,16 @@ public partial class M
7676
return null;
7777
}
7878
}
79+
80+
public partial class ResetAll
81+
{
82+
/// <inheritdoc/>
83+
public override RuntimeMetadata? GetRuntimeMetadata(IApplyData args)
84+
{
85+
var metadata = base.GetRuntimeMetadata(args);
86+
if (metadata == null) throw new NullReferenceException($"Null RuntimeMetadata found for {this.ToString()}.");
87+
metadata.IsComposite = true;
88+
return metadata;
89+
}
90+
}
7991
}

src/Simulation/Simulators.Tests/RuntimeMetadataTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,28 @@ public void M()
297297
Assert.Equal(op.GetRuntimeMetadata(args), expected);
298298
}
299299

300+
[Fact]
301+
public void Reset()
302+
{
303+
var target = new FreeQubit(0);
304+
var op = new QuantumSimulator().Get<Intrinsic.Reset>();
305+
var args = op.__dataIn(target);
306+
var expected = new RuntimeMetadata()
307+
{
308+
Label = "Reset",
309+
FormattedNonQubitArgs = "",
310+
IsAdjoint = false,
311+
IsControlled = false,
312+
IsMeasurement = false,
313+
IsComposite = false,
314+
Children = null,
315+
Controls = new List<Qubit>() { },
316+
Targets = new List<Qubit>() { target },
317+
};
318+
319+
Assert.Equal(op.GetRuntimeMetadata(args), expected);
320+
}
321+
300322
[Fact]
301323
public void ResetAll()
302324
{
@@ -310,7 +332,7 @@ public void ResetAll()
310332
IsAdjoint = false,
311333
IsControlled = false,
312334
IsMeasurement = false,
313-
IsComposite = false,
335+
IsComposite = true,
314336
Children = null,
315337
Controls = new List<Qubit>() { },
316338
Targets = targets,

0 commit comments

Comments
 (0)