Exemplo n.º 1
0
 def test_restore_when_bad_key(self):
     with theano.configparser.change_flags(compute_test_value='off'):
         with pytest.raises(ValueError):
             conf = collections.OrderedDict(
                 [('compute_test_value', 'raise'), ('bad_key', True)])
             set_theano_conf(conf)
         assert theano.config.compute_test_value == 'off'
Exemplo n.º 2
0
 def test_restore_when_bad_key(self):
     with theano.configparser.change_flags(compute_test_value='off'):
         with pytest.raises(ValueError):
             conf = collections.OrderedDict([('compute_test_value',
                                              'raise'), ('bad_key', True)])
             set_theano_conf(conf)
         assert theano.config.compute_test_value == 'off'
Exemplo n.º 3
0
 def test_restore_when_bad_key(self):
     with theano.configparser.change_flags(compute_test_value="off"):
         with pytest.raises(ValueError):
             conf = collections.OrderedDict([("compute_test_value",
                                              "raise"), ("bad_key", True)])
             set_theano_conf(conf)
         assert theano.config.compute_test_value == "off"
Exemplo n.º 4
0
 def __exit__(self, typ, value, traceback):
     type(self).get_contexts().pop()
     # self._theano_config is set in Model.__new__
     if hasattr(self, '_old_theano_config'):
         set_theano_conf(self._old_theano_config)
Exemplo n.º 5
0
 def __enter__(self):
     type(self).get_contexts().append(self)
     # self._theano_config is set in Model.__new__
     if hasattr(self, '_theano_config'):
         self._old_theano_config = set_theano_conf(self._theano_config)
     return self
Exemplo n.º 6
0
 def test_restore(self):
     with theano.configparser.change_flags(compute_test_value="off"):
         conf = set_theano_conf({"compute_test_value": "raise"})
         assert conf == {"compute_test_value": "off"}
         conf = set_theano_conf(conf)
         assert conf == {"compute_test_value": "raise"}
Exemplo n.º 7
0
 def test_invalid_key(self):
     with pytest.raises(ValueError) as e:
         set_theano_conf({"bad_key": True})
     e.match("Unknown")
Exemplo n.º 8
0
 def test_restore(self):
     with theano.configparser.change_flags(compute_test_value='off'):
         conf = set_theano_conf({'compute_test_value': 'raise'})
         assert conf == {'compute_test_value': 'off'}
         conf = set_theano_conf(conf)
         assert conf == {'compute_test_value': 'raise'}
Exemplo n.º 9
0
 def __exit__(self, typ, value, traceback):
     type(self).get_contexts().pop()
     # self._theano_config is set in Model.__new__
     if hasattr(self, '_old_theano_config'):
         set_theano_conf(self._old_theano_config)
Exemplo n.º 10
0
 def __enter__(self):
     type(self).get_contexts().append(self)
     # self._theano_config is set in Model.__new__
     if hasattr(self, '_theano_config'):
         self._old_theano_config = set_theano_conf(self._theano_config)
     return self
Exemplo n.º 11
0
 def test_invalid_key(self):
     with pytest.raises(ValueError) as e:
         set_theano_conf({'bad_key': True})
     e.match('Unknown')
Exemplo n.º 12
0
 def test_restore(self):
     with theano.configparser.change_flags(compute_test_value='off'):
         conf = set_theano_conf({'compute_test_value': 'raise'})
         assert conf == {'compute_test_value': 'off'}
         conf = set_theano_conf(conf)
         assert conf == {'compute_test_value': 'raise'}