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.calculus 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, "--- TABLES : uncomplete but proportional\n") 00046 00047 #t1 = Table_UP([[Item((2)), Item(("AB")), Item((6)) ], 00048 # [Item((3.4)), Item((8.5)), Item(("MN")) ] 00049 # ] 00050 # ) 00051 00052 AB = Item("AB") 00053 MN = Item("MN") 00054 CD = Item("CD") 00055 EF = Item("EF") 00056 GH = Item("GH") 00057 00058 t1 = Table_UP(1.7, 00059 [Item(2), Item(5), Item(6)], 00060 [None, (AB, None), (None, MN)] 00061 ) 00062 00063 check(t1, 00064 [ "\\begin{tabular}{|c|c|c|}" \ 00065 + "\hline " \ 00066 + "2&\\text{AB}&6\\\\" \ 00067 + "\\hline " \ 00068 + locale.str(3.4) + "&" + locale.str(8.5) + "&\\text{MN}\\\\" \ 00069 + "\\hline " \ 00070 + "\end{tabular}" ]) 00071 00072 #t2 = Table_UP([[Item((2)), Item(("AB")), Item(("EF")), Item((4)) ], 00073 # [Item((2.5)), Item(("CD")), Item((3.75)), Item(("GH")) ] 00074 # ] 00075 # ) 00076 00077 t2 = Table_UP(1.25, 00078 [Item(2), None, Item(3), Item(4) 00079 ], 00080 [None, 00081 (AB, CD), 00082 (EF, None), 00083 (None, GH) 00084 ] 00085 ) 00086 00087 check(t2, 00088 [ "\\begin{tabular}{|c|c|c|c|}" \ 00089 + "\hline " \ 00090 + "2&\\text{AB}&\\text{EF}&4\\\\" \ 00091 + "\\hline " \ 00092 + "" + locale.str(2.5) + "&\\text{CD}&" \ 00093 + locale.str(3.75) + "&\\text{GH}\\\\" \ 00094 + "\\hline " \ 00095 + "\end{tabular}" ]) 00096 00097 check(str(t1.crossproducts_info[AB]), 00098 ["(1, 0)"]) 00099 00100 check(str(t1.crossproducts_info[MN]), 00101 ["(2, 0)"]) 00102 00103 check(str(t2.crossproducts_info[EF]), 00104 ["(2, 0)"]) 00105 00106 check(str(t2.crossproducts_info[GH]), 00107 ["(3, 0)"]) 00108 00109 check(t1.into_crossproduct_equation(AB), 00110 ["\\frac{2}{" + locale.str(3.4) + "}=\\frac{\\text{AB}}{" \ 00111 + locale.str(8.5) + "}"]) 00112 00113 check(t1.into_crossproduct_equation(MN), 00114 ["\\frac{2}{" + locale.str(3.4) + "}=\\frac{" \ 00115 + locale.str(6) + "}{\\text{MN}}"]) 00116 00117 check(t2.into_crossproduct_equation(GH), 00118 ["\\frac{2}{" + locale.str(2.5) + "}=\\frac{" \ 00119 + locale.str(4) + "}{\\text{GH}}"]) 00120 00121 t3 = Table_UP(0.8, 00122 [Item(3), Item(4), Item(9)], 00123 [(AB, None), (None, None), (None, MN)] 00124 ) 00125 00126 check(t3, 00127 [ "\\begin{tabular}{|c|c|c|}" \ 00128 + "\hline " \ 00129 + "\\text{AB}&4&9\\\\" \ 00130 + "\\hline " \ 00131 + "" + locale.str(2.4) + "&" + locale.str(3.2) + "&\\text{MN}\\\\" \ 00132 + "\\hline " \ 00133 + "\end{tabular}" ]) 00134 00135 check(t3.into_crossproduct_equation(AB), 00136 ["\\frac{\\text{AB}}{" + locale.str(2.4) + "}=\\frac{" \ 00137 + locale.str(4) + "}{" + locale.str(3.2) + "}"]) 00138 00139 check(t3.into_crossproduct_equation(MN), 00140 ["\\frac{" + locale.str(4) + "}{" + locale.str(3.2) + "}=\\frac{" \ 00141 + locale.str(9) + "}{\\text{MN}}"]) 00142 00143 00144 00145