# test_msgs/msg/BoundedSequences msg_to_dict
def to_dict(_m):
    return {'bool_values': _m.bool_values, 'byte_values': _b64(b''.join(_m.byte_values)), 'char_values': _b64(_m.char_values.tobytes()), 'float32_values': _np.frombuffer(_m.float32_values, dtype=_np.float32), 'float64_values': (_np.frombuffer(_s1, dtype=_np.float64) if len(_s1 := _m.float64_values) >= 64 else _s1.tolist()), 'int8_values': (_np.frombuffer(_s2, dtype=_np.int8) if len(_s2 := _m.int8_values) >= 64 else _s2.tolist()), 'uint8_values': _b64(_m.uint8_values.tobytes()), 'int16_values': (_np.frombuffer(_s3, dtype=_np.int16) if len(_s3 := _m.int16_values) >= 64 else _s3.tolist()), 'uint16_values': (_np.frombuffer(_s4, dtype=_np.uint16) if len(_s4 := _m.uint16_values) >= 64 else _s4.tolist()), 'int32_values': (_np.frombuffer(_s5, dtype=_np.int32) if len(_s5 := _m.int32_values) >= 64 else _s5.tolist()), 'uint32_values': (_np.frombuffer(_s6, dtype=_np.uint32) if len(_s6 := _m.uint32_values) >= 64 else _s6.tolist()), 'int64_values': [str(_w) for _w in _m.int64_values.tolist()], 'uint64_values': [str(_w) for _w in _m.uint64_values.tolist()], 'string_values': _m.string_values, 'basic_types_values': [{'bool_value': _i1.bool_value, 'byte_value': _i1.byte_value[0], 'char_value': _i1.char_value, 'float32_value': _i1.float32_value, 'float64_value': _i1.float64_value, 'int8_value': _i1.int8_value, 'uint8_value': _i1.uint8_value, 'int16_value': _i1.int16_value, 'uint16_value': _i1.uint16_value, 'int32_value': _i1.int32_value, 'uint32_value': _i1.uint32_value, 'int64_value': str(_i1.int64_value), 'uint64_value': str(_i1.uint64_value)} for _i1 in _m.basic_types_values], 'constants_values': [{} for _i1 in _m.constants_values], 'defaults_values': [{'bool_value': _i1.bool_value, 'byte_value': _i1.byte_value[0], 'char_value': _i1.char_value, 'float32_value': _i1.float32_value, 'float64_value': _i1.float64_value, 'int8_value': _i1.int8_value, 'uint8_value': _i1.uint8_value, 'int16_value': _i1.int16_value, 'uint16_value': _i1.uint16_value, 'int32_value': _i1.int32_value, 'uint32_value': _i1.uint32_value, 'int64_value': str(_i1.int64_value), 'uint64_value': str(_i1.uint64_value)} for _i1 in _m.defaults_values], 'bool_values_default': _m.bool_values_default, 'byte_values_default': _b64(b''.join(_m.byte_values_default)), 'char_values_default': _b64(_m.char_values_default.tobytes()), 'float32_values_default': _np.frombuffer(_m.float32_values_default, dtype=_np.float32), 'float64_values_default': (_np.frombuffer(_s7, dtype=_np.float64) if len(_s7 := _m.float64_values_default) >= 64 else _s7.tolist()), 'int8_values_default': (_np.frombuffer(_s8, dtype=_np.int8) if len(_s8 := _m.int8_values_default) >= 64 else _s8.tolist()), 'uint8_values_default': _b64(_m.uint8_values_default.tobytes()), 'int16_values_default': (_np.frombuffer(_s9, dtype=_np.int16) if len(_s9 := _m.int16_values_default) >= 64 else _s9.tolist()), 'uint16_values_default': (_np.frombuffer(_s10, dtype=_np.uint16) if len(_s10 := _m.uint16_values_default) >= 64 else _s10.tolist()), 'int32_values_default': (_np.frombuffer(_s11, dtype=_np.int32) if len(_s11 := _m.int32_values_default) >= 64 else _s11.tolist()), 'uint32_values_default': (_np.frombuffer(_s12, dtype=_np.uint32) if len(_s12 := _m.uint32_values_default) >= 64 else _s12.tolist()), 'int64_values_default': [str(_w) for _w in _m.int64_values_default.tolist()], 'uint64_values_default': [str(_w) for _w in _m.uint64_values_default.tolist()], 'string_values_default': _m.string_values_default, 'alignment_check': _m.alignment_check}

# test_msgs/msg/BoundedSequences dict_to_msg
def _build1(_d):
    # test_msgs/msg/BasicTypes at basic_types_values[]
    if type(_d) is not dict:
        raise ConversionError('basic_types_values[]: expected an object, got ' + repr(_d), field='basic_types_values[]')
    _unknown = _d.keys() - {'bool_value', 'byte_value', 'char_value', 'float32_value', 'float64_value', 'int8_value', 'uint8_value', 'int16_value', 'uint16_value', 'int32_value', 'uint32_value', 'int64_value', 'uint64_value'}
    if _unknown:
        raise ConversionError('basic_types_values[]: unknown field(s) ' + ', '.join(sorted(_unknown)), field='basic_types_values[]')
    _m = _T1()
    _v = _d.get('bool_value', _MISS)
    if _v is not _MISS:
        _m.bool_value = _to_bool(_v, 'basic_types_values[].bool_value')
    _v = _d.get('byte_value', _MISS)
    if _v is not _MISS:
        _m.byte_value = _to_octet(_v, 'basic_types_values[].byte_value')
    _v = _d.get('char_value', _MISS)
    if _v is not _MISS:
        _m.char_value = _to_int(_v, 0, 255, 'basic_types_values[].char_value')
    _v = _d.get('float32_value', _MISS)
    if _v is not _MISS:
        _m.float32_value = _to_float(_v, 'basic_types_values[].float32_value')
    _v = _d.get('float64_value', _MISS)
    if _v is not _MISS:
        _m.float64_value = _to_float(_v, 'basic_types_values[].float64_value')
    _v = _d.get('int8_value', _MISS)
    if _v is not _MISS:
        _m.int8_value = _to_int(_v, -128, 127, 'basic_types_values[].int8_value')
    _v = _d.get('uint8_value', _MISS)
    if _v is not _MISS:
        _m.uint8_value = _to_int(_v, 0, 255, 'basic_types_values[].uint8_value')
    _v = _d.get('int16_value', _MISS)
    if _v is not _MISS:
        _m.int16_value = _to_int(_v, -32768, 32767, 'basic_types_values[].int16_value')
    _v = _d.get('uint16_value', _MISS)
    if _v is not _MISS:
        _m.uint16_value = _to_int(_v, 0, 65535, 'basic_types_values[].uint16_value')
    _v = _d.get('int32_value', _MISS)
    if _v is not _MISS:
        _m.int32_value = _to_int(_v, -2147483648, 2147483647, 'basic_types_values[].int32_value')
    _v = _d.get('uint32_value', _MISS)
    if _v is not _MISS:
        _m.uint32_value = _to_int(_v, 0, 4294967295, 'basic_types_values[].uint32_value')
    _v = _d.get('int64_value', _MISS)
    if _v is not _MISS:
        _m.int64_value = _to_wide_int(_v, -9223372036854775808, 9223372036854775807, 'basic_types_values[].int64_value')
    _v = _d.get('uint64_value', _MISS)
    if _v is not _MISS:
        _m.uint64_value = _to_wide_int(_v, 0, 18446744073709551615, 'basic_types_values[].uint64_value')
    return _m

def _build2(_d):
    # test_msgs/msg/Constants at constants_values[]
    if type(_d) is not dict:
        raise ConversionError('constants_values[]: expected an object, got ' + repr(_d), field='constants_values[]')
    _unknown = set(_d)
    if _unknown:
        raise ConversionError('constants_values[]: unknown field(s) ' + ', '.join(sorted(_unknown)), field='constants_values[]')
    _m = _T2()
    return _m

def _build3(_d):
    # test_msgs/msg/Defaults at defaults_values[]
    if type(_d) is not dict:
        raise ConversionError('defaults_values[]: expected an object, got ' + repr(_d), field='defaults_values[]')
    _unknown = _d.keys() - {'bool_value', 'byte_value', 'char_value', 'float32_value', 'float64_value', 'int8_value', 'uint8_value', 'int16_value', 'uint16_value', 'int32_value', 'uint32_value', 'int64_value', 'uint64_value'}
    if _unknown:
        raise ConversionError('defaults_values[]: unknown field(s) ' + ', '.join(sorted(_unknown)), field='defaults_values[]')
    _m = _T3()
    _v = _d.get('bool_value', _MISS)
    if _v is not _MISS:
        _m.bool_value = _to_bool(_v, 'defaults_values[].bool_value')
    _v = _d.get('byte_value', _MISS)
    if _v is not _MISS:
        _m.byte_value = _to_octet(_v, 'defaults_values[].byte_value')
    _v = _d.get('char_value', _MISS)
    if _v is not _MISS:
        _m.char_value = _to_int(_v, 0, 255, 'defaults_values[].char_value')
    _v = _d.get('float32_value', _MISS)
    if _v is not _MISS:
        _m.float32_value = _to_float(_v, 'defaults_values[].float32_value')
    _v = _d.get('float64_value', _MISS)
    if _v is not _MISS:
        _m.float64_value = _to_float(_v, 'defaults_values[].float64_value')
    _v = _d.get('int8_value', _MISS)
    if _v is not _MISS:
        _m.int8_value = _to_int(_v, -128, 127, 'defaults_values[].int8_value')
    _v = _d.get('uint8_value', _MISS)
    if _v is not _MISS:
        _m.uint8_value = _to_int(_v, 0, 255, 'defaults_values[].uint8_value')
    _v = _d.get('int16_value', _MISS)
    if _v is not _MISS:
        _m.int16_value = _to_int(_v, -32768, 32767, 'defaults_values[].int16_value')
    _v = _d.get('uint16_value', _MISS)
    if _v is not _MISS:
        _m.uint16_value = _to_int(_v, 0, 65535, 'defaults_values[].uint16_value')
    _v = _d.get('int32_value', _MISS)
    if _v is not _MISS:
        _m.int32_value = _to_int(_v, -2147483648, 2147483647, 'defaults_values[].int32_value')
    _v = _d.get('uint32_value', _MISS)
    if _v is not _MISS:
        _m.uint32_value = _to_int(_v, 0, 4294967295, 'defaults_values[].uint32_value')
    _v = _d.get('int64_value', _MISS)
    if _v is not _MISS:
        _m.int64_value = _to_wide_int(_v, -9223372036854775808, 9223372036854775807, 'defaults_values[].int64_value')
    _v = _d.get('uint64_value', _MISS)
    if _v is not _MISS:
        _m.uint64_value = _to_wide_int(_v, 0, 18446744073709551615, 'defaults_values[].uint64_value')
    return _m

def _build0(_d):
    # test_msgs/msg/BoundedSequences at body
    if type(_d) is not dict:
        raise ConversionError('body: expected an object, got ' + repr(_d))
    _unknown = _d.keys() - {'bool_values', 'byte_values', 'char_values', 'float32_values', 'float64_values', 'int8_values', 'uint8_values', 'int16_values', 'uint16_values', 'int32_values', 'uint32_values', 'int64_values', 'uint64_values', 'string_values', 'basic_types_values', 'constants_values', 'defaults_values', 'bool_values_default', 'byte_values_default', 'char_values_default', 'float32_values_default', 'float64_values_default', 'int8_values_default', 'uint8_values_default', 'int16_values_default', 'uint16_values_default', 'int32_values_default', 'uint32_values_default', 'int64_values_default', 'uint64_values_default', 'string_values_default', 'alignment_check'}
    if _unknown:
        raise ConversionError('body: unknown field(s) ' + ', '.join(sorted(_unknown)))
    _m = _T0()
    _v = _d.get('bool_values', _MISS)
    if _v is not _MISS:
        _m.bool_values = [_to_bool(_j1, 'bool_values[]') for _j1 in _check_max(_v, 3, 'bool_values')]
    _v = _d.get('byte_values', _MISS)
    if _v is not _MISS:
        _m.byte_values = _octet_list(_v, None, 3, 'byte_values')
    _v = _d.get('char_values', _MISS)
    if _v is not _MISS:
        _m.char_values = _arr('B', _bytes_of(_v, None, 3, 'char_values'))
    _v = _d.get('float32_values', _MISS)
    if _v is not _MISS:
        _m.float32_values = _arr('f', [_to_float(_j1, 'float32_values[]') for _j1 in _check_max(_v, 3, 'float32_values')])
    _v = _d.get('float64_values', _MISS)
    if _v is not _MISS:
        _m.float64_values = _arr('d', [_to_float(_j1, 'float64_values[]') for _j1 in _check_max(_v, 3, 'float64_values')])
    _v = _d.get('int8_values', _MISS)
    if _v is not _MISS:
        _m.int8_values = _arr('b', [_to_int(_j1, -128, 127, 'int8_values[]') for _j1 in _check_max(_v, 3, 'int8_values')])
    _v = _d.get('uint8_values', _MISS)
    if _v is not _MISS:
        _m.uint8_values = _arr('B', _bytes_of(_v, None, 3, 'uint8_values'))
    _v = _d.get('int16_values', _MISS)
    if _v is not _MISS:
        _m.int16_values = _arr('h', [_to_int(_j1, -32768, 32767, 'int16_values[]') for _j1 in _check_max(_v, 3, 'int16_values')])
    _v = _d.get('uint16_values', _MISS)
    if _v is not _MISS:
        _m.uint16_values = _arr('H', [_to_int(_j1, 0, 65535, 'uint16_values[]') for _j1 in _check_max(_v, 3, 'uint16_values')])
    _v = _d.get('int32_values', _MISS)
    if _v is not _MISS:
        _m.int32_values = _arr('i', [_to_int(_j1, -2147483648, 2147483647, 'int32_values[]') for _j1 in _check_max(_v, 3, 'int32_values')])
    _v = _d.get('uint32_values', _MISS)
    if _v is not _MISS:
        _m.uint32_values = _arr('I', [_to_int(_j1, 0, 4294967295, 'uint32_values[]') for _j1 in _check_max(_v, 3, 'uint32_values')])
    _v = _d.get('int64_values', _MISS)
    if _v is not _MISS:
        _m.int64_values = _arr('q', [_to_wide_int(_j1, -9223372036854775808, 9223372036854775807, 'int64_values[]') for _j1 in _check_max(_v, 3, 'int64_values')])
    _v = _d.get('uint64_values', _MISS)
    if _v is not _MISS:
        _m.uint64_values = _arr('Q', [_to_wide_int(_j1, 0, 18446744073709551615, 'uint64_values[]') for _j1 in _check_max(_v, 3, 'uint64_values')])
    _v = _d.get('string_values', _MISS)
    if _v is not _MISS:
        _m.string_values = [_to_str(_j1, 'string_values[]') for _j1 in _check_max(_v, 3, 'string_values')]
    _v = _d.get('basic_types_values', _MISS)
    if _v is not _MISS:
        _m.basic_types_values = [_build1(_j1) for _j1 in _check_max(_v, 3, 'basic_types_values')]
    _v = _d.get('constants_values', _MISS)
    if _v is not _MISS:
        _m.constants_values = [_build2(_j1) for _j1 in _check_max(_v, 3, 'constants_values')]
    _v = _d.get('defaults_values', _MISS)
    if _v is not _MISS:
        _m.defaults_values = [_build3(_j1) for _j1 in _check_max(_v, 3, 'defaults_values')]
    _v = _d.get('bool_values_default', _MISS)
    if _v is not _MISS:
        _m.bool_values_default = [_to_bool(_j1, 'bool_values_default[]') for _j1 in _check_max(_v, 3, 'bool_values_default')]
    _v = _d.get('byte_values_default', _MISS)
    if _v is not _MISS:
        _m.byte_values_default = _octet_list(_v, None, 3, 'byte_values_default')
    _v = _d.get('char_values_default', _MISS)
    if _v is not _MISS:
        _m.char_values_default = _arr('B', _bytes_of(_v, None, 3, 'char_values_default'))
    _v = _d.get('float32_values_default', _MISS)
    if _v is not _MISS:
        _m.float32_values_default = _arr('f', [_to_float(_j1, 'float32_values_default[]') for _j1 in _check_max(_v, 3, 'float32_values_default')])
    _v = _d.get('float64_values_default', _MISS)
    if _v is not _MISS:
        _m.float64_values_default = _arr('d', [_to_float(_j1, 'float64_values_default[]') for _j1 in _check_max(_v, 3, 'float64_values_default')])
    _v = _d.get('int8_values_default', _MISS)
    if _v is not _MISS:
        _m.int8_values_default = _arr('b', [_to_int(_j1, -128, 127, 'int8_values_default[]') for _j1 in _check_max(_v, 3, 'int8_values_default')])
    _v = _d.get('uint8_values_default', _MISS)
    if _v is not _MISS:
        _m.uint8_values_default = _arr('B', _bytes_of(_v, None, 3, 'uint8_values_default'))
    _v = _d.get('int16_values_default', _MISS)
    if _v is not _MISS:
        _m.int16_values_default = _arr('h', [_to_int(_j1, -32768, 32767, 'int16_values_default[]') for _j1 in _check_max(_v, 3, 'int16_values_default')])
    _v = _d.get('uint16_values_default', _MISS)
    if _v is not _MISS:
        _m.uint16_values_default = _arr('H', [_to_int(_j1, 0, 65535, 'uint16_values_default[]') for _j1 in _check_max(_v, 3, 'uint16_values_default')])
    _v = _d.get('int32_values_default', _MISS)
    if _v is not _MISS:
        _m.int32_values_default = _arr('i', [_to_int(_j1, -2147483648, 2147483647, 'int32_values_default[]') for _j1 in _check_max(_v, 3, 'int32_values_default')])
    _v = _d.get('uint32_values_default', _MISS)
    if _v is not _MISS:
        _m.uint32_values_default = _arr('I', [_to_int(_j1, 0, 4294967295, 'uint32_values_default[]') for _j1 in _check_max(_v, 3, 'uint32_values_default')])
    _v = _d.get('int64_values_default', _MISS)
    if _v is not _MISS:
        _m.int64_values_default = _arr('q', [_to_wide_int(_j1, -9223372036854775808, 9223372036854775807, 'int64_values_default[]') for _j1 in _check_max(_v, 3, 'int64_values_default')])
    _v = _d.get('uint64_values_default', _MISS)
    if _v is not _MISS:
        _m.uint64_values_default = _arr('Q', [_to_wide_int(_j1, 0, 18446744073709551615, 'uint64_values_default[]') for _j1 in _check_max(_v, 3, 'uint64_values_default')])
    _v = _d.get('string_values_default', _MISS)
    if _v is not _MISS:
        _m.string_values_default = [_to_str(_j1, 'string_values_default[]') for _j1 in _check_max(_v, 3, 'string_values_default')]
    _v = _d.get('alignment_check', _MISS)
    if _v is not _MISS:
        _m.alignment_check = _to_int(_v, -2147483648, 2147483647, 'alignment_check')
    return _m

def from_dict(_d):
    return _build0(_d)
