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'
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'
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"
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)
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
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"}
def test_invalid_key(self): with pytest.raises(ValueError) as e: set_theano_conf({"bad_key": True}) e.match("Unknown")
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'}
def test_invalid_key(self): with pytest.raises(ValueError) as e: set_theano_conf({'bad_key': True}) e.match('Unknown')