Пример #1
0
 def test_datetime(self):
     array = np.array([
         datetime.datetime(1970, 1, 1),
         datetime.datetime(1970, 1, 2),
         datetime.datetime(1970, 1, 3)
     ],
                      dtype=np.dtype('int64'))
     bsonnumpy.ndarray_to_sequence(array)
Пример #2
0
 def test_timestamp(self):
     array = np.array([
         bson.timestamp.Timestamp(time=00000, inc=77),
         bson.timestamp.Timestamp(time=00000, inc=88),
         bson.timestamp.Timestamp(time=00000, inc=99)
     ],
                      dtype=np.dtype('uint64'))
     bsonnumpy.ndarray_to_sequence(array)
Пример #3
0
 def test_binary(self):
     array = np.array([
         bson.Binary(b"binary_0"),
         bson.Binary(b"bin1"),
         bson.Binary(b"utf8-2")
     ],
                      dtype=np.dtype('<V15'))
     bsonnumpy.ndarray_to_sequence(array)
Пример #4
0
 def test_oid(self):
     array = np.array([
         bson.ObjectId(),
         bson.ObjectId(),
         bson.ObjectId(),
         bson.ObjectId()
     ],
                      dtype=np.dtype('<V12'))
     bsonnumpy.ndarray_to_sequence(array)
 def test_incorrect_arguments(self):
     with self.assertRaisesPattern(
             bsonnumpy.error, r'sequence_to_ndarray requires a numpy\.'
             r'ndarray'):
         bsonnumpy.ndarray_to_sequence(None)
     with self.assertRaisesPattern(
             bsonnumpy.error, r'sequence_to_ndarray requires a numpy\.'
             r'ndarray'):
         bsonnumpy.ndarray_to_sequence([])
     with self.assertRaisesPattern(
             bsonnumpy.error, r'sequence_to_ndarray requires a numpy\.'
             r'ndarray'):
         bsonnumpy.ndarray_to_sequence(1)
     with self.assertRaises(TypeError):
         bsonnumpy.ndarray_to_sequence(10, 10)
Пример #6
0
 def test_subarray(self):
     array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                      dtype=np.dtype('int32'))
     bsonnumpy.ndarray_to_sequence(array)
Пример #7
0
 def test_string(self):
     array = np.array([b"string_0", b"str1", b"utf8-2"],
                      dtype=np.dtype('<S2'))
     bsonnumpy.ndarray_to_sequence(array)
Пример #8
0
 def test_float64_types(self):
     array = np.array([99.99, 88.88, 77.77, 66.66], dtype=np.float64)
     bsonnumpy.ndarray_to_sequence(array)
Пример #9
0
 def test_bool(self):
     array = np.array([True, False, True, False], dtype=np.bool)
     bsonnumpy.ndarray_to_sequence(array)
Пример #10
0
 def test_integer64_types(self):
     array = np.array([99, 88, 77, 66], dtype=np.int64)
     bsonnumpy.ndarray_to_sequence(array)