예제 #1
0
def plot():
    equation_string = flask.request.args.get('equation')
    diff_equation = FieldPlotter()
    diff_equation.set_equation_from_string(equation_string)
    diff_equation.make_plot()
    
    # If plotting was successful, write plot out
    if diff_equation.figure:
        
        # Write output to memory and add to response object
        output = StringIO.StringIO()
        response = flask.make_response(base64.b64encode(diff_equation.write_data(output)))
        response.mimetype = 'image/png'
        return response
    else:
        return flask.make_response('')
예제 #2
0
 def test_make_plot(self):
     equation = sympy.sympify('x+y')
     plotter = FieldPlotter(equation)
     plotter.make_plot()
     self.assertIsNotNone(plotter.figure)
예제 #3
0
 def test_missing_equation(self):
     plotter = FieldPlotter()
     with self.assertRaises(FieldPlotter.MissingEquationError):
         plotter.make_plot()