@@ -68,9 +68,12 @@ class OneDimensionalArray(Array):
68
68
__slots__ = ['_size' , '_data' , '_dtype' ]
69
69
70
70
def __new__ (cls , dtype = NoneType , * args , ** kwargs ):
71
- if dtype is NoneType or len (args ) not in (1 , 2 ):
72
- raise ValueError ("1D array cannot be created due to incorrect"
73
- " information." )
71
+ if dtype is NoneType :
72
+ raise ValueError ("Data type is not defined." )
73
+ if len (args ) not in (1 , 2 ):
74
+ raise ValueError ("Too few arguments to create a 1D array,"
75
+ " pass either size of the array"
76
+ " or list of elements or both." )
74
77
obj = Array .__new__ (cls )
75
78
obj ._dtype = dtype
76
79
if len (args ) == 2 :
@@ -90,7 +93,7 @@ def __new__(cls, dtype=NoneType, *args, **kwargs):
90
93
raise TypeError ("Expected type of size is int and "
91
94
"expected type of data is list/tuple." )
92
95
if size != len (data ):
93
- raise ValueError ("Conflict in the size %s and length of data %s"
96
+ raise ValueError ("Conflict in the size, %s and length of data, %s"
94
97
% (size , len (data )))
95
98
obj ._size , obj ._data = size , data
96
99
@@ -181,9 +184,11 @@ class MultiDimensionalArray(Array):
181
184
__slots__ = ['_sizes' , '_data' , '_dtype' ]
182
185
183
186
def __new__ (cls , dtype : type = NoneType , * args , ** kwargs ):
184
- if dtype is NoneType or not args :
185
- raise ValueError ("Array cannot be created due to incorrect"
186
- " information." )
187
+ if dtype is NoneType :
188
+ raise ValueError ("Data type is not defined." )
189
+ elif not args :
190
+ raise ValueError ("Too few arguments to create a multi dimensional array,"
191
+ " pass dimensions." )
187
192
if len (args ) == 1 :
188
193
obj = Array .__new__ (cls )
189
194
obj ._dtype = dtype
@@ -194,8 +199,8 @@ def __new__(cls, dtype: type = NoneType, *args, **kwargs):
194
199
dimensions = args
195
200
for dimension in dimensions :
196
201
if dimension < 1 :
197
- raise ValueError ("Array cannot be created due to incorrect "
198
- " dimensions. " )
202
+ raise ValueError ("Number of dimensions "
203
+ " cannot be less than 1 " )
199
204
n_dimensions = len (dimensions )
200
205
d_sizes = []
201
206
index = 0
0 commit comments