MCPcopy Create free account
hub / github.com/numpy/numpy / __getattribute__

Method __getattribute__

numpy/core/records.py:242–265  ·  view source on GitHub ↗
(self, attr)

Source from the content-addressed store, hash-verified

240 return super().__str__()
241
242 def __getattribute__(self, attr):
243 if attr in ('setfield', 'getfield', 'dtype'):
244 return nt.void.__getattribute__(self, attr)
245 try:
246 return nt.void.__getattribute__(self, attr)
247 except AttributeError:
248 pass
249 fielddict = nt.void.__getattribute__(self, 'dtype').fields
250 res = fielddict.get(attr, None)
251 if res:
252 obj = self.getfield(*res[:2])
253 # if it has fields return a record,
254 # otherwise return the object
255 try:
256 dt = obj.dtype
257 except AttributeError:
258 #happens if field is Object type
259 return obj
260 if dt.names is not None:
261 return obj.view((self.__class__, obj.dtype))
262 return obj
263 else:
264 raise AttributeError("'record' object has no "
265 "attribute '%s'" % attr)
266
267 def __setattr__(self, attr, val):
268 if attr in ('setfield', 'getfield', 'dtype'):

Callers 4

__setattr__Method · 0.45
__getattribute__Method · 0.45
__setattr__Method · 0.45
fieldMethod · 0.45

Calls 2

getMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected