6
6
import re
7
7
from functools import reduce
8
8
from typing import Any
9
+ import sys
9
10
10
11
import numpy as np
11
12
from numcodecs .compat import ensure_bytes
62
63
63
64
__all__ = ["Array" ]
64
65
66
+ if "pytest" in sys .modules :
67
+ from packaging .version import Version
68
+
69
+ if Version (np .__version__ ) < Version ("2" ):
70
+ # Some data types returned by numpy changed in numpy 2.0, so skip
71
+ # doc tests on older versions
72
+ __doctest_skip__ = ["*" ]
73
+
65
74
66
75
# noinspection PyUnresolvedReferences
67
76
class Array :
@@ -609,11 +618,11 @@ def islice(self, start=None, end=None):
609
618
610
619
Iterate over part of the array:
611
620
>>> for value in z.islice(25, 30): value;
612
- 25
613
- 26
614
- 27
615
- 28
616
- 29
621
+ np.int64(25)
622
+ np.int64(26)
623
+ np.int64(27)
624
+ np.int64(28)
625
+ np.int64(29)
617
626
"""
618
627
619
628
if len (self .shape ) == 0 :
@@ -679,7 +688,7 @@ def __getitem__(self, selection):
679
688
Retrieve a single item::
680
689
681
690
>>> z[5]
682
- 5
691
+ np.int64(5)
683
692
684
693
Retrieve a region via slicing::
685
694
@@ -706,7 +715,7 @@ def __getitem__(self, selection):
706
715
Retrieve an item::
707
716
708
717
>>> z[2, 2]
709
- 22
718
+ np.int64(22)
710
719
711
720
Retrieve a region via slicing::
712
721
@@ -830,7 +839,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
830
839
Retrieve a single item::
831
840
832
841
>>> z.get_basic_selection(5)
833
- 5
842
+ np.int64(5)
834
843
835
844
Retrieve a region via slicing::
836
845
@@ -852,7 +861,7 @@ def get_basic_selection(self, selection=Ellipsis, out=None, fields=None):
852
861
Retrieve an item::
853
862
854
863
>>> z.get_basic_selection((2, 2))
855
- 22
864
+ np.int64(22)
856
865
857
866
Retrieve a region via slicing::
858
867
@@ -2819,7 +2828,7 @@ def view(
2819
2828
>>> v[:]
2820
2829
array([False, False, True, ..., True, False, False])
2821
2830
>>> np.all(a[:].view(dtype=bool) == v[:])
2822
- True
2831
+ np.True_
2823
2832
2824
2833
An array can be viewed with a dtype with a different item size, however
2825
2834
some care is needed to adjust the shape and chunk shape so that chunk
@@ -2833,7 +2842,7 @@ def view(
2833
2842
>>> v[:10]
2834
2843
array([0, 0, 1, 0, 2, 0, 3, 0, 4, 0], dtype=uint8)
2835
2844
>>> np.all(a[:].view('u1') == v[:])
2836
- True
2845
+ np.True_
2837
2846
2838
2847
Change fill value for uninitialized chunks:
2839
2848
0 commit comments