<jupyter_start><jupyter_text>ExerciseSolve this system of equations for $x$ and $y$.$$\begin{equation}  \begin{cases}    y = x + 3 \\     y - 12 = -2x   \end{cases}\end{equation}$$Write a function `ex()` to return SymPy equations for `x` and `y`.<jupyter_code>from sympy import symbols, Eq, simplify


def ex():
    x, y = symbols('x y')
    my_x, my_y = Eq(x, 0), Eq(y, 0)

    print('Starting equations:')
    eq1, eq2 = Eq(y, x + 3), Eq(y - 12, -2*x)
    display(eq1)
    display(eq2)
    
    print('Your solution:')
    # YOUR CODE HERE
    raise NotImplementedError()
        
    return(my_x, my_y)


x_ans, y_ans = ex()  # Test out results
print('Your answer:')
display(x_ans)
display(y_ans)
# hide_me

import unittest
import inspect

x, y = symbols('x y')

enable_print  = print
enable_display = display
disable_print = lambda *x, **y: None
disable_display = lambda *x, **y: None

print = disable_print
display = disable_display
    
class TestSystemEquations(unittest.TestCase):

    def test_functionExists(self):
        """You should have a function ex() defined."""
        self.assertTrue('ex' in globals())

    def test_xAnswer(self):
        """Your x answer should equal 3."""
        self.assertEqual(simplify(ex()[0]), Eq(x, 3))
        
    def test_xSet(self):
        """You should not directly assign the x answer."""
        self.assertTrue('Eq(x, 3)' not in inspect.getsource(ex))

    def test_yAnswer(self):
        """Your y answer should be 6."""
        self.assertEqual(simplify(ex()[1]), Eq(y, 6))

    def test_ySet(self):
        """You should not directly assign the y answer."""
        self.assertTrue('Eq(y, 6)' not in inspect.getsource(ex))

    def test_useLHS(self):
        """You should use the .lhs attribute."""
        self.assertTrue('.lhs' in inspect.getsource(ex))
        
    def test_useRHS(self):
        """You should use the .rhs attribute."""
        self.assertTrue('.lhs' in inspect.getsource(ex))

    def test_noSolver(self):
        """You should not use the solve function."""
        self.assertTrue('solve' not in inspect.getsource(ex))
    
    def test_noLinearSolver(self):
        """You should not use the solve_linear_systems function."""
        self.assertTrue('solve_linear_system' not in inspect.getsource(ex))
    
    def test_returnEquations(self):
        """Your function should return SymPy equations."""
        self.assertTrue(type(ex()[1]) == Eq and type(ex()[1]) == Eq)


def suite():
    suite = unittest.TestSuite()
    suite.addTest(TestSystemEquations('test_functionExists'))
    suite.addTest(TestSystemEquations('test_xAnswer'))
    suite.addTest(TestSystemEquations('test_xSet'))
    suite.addTest(TestSystemEquations('test_yAnswer'))
    suite.addTest(TestSystemEquations('test_ySet'))
    suite.addTest(TestSystemEquations('test_useLHS'))
    suite.addTest(TestSystemEquations('test_useRHS'))
    suite.addTest(TestSystemEquations('test_noSolver'))
    suite.addTest(TestSystemEquations('test_noLinearSolver'))
    suite.addTest(TestSystemEquations('test_returnEquations'))
    return suite


runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())

# Reset suppression of print statements
print = enable_print
display = enable_display<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13547400611620794, 'fraction_numerical': 0.00764525993883792, 'mean_word_length': 3.613540197461213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '421039', 'license': 'MIT', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1035, 'n_words': 258, 'path': 'release/solve_line_intersection/sys_of_eq.ipynb', 'repo_name': 'erictleung/machine-learning', 'size': '3270'}