예제 #1
0
	def test_value_bounds_inf(self):
		mydict = {(100,100,100): 50, (0,200,0): 50}
		myfunc = create(mydict,[1,1,1])
		self.assertEqual(myfunc.value_bounds((50,50,50)),(np.NINF,50))
		myfunc = create(mydict,[-1,-1,-1])
		self.assertEqual(myfunc.value_bounds((50,50,50)),(50,np.inf))
		self.assertEqual(myfunc.value_bounds((200,0,50)),(np.NINF,np.inf))
예제 #2
0
 def test_value_bounds_inf(self):
     mydict = {(100, 100, 100): 50, (0, 200, 0): 50}
     myfunc = create(mydict, [1, 1, 1])
     self.assertEqual(myfunc.value_bounds((50, 50, 50)), (np.NINF, 50))
     myfunc = create(mydict, [-1, -1, -1])
     self.assertEqual(myfunc.value_bounds((50, 50, 50)), (50, np.inf))
     self.assertEqual(myfunc.value_bounds((200, 0, 50)), (np.NINF, np.inf))
예제 #3
0
 def test_value_bounds(self):
     mydict = {(10, 10, 1): 50, (0, 0, 0): 20}
     myfunc = create(mydict, [1, 1, 1], maxval=100, minval=0.0)
     self.assertEqual(myfunc.value_bounds((5, 5, 0.5)), (20, 50))
     self.assertEqual(myfunc.value_bounds((10, 10, 1)), (50, 50))
     self.assertEqual(myfunc.value_bounds((20, 20, 2)), (50, 100))
     self.assertEqual(myfunc.value_bounds((0, 0, 1)), (20, 50))
     self.assertEqual(myfunc.value_bounds((0, 0, 0)), (20, 20))
     self.assertEqual(myfunc.value_bounds((-1, 0, 0)), (0, 20))
예제 #4
0
	def test_value_bounds(self):
		mydict = {(10,10,1): 50, (0,0,0): 20}
		myfunc = create(mydict,[1,1,1],maxval=100,minval=0.0)
		self.assertEqual(myfunc.value_bounds((5,5,0.5)),(20,50))
		self.assertEqual(myfunc.value_bounds((10,10,1)),(50,50))
		self.assertEqual(myfunc.value_bounds((20,20,2)),(50,100))
		self.assertEqual(myfunc.value_bounds((0,0,1)),(20,50))
		self.assertEqual(myfunc.value_bounds((0,0,0)),(20,20))
		self.assertEqual(myfunc.value_bounds((-1,0,0)),(0,20))
예제 #5
0
 def test_extreme(self):
     mydict = {
         (0.0, ): 100.0,
         (30.0, ): 30.0,
         (10.0, ): 60.0,
         (5.0, ): 85.0,
         (20.0, ): 50.0,
         (10000.0, ): 0.0
     }
     myfunc = create(mydict, [-1])
     self.assertEqual(myfunc.calculate([10000])[0], 0.0)
     self.assertEqual(myfunc.calculate([30])[0], 30.0)
예제 #6
0
 def test_bad_monotone_vector(self):
     mydict = {(0, 0, 0): 100, (1, 1, 1): 0}
     with pytest.raises(ScoreCreationError):
         create(mydict, [-1, -1, 0])
예제 #7
0
	def test_non_monotone_mixed(self):
		mydict = {(0,0,5): 100, (5,5,0): 0}
		with pytest.raises(MonotoneError):
			create(mydict,[1,1,-1])
예제 #8
0
 def test_interpolation(self):
     mydict = {(50, 1, 1): 100, (0, 0, 0): 0}
     myfunc = create(mydict, [1, 1, 1], maxval=100, minval=0)
     self.assertTrue(
         np.allclose(myfunc.calculate([(0, 0, 0), (50, 1, 1)]), [0, 100]))
예제 #9
0
 def test_min_bounds(self):
     mydict = {(1, 1, 1): 100, (0, 0, 0): 0}
     with pytest.raises(MonotoneBoundsError):
         create(mydict, [1, 1, 1], minval=10)
예제 #10
0
	def test_value_bounds_min_max(self):
		mydict = {(100,100,100): 50, (0,200,0): 50}
		myfunc = create(mydict,[1,1,1],maxval=100,minval=0.0)
		self.assertEqual(myfunc.value_bounds((50,50,50)),(0,50))
		myfunc = create(mydict,[-1,-1,-1],maxval=100,minval=0.0)
		self.assertEqual(myfunc.value_bounds((50,50,50)),(50,100))
예제 #11
0
	def test_min_and_max(self):
		mydict = {(1,1,1): 100, (0,0,0): 0}
		myfunc = create(mydict,(1,1,1),maxval=100,minval=0.0)
		self.assertEqual(myfunc.calculate([(-1,-1,-1)])[0],0.0)
		self.assertEqual(myfunc.calculate([(2,2,2)])[0],100.0)
예제 #12
0
	def test_interpolation(self):
		mydict = {(50,1,1): 100, (0,0,0): 0}
		myfunc = create(mydict,[1,1,1],maxval=100,minval=0)
		self.assertTrue(np.allclose(myfunc.calculate([(0,0,0),(50,1,1)]),[0,100]))
예제 #13
0
	def test_max_bounds(self):
		mydict = {(100,100,100): 100, (0,0,0): 0}
		with pytest.raises(MonotoneBoundsError):
			create(mydict,[1,1,1],maxval=90)
예제 #14
0
	def test_min_bounds(self):
		mydict = {(1,1,1): 100, (0,0,0): 0}
		with pytest.raises(MonotoneBoundsError):
			create(mydict,[1,1,1],minval=10)
예제 #15
0
	def test_non_monotone_all_decreasing(self):
		mydict = {(1,1,1): 100, (0,0,0): 0}
		with pytest.raises(MonotoneError):
			create(mydict,[-1,-1,-1])
예제 #16
0
 def test_non_monotone_mixed(self):
     mydict = {(0, 0, 5): 100, (5, 5, 0): 0}
     with pytest.raises(MonotoneError):
         create(mydict, [1, 1, -1])
예제 #17
0
 def test_non_monotone_all_decreasing(self):
     mydict = {(1, 1, 1): 100, (0, 0, 0): 0}
     with pytest.raises(MonotoneError):
         create(mydict, [-1, -1, -1])
예제 #18
0
	def test_pickling(self):
		mydict = {(0,0): 0, (100,100): 100}
		myfunc = create(mydict,[1,1])
		self.assertEqual(myfunc.calculate([5,10]),pickle.loads(pickle.dumps(myfunc)).calculate([5,10]))
예제 #19
0
 def test_max_bounds(self):
     mydict = {(100, 100, 100): 100, (0, 0, 0): 0}
     with pytest.raises(MonotoneBoundsError):
         create(mydict, [1, 1, 1], maxval=90)
예제 #20
0
	def test_extreme(self):
		mydict = {(0.0,): 100.0, (30.0,): 30.0, (10.0,): 60.0, (5.0,): 85.0, (20.0,): 50.0, (10000.0,): 0.0}
		myfunc = create(mydict,[-1])
		self.assertEqual(myfunc.calculate([10000])[0],0.0)
		self.assertEqual(myfunc.calculate([30])[0],30.0)
예제 #21
0
 def test_min_and_max(self):
     mydict = {(1, 1, 1): 100, (0, 0, 0): 0}
     myfunc = create(mydict, (1, 1, 1), maxval=100, minval=0.0)
     self.assertEqual(myfunc.calculate([(-1, -1, -1)])[0], 0.0)
     self.assertEqual(myfunc.calculate([(2, 2, 2)])[0], 100.0)
예제 #22
0
	def test_nodiff_y(self):
		mydict = {(0.0,): 50.0, (100.0,): 50.0}
		myfunc = create(mydict,[-1])
		self.assertAlmostEqual(myfunc.calculate([50])[0],50.0)
예제 #23
0
 def test_value_bounds_min_max(self):
     mydict = {(100, 100, 100): 50, (0, 200, 0): 50}
     myfunc = create(mydict, [1, 1, 1], maxval=100, minval=0.0)
     self.assertEqual(myfunc.value_bounds((50, 50, 50)), (0, 50))
     myfunc = create(mydict, [-1, -1, -1], maxval=100, minval=0.0)
     self.assertEqual(myfunc.value_bounds((50, 50, 50)), (50, 100))
예제 #24
0
	def test_nodiff_x(self):
		mydict = {(0,1): 10, (0,2): 20}
		myfunc = create(mydict, [1,1])
		self.assertAlmostEqual(myfunc.calculate([(0,1)])[0],10.0)
예제 #25
0
 def test_pickling(self):
     mydict = {(0, 0): 0, (100, 100): 100}
     myfunc = create(mydict, [1, 1])
     self.assertEqual(myfunc.calculate([5, 10]),
                      pickle.loads(pickle.dumps(myfunc)).calculate([5, 10]))
예제 #26
0
 def test_nodiff_x(self):
     mydict = {(0, 1): 10, (0, 2): 20}
     myfunc = create(mydict, [1, 1])
     self.assertAlmostEqual(myfunc.calculate([(0, 1)])[0], 10.0)
예제 #27
0
 def test_nodiff_y(self):
     mydict = {(0.0, ): 50.0, (100.0, ): 50.0}
     myfunc = create(mydict, [-1])
     self.assertAlmostEqual(myfunc.calculate([50])[0], 50.0)
예제 #28
0
	def test_bad_monotone_vector(self):
		mydict = {(0,0,0): 100, (1,1,1): 0}
		with pytest.raises(ScoreCreationError):
			create(mydict,[-1,-1,0])