Пример #1
0
    def test_zero_dimension(self):
        provider = WXFExprProvider(NumPyWXFEncoder())
        arr = numpy.ndarray([2, 0, 3])
        with self.assertRaises(Exception) as err:
            next(provider.provide_wxfexpr(arr))

        self.assertEqual(force_text(err.exception), "Dimensions must be positive integers.")
Пример #2
0
    def init(pa, ra):
        expr_provider = WXFExprProvider()
        numpy_encoder = NumPyWXFEncoder(packed_array_support=pa, numeric_array_support=ra)

        expr_provider.add_encoder(numpy_encoder)
        expr_provider.add_encoder(DefaultWXFEncoder())
        serializer = WXFExprSerializer(six.BytesIO(), expr_provider=expr_provider)
        return serializer
Пример #3
0
 def test_dimensions(self):
     provider = WXFExprProvider(NumPyWXFEncoder())
     arr = numpy.ndarray([2, 1, 3])
     wxfExpr = next(provider.provide_wxfexpr(arr))
     self.assertEqual(wxfExpr.dimensions, (2, 1, 3))
Пример #4
0
 def test_bad_options(self):
     with self.assertRaises(ValueError):
         NumPyWXFEncoder(packed_array_support=False,
                         numeric_array_support=False)