1
0
Huan 5 жил өмнө
parent
commit
cfb57191fe

+ 0 - 4
Hello.py

@@ -10,12 +10,8 @@ import os
 import tkinter.messagebox
 import webbrowser
 import random
-<<<<<<< Updated upstream
 
 from newtkinter import DragWindow, center_windows
-=======
-import flask
->>>>>>> Stashed changes
 
 img = None
 SCREEN = None

+ 3 - 6
algebraicfactory/gui.py

@@ -332,7 +332,7 @@ class UIAPI:
     @staticmethod
     @exception_catch()
     def equation_solution_set_gui():
-        return equation_solution_set[equation_solution_box.curselection()[0]][1]
+        return equation_solution_set[equation_solution_box.curselection()[0]]
 
     @staticmethod
     @exception_catch()
@@ -975,9 +975,7 @@ class API(UIAPI):
     @staticmethod
     @exception_catch()
     def add_to_algebraic_box():
-        get = API.equation_solution_set_gui()[
-            1
-        ]  # [1]取结果
+        get = API.equation_solution_set_gui()[1]
         API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
 
     @staticmethod
@@ -1630,8 +1628,7 @@ class API(UIAPI):
                 )
                 alg_str = API.application(alg_str, new_alg)
 
-            if not algebra_controller.add_expression(name, alg_str):
-                raise Exception
+            algebra_controller.add_expression(name, alg_str)
 
             API.update_symbol_algebraic_box_gui()
             API.output_prompt_gui("代数式新增成功")

+ 1 - 1
crawler/gui.py

@@ -703,7 +703,7 @@ class API(UIAPI):
 
 
 def crawler_main(in_queue, out_queue):
-    global SCREEN
+    global SCREEN, save_dir, url, loader, page_parser, database
     SCREEN.update()  # 要预先update一下,否则会卡住
     save_dir = askdirectory(title="选择项目位置", must=True)  # 项目位置
     url = crawler.controller.Url(save_dir, save_dir)  # url管理器

+ 1 - 1
draftboard/drawingfunction.py

@@ -18,7 +18,7 @@ class Logger:
         self.custom_function_index = 18
     
     def __call__(self, *args, **kwargs):
-        for i in self.func_dict:
+        for i in self.custom_loger:
             self.func_dict[i] = self.custom_loger[i]()
         return self.func_dict
 

+ 14 - 9
funcsystem/factory.py

@@ -151,14 +151,14 @@ class UIAPI:
 
     @staticmethod
     @exception_catch()
-    def update_prediction_box_gui(answer):
+    def update_prediction_box_gui(*answer):
         prediction_box.delete(0, tkinter.END)
         prediction_box.insert(tkinter.END, *answer)
 
     @staticmethod
     @exception_catch()
     def get_projection_value_gui():
-        return projection_value.get
+        return projection_value.get()
 
     @staticmethod
     @exception_catch()
@@ -293,13 +293,12 @@ class API(UIAPI):
     def check_center_of_symmetry():
         accuracy_ = API.computing_gui()
         try:
-            result = func.check_symmetry_center(
-                API.confirmation_expression(API.get_projection_value_gui()), API.output_prompt_gui, accuracy_
-            )
+            result = func.check_symmetry_center(API.get_projection_value_gui(), API.output_prompt_gui, accuracy_)
             if result[0]:
                 API.add_projection_box_gui(result[1])
                 API.output_prompt_gui("预测完成")
             else:
+                API.add_projection_box_gui(result[1])
                 raise Exception
         except BaseException:
             API.output_prompt_gui("预测失败")
@@ -317,10 +316,11 @@ class API(UIAPI):
                 API.add_projection_box_gui(result[1])
                 API.output_prompt_gui("预测完成")
             else:
+                API.add_projection_box_gui(result[1])
                 raise Exception
         except BaseException:
             API.output_prompt_gui("预测失败")
-            raise
+            raise  # 给log捕捉
 
     @staticmethod
     @exception_catch()
@@ -334,6 +334,7 @@ class API(UIAPI):
                 API.add_projection_box_gui(result[1])
                 API.output_prompt_gui("预测完成")
             else:
+                API.add_projection_box_gui(result[1])
                 raise Exception
         except BaseException:
             API.output_prompt_gui("预测失败")
@@ -351,6 +352,7 @@ class API(UIAPI):
                 API.add_projection_box_gui(result[1])
                 API.output_prompt_gui("预测完成")
             else:
+                API.add_projection_box_gui(result[1])
                 raise Exception
         except BaseException:
             API.output_prompt_gui("预测失败")
@@ -762,7 +764,7 @@ class API(UIAPI):
                 frame = int(frame_rate.get())
             except ValueError:
                 frame = 100
-            FuncAnimation(
+            ani = FuncAnimation(
                 fig,
                 update,
                 frames=plot_x_len,
@@ -796,12 +798,15 @@ class API(UIAPI):
                 return None
 
             def update(n):
+                print('A')
                 get_ = func_cul_list[n - 1]
                 ln_list[0].set_text(get_[2])
                 for i in range(max(m)):
                     try:
                         x = get_[0][i]
                         y = get_[1][i]
+                        print(x)
+                        print(y)
                         ln_list[i + 1].set_data(x, y)
                     except IndexError:
                         ln_list[i + 1].set_data([], [])
@@ -811,9 +816,9 @@ class API(UIAPI):
                 frame = int(frame_rate.get())
             except ValueError:
                 frame = 100
-            FuncAnimation(
+            ani = FuncAnimation(
                 fig, update, frames=plot_x_len, init_func=_init, interval=frame, blit=False
-            )  # 动态绘图
+            )  # 动态绘图(请不要去除ani = ,原因不清楚)
         API.output_prompt_gui("绘制完毕")
         plt.show()  # 显示图像
         return True

+ 18 - 17
funcsystem/template.py

@@ -800,6 +800,7 @@ class ExpFuncInit(ExpFuncBase):
             self.func_name = (
                 f"{name}:y={func} a={a_default}({a_start},{a_end},{a_span})"
             )
+            print(self.son_list)
         else:
             self.son_list = []
             self.func_name = f"{name}:y={func} a={a_default})"  # 这个是函数名字
@@ -1125,7 +1126,7 @@ class ExpComputing(ExpFuncInit, metaclass=ABCMeta):
             secondary_verification_effect = abs(float(secondary_verification_effect))
         except (ValueError, TypeError):
             allow_original_value = False
-            allow_extended_calculations = True
+            allow_extended_calculations = False
             secondary_verification = False
             max_iter = 100
             accuracy = 0.0001
@@ -1151,7 +1152,7 @@ class ExpComputing(ExpFuncInit, metaclass=ABCMeta):
                 return [], []  # 返回空值
             if allow_original_value and y_value in y:  # 如果已经计算过
                 num = y.index(y_value)
-                return x[num]
+                return [f"(误差)y={y_value} -> x={x[num]}"], [x[num]]
         except BaseException as e:
             logging.warning(str(e))
         iter_interval = [[self.start, self.end]]  # 准备迭代的列表
@@ -1448,7 +1449,7 @@ class ExpProperty(ExpFuncInit, metaclass=ABCMeta):
     ):
         try:
             accuracy = float(accuracy)
-        except ValueError:
+        except TypeError:
             accuracy = None
         answer = []
         parity = self.parity()
@@ -1509,9 +1510,8 @@ class ExpProperty(ExpFuncInit, metaclass=ABCMeta):
         while start <= end:
             try:
                 y = self(start)
-                x_list = self.dichotomy(y)[1]
+                x_list = self.sympy_calculation(y)[1]
                 output_prompt("迭代运算...")
-                # print(x_list)
                 possible_cycle = []
                 for o_x in x_list:
                     a = round(abs(o_x - start), self.accuracy)
@@ -1524,7 +1524,6 @@ class ExpProperty(ExpFuncInit, metaclass=ABCMeta):
             except BaseException as e:
                 logging.warning(str(e))
             start += span
-
         possible_cycle = []  # a的可能列表
         max_count = 0
         output_prompt("正在筛选结果")
@@ -1559,20 +1558,16 @@ class ExpProperty(ExpFuncInit, metaclass=ABCMeta):
         output_prompt("正在预测对称轴")
         while start <= end:
             try:
-                y = self(start)
-                x_list = self.dichotomy(y)[1]
+                y = round(self(start), 1)
+                x_list = self.sympy_calculation(y)[1]
                 output_prompt("迭代运算...")
-                # print(x_list)
-                possible_symmetry_axis = []
-                for o_x in x_list:
-                    a = (o_x + start) / 2
-                    if a:
-                        possible_symmetry_axis.append(round(a, self.accuracy))
-                possible_symmetry_axis_list.extend(list(set(possible_symmetry_axis)))
+                print(len(x_list))
+                if (len(x_list) % 2) == 0:
+                    possible_symmetry_axis_list.append(round((x_list[0] + x_list[-1])/2, self.accuracy))
             except BaseException as e:
                 logging.warning(str(e))
             start += span
-
+        print(possible_symmetry_axis_list)
         possible_symmetry_axis = []  # a的可能列表
         c = 0
         output_prompt("正在筛选结果")
@@ -1671,6 +1666,8 @@ class ExpCheck(ExpFuncInit, metaclass=ABCMeta):
                 start += span
                 continue
             if last_y is None:
+                last_y = now_y
+                start += span
                 continue
             if flat == 0 and last_y > now_y:  # 增区间,o_y不小于y
                 result = False
@@ -1710,8 +1707,12 @@ class ExpCheck(ExpFuncInit, metaclass=ABCMeta):
                 output_prompt("迭代运算...")
                 now_y = round(self(start), self.accuracy)
                 last_y = round(self(start + parameters), self.accuracy)
-                if now_y != last_y:
+                if abs(now_y - last_y) > (10 ** -self.accuracy + 10 ** (-self.accuracy - 1)):
+                    print(now_y, last_y)
+                    print(abs(now_y - last_y))
+                    print(10 ** -self.accuracy)
                     result = False
+                    break
             except BaseException as e:
                 logging.warning(str(e))
             start += span

+ 4 - 2
gitrepo/gui.py

@@ -122,8 +122,8 @@ class UIAPI:
                             cli_screen.update()
                         except BaseException as e:
                             logging.warning(str(e))
-                    assert not time.time() - start >= break_time != 0
-                    assert not break_time == 0 and start == 0
+                    assert not time.time() - start >= break_time or break_time == 0
+                    assert not (break_time == 0 and start == 0)
                 except AssertionError:
                     start = 0
                     break
@@ -194,6 +194,8 @@ class UIAPI:
                     i = command_thread.stdout.readline()
                     bool_text = i.replace(" ", "").replace("\n", "")
                     if bool_text != "":
+                        print(stop_key)
+                        print(bool_text)
                         if stop and bool_text == stop_key:
                             start = 0
                         else:

+ 6 - 4
gitrepo/template.py

@@ -34,11 +34,12 @@ class GitBase(metaclass=ABCMeta):
 
     @staticmethod
     def make_stop_key():  # 生成一个随机stopKey
+        global stop_key
         code = ""
         for _ in range(8):  # 八位随机数
             code += passwd[random.randint(0, len(passwd) - 1)]  # 时间戳+8位随机数
-        stop_key_ = (str(time()) + code).replace(".", "")
-        return stop_key_
+        stop_key = (str(time()) + code).replace(".", "")
+        return stop_key
 
     def get_flie_list(self, file_list, is_file=True, pat=" "):
         if file_list == ".":
@@ -461,9 +462,10 @@ class RemoteClasses(GitBase, metaclass=ABCMeta):
 class GitRepo(ViewClasses, NewClasses, RemoveClass, BackClasses, ParallelClasses, RemoteClasses):  # git的基类
 
     def init(self, repo_dir):
+        print(repo_dir)
         self.url = None
         try:
-            if exists(repo_dir + r"/.git"):  # 是否为git 仓库
+            if exists(repo_dir + rf"{os.sep}.git"):  # 是否为git 仓库
                 pass
             elif repo_dir.endswith(".git"):
                 repo_dir = repo_dir[:-5]  # -5,得把/去掉
@@ -471,7 +473,7 @@ class GitRepo(ViewClasses, NewClasses, RemoveClass, BackClasses, ParallelClasses
                 assert False
         except (AssertionError, IndexError):
             subprocess.Popen(
-                f"{git_path} init", cwd=self.repo_dir, **sys_seeting
+                f"{git_path} init", cwd=repo_dir, **sys_seeting
             ).wait()
         self.repo_dir = repo_dir  # 仓库地址(末尾不带/)
         self.repo = Repo(repo_dir)  # 读取一个仓库

+ 5 - 5
newtkinter/__init__.py

@@ -1,6 +1,6 @@
 import tkinter as tk
 from tkinter import filedialog
-
+import os
 
 def center_windows(screen, w, h):
     ws = screen.winfo_screenwidth()
@@ -63,7 +63,7 @@ def askopenfilename(title, must=False, **parameters):
                 raise NameError
             continue
         break
-    return name
+    return name.replace('/', os.sep)
 
 
 def asksaveasfilename(title, **parameters):
@@ -72,8 +72,8 @@ def asksaveasfilename(title, **parameters):
         raise NameError
     end = parameters.get('filetypes', [('', '')])[0][0]
     if name.endswith(end):
-        return name
-    return name + end
+        return name.replace('/', os.sep)
+    return name.replace('/', os.sep) + end
 
 
 def askdirectory(title, must=False, **parameters):
@@ -84,4 +84,4 @@ def askdirectory(title, must=False, **parameters):
                 raise NameError
             continue
         break
-    return name
+    return name.replace('/', os.sep)