-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Hi all,
I'm working on packaging Cirq for Nix (https://github.com/NixOS/nixpkgs), and running into a few test issues (NixOS/nixpkgs#78779, NixOS/nixpkgs#78779 (comment)). Everything else seems to work.
I started working on it before the 0.7 release, so that's why it's behind. I tried a basic bump to 0.7 but it raised even more issues (can discuss in separate issue).
Question
I have failing tests on cirq/google/op_serializer_test.py. See below for details. Seems to be issue when comparing boolean types, and I'm just not familiar with protobuf to debug it. Seems to fail on both protobuf=3.8 & 3.7. (condensed duplicate failures)
______________ test_to_proto_attribute[val_type5-val5-arg_value5] ______________
val_type = typing.List[bool], val = array([ True, False])
arg_value = {'arg_value': {'bool_values': {'values': [True, False]}}}
@pytest.mark.parametrize(('val_type', 'val', 'arg_value'), TEST_CASES)
def test_to_proto_attribute(val_type, val, arg_value):
serializer = cg.GateOpSerializer(gate_type=GateWithAttribute,
serialized_gate_id='my_gate',
args=[
cg.SerializingArg(
serialized_name='my_val',
serialized_type=val_type,
gate_getter='val')
])
q = cirq.GridQubit(1, 2)
> result = serializer.to_proto_dict(GateWithAttribute(val)(q))
cirq/google/op_serializer_test.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cirq/google/op_serializer.py:111: in to_proto_dict
msg = self.to_proto(op)
cirq/google/op_serializer.py:145: in to_proto
self._arg_value_to_proto(value, msg.args[arg.serialized_name])
cirq/google/op_serializer.py:200: in _arg_value_to_proto
msg.arg_value.bool_values.values.extend(value)
/nix/store/86g6marsgjjr7yqs903rzp0dynxbcck0-python3.7-protobuf-3.8.0/lib/python3.7/site-packages/google/protobuf/internal/containers.py:281: in extend
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
/nix/store/86g6marsgjjr7yqs903rzp0dynxbcck0-python3.7-protobuf-3.8.0/lib/python3.7/site-packages/google/protobuf/internal/containers.py:281: in <listcomp>
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <google.protobuf.internal.type_checkers.TypeCheckerWithDefault object at 0x7fffd76f6810>
proposed_value = True
def CheckValue(self, proposed_value):
"""Type check the provided value and return it.
The returned value might have been normalized to another type.
"""
if not isinstance(proposed_value, self._acceptable_types):
message = ('%.1024r has type %s, but expected one of: %s' %
(proposed_value, type(proposed_value), self._acceptable_types))
> raise TypeError(message)
E TypeError: True has type <class 'numpy.bool_'>, but expected one of: (<class 'bool'>, <class 'numbers.Integral'>)
/nix/store/86g6marsgjjr7yqs903rzp0dynxbcck0-python3.7-protobuf-3.8.0/lib/python3.7/site-packages/google/protobuf/internal/type_checkers.py:109: TypeError
______________ test_to_proto_property[val_type5-val5-arg_value5] _______________
[...]
______________ test_to_proto_callable[val_type5-val5-arg_value5] _______________
[...]
Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels