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

Method __new__

numpy/core/defchararray.py:2063–2096  ·  view source on GitHub ↗
(subtype, shape, itemsize=1, unicode=False, buffer=None,
                offset=0, strides=None, order='C')

Source from the content-addressed store, hash-verified

2061
2062 """
2063 def __new__(subtype, shape, itemsize=1, unicode=False, buffer=None,
2064 offset=0, strides=None, order='C'):
2065 global _globalvar
2066
2067 if unicode:
2068 dtype = str_
2069 else:
2070 dtype = bytes_
2071
2072 # force itemsize to be a Python int, since using NumPy integer
2073 # types results in itemsize.itemsize being used as the size of
2074 # strings in the new array.
2075 itemsize = int(itemsize)
2076
2077 if isinstance(buffer, str):
2078 # unicode objects do not have the buffer interface
2079 filler = buffer
2080 buffer = None
2081 else:
2082 filler = None
2083
2084 _globalvar = 1
2085 if buffer is None:
2086 self = ndarray.__new__(subtype, shape, (dtype, itemsize),
2087 order=order)
2088 else:
2089 self = ndarray.__new__(subtype, shape, (dtype, itemsize),
2090 buffer=buffer,
2091 offset=offset, strides=strides,
2092 order=order)
2093 if filler is not None:
2094 self[...] = filler
2095 _globalvar = 0
2096 return self
2097
2098 def __array_finalize__(self, obj):
2099 # The b is a special case because it is used for reconstructing.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected