Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
36dffce1
Commit
36dffce1
authored
Nov 13, 2018
by
Mccaskey, Alex
Browse files
Fixing bug in buffer load, fixing bug in roerror decorator
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
906506fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
python/xacc-py.cpp
View file @
36dffce1
...
...
@@ -326,6 +326,7 @@ PYBIND11_MODULE(_pyxacc, m) {
xacc
::
AcceleratorBuffer
::*
)(
const
std
::
string
))
&
xacc
::
AcceleratorBuffer
::
getChildren
,
""
)
.
def
(
"nChildren"
,
&
xacc
::
AcceleratorBuffer
::
nChildren
,
""
)
.
def
(
"getChildren"
,
(
std
::
vector
<
std
::
shared_ptr
<
AcceleratorBuffer
>>
(
xacc
::
AcceleratorBuffer
::*
)())
&
...
...
quantum/gate/accelerator/ROErrorDecorator.cpp
View file @
36dffce1
...
...
@@ -186,6 +186,11 @@ std::vector<std::shared_ptr<AcceleratorBuffer>> ROErrorDecorator::execute(
}
fixedExp
+=
((
double
)
count
/
(
double
)
nShots
)
*
prod
;
}
// Correct in case our shift has gone outside physical bounds
if
(
fixedExp
>
1.0
)
{
fixedExp
=
1.0
;}
if
(
fixedExp
<
-
1.0
)
{
fixedExp
=
-
1.0
;}
b
->
addExtraInfo
(
"ro-fixed-exp-val-z"
,
ExtraInfo
(
fixedExp
));
counter
++
;
...
...
xacc/accelerator/AcceleratorBuffer.cpp
View file @
36dffce1
...
...
@@ -521,10 +521,11 @@ void AcceleratorBuffer::load(std::istream &stream) {
for
(
auto
&
c
:
children
)
{
auto
childBuffer
=
std
::
make_shared
<
AcceleratorBuffer
>
(
c
[
"name"
].
GetString
(),
nBits
);
auto
&
info
=
c
[
"Information"
];
for
(
auto
itr
=
info
.
MemberBegin
();
itr
!=
info
.
MemberEnd
();
++
itr
)
{
auto
&
value
=
info
[
itr
->
name
.
GetString
()];
std
::
stringstream
sss
;
sss
<<
itr
->
name
.
GetString
();
if
(
value
.
IsInt
())
{
childBuffer
->
addExtraInfo
(
itr
->
name
.
GetString
(),
ExtraInfo
(
value
.
GetInt
()));
...
...
@@ -556,11 +557,10 @@ void AcceleratorBuffer::load(std::istream &stream) {
childBuffer
->
addExtraInfo
(
itr
->
name
.
GetString
(),
ExtraInfo
(
childValues
));
}
else
{
std
::
cout
<<
"HELLO EXTRA: "
<<
itr
->
name
.
GetString
()
<<
"
\n
"
;
xacc
::
info
(
"HELLO EXTRA: "
+
std
::
string
(
itr
->
name
.
GetString
()
));
//
<< "\n";
}
// FIXME Handle Map<int, [int*]>
appendChild
(
c
[
"name"
].
GetString
(),
childBuffer
);
}
}
...
...
@@ -570,6 +570,9 @@ void AcceleratorBuffer::load(std::istream &stream) {
childBuffer
->
appendMeasurement
(
itr
->
name
.
GetString
(),
itr
->
value
.
GetInt
());
}
appendChild
(
c
[
"name"
].
GetString
(),
childBuffer
);
}
}
...
...
xacc/accelerator/AcceleratorBuffer.hpp
View file @
36dffce1
...
...
@@ -133,6 +133,7 @@ public:
std
::
shared_ptr
<
AcceleratorBuffer
>
clone
();
const
int
nChildren
()
{
return
getChildren
().
size
();
}
/**
* Return all children with ExtraInfo infoName equal
* to the given ExtraInfo i.
...
...
xacc/accelerator/tests/AcceleratorBufferTester.cpp
View file @
36dffce1
...
...
@@ -155,6 +155,50 @@ TEST(AcceleratorBufferTester, checkLoadDwave) {
buffer
.
print
(
ss
);
EXPECT_EQ
(
ss
.
str
(),
dwaveBuffer
);
}
TEST
(
AcceleratorBufferTester
,
checkEmptyParametersBug
)
{
const
std
::
string
str
=
R"str({
"AcceleratorBuffer": {
"name": "q",
"size": 4,
"Information": {
"accelerator": "ibm",
"algorithm": "vqe-energy",
"vqe-energy": -1.135636239214126,
"vqe-nQPU-calls": 1,
"x-gates": "[0,1]"
},
"Measurements": {},
"Children": [
{
"name": "Z2Z3",
"Information": {
"coefficient": 0.17407289234592944,
"exp-val-z": 0.932373046875,
"kernel": "Z2Z3",
"parameters": [],
"ro-fixed-exp-val-z": 1.0342163557701439,
"time": 11.214285714285714
},
"Measurements": {
"0000": 15821,
"0100": 334,
"1000": 220,
"1100": 9
}
}
]
}
})str"
;
AcceleratorBuffer
b
;
std
::
istringstream
s
(
str
);
b
.
load
(
s
);
b
.
print
();
}
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment