neulab/docprompting-conala huggingface dataset:
Using via numpy.distutils numpy.distutils is part of NumPy, and extends the standard Python distutils module to deal with Fortran sources and F2PY signature files, e.g. compile Fortran sources, call F2PY to construct extension modules, etc.  Example Consider the following setup_file.py for the fib and scalar examples from Three ways to wrap - getting started section: from numpy.distutils.core import Extension

ext1 = Extension(name = 'scalar',
                 sources = ['scalar.f'])
ext2 = Extension(name = 'fib2',
                 sources = ['fib2.pyf', 'fib1.f'])

if __name__ == "__main__":
    from numpy.distutils.core import setup
    setup(name = 'f2py_example',
          description       = "F2PY Users Guide examples",
          author            = "Pearu Peterson",
          author_email      = "pearu@cens.ioc.ee",
          ext_modules = [ext1, ext2]
          )
# End of setup_example.py
 Running python setup_example.py build
 will build two extension modules scalar and fib2 to the build directory.   Extensions to distutils
 numpy.distutils extends distutils with the following features:  
Extension class argument sources may contain Fortran source files. In addition, the list sources may contain at most one F2PY signature file, and in this case, the name of an Extension module must match with the <modulename> used in signature file. It is assumed that an F2PY signature file contains exactly one python
module block. If sources do not contain a signature file, then F2PY is used to scan Fortran source files to construct wrappers to the Fortran codes. Additional options to the F2PY executable can be given using the Extension class argument f2py_options.  
The following new distutils commands are defined:  build_src

to construct Fortran wrapper extension modules, among many other things.  config_fc

to change Fortran compiler options.   Additionally, the build_ext and build_clib commands are also enhanced to support Fortran sources. Run python <setup.py file> config_fc build_src build_ext --help
 to see available options for these commands.  
When building Python packages containing Fortran sources, one can choose different Fortran compilers by using the build_ext command option --fcompiler=<Vendor>. Here <Vendor> can be one of the following names (on linux systems): absoft compaq fujitsu g95 gnu gnu95 intel intele intelem lahey nag nagfor nv pathf95 pg vast
 See numpy_distutils/fcompiler.py for an up-to-date list of supported compilers for different platforms, or run python -m numpy.f2py -c --help-fcompiler
numpy.busdaycalendar.holidays attribute   busdaycalendar.holidays
 
A copy of the holiday array indicating additional invalid days.
numpy.busdaycalendar.weekmask attribute   busdaycalendar.weekmask
 
A copy of the seven-element boolean mask indicating valid days.
numpy.char.add   char.add(x1, x2)[source]
 
Return element-wise string concatenation for two arrays of str or unicode. Arrays x1 and x2 must have the same shape.  Parameters 
 
x1array_like of str or unicode


Input array.  
x2array_like of str or unicode


Input array.    Returns 
 
addndarray


Output array of string_ or unicode_, depending on input types of the same shape as x1 and x2.
numpy.char.array   char.array(obj, itemsize=None, copy=True, unicode=None, order=None)[source]
 
Create a chararray.  Note This class is provided for numarray backward-compatibility. New code (not concerned with numarray compatibility) should use arrays of type string_ or unicode_ and use the free functions in numpy.char for fast vectorized string operations instead.  Versus a regular NumPy array of type str or unicode, this class adds the following functionality:  values automatically have whitespace removed from the end when indexed comparison operators automatically remove whitespace from the end when comparing values vectorized string operations are provided as methods (e.g. str.endswith) and infix operators (e.g. +, *, %)   Parameters 
 
objarray of str or unicode-like


itemsizeint, optional


itemsize is the number of characters per scalar in the resulting array. If itemsize is None, and obj is an object array or a Python list, the itemsize will be automatically determined. If itemsize is provided and obj is of type str or unicode, then the obj string will be chunked into itemsize pieces.  
copybool, optional


If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (itemsize, unicode, order, etc.).  
unicodebool, optional


When true, the resulting chararray can contain Unicode characters, when false only 8-bit characters. If unicode is None and obj is one of the following:  a chararray, an ndarray of type str or unicode
 a Python str or unicode object,  then the unicode setting of the output array will be automatically determined.  
order{‘C’, ‘F’, ‘A’}, optional


Specify the order of the array. If order is ‘C’ (default), then the array will be in C-contiguous order (last-index varies the fastest). If order is ‘F’, then the returned array will be in Fortran-contiguous order (first-index varies the fastest). If order is ‘A’, then the returned array may be in any order (either C-, Fortran-contiguous, or even discontiguous).
numpy.char.asarray   char.asarray(obj, itemsize=None, unicode=None, order=None)[source]
 
Convert the input to a chararray, copying the data only if necessary. Versus a regular NumPy array of type str or unicode, this class adds the following functionality:  values automatically have whitespace removed from the end when indexed comparison operators automatically remove whitespace from the end when comparing values vectorized string operations are provided as methods (e.g. str.endswith) and infix operators (e.g. +, *,``%``)   Parameters 
 
objarray of str or unicode-like


itemsizeint, optional


itemsize is the number of characters per scalar in the resulting array. If itemsize is None, and obj is an object array or a Python list, the itemsize will be automatically determined. If itemsize is provided and obj is of type str or unicode, then the obj string will be chunked into itemsize pieces.  
unicodebool, optional


When true, the resulting chararray can contain Unicode characters, when false only 8-bit characters. If unicode is None and obj is one of the following:  a chararray, an ndarray of type str or ‘unicode` a Python str or unicode object,  then the unicode setting of the output array will be automatically determined.  
order{‘C’, ‘F’}, optional


Specify the order of the array. If order is ‘C’ (default), then the array will be in C-contiguous order (last-index varies the fastest). If order is ‘F’, then the returned array will be in Fortran-contiguous order (first-index varies the fastest).
numpy.char.capitalize   char.capitalize(a)[source]
 
Return a copy of a with only the first character of each element capitalized. Calls str.capitalize element-wise. For 8-bit strings, this method is locale-dependent.  Parameters 
 
aarray_like of str or unicode


Input array of strings to capitalize.    Returns 
 
outndarray


Output array of str or unicode, depending on input types      See also  str.capitalize
  Examples >>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
array(['a1b2', '1b2a', 'b2a1', '2a1b'],
    dtype='|S4')
>>> np.char.capitalize(c)
array(['A1b2', '1b2a', 'B2a1', '2a1b'],
    dtype='|S4')
numpy.char.center   char.center(a, width, fillchar=' ')[source]
 
Return a copy of a with its elements centered in a string of length width. Calls str.center element-wise.  Parameters 
 
aarray_like of str or unicode


widthint


The length of the resulting strings  
fillcharstr or unicode, optional


The padding character to use (default is space).    Returns 
 
outndarray


Output array of str or unicode, depending on input types      See also  str.center
numpy.char.chararray.argsort method   char.chararray.argsort(axis=- 1, kind=None, order=None)[source]
 
Returns the indices that would sort this array. Refer to numpy.argsort for full documentation.  See also  numpy.argsort

equivalent function
numpy.char.chararray.astype method   char.chararray.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)
 
Copy of the array, cast to a specified type.  Parameters 
 
dtypestr or dtype


Typecode or data-type to which the array is cast.  
order{‘C’, ‘F’, ‘A’, ‘K’}, optional


Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.  
casting{‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional


Controls what kind of data casting may occur. Defaults to ‘unsafe’ for backwards compatibility.  ‘no’ means the data types should not be cast at all. ‘equiv’ means only byte-order changes are allowed. ‘safe’ means only casts which can preserve values are allowed. ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed. ‘unsafe’ means any data conversions may be done.   
subokbool, optional


If True, then sub-classes will be passed-through (default), otherwise the returned array will be forced to be a base-class array.  
copybool, optional


By default, astype always returns a newly allocated array. If this is set to false, and the dtype, order, and subok requirements are satisfied, the input array is returned instead of a copy.    Returns 
 
arr_tndarray


Unless copy is False and the other conditions for returning the input array are satisfied (see description for copy input parameter), arr_t is a new array of the same shape as the input array, with dtype, order given by dtype, order.    Raises 
 ComplexWarning

When casting from complex to float or int. To avoid this, one should use a.real.astype(t).     Notes  Changed in version 1.17.0: Casting between a simple data type and a structured one is possible only for “unsafe” casting. Casting to multiple fields is allowed, but casting from multiple fields is not.   Changed in version 1.9.0: Casting from numeric to string types in ‘safe’ casting mode requires that the string dtype length is long enough to store the max integer/float value converted.  Examples >>> x = np.array([1, 2, 2.5])
>>> x
array([1. ,  2. ,  2.5])
 >>> x.astype(int)
array([1, 2, 2])
numpy.char.chararray.base attribute   char.chararray.base
 
Base object if memory is from some other object. Examples The base of an array that owns its memory is None: >>> x = np.array([1,2,3,4])
>>> x.base is None
True
 Slicing creates a view, whose memory is shared with x: >>> y = x[2:]
>>> y.base is x
True
numpy.char.chararray.copy method   char.chararray.copy(order='C')
 
Return a copy of the array.  Parameters 
 
order{‘C’, ‘F’, ‘A’, ‘K’}, optional


Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and numpy.copy are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)      See also  numpy.copy

Similar function with different default behavior  numpy.copyto
  Notes This function is the preferred method for creating an array copy. The function numpy.copy is similar, but it defaults to using order ‘K’, and will not pass sub-classes through by default. Examples >>> x = np.array([[1,2,3],[4,5,6]], order='F')
 >>> y = x.copy()
 >>> x.fill(0)
 >>> x
array([[0, 0, 0],
       [0, 0, 0]])
 >>> y
array([[1, 2, 3],
       [4, 5, 6]])
 >>> y.flags['C_CONTIGUOUS']
True
numpy.char.chararray.count method   char.chararray.count(sub, start=0, end=None)[source]
 
Returns an array with the number of non-overlapping occurrences of substring sub in the range [start, end].  See also  char.count
numpy.char.chararray.data attribute   char.chararray.data
 
Python buffer object pointing to the start of the array’s data.
numpy.char.chararray.decode method   char.chararray.decode(encoding=None, errors=None)[source]
 
Calls str.decode element-wise.  See also  char.decode
numpy.char.chararray.dtype attribute   char.chararray.dtype
 
Data-type of the array’s elements.  Parameters 
 None
  Returns 
 
dnumpy dtype object

    See also  numpy.dtype
  Examples >>> x
array([[0, 1],
       [2, 3]])
>>> x.dtype
dtype('int32')
>>> type(x.dtype)
<type 'numpy.dtype'>
numpy.char.chararray.dump method   char.chararray.dump(file)
 
Dump a pickle of the array to the specified file. The array can be read back with pickle.load or numpy.load.  Parameters 
 
filestr or Path


A string naming the dump file.  Changed in version 1.17.0: pathlib.Path objects are now accepted.
numpy.char.chararray.dumps method   char.chararray.dumps()
 
Returns the pickle of the array as a string. pickle.loads will convert the string back to an array.  Parameters 
 None
numpy.char.chararray.encode method   char.chararray.encode(encoding=None, errors=None)[source]
 
Calls str.encode element-wise.  See also  char.encode
numpy.char.chararray.endswith method   char.chararray.endswith(suffix, start=0, end=None)[source]
 
Returns a boolean array which is True where the string element in self ends with suffix, otherwise False.  See also  char.endswith
numpy.char.chararray.expandtabs method   char.chararray.expandtabs(tabsize=8)[source]
 
Return a copy of each string element where all tab characters are replaced by one or more spaces.  See also  char.expandtabs
numpy.char.chararray.fill method   char.chararray.fill(value)
 
Fill the array with a scalar value.  Parameters 
 
valuescalar


All elements of a will be assigned this value.     Examples >>> a = np.array([1, 2])
>>> a.fill(0)
>>> a
array([0, 0])
>>> a = np.empty(2)
>>> a.fill(1)
>>> a
array([1.,  1.])
numpy.char.chararray.find method   char.chararray.find(sub, start=0, end=None)[source]
 
For each element, return the lowest index in the string where substring sub is found.  See also  char.find
numpy.char.chararray.flags attribute   char.chararray.flags
 
Information about the memory layout of the array. Notes The flags object can be accessed dictionary-like (as in a.flags['WRITEABLE']), or by using lowercased attribute names (as in a.flags.writeable). Short flag names are only supported in dictionary access. Only the WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be changed by the user, via direct assignment to the attribute or dictionary entry, or by calling ndarray.setflags. The array flags cannot be set arbitrarily:  UPDATEIFCOPY can only be set False. WRITEBACKIFCOPY can only be set False. ALIGNED can only be set True if the data is truly aligned. WRITEABLE can only be set True if the array owns its own memory or the ultimate owner of the memory exposes a writeable buffer interface or is a string.  Arrays can be both C-style and Fortran-style contiguous simultaneously. This is clear for 1-dimensional arrays, but can also be true for higher dimensional arrays. Even for contiguous arrays a stride for a given dimension arr.strides[dim] may be arbitrary if arr.shape[dim] == 1 or the array has no elements. It does not generally hold that self.strides[-1] == self.itemsize for C-style contiguous arrays or self.strides[0] == self.itemsize for Fortran-style contiguous arrays is true.  Attributes 
 C_CONTIGUOUS (C)

The data is in a single, C-style contiguous segment.  F_CONTIGUOUS (F)

The data is in a single, Fortran-style contiguous segment.  OWNDATA (O)

The array owns the memory it uses or borrows it from another object.  WRITEABLE (W)

The data area can be written to. Setting this to False locks the data, making it read-only. A view (slice, etc.) inherits WRITEABLE from its base array at creation time, but a view of a writeable array may be subsequently locked while the base array remains writeable. (The opposite is not true, in that a view of a locked array may not be made writeable. However, currently, locking a base object does not lock any views that already reference it, so under that circumstance it is possible to alter the contents of a locked array via a previously created writeable view onto it.) Attempting to change a non-writeable array raises a RuntimeError exception.  ALIGNED (A)

The data and all elements are aligned appropriately for the hardware.  WRITEBACKIFCOPY (X)

This array is a copy of some other array. The C-API function PyArray_ResolveWritebackIfCopy must be called before deallocating to the base array will be updated with the contents of this array.  UPDATEIFCOPY (U)

(Deprecated, use WRITEBACKIFCOPY) This array is a copy of some other array. When this array is deallocated, the base array will be updated with the contents of this array.  FNC

F_CONTIGUOUS and not C_CONTIGUOUS.  FORC

F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).  BEHAVED (B)

ALIGNED and WRITEABLE.  CARRAY (CA)

BEHAVED and C_CONTIGUOUS.  FARRAY (FA)

BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.
numpy.char.chararray.flat attribute   char.chararray.flat
 
A 1-D iterator over the array. This is a numpy.flatiter instance, which acts similarly to, but is not a subclass of, Python’s built-in iterator object.  See also  flatten

Return a copy of the array collapsed into one dimension.  flatiter
  Examples >>> x = np.arange(1, 7).reshape(2, 3)
>>> x
array([[1, 2, 3],
       [4, 5, 6]])
>>> x.flat[3]
4
>>> x.T
array([[1, 4],
       [2, 5],
       [3, 6]])
>>> x.T.flat[3]
5
>>> type(x.flat)
<class 'numpy.flatiter'>
 An assignment example: >>> x.flat = 3; x
array([[3, 3, 3],
       [3, 3, 3]])
>>> x.flat[[1,4]] = 1; x
array([[3, 1, 3],
       [3, 1, 3]])
numpy.char.chararray.flatten method   char.chararray.flatten(order='C')
 
Return a copy of the array collapsed into one dimension.  Parameters 
 
order{‘C’, ‘F’, ‘A’, ‘K’}, optional


‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.    Returns 
 
yndarray


A copy of the input array, flattened to one dimension.      See also  ravel

Return a flattened array.  flat

A 1-D flat iterator over the array.    Examples >>> a = np.array([[1,2], [3,4]])
>>> a.flatten()
array([1, 2, 3, 4])
>>> a.flatten('F')
array([1, 3, 2, 4])
numpy.char.chararray.getfield method   char.chararray.getfield(dtype, offset=0)
 
Returns a field of the given array as a certain type. A field is a view of the array data with a given data-type. The values in the view are determined by the given type and the offset into the current array in bytes. The offset needs to be such that the view dtype fits in the array dtype; for example an array of dtype complex128 has 16-byte elements. If taking a view with a 32-bit integer (4 bytes), the offset needs to be between 0 and 12 bytes.  Parameters 
 
dtypestr or dtype


The data type of the view. The dtype size of the view can not be larger than that of the array itself.  
offsetint


Number of bytes to skip before beginning the element view.     Examples >>> x = np.diag([1.+1.j]*2)
>>> x[1, 1] = 2 + 4.j
>>> x
array([[1.+1.j,  0.+0.j],
       [0.+0.j,  2.+4.j]])
>>> x.getfield(np.float64)
array([[1.,  0.],
       [0.,  2.]])
 By choosing an offset of 8 bytes we can select the complex part of the array for our view: >>> x.getfield(np.float64, offset=8)
array([[1.,  0.],
       [0.,  4.]])
numpy.char.chararray.imag attribute   char.chararray.imag
 
The imaginary part of the array. Examples >>> x = np.sqrt([1+0j, 0+1j])
>>> x.imag
array([ 0.        ,  0.70710678])
>>> x.imag.dtype
dtype('float64')
numpy.char.chararray.index method   char.chararray.index(sub, start=0, end=None)[source]
 
Like find, but raises ValueError when the substring is not found.  See also  char.index
numpy.char.chararray.isalnum method   char.chararray.isalnum()[source]
 
Returns true for each element if all characters in the string are alphanumeric and there is at least one character, false otherwise.  See also  char.isalnum
numpy.char.chararray.isalpha method   char.chararray.isalpha()[source]
 
Returns true for each element if all characters in the string are alphabetic and there is at least one character, false otherwise.  See also  char.isalpha
numpy.char.chararray.isdecimal method   char.chararray.isdecimal()[source]
 
For each element in self, return True if there are only decimal characters in the element.  See also  char.isdecimal
numpy.char.chararray.isdigit method   char.chararray.isdigit()[source]
 
Returns true for each element if all characters in the string are digits and there is at least one character, false otherwise.  See also  char.isdigit
numpy.char.chararray.islower method   char.chararray.islower()[source]
 
Returns true for each element if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.  See also  char.islower
numpy.char.chararray.isnumeric method   char.chararray.isnumeric()[source]
 
For each element in self, return True if there are only numeric characters in the element.  See also  char.isnumeric
numpy.char.chararray.isspace method   char.chararray.isspace()[source]
 
Returns true for each element if there are only whitespace characters in the string and there is at least one character, false otherwise.  See also  char.isspace
numpy.char.chararray.istitle method   char.chararray.istitle()[source]
 
Returns true for each element if the element is a titlecased string and there is at least one character, false otherwise.  See also  char.istitle
numpy.char.chararray.isupper method   char.chararray.isupper()[source]
 
Returns true for each element if all cased characters in the string are uppercase and there is at least one character, false otherwise.  See also  char.isupper
numpy.char.chararray.item method   char.chararray.item(*args)
 
Copy an element of an array to a standard Python scalar and return it.  Parameters 
 
*argsArguments (variable number and type)


 none: in this case, the method only works for arrays with one element (a.size == 1), which element is copied into a standard Python scalar object and returned. int_type: this argument is interpreted as a flat index into the array, specifying which element to copy and return. tuple of int_types: functions as does a single int_type argument, except that the argument is interpreted as an nd-index into the array.     Returns 
 
zStandard Python scalar object


A copy of the specified element of the array as a suitable Python scalar     Notes When the data type of a is longdouble or clongdouble, item() returns a scalar array object because there is no available Python scalar that would not lose information. Void arrays return a buffer object for item(), unless fields are defined, in which case a tuple is returned. item is very similar to a[args], except, instead of an array scalar, a standard Python scalar is returned. This can be useful for speeding up access to elements of the array and doing arithmetic on elements of the array using Python’s optimized math. Examples >>> np.random.seed(123)
>>> x = np.random.randint(9, size=(3, 3))
>>> x
array([[2, 2, 6],
       [1, 3, 6],
       [1, 0, 1]])
>>> x.item(3)
1
>>> x.item(7)
0
>>> x.item((0, 1))
2
>>> x.item((2, 2))
1
numpy.char.chararray.itemsize attribute   char.chararray.itemsize
 
Length of one array element in bytes. Examples >>> x = np.array([1,2,3], dtype=np.float64)
>>> x.itemsize
8
>>> x = np.array([1,2,3], dtype=np.complex128)
>>> x.itemsize
16
numpy.char.chararray.join method   char.chararray.join(seq)[source]
 
Return a string which is the concatenation of the strings in the sequence seq.  See also  char.join
numpy.char.chararray.ljust method   char.chararray.ljust(width, fillchar=' ')[source]
 
Return an array with the elements of self left-justified in a string of length width.  See also  char.ljust
numpy.char.chararray.lower method   char.chararray.lower()[source]
 
Return an array with the elements of self converted to lowercase.  See also  char.lower