示例#1
0
def test_json_bit_packing_force():
    assert _pack_digits(np.ones(10, dtype=int),
                        pack_bits='force') == _pack_digits(np.ones(10),
                                                           pack_bits='auto')

    assert _pack_digits(2 * np.ones(10, dtype=int),
                        pack_bits='force') != _pack_digits(
                            2 * np.ones(10, dtype=int), pack_bits='auto')
    # These are the `np.packbits` semantics, namely calling packbits on things
    # that aren't bits first converts elements to bool, which is why these
    # two calls are equivalent.
    assert _pack_digits(2 * np.ones(10, dtype=int),
                        pack_bits='force') == _pack_digits(np.ones(10),
                                                           pack_bits='auto')
示例#2
0
def test_json_bit_packing_error():
    with pytest.raises(ValueError):
        _pack_digits(np.ones(10), pack_bits='hi mom')
 def ndarray_to_hex_str(a):
     return _pack_digits(a, pack_bits='never')[0]