Skip to content

Commit d39112e

Browse files
Add tuples, ndarrays, and complex numbers to cirq_google proto (#7226)
* Add tuples, ndarrays, and complex numbers to cirq_google proto - Adds support for (potentially nested) tuples of mismatched types - Adds support for serializing ndarrays - Adds support for serializing complex numbers * my o my, it's mypy * Fix all the review comments, add set support. * Fix invert mask, which assumes list, so it can accept tuples. * Update cirq-google/cirq_google/serialization/arg_func_langs.py Co-authored-by: Pavol Juhas <[email protected]> * Fix coverage. --------- Co-authored-by: Pavol Juhas <[email protected]>
1 parent 9fd4751 commit d39112e

File tree

6 files changed

+535
-166
lines changed

6 files changed

+535
-166
lines changed

cirq-google/cirq_google/api/v2/program.proto

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ syntax = "proto3";
33
package cirq.google.api.v2;
44

55
import "tunits/proto/tunits.proto";
6+
import "cirq_google/api/v2/ndarrays.proto";
67

78
option java_package = "com.google.cirq.google.api.v2";
89
option java_outer_classname = "ProgramProto";
@@ -397,6 +398,9 @@ message ArgValue {
397398
tunits.Value value_with_unit = 8;
398399
bool bool_value = 9;
399400
bytes bytes_value = 10;
401+
Complex complex_value = 11;
402+
Tuple tuple_value = 12;
403+
NDArray ndarray_value = 13;
400404
}
401405
}
402406

@@ -417,6 +421,45 @@ message RepeatedBoolean {
417421
repeated bool values = 1;
418422
}
419423

424+
// Representation of a mixed tuple of values
425+
message Tuple {
426+
427+
// Original (python) type of the data
428+
enum SequenceType {
429+
UNSPECIFIED = 0;
430+
LIST = 1;
431+
TUPLE = 2;
432+
SET = 3;
433+
FROZENSET = 4;
434+
}
435+
436+
SequenceType sequence_type = 1;
437+
438+
repeated Arg values = 2;
439+
}
440+
441+
// Representation of a complex number
442+
message Complex {
443+
double real_value = 1;
444+
double imag_value = 2;
445+
}
446+
447+
message NDArray {
448+
oneof arr {
449+
Complex128Array complex128_array = 1;
450+
Complex64Array complex64_array = 2;
451+
Float16Array float16_array = 3;
452+
Float32Array float32_array = 4;
453+
Float64Array float64_array = 5;
454+
Int64Array int64_array = 6;
455+
Int32Array int32_array = 7;
456+
Int16Array int16_array = 8;
457+
Int8Array int8_array = 9;
458+
UInt8Array uint8_array = 10;
459+
BitArray bit_array = 11;
460+
}
461+
}
462+
420463
// A function of arguments. This is an s-expression tree representing
421464
// mathematically the function being evaluated.
422465
//

cirq-google/cirq_google/api/v2/program_pb2.py

Lines changed: 128 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cirq-google/cirq_google/api/v2/program_pb2.pyi

Lines changed: 136 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)