mathmaker
0.4(alpha)
|
00001 # -*- coding: utf-8 -*- 00002 00003 # Mathmaker creates automatically maths exercises sheets 00004 # with their answers 00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net> 00006 00007 # This file is part of Mathmaker. 00008 00009 # Mathmaker is free software; you can redistribute it and/or modify 00010 # it under the terms of the GNU General Public License as published by 00011 # the Free Software Foundation; either version 3 of the License, or 00012 # any later version. 00013 00014 # Mathmaker is distributed in the hope that it will be useful, 00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 # GNU General Public License for more details. 00018 00019 # You should have received a copy of the GNU General Public License 00020 # along with Mathmaker; if not, write to the Free Software 00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 import os 00024 import sys 00025 import math 00026 #import locale 00027 00028 #from lib.common import default 00029 00030 from core import * 00031 from core.base_calculus import * 00032 from core.base_geometry import * 00033 00034 from maintenance.autotest import common 00035 00036 #try: 00037 # locale.setlocale(locale.LC_ALL, default.LANGUAGE + '.' + default.ENCODING) 00038 #except: 00039 # locale.setlocale(locale.LC_ALL, '') 00040 00041 check = common.check 00042 00043 def action(): 00044 if common.verbose: 00045 os.write(common.output, "--- FUNCTIONAL ITEMS\n") 00046 00047 # Don't forget to uncomment the convenient lines above if a test 00048 # requires to use the locale module. 00049 00050 f1 = Function(("f", Item("x"), None, None)) 00051 00052 check(f1.into_str(), 00053 ["f(x)"]) 00054 00055 f1.set_sign('-') 00056 00057 check(f1.into_str(), 00058 ["-f(x)"]) 00059 00060 f1.set_exponent(Item(2)) 00061 00062 check(f1.into_str(), 00063 ["-f^{2}(x)"]) 00064 00065 theta = Angle((Point(["A", (0, 0)]), 00066 Point(["B", (1, 0)]), 00067 Point(["C", (0, 1)]))) 00068 00069 f2 = Function(("\cos", theta, math.cos, math.acos)) 00070 00071 check(f2.into_str(), 00072 ["\cos(\widehat{ABC})"]) 00073 00074 f2.set_numeric_value(Value(60, unit="\textdegree")) 00075 00076 f2.swap_to_numeric() 00077 00078 check(f2.into_str(), 00079 ["\cos(60\\textdegree)"]) 00080 00081 f2.swap_to_literal() 00082 00083 check(f2.into_str(), 00084 ["\cos(\widehat{ABC})"]) 00085 00086 f2.calculate_next_step() 00087 00088 check(f2.into_str(), 00089 ["\cos(60\textdegree)"]) 00090 00091 f2.calculate_next_step() 00092 00093 check(f2.into_str(), 00094 ["None"]) 00095 00096 f2.calculate_next_step(do_evaluate_fct=True) 00097 00098 check(f2.into_str(), 00099 ["0.5"]) 00100 00101 f3 = Function(("\sin", theta, math.sin, math.asin)) 00102 00103 check(f3.into_str(), 00104 ["\sin(\widehat{ABC})"]) 00105 00106 check(str(f3.calculate_next_step()), 00107 ["None"]) 00108 00109