def testCalculusIntegrate(self):
dataset_objects = algorithmic_math.math_dataset_init(
8, digits=5, functions={"log": "L"})
counter = 0
for d in algorithmic_math.calculus_integrate(8, 0, 3, 10):
counter += 1
decoded_input = dataset_objects.int_decoder(d["inputs"])
var, expression = decoded_input.split(":")
target = dataset_objects.int_decoder(d["targets"])
for fn_name, fn_char in six.iteritems(dataset_objects.functions):
target = target.replace(fn_char, fn_name)
# Take the derivative of the target.
derivative = str(sympy.diff(target, var))
# Check that the derivative of the integral equals the input.
self.assertEqual(0, sympy.simplify("%s-(%s)" % (expression, derivative)))
self.assertEqual(counter, 10)
评论列表
文章目录