提交 f436939a authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add mechanism to specify behaviour of numpy.seterr.

上级 d75c6f30
...@@ -81,6 +81,36 @@ import gof ...@@ -81,6 +81,36 @@ import gof
if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'): if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
import theano.sandbox.cuda import theano.sandbox.cuda
# Use config.numpy to call numpy.seterr
import numpy
if config.numpy.seterr_all == 'None':
_all = None
else:
_all = config.numpy.seterr_all
if config.numpy.seterr_divide == 'None':
_divide = None
else:
_divide = config.numpy.seterr_divide
if config.numpy.seterr_over == 'None':
_over = None
else:
_over = config.numpy.seterr_over
if config.numpy.seterr_under == 'None':
_under = None
else:
_under = config.numpy.seterr_under
if config.numpy.seterr_invalid == 'None':
_invalid = None
else:
_invalid = config.numpy.seterr_invalid
numpy.seterr(
all=_all,
divide=_divide,
over=_over,
under=_under,
invalid=_invalid)
del _all, _divide, _over, _under, _invalid
## import scalar_opt ## import scalar_opt
### This is defined here because it is designed to work across symbolic datatypes ### This is defined here because it is designed to work across symbolic datatypes
......
...@@ -115,6 +115,44 @@ AddConfigVar('experimental.mrg', ...@@ -115,6 +115,44 @@ AddConfigVar('experimental.mrg',
"Another random number generator that work on the gpu", "Another random number generator that work on the gpu",
BoolParam(False)) BoolParam(False))
AddConfigVar('numpy.seterr_all',
("Sets numpy's behaviour for floating-point errors, ",
"see numpy.seterr. "
"'None' means not to change numpy's default, which can be "
"different for different numpy releases. "
"This flag sets the default behaviour for all kinds of floating-"
"point errors, its effect can be overriden for specific errors "
"by the following flags: seterr_divide, seterr_over, "
"seterr_under and seterr_invalid."),
EnumStr('ignore', 'warn', 'raise', 'call', 'print', 'log', 'None',
allow_override=False))
AddConfigVar('numpy.seterr_divide',
("Sets numpy's behavior for division by zero, see numpy.seterr. "
"'None' means using the default, defined by numpy.seterr_all."),
EnumStr('None', 'ignore', 'warn', 'raise', 'call', 'print', 'log',
allow_override=False))
AddConfigVar('numpy.seterr_over',
("Sets numpy's behavior for floating-point overflow, "
"see numpy.seterr. "
"'None' means using the default, defined by numpy.seterr_all."),
EnumStr('None', 'ignore', 'warn', 'raise', 'call', 'print', 'log',
allow_override=False))
AddConfigVar('numpy.seterr_under',
("Sets numpy's behavior for floating-point underflow, "
"see numpy.seterr. "
"'None' means using the default, defined by numpy.seterr_all."),
EnumStr('None', 'ignore', 'warn', 'raise', 'call', 'print', 'log',
allow_override=False))
AddConfigVar('numpy.seterr_invalid',
("Sets numpy's behavior for invalid floating-point operation, "
"see numpy.seterr. "
"'None' means using the default, defined by numpy.seterr_all."),
EnumStr('None', 'ignore', 'warn', 'raise', 'call', 'print', 'log',
allow_override=False))
### ###
### To disable some warning about old bug that are fixed now. ### To disable some warning about old bug that are fixed now.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论