(self, attr)
| 439 | self.dtype = self.dtype |
| 440 | |
| 441 | def __getattribute__(self, attr): |
| 442 | # See if ndarray has this attr, and return it if so. (note that this |
| 443 | # means a field with the same name as an ndarray attr cannot be |
| 444 | # accessed by attribute). |
| 445 | try: |
| 446 | return object.__getattribute__(self, attr) |
| 447 | except AttributeError: # attr must be a fieldname |
| 448 | pass |
| 449 | |
| 450 | # look for a field with this name |
| 451 | fielddict = ndarray.__getattribute__(self, 'dtype').fields |
| 452 | try: |
| 453 | res = fielddict[attr][:2] |
| 454 | except (TypeError, KeyError) as e: |
| 455 | raise AttributeError("recarray has no attribute %s" % attr) from e |
| 456 | obj = self.getfield(*res) |
| 457 | |
| 458 | # At this point obj will always be a recarray, since (see |
| 459 | # PyArray_GetField) the type of obj is inherited. Next, if obj.dtype is |
| 460 | # non-structured, convert it to an ndarray. Then if obj is structured |
| 461 | # with void type convert it to the same dtype.type (eg to preserve |
| 462 | # numpy.record type if present), since nested structured fields do not |
| 463 | # inherit type. Don't do this for non-void structures though. |
| 464 | if obj.dtype.names is not None: |
| 465 | if issubclass(obj.dtype.type, nt.void): |
| 466 | return obj.view(dtype=(self.dtype.type, obj.dtype)) |
| 467 | return obj |
| 468 | else: |
| 469 | return obj.view(ndarray) |
| 470 | |
| 471 | # Save the dictionary. |
| 472 | # If the attr is a field name and not in the saved dictionary |
nothing calls this directly
no test coverage detected