@@ -268,8 +268,8 @@ def __getattribute__(self, attr):
268268 except AttributeError :
269269 #happens if field is Object type
270270 return obj
271- if dt .fields :
272- return obj .view ((self .__class__ , obj .dtype . fields ))
271+ if dt .names is not None :
272+ return obj .view ((self .__class__ , obj .dtype ))
273273 return obj
274274 else :
275275 raise AttributeError ("'record' object has no "
@@ -293,8 +293,8 @@ def __getitem__(self, indx):
293293 obj = nt .void .__getitem__ (self , indx )
294294
295295 # copy behavior of record.__getattribute__,
296- if isinstance (obj , nt .void ) and obj .dtype .fields :
297- return obj .view ((self .__class__ , obj .dtype . fields ))
296+ if isinstance (obj , nt .void ) and obj .dtype .names is not None :
297+ return obj .view ((self .__class__ , obj .dtype ))
298298 else :
299299 # return a single element
300300 return obj
@@ -444,7 +444,7 @@ def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None,
444444 return self
445445
446446 def __array_finalize__ (self , obj ):
447- if self .dtype .type is not record and self .dtype .fields :
447+ if self .dtype .type is not record and self .dtype .names is not None :
448448 # if self.dtype is not np.record, invoke __setattr__ which will
449449 # convert it to a record if it is a void dtype.
450450 self .dtype = self .dtype
@@ -472,7 +472,7 @@ def __getattribute__(self, attr):
472472 # with void type convert it to the same dtype.type (eg to preserve
473473 # numpy.record type if present), since nested structured fields do not
474474 # inherit type. Don't do this for non-void structures though.
475- if obj .dtype .fields :
475+ if obj .dtype .names is not None :
476476 if issubclass (obj .dtype .type , nt .void ):
477477 return obj .view (dtype = (self .dtype .type , obj .dtype ))
478478 return obj
@@ -487,7 +487,7 @@ def __setattr__(self, attr, val):
487487
488488 # Automatically convert (void) structured types to records
489489 # (but not non-void structures, subarrays, or non-structured voids)
490- if attr == 'dtype' and issubclass (val .type , nt .void ) and val .fields :
490+ if attr == 'dtype' and issubclass (val .type , nt .void ) and val .names is not None :
491491 val = sb .dtype ((record , val ))
492492
493493 newattr = attr not in self .__dict__
@@ -521,7 +521,7 @@ def __getitem__(self, indx):
521521 # copy behavior of getattr, except that here
522522 # we might also be returning a single element
523523 if isinstance (obj , ndarray ):
524- if obj .dtype .fields :
524+ if obj .dtype .names is not None :
525525 obj = obj .view (type (self ))
526526 if issubclass (obj .dtype .type , nt .void ):
527527 return obj .view (dtype = (self .dtype .type , obj .dtype ))
@@ -577,7 +577,7 @@ def field(self, attr, val=None):
577577
578578 if val is None :
579579 obj = self .getfield (* res )
580- if obj .dtype .fields :
580+ if obj .dtype .names is not None :
581581 return obj
582582 return obj .view (ndarray )
583583 else :
0 commit comments