def test_usecase_simple(self): task = capi.createTask() model = capi.createModel() capi.setRootModel(task, model) p1 = capi.addParameter(model, 2, 2, (1, 1)) # axis-X p2 = capi.addParameter(model, 3, 2, (2, 1, 1)) # axis-Y paramCount = capi.getTotalParameterCount(task) self.assertEqual(2, paramCount) capi.addExclusion(task, ((p1, 0), (p2, 2))) capi.addExclusion(task, ((p1, 1), (p2, 0))) capi.addSeed(task, ((p1, 0), (p2, 0))) capi.generate(task) capi.resetResultFetching(task) row = capi.allocateResultBuffer(task) self.assertNotEqual(0, row) fullRows = ['0,0', '0,1', '0,2', '1,0', '1,1', '1,2'] excludedRows = ['0,2', '1,0'] expectedRows = set(fullRows) - set(excludedRows) actualRows = [] rowsRemaining = len(expectedRows) while True: self.assertEqual(rowsRemaining, capi.getNextResultRow(task, row)) if rowsRemaining == 0: break actualRows.append(','.join([str(x) for x in row])) rowsRemaining -= 1 self.assertEqual(sorted(expectedRows), sorted(actualRows)) capi.freeResultBuffer(row) capi.deleteTask(task) capi.deleteModel(model)
def generate(self) -> '_ResultSet': capi.generate(self.handle) return _ResultSet(self)
print('Model handle:', model) capi.setRootModel(task, model) p1 = capi.addParameter(model, 2, 2, (1, 1)) print('Param 1 handle:', p1) p2 = capi.addParameter(model, 3, 2, (2, 1, 1)) print('Param 2 handle:', p2) print('Parameter count:', capi.getTotalParameterCount(task)) print('Exclude [0, 2]') capi.addExclusion(task, ((p1, 0), (p2, 2))) print('Exclude [1, 0]') capi.addExclusion(task, ((p1, 1), (p2, 0))) capi.addSeed(task, ((p1, 0), (p2, 0))) capi.generate(task) capi.resetResultFetching(task) row = capi.allocateResultBuffer(task) print('Result Buffer:', row) while True: remaining_rows = capi.getNextResultRow(task, row) if remaining_rows == 0: break print('Result Row:', list(row)) print('Cleaning up...') capi.freeResultBuffer(row) capi.deleteTask(task) capi.deleteModel(model)