From 12ef6f8151cc686bb0deaac11e980eddfd0370e4 Mon Sep 17 00:00:00 2001 From: Oliver Lee Date: Tue, 20 Oct 2015 19:01:50 +0200 Subject: [PATCH] Add test to reproduce linewrap error --- pydy/tests/test_utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pydy/tests/test_utils.py b/pydy/tests/test_utils.py index 18474422..74502879 100644 --- a/pydy/tests/test_utils.py +++ b/pydy/tests/test_utils.py @@ -4,7 +4,11 @@ from setuptools import __version__ as SETUPTOOLS_VERSION from nose.tools import assert_raises +from sympy import cos, sin, tan, sqrt, Matrix +from sympy.physics.mechanics import dynamicsymbols + from ..utils import sympy_equal_to_or_newer_than +from ..codegen.cython_code import CythonMatrixGenerator def test_sympy_equal_to_or_newer_than(): @@ -18,3 +22,17 @@ def test_sympy_equal_to_or_newer_than(): if parse_version(SETUPTOOLS_VERSION) >= parse_version('8.0'): with assert_raises(ValueError): sympy_equal_to_or_newer_than('0.7.7', '0.7.6-git') + +def test_codegen_linewrap(): + + # Generated can result in long expressions with no obvious place to insert a + # newline. Refer to https://github.com/pydy/pydy/issues/263. + x, y, z = dynamicsymbols('x y z') + expr = (x*y*z*cos(x)*sin(x)*tan(x)*sqrt(x)*cos(y)*sin(y)*tan(y)* + sqrt(y)*cos(z)*sin(z)*tan(z)*sqrt(z)*cos(x*y)*sin(x*y)*tan(x*y)* + sqrt(x*y)* cos(y*z)*sin(y*z)*tan(y*z)*sqrt(y*z)*cos(z*x)* + sin(z*x)*tan(z*x)*sqrt(z*x)*3)/8 + mat_expr = Matrix([expr]) + + q = [x, y, z] + gen = CythonMatrixGenerator([q], [mat_expr])