@@ -723,6 +723,15 @@ cdef class RandomState:
723
723
724
724
_dtype = np .dtype (dtype )
725
725
726
+ if not _dtype .isnative :
727
+ # numpy 1.17.0, 2019-05-28
728
+ warnings .warn ('Providing a dtype with a non-native byteorder is '
729
+ 'not supported. If you require platform-independent '
730
+ 'byteorder, call byteswap when required.\n In future '
731
+ 'version, providing byteorder will raise a '
732
+ 'ValueError' , DeprecationWarning )
733
+ _dtype = _dtype .newbyteorder ()
734
+
726
735
# Implementation detail: the use a masked method to generate
727
736
# bounded uniform integers. Lemire's method is preferable since it is
728
737
# faster. randomgen allows a choice, we will always use the slower but
@@ -748,11 +757,6 @@ cdef class RandomState:
748
757
ret = _rand_uint8 (low , high , size , _masked , _endpoint , & self ._bitgen , self .lock )
749
758
elif _dtype == np .bool_ :
750
759
ret = _rand_bool (low , high , size , _masked , _endpoint , & self ._bitgen , self .lock )
751
- elif not _dtype .isnative :
752
- raise ValueError ('Providing a dtype with a non-native byteorder '
753
- 'is not supported. If you require '
754
- 'platform-independent byteorder, call byteswap '
755
- 'when required.' )
756
760
else :
757
761
raise TypeError ('Unsupported dtype %r for randint' % _dtype )
758
762
0 commit comments