Packaging Cirq 0.7 for Nix: serialization failures
See original GitHub issueHi all, #2727 is higher priority.
For https://github.com/NixOS/nixpkgs/pull/78779 I tried building Cirq tag 0.7.0, and got several test failures. Are these in the main tree or local to me? And any tips on resolving them? (note: this is after disabling the failures from #2727, which also appear here).
Failure 2 looks like same issue as #2727.
________________________ test_serialize_sympy_constants ________________________
def test_serialize_sympy_constants():
proto = _arg_to_proto(sympy.pi, arg_function_language='')
packed = json_format.MessageToDict(proto,
including_default_value_fields=True,
preserving_proto_field_name=True,
use_integers_for_enums=True)
> assert packed == {'arg_value': {'float_value': float(np.float32(sympy.pi))}}
E AssertionError: assert {'arg_value':...592653589793}} == {'arg_value':...927410125732}}
E Differing items:
E {'arg_value': {'float_value': 3.141592653589793}} != {'arg_value': {'float_value': 3.1415927410125732}}
E Use -v to get the full diff
cirq/google/arg_func_langs_test.py:108: AssertionError
___________________ test_serialize_conversion[value1-proto1] ___________________
value = array([ True, False])
proto = {'arg_value': {'bool_values': {'values': [True, False]}}}
@pytest.mark.parametrize('value,proto', [
((True, False), {
'arg_value': {
'bool_values': {
'values': [True, False]
}
}
}),
(np.array([True, False], dtype=np.bool), {
'arg_value': {
'bool_values': {
'values': [True, False]
}
}
}),
])
def test_serialize_conversion(value: ARG_LIKE, proto: v2.program_pb2.Arg):
msg = v2.program_pb2.Arg()
json_format.ParseDict(proto, msg)
packed = json_format.MessageToDict(_arg_to_proto(value,
> arg_function_language=''),
including_default_value_fields=True,
preserving_proto_field_name=True,
use_integers_for_enums=True)
cirq/google/arg_func_langs_test.py:138:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cirq/google/arg_func_langs.py:131: in _arg_to_proto
msg.arg_value.bool_values.values.extend(value)
/nix/store/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/containers.py:279: in extend
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
/nix/store/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/containers.py:279: in <listcomp>
new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <google.protobuf.internal.type_checkers.TypeCheckerWithDefault object at 0x7fffd76f45d0>
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/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/type_checkers.py:109: TypeError
Thanks in advance!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Serialization guidelines | Cirq - Google Quantum AI
This developer document explains how Cirq serializes objects into (and out of) JSON. It also explains how to add a new serializable object, ......
Read more >Google Cirq Gate Throws Serialization Error #200 - GitHub
We wanted to be able to serialize and deserialize circuits to protocol buffer representations when passing them between our ops (C++ protocol ...
Read more >Compare Packages Between Distributions - DistroWatch.com
Complete summaries of the openSUSE and CentOS projects are available. Note: In case where multiple versions of a package are shipped with a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think they’re talking about protobuf 3.8
Yes, it looks like it’s been resolved. Likely due to Nixpkgs updating their protobuf version.
Relevant test config: