summaryrefslogtreecommitdiff
path: root/numpy/f2py
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2020-11-01 12:55:18 +0000
committerGitHub <noreply@github.com>2020-11-01 12:55:18 +0000
commit5b5c15e3096f0f040a70040dc006fa23fec371d0 (patch)
tree81834b47d03d2d7d790e00f33faee327fc349d56 /numpy/f2py
parent3052bbcf1ec4de331154f920dd9bba0bbc200b95 (diff)
parent48a9a519cc7a4d52ff85577efee0048350d07254 (diff)
downloadnumpy-5b5c15e3096f0f040a70040dc006fa23fec371d0.tar.gz
Merge pull request #17670 from eric-wieser/test-getarrlen
DOC: f2py: Add a docstring for getarrlen
Diffstat (limited to 'numpy/f2py')
-rwxr-xr-xnumpy/f2py/crackfortran.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 67101b353..6ff30560d 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -2196,6 +2196,37 @@ _varname_match = re.compile(r'\A[a-z]\w*\Z').match
def getarrlen(dl, args, star='*'):
+ """
+ Parameters
+ ----------
+ dl : sequence of two str objects
+ dimensions of the array
+ args : Iterable[str]
+ symbols used in the expression
+ star : Any
+ unused
+
+ Returns
+ -------
+ expr : str
+ Some numeric expression as a string
+ arg : Optional[str]
+ If understood, the argument from `args` present in `expr`
+ expr2 : Optional[str]
+ If understood, an expression fragment that should be used as
+ ``"(%s%s".format(something, expr2)``.
+
+ Examples
+ --------
+ >>> getarrlen(['10*x + 20', '40*x'], {'x'})
+ ('30 * x - 19', 'x', '+19)/(30)')
+ >>> getarrlen(['1', '10*x + 20'], {'x'})
+ ('10 * x + 20', 'x', '-20)/(10)')
+ >>> getarrlen(['10*x + 20', '1'], {'x'})
+ ('-10 * x - 18', 'x', '+18)/(-10)')
+ >>> getarrlen(['20', '1'], {'x'})
+ ('-18', None, None)
+ """
edl = []
try:
edl.append(myeval(dl[0], {}, {}))