Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Added some unit tests for the backend configurator.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjc committed May 7, 2015
1 parent 41a89cc commit e78b46b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sknn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __getattr__(self, name):
if name.endswith('32'):
flags = ',floatX=float32'
if name.endswith('64'):
flags = ',floatX=float32'
flags = ',floatX=float64'

if name.startswith('cpu'):
return self.configure('device=cpu'+flags)
Expand Down
43 changes: 43 additions & 0 deletions sknn/tests/test_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import unittest
from nose.tools import (assert_in, assert_equal)

import os
import sys

import sknn


class TestBackendPseudoModule(unittest.TestCase):

def setUp(self):
if 'THEANO_FLAGS' in os.environ:
del os.environ['THEANO_FLAGS']
for name in sys.modules.keys():
if name.startswith('theano'):
del sys.modules[name]
sys.modules['sknn.backend'].configured = False

def test_TheanoWarning(self):
pass

def _check(self, flags):
assert_in('THEANO_FLAGS', os.environ)
variable = os.environ['THEANO_FLAGS']
for f in flags:
assert_in(f, variable)

def test_FlagsGPU32(self):
from sknn.backend import gpu32
self._check(['floatX=float32','device=gpu'])

def test_FlagsCPU32(self):
from sknn.backend import cpu32
self._check(['floatX=float32','device=cpu'])

def test_FlagsGPU64(self):
from sknn.backend import gpu64
self._check(['floatX=float64','device=gpu'])

def test_FlagsCPU64(self):
from sknn.backend import cpu64
self._check(['floatX=float64','device=cpu'])

0 comments on commit e78b46b

Please sign in to comment.