f = pg.RTransLin(factor=2., offset=4.) np.testing.assert_array_equal(f(x), x*2. + 4.) np.testing.assert_array_equal(f.trans(x), x*2. + 4.) np.testing.assert_array_equal(f.inv(f(x)), x) self.assertEqual(f(1.0), 6.0) self.assertEqual(f.trans(1.0), 6.0) self.assertEqual(f.inv(6.0), 1.0) self.assertEqual(f.invTrans(6.0), 1.0) def test_DataContainerFilter(self): """ """ data = pg.DataContainer() data.resize(101) data.markInvalid([0, 100]) x = np.array([0, 100], dtype="int") a = pg.IndexArray(x) data.markInvalid(a) data.markInvalid(pg.IndexArray(np.array([0, 100], dtype="int"))) #data.markInvalid(np.array([0, 100], dtype="int")) # fails #data.markInvalid(np.array([0, 100], dtype=np.int64)) # fails if __name__ == '__main__': pg.setDebug(1) unittest.main()
implemented through hand_made_wrapper.py ''' mesh = pg.createGrid(x=[0, 1, 2], y=[0, 1, 2]) v = np.asarray(mesh.nodeCenters()) self.assertEqual(type(v), np.ndarray) self.assertEqual(len(v), mesh.nodeCount()) a = np.array(mesh.cellCenter()) self.assertEqual(type(a), np.ndarray) self.assertEqual(len(a), mesh.cellCount()) if __name__ == '__main__': pg.setDebug(0) unittest.main() # do we need Implicit converter .. currently deactivated in vector.h # suite = unittest.TestSuite() # # suite.addTest(TestRVectorMethods("test_ListToR3Vector")) # suite.addTest(TestRVectorMethods("test_NumpyToIndexArray")) # # suite.addTest(TestRVectorMethods("test_BVectorToNumpy")) # suite.addTest(TestRVectorMethods("test_IndexArrayToNumpy")) # suite.addTest(TestRVectorMethods("test_ListToIndexArray")) # suite.addTest(TestRVectorMethods("test_ListToRVector")) # suite.addTest(TestRVectorMethods("test_NumpyToRVector")) #
# test pygimli log pg.info("Start numeric log test." + str(pg.log(pg.RVector(1, 1.)))) pg.warn("Start warning test.") def testTraceback1(): def testTraceback2(): pg.error("Start error test.: int", 1, " vec", pg.RVector(2)) testTraceback2() testTraceback1() #pg.critical("Start critical test.") pg.debug("debug 0") pg.setDebug(1) pg.debug("debug ON") pg.setThreadCount(2) # should not printed out pg.setDebug(0) pg.debug("debug OFF") pg.setThreadCount(2) # test core log (should not be used outside the core) pg.log(pg.Info, "core log ") pg.log(pg.Warning, "core log ") pg.log(pg.Error, "core log ") pg.log(pg.Critical, "core log ") #pg.logger.exception("Exception")