@@ -15,49 +15,35 @@ def __init__(self, *args):
15
15
super ().__init__ (self ._msg .format (* args ))
16
16
17
17
18
- class ContainsGroupError (_BaseZarrError ):
19
- _msg = "path {0!r} contains a group"
18
+ class _BaseZarrIndexError (IndexError ):
19
+ _msg = ""
20
+
21
+ def __init__ (self , * args ):
22
+ super ().__init__ (self ._msg .format (* args ))
20
23
21
24
22
- def err_contains_group ( path ):
23
- raise ContainsGroupError ( path ) # pragma: no cover
25
+ class ContainsGroupError ( _BaseZarrError ):
26
+ _msg = " path {0!r} contains a group"
24
27
25
28
26
29
class ContainsArrayError (_BaseZarrError ):
27
30
_msg = "path {0!r} contains an array"
28
31
29
32
30
- def err_contains_array (path ):
31
- raise ContainsArrayError (path ) # pragma: no cover
32
-
33
-
34
33
class ArrayNotFoundError (_BaseZarrError ):
35
34
_msg = "array not found at path %r' {0!r}"
36
35
37
36
38
- def err_array_not_found (path ):
39
- raise ArrayNotFoundError (path ) # pragma: no cover
40
-
41
-
42
37
class GroupNotFoundError (_BaseZarrError ):
43
38
_msg = "group not found at path {0!r}"
44
39
45
40
46
- def err_group_not_found (path ):
47
- raise GroupNotFoundError (path ) # pragma: no cover
48
-
49
-
50
41
class PathNotFoundError (_BaseZarrError ):
51
42
_msg = "nothing found at path {0!r}"
52
43
53
44
54
- def err_path_not_found (path ):
55
- raise PathNotFoundError (path ) # pragma: no cover
56
-
57
-
58
- def err_bad_compressor (compressor ):
59
- raise ValueError ('bad compressor; expected Codec object, found %r' %
60
- compressor )
45
+ class BadCompressorError (_BaseZarrError ):
46
+ _msg = "bad compressor; expected Codec object, found {0!r}"
61
47
62
48
63
49
class FSPathExistNotDir (GroupNotFoundError ):
@@ -69,25 +55,23 @@ def __init__(self):
69
55
super ().__init__ ("object is read-only" )
70
56
71
57
72
- def err_read_only ():
73
- raise ReadOnlyError () # pragma: no cover
74
-
58
+ class BoundsCheckError (_BaseZarrIndexError ):
59
+ _msg = "index out of bounds for dimension with length {0}"
75
60
76
- def err_boundscheck (dim_len ):
77
- raise IndexError ('index out of bounds for dimension with length {}'
78
- .format (dim_len ))
79
61
80
-
81
- def err_negative_step ( ):
82
- raise IndexError ( ' only slices with step >= 1 are supported' )
62
+ class NegativeStepError ( IndexError ):
63
+ def __init__ ( self ):
64
+ super (). __init__ ( " only slices with step >= 1 are supported" )
83
65
84
66
85
67
def err_too_many_indices (selection , shape ):
86
68
raise IndexError ('too many indices for array; expected {}, got {}'
87
69
.format (len (shape ), len (selection )))
88
70
89
71
90
- def err_vindex_invalid_selection (selection ):
91
- raise IndexError ('unsupported selection type for vectorized indexing; only '
92
- 'coordinate selection (tuple of integer arrays) and mask selection '
93
- '(single Boolean array) are supported; got {!r}' .format (selection ))
72
+ class VindexInvalidSelectionError (_BaseZarrIndexError ):
73
+ _msg = (
74
+ "unsupported selection type for vectorized indexing; only "
75
+ "coordinate selection (tuple of integer arrays) and mask selection "
76
+ "(single Boolean array) are supported; got {0!r}"
77
+ )
0 commit comments