Skip to content

Commit d880dce

Browse files
committed
Fix bugs and warnings from LGTM report
1 parent 26752c3 commit d880dce

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

numpy/f2py/crackfortran.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,8 @@ def _eval_scalar(value, params):
24152415
if _is_kind_number(value):
24162416
value = value.split('_')[0]
24172417
try:
2418-
value = str(eval(value, {}, params))
2418+
value = eval(value, {}, params)
2419+
value = (repr if isinstance(value, str) else str)(value)
24192420
except (NameError, SyntaxError, TypeError):
24202421
return value
24212422
except Exception as msg:
@@ -2614,10 +2615,6 @@ def analyzevars(block):
26142615
vars[n]['dimension'].append(d)
26152616

26162617
if 'dimension' in vars[n]:
2617-
if isintent_c(vars[n]):
2618-
shape_macro = 'shape'
2619-
else:
2620-
shape_macro = 'shape' # 'fshape'
26212618
if isstringarray(vars[n]):
26222619
if 'charselector' in vars[n]:
26232620
d = vars[n]['charselector']
@@ -2647,7 +2644,6 @@ def analyzevars(block):
26472644
n_is_input = l_or(isintent_in, isintent_inout,
26482645
isintent_inplace)(vars[n])
26492646
if 'dimension' in vars[n]: # n is array
2650-
ni = len(vars[n]['dimension']) # array dimensionality
26512647
for i, d in enumerate(vars[n]['dimension']):
26522648
coeffs_and_deps = dimension_exprs.get(d)
26532649
if coeffs_and_deps is None:
@@ -2721,7 +2717,6 @@ def analyzevars(block):
27212717
if v_deps:
27222718
vars[v]['depend'] = list(set(v_deps))
27232719
elif isstring(vars[n]):
2724-
length = '1'
27252720
if 'charselector' in vars[n]:
27262721
if '*' in vars[n]['charselector']:
27272722
length = _eval_length(vars[n]['charselector']['*'],

numpy/f2py/symbolic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def __lt__(self, other):
205205
return self.data < other.data
206206
return NotImplemented
207207

208+
def __le__(self, other): return self == other or self < other
209+
210+
def __gt__(self, other): return not (self <= other)
211+
212+
def __ge__(self, other): return not (self < other)
213+
208214
def __repr__(self):
209215
return f'{type(self).__name__}({self.op}, {self.data!r})'
210216

@@ -354,7 +360,7 @@ def __add__(self, other):
354360
return normalize(r)
355361
if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL):
356362
return self + as_complex(other)
357-
elif self.op is (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX:
363+
elif self.op in (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX:
358364
return as_complex(self) + other
359365
elif self.op is Op.REAL and other.op is Op.INTEGER:
360366
return self + as_real(other, kind=self.data[1])

0 commit comments

Comments
 (0)