Skip to content

Packaging Cirq 0.7 for Nix: serialization failures #2728

@drewrisinger

Description

@drewrisinger

Hi all,
#2727 is higher priority.

For NixOS/nixpkgs#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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/serializationkind/bug-reportSomething doesn't seem to work.triage/needs-more-evidence[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions