MCPcopy Index your code
hub / github.com/numpy/numpy / __getattribute__

Method __getattribute__

numpy/_core/records.py:215–237  ·  view source on GitHub ↗
(self, attr)

Source from the content-addressed store, hash-verified

213 return super().__str__()
214
215 def __getattribute__(self, attr):
216 if attr in ('setfield', 'getfield', 'dtype'):
217 return nt.void.__getattribute__(self, attr)
218 try:
219 return nt.void.__getattribute__(self, attr)
220 except AttributeError:
221 pass
222 fielddict = nt.void.__getattribute__(self, 'dtype').fields
223 res = fielddict.get(attr, None)
224 if res:
225 obj = self.getfield(*res[:2])
226 # if it has fields return a record,
227 # otherwise return the object
228 try:
229 dt = obj.dtype
230 except AttributeError:
231 # happens if field is Object type
232 return obj
233 if dt.names is not None:
234 return obj.view((self.__class__, obj.dtype))
235 return obj
236 else:
237 raise AttributeError(f"'record' object has no attribute '{attr}'")
238
239 def __setattr__(self, attr, val):
240 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