Skip to content

Commit 0ef46f7

Browse files
author
Dorian Birraux
committed
refactor
1 parent 8e13d4f commit 0ef46f7

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

wolframclient/language/array.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

3+
from wolframclient.exception import WolframLanguageException
34
from wolframclient.serializers.wxfencoder import constants
45
from wolframclient.utils.encoding import concatenate_bytes
5-
from wolframclient.exception import WolframLanguageException
66

77
try:
88
from collections.abc import Sequence
@@ -19,7 +19,10 @@ def __init__(self, array, type, shape=None):
1919
try:
2020
self.struct = constants.STRUCT_MAPPING[type]
2121
except KeyError:
22-
raise WolframLanguageException('Type %s is not one of the supported array types: %s.' % (type, ', '.join(constants.STRUCT_MAPPING.keys())))
22+
raise WolframLanguageException(
23+
"Type %s is not one of the supported array types: %s."
24+
% (type, ", ".join(constants.STRUCT_MAPPING.keys()))
25+
)
2326

2427
def tobytes(self):
2528
return concatenate_bytes(self.struct.pack(el) for el in self.array)
@@ -30,5 +33,6 @@ def __getitem__(self, k):
3033
def __len__(self):
3134
return len(self.array)
3235

36+
3337
class PackedArray(NumericArray):
34-
pass
38+
pass

wolframclient/serializers/encoders/builtin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def encode_association(serializer, o):
180180
def encode_array(serializer, o):
181181
return serializer.serialize_numeric_array(o.tobytes(), o.shape, o.type)
182182

183+
183184
@encoder.dispatch(PackedArray)
184185
def encode_array(serializer, o):
185186
return serializer.serialize_packed_array(o.tobytes(), o.shape, o.type)

wolframclient/tests/serializers/wxf_pythonarray.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class TestCase(BaseTestCase):
12-
1312
def test_python_array(self):
1413

1514
for array, numpy_type, wl_type in (
@@ -29,5 +28,5 @@ def test_python_array(self):
2928

3029
self.assertEqual(
3130
export(arr, target_format="wxf"),
32-
export(NumericArray(array, wl_type, shape = shape), target_format="wxf"),
31+
export(NumericArray(array, wl_type, shape=shape), target_format="wxf"),
3332
)

0 commit comments

Comments
 (0)