Changeset 279e371 in sasview for sansmodels/test
- Timestamp:
- Apr 18, 2012 1:26:13 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 499fe7a
- Parents:
- 3ee4d96
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/test/utest_other_models.py
r6e2d708 r279e371 1447 1447 self.comp.setParam('B', 0.0) 1448 1448 self.assertRaises(ZeroDivisionError, self.comp.run, 10) 1449 #self.assert_(numpy.isfinite(self.comp.run(0.0))) 1450 1451 1452 class TestFractalAbsModel(unittest.TestCase): 1453 """ Unit tests for FractalAbsModel""" 1454 1455 def setUp(self): 1456 from sans.models.FractalAbsModel import FractalAbsModel 1457 self.comp = FractalAbsModel() 1458 self.comp.setParam('scale', 0.05) 1459 self.comp.setParam('radius', 5.0) 1460 self.comp.setParam('fractal_dim', 2.0) 1461 self.comp.setParam('cor_length',100.0) 1462 self.comp.setParam('sldBlock', 2.0e-6) 1463 self.comp.setParam('sldSolv', 6.35e-6) 1464 self.comp.setParam('background',0.0) 1465 1466 self.x = numpy.array([0.4, 1.3]) 1467 self.y = numpy.array([0.5, 1.57]) 1468 1469 self.x_array = self.comp.evalDistribution(self.x) 1470 self.y_array = self.comp.evalDistribution(self.y) 1471 qx_prime = numpy.reshape(self.x, [1,len(self.x)]) 1472 qy_prime = numpy.reshape(self.y, [len(self.y),1]) 1473 self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) 1474 1475 def test1D(self): 1476 """ Test 1D model for a Fractal Abs Model""" 1477 self.assertAlmostEqual(self.comp.run(0.001), 39.2881, 3) 1478 1479 def test1D_2(self): 1480 """ Test 2D model for a Fractal Abs Model""" 1481 self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 39.2881, 3) 1482 1483 def testEval_1D(self): 1484 """ Test 1D model for a Fractal Abs Model with evalDistribution""" 1485 self.assertEquals(self.comp.run(0.4),self.x_array[0]) 1486 self.assertEquals(self.comp.run(1.3),self.x_array[1]) 1487 1488 def testEval_2D(self): 1489 """ Test 2D model for a Fractal Abs Model with evalDistribution""" 1490 self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) 1491 self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) 1492 1493 # No more singular point 1494 #def testCriticalPoint(self): 1495 # """ Test Fractal Abs at the critical point""" 1496 # self.assert_(numpy.isfinite(self.comp.run(0.0))) 1449 #self.assert_(numpy.isfinite(self.comp.run(0.0))) 1497 1450 1498 1451 class TestFractalModel(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.