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