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

Function param_parse

numpy/f2py/crackfortran.py:3062–3139  ·  view source on GitHub ↗

Recursively parse array dimensions. Parses the declaration of an array variable or parameter `dimension` keyword, and is called recursively if the dimension for this array is a previously defined parameter (found in `params`). Parameters ---------- d : str Fortr

(d, params)

Source from the content-addressed store, hash-verified

3060
3061
3062def param_parse(d, params):
3063 """Recursively parse array dimensions.
3064
3065 Parses the declaration of an array variable or parameter
3066 `dimension` keyword, and is called recursively if the
3067 dimension for this array is a previously defined parameter
3068 (found in `params`).
3069
3070 Parameters
3071 ----------
3072 d : str
3073 Fortran expression describing the dimension of an array.
3074 params : dict
3075 Previously parsed parameters declared in the Fortran source file.
3076
3077 Returns
3078 -------
3079 out : str
3080 Parsed dimension expression.
3081
3082 Examples
3083 --------
3084
3085 * If the line being analyzed is
3086
3087 `integer, parameter, dimension(2) :: pa = (/ 3, 5 /)`
3088
3089 then `d = 2` and we return immediately, with
3090
3091 >>> d = '2'
3092 >>> param_parse(d, params)
3093 2
3094
3095 * If the line being analyzed is
3096
3097 `integer, parameter, dimension(pa) :: pb = (/1, 2, 3/)`
3098
3099 then `d = 'pa'`; since `pa` is a previously parsed parameter,
3100 and `pa = 3`, we call `param_parse` recursively, to obtain
3101
3102 >>> d = 'pa'
3103 >>> params = {'pa': 3}
3104 >>> param_parse(d, params)
3105 3
3106
3107 * If the line being analyzed is
3108
3109 `integer, parameter, dimension(pa(1)) :: pb = (/1, 2, 3/)`
3110
3111 then `d = 'pa(1)'`; since `pa` is a previously parsed parameter,
3112 and `pa(1) = 3`, we call `param_parse` recursively, to obtain
3113
3114 >>> d = 'pa(1)'
3115 >>> params = dict(pa={1: 3, 2: 5})
3116 >>> param_parse(d, params)
3117 3
3118 """
3119 if "(" in d:

Callers 2

analyzevarsFunction · 0.85
param_evalFunction · 0.85

Calls 3

findMethod · 0.80
rfindMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected