File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3530,7 +3530,14 @@ def get_fill_value(self):
35303530 """
35313531 if self ._fill_value is None :
35323532 self ._fill_value = _check_fill_value (None , self .dtype )
3533- return self ._fill_value [()]
3533+
3534+ # Temporary workaround to account for the fact that str and bytes
3535+ # scalars cannot be indexed with (), whereas all other numpy
3536+ # scalars can. See issues #7259 and #7267.
3537+ # The if-block can be removed after #7267 has been fixed.
3538+ if isinstance (self ._fill_value , ndarray ):
3539+ return self ._fill_value [()]
3540+ return self ._fill_value
35343541
35353542 def set_fill_value (self , value = None ):
35363543 """
Original file line number Diff line number Diff line change @@ -1819,6 +1819,13 @@ def test_fillvalue_in_view(self):
18191819 y = x .view (dtype = np .int32 )
18201820 assert_ (y .fill_value == 999999 )
18211821
1822+ def test_fillvalue_bytes_or_str (self ):
1823+ # Test whether fill values work as expected for structured dtypes
1824+ # containing bytes or str. See issue #7259.
1825+ a = empty (shape = (3 , ), dtype = "(2)3S,(2)3U" )
1826+ assert_equal (a ["f0" ].fill_value , default_fill_value (b"spam" ))
1827+ assert_equal (a ["f1" ].fill_value , default_fill_value ("eggs" ))
1828+
18221829
18231830class TestUfuncs (TestCase ):
18241831 # Test class for the application of ufuncs on MaskedArrays.
You can’t perform that action at this time.
0 commit comments