diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2021-09-01 22:54:12 +0300 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2021-09-01 22:54:12 +0300 |
commit | d880dce560fd6369d7418ba83c03cc5947993103 (patch) | |
tree | 31b9866922b6440fe65d688c7d16af3bfae9bed5 | |
parent | 26752c3ad454f72a94cc7db32ccba43a76a85a5e (diff) | |
download | numpy-d880dce560fd6369d7418ba83c03cc5947993103.tar.gz |
Fix bugs and warnings from LGTM report
-rwxr-xr-x | numpy/f2py/crackfortran.py | 9 | ||||
-rw-r--r-- | numpy/f2py/symbolic.py | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index b675c936d..8cb1f73d2 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -2415,7 +2415,8 @@ def _eval_scalar(value, params): if _is_kind_number(value): value = value.split('_')[0] try: - value = str(eval(value, {}, params)) + value = eval(value, {}, params) + value = (repr if isinstance(value, str) else str)(value) except (NameError, SyntaxError, TypeError): return value except Exception as msg: @@ -2614,10 +2615,6 @@ def analyzevars(block): vars[n]['dimension'].append(d) if 'dimension' in vars[n]: - if isintent_c(vars[n]): - shape_macro = 'shape' - else: - shape_macro = 'shape' # 'fshape' if isstringarray(vars[n]): if 'charselector' in vars[n]: d = vars[n]['charselector'] @@ -2647,7 +2644,6 @@ def analyzevars(block): n_is_input = l_or(isintent_in, isintent_inout, isintent_inplace)(vars[n]) if 'dimension' in vars[n]: # n is array - ni = len(vars[n]['dimension']) # array dimensionality for i, d in enumerate(vars[n]['dimension']): coeffs_and_deps = dimension_exprs.get(d) if coeffs_and_deps is None: @@ -2721,7 +2717,6 @@ def analyzevars(block): if v_deps: vars[v]['depend'] = list(set(v_deps)) elif isstring(vars[n]): - length = '1' if 'charselector' in vars[n]: if '*' in vars[n]['charselector']: length = _eval_length(vars[n]['charselector']['*'], diff --git a/numpy/f2py/symbolic.py b/numpy/f2py/symbolic.py index f0b1da288..56faa309c 100644 --- a/numpy/f2py/symbolic.py +++ b/numpy/f2py/symbolic.py @@ -205,6 +205,12 @@ class Expr: return self.data < other.data return NotImplemented + def __le__(self, other): return self == other or self < other + + def __gt__(self, other): return not (self <= other) + + def __ge__(self, other): return not (self < other) + def __repr__(self): return f'{type(self).__name__}({self.op}, {self.data!r})' @@ -354,7 +360,7 @@ class Expr: return normalize(r) if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL): return self + as_complex(other) - elif self.op is (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX: + elif self.op in (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX: return as_complex(self) + other elif self.op is Op.REAL and other.op is Op.INTEGER: return self + as_real(other, kind=self.data[1]) |