Skip to content

Commit 26752c3

Browse files
committed
Workaround numpy.tests.test_warnings bug of treating local warn function as warnings.warn
1 parent 7b229a2 commit 26752c3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

numpy/f2py/symbolic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ExprWarning(UserWarning):
103103
pass
104104

105105

106-
def warn(message):
106+
def ewarn(message):
107107
warnings.warn(message, ExprWarning, stacklevel=2)
108108

109109

@@ -489,7 +489,7 @@ def __getitem__(self, index):
489489
if not isinstance(index, tuple):
490490
index = index,
491491
if len(index) > 1:
492-
warn(f'C-index should be a single expression but got `{index}`')
492+
ewarn(f'C-index should be a single expression but got `{index}`')
493493
return Expr(Op.INDEXING, (self,) + index)
494494

495495
def substitute(self, symbols_map):
@@ -525,8 +525,8 @@ def substitute(self, symbols_map):
525525
else:
526526
r += term.substitute(symbols_map) * coeff
527527
if r is None:
528-
warn('substitute: empty TERMS expression interpreted as'
529-
' int-literal 0')
528+
ewarn('substitute: empty TERMS expression interpreted as'
529+
' int-literal 0')
530530
return as_number(0)
531531
return r
532532
if self.op is Op.FACTORS:
@@ -537,8 +537,8 @@ def substitute(self, symbols_map):
537537
else:
538538
r *= base.substitute(symbols_map) ** exponent
539539
if r is None:
540-
warn('substitute: empty FACTORS expression interpreted'
541-
' as int-literal 1')
540+
ewarn('substitute: empty FACTORS expression interpreted'
541+
' as int-literal 1')
542542
return as_number(1)
543543
return r
544544
if self.op is Op.APPLY:
@@ -1260,5 +1260,5 @@ def _fromstring_worker(s, dummy=None):
12601260
# f2py special dummy name
12611261
return as_symbol(r)
12621262

1263-
warn(f'fromstring: treating {r!r} as symbol')
1263+
ewarn(f'fromstring: treating {r!r} as symbol')
12641264
return as_symbol(r)

0 commit comments

Comments
 (0)