diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 8812dec..150af57 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.179 +version = 0.1.181 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 3a43bde..fe8442d 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: guan -Version: 0.1.179 +Version: 0.1.181 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan.egg-info/SOURCES.txt b/PyPI/src/guan.egg-info/SOURCES.txt index b8fe1e6..18ff90e 100644 --- a/PyPI/src/guan.egg-info/SOURCES.txt +++ b/PyPI/src/guan.egg-info/SOURCES.txt @@ -8,14 +8,11 @@ src/guan/Hamiltonian_of_examples.py src/guan/__init__.py src/guan/band_structures_and_wave_functions.py src/guan/basic_functions.py -src/guan/custom_classes.py src/guan/data_processing.py src/guan/decorators.py src/guan/density_of_states.py -src/guan/deprecated.py src/guan/figure_plotting.py src/guan/file_reading_and_writing.py -src/guan/functions_using_objects_of_custom_classes.py src/guan/machine_learning.py src/guan/others.py src/guan/quantum_transport.py diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index 0c6d5a8..34165f5 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -14,7 +14,4 @@ from .figure_plotting import * from .data_processing import * from .decorators import * from .others import * -from .custom_classes import * -from .functions_using_objects_of_custom_classes import * -from .deprecated import * statistics_of_guan_package() \ No newline at end of file diff --git a/PyPI/src/guan/custom_classes.py b/PyPI/src/guan/custom_classes.py deleted file mode 100644 index f12237a..0000000 --- a/PyPI/src/guan/custom_classes.py +++ /dev/null @@ -1,11 +0,0 @@ -# Module: custom_classes - -# 原子类 -class Atom: - def __init__(self, name='atom', index=0, x=0, y=0, z=0, energy=0): - self.name = name - self.index = index - self.x = x - self.y = y - self.z = z - self.energy = energy \ No newline at end of file diff --git a/PyPI/src/guan/data_processing.py b/PyPI/src/guan/data_processing.py index 72d240e..7366d64 100644 --- a/PyPI/src/guan/data_processing.py +++ b/PyPI/src/guan/data_processing.py @@ -11,7 +11,7 @@ def logging_with_day_and_time(content='', filename='time_logging', file_format=' else: f2.write(datetime_today+' '+datetime_time+' '+content+'\n') -# 使用该函数获取函数计算时间(秒) +# 使用该函数运行某个函数并获取函数计算时间(秒) def timer(function_name, *args, **kwargs): import time start = time.time() @@ -20,13 +20,54 @@ def timer(function_name, *args, **kwargs): print(f"Running time of {function_name.__name__}: {end - start} seconds") return result -# 使用该函数实现 try except 结构 +# 使用该函数运行某个函数并实现 try-except-pass 结构 def try_except(function_name, *args, **kwargs): try: return function_name(*args, **kwargs) except: pass +# 循环一个参数计算某个函数,并返回计算结果的数组 +def loop_calculation_with_one_parameter(function_name, parameter_array): + import numpy as np + result_array = [] + for parameter in parameter_array: + result = function_name(parameter) + result_array.append(result) + result_array = np.array(result_array) + return result_array + +# 循环两个参数计算某个函数,并返回计算结果的数组 +def loop_calculation_with_two_parameters(function_name, parameter_array_1, parameter_array_2): + import numpy as np + result_array = np.zeros((len(parameter_array_2), len(parameter_array_1))) + i1 = 0 + for parameter_1 in parameter_array_1: + i2 = 0 + for parameter_2 in parameter_array_2: + result = function_name(parameter_1, parameter_2) + result_array[i2, i1] = result + i2 += 1 + i1 += 1 + return result_array + +# 循环三个参数计算某个函数,并返回计算结果的数组 +def loop_calculation_with_three_parameters(function_name, parameter_array_1, parameter_array_2, parameter_array_3): + import numpy as np + result_array = np.zeros((len(parameter_array_3), len(parameter_array_2), len(parameter_array_1))) + i1 = 0 + for parameter_1 in parameter_array_1: + i2 = 0 + for parameter_2 in parameter_array_2: + i3 = 0 + for parameter_3 in parameter_array_3: + result = function_name(parameter_1, parameter_2, parameter_3) + result_array[i3, i2, i1] = result + i3 += 1 + i2 += 1 + i1 += 1 + return result_array + # 打印数组 def print_array(array, line_break=0): if line_break == 0: diff --git a/PyPI/src/guan/deprecated.py b/PyPI/src/guan/deprecated.py deleted file mode 100644 index 976918e..0000000 --- a/PyPI/src/guan/deprecated.py +++ /dev/null @@ -1,45 +0,0 @@ -# Module: deprecated - -def make_sh_file(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.make_sh_file_for_qsub().') - guan.make_sh_file_for_qsub(sh_filename=sh_filename, command_line=command_line, cpu_num=cpu_num, task_name=task_name, cd_dir=cd_dir) - -def plot_without_starting_fig(plt, fig, ax, x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, style='', y_min=None, y_max=None, linewidth=None, markersize=None, color=None, fontfamily='Times New Roman'): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.plot_without_starting_fig_ax().') - guan.plot_without_starting_fig_ax(plt, fig, ax, x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=title, fontsize=fontsize, style=style, y_min=y_min, y_max=y_max, linewidth=linewidth, markersize=markersize, color=color, fontfamily=fontfamily) - -def draw_dots_and_lines_without_starting_fig(plt, fig, ax, coordinate_array, draw_dots=1, draw_lines=1, max_distance=1, line_style='-k', linewidth=1, dot_style='ro', markersize=3): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.draw_dots_and_lines_without_starting_fig_ax().') - guan.draw_dots_and_lines_without_starting_fig_ax(plt, fig, ax, coordinate_array, draw_dots=draw_dots, draw_lines=draw_lines, max_distance=max_distance, line_style=line_style, linewidth=linewidth, dot_style=dot_style, markersize=markersize) - -def get_days_of_the_current_month(str_or_datetime='str'): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_current_month().') - date_array = guan.get_date_array_of_the_current_month(str_or_datetime=str_or_datetime) - return date_array - -def get_days_of_the_last_month(str_or_datetime='str'): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_last_month().') - date_array = guan.get_date_array_of_the_last_month(str_or_datetime=str_or_datetime) - return date_array - -def get_days_of_the_month_before_last(str_or_datetime='str'): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_month_before_last().') - date_array = guan.get_date_array_of_the_month_before_last(str_or_datetime=str_or_datetime) - return date_array - -def pdf_to_text(pdf_path): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.pdf_to_text_with_pdfminer3k().') - content = guan.pdf_to_text_with_pdfminer3k(pdf_path) - return content - -def statistics_with_day_and_time(content='', filename='time_logging', file_format='.txt'): - import guan - print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.logging_with_day_and_time().') - guan.logging_with_day_and_time(content=content, filename=filename, file_format=file_format) \ No newline at end of file diff --git a/PyPI/src/guan/functions_using_objects_of_custom_classes.py b/PyPI/src/guan/functions_using_objects_of_custom_classes.py deleted file mode 100644 index 75371b6..0000000 --- a/PyPI/src/guan/functions_using_objects_of_custom_classes.py +++ /dev/null @@ -1,79 +0,0 @@ -# Module: functions_using_objects_of_custom_classes - -# 将原子对象列表转成多个独立列表 -def convert_atom_object_list_to_multiple_lists(atom_object_list): - name_list = [] - index_list = [] - x_list = [] - y_list = [] - z_list = [] - energy_list = [] - for atom_object in atom_object_list: - name_list.append(atom_object.name) - index_list.append(atom_object.index) - x_list.append(atom_object.x) - y_list.append(atom_object.y) - z_list.append(atom_object.z) - energy_list.append(atom_object.energy) - return name_list, index_list, x_list, y_list, z_list, energy_list - -# 将原子对象列表转成原子字典列表 -def convert_atom_object_list_to_atom_dict_list(atom_object_list): - atom_dict_list = [] - for atom_object in atom_object_list: - atom_dict = { - 'name': atom_object.name, - 'index': atom_object.index, - 'x': atom_object.x, - 'y': atom_object.y, - 'z': atom_object.z, - 'energy': atom_object.energy, - } - atom_dict_list.append(atom_dict) - return atom_dict_list - -# 从原子对象列表中获取 (x, y) 坐标数组 -def get_coordinate_array_from_atom_object_list(atom_object_list): - coordinate_array = [] - for atom in atom_object_list: - x = atom.x - y = atom.y - coordinate_array.append([x, y]) - return coordinate_array - -# 从原子对象列表中获取 x 和 y 的最大值和最小值 -def get_max_min_x_y_from_atom_object_list(atom_object_list): - import guan - coordinate_array = guan.get_coordinate_array_from_atom_object_list(atom_object_list) - x_array = [] - for coordinate in coordinate_array: - x_array.append(coordinate[0]) - y_array = [] - for coordinate in coordinate_array: - y_array.append(coordinate[1]) - max_x = max(x_array) - min_x = min(x_array) - max_y = max(y_array) - min_y = min(y_array) - return max_x, min_x, max_y, min_y - -# 从原子对象列表中获取满足坐标条件的索引 -def get_index_via_coordinate_from_atom_object_list(atom_object_list, x=0, y=0, z=0, eta=1e-3): - for atom in atom_object_list: - x_i = atom.x - y_i = atom.y - z_i = atom.z - index = atom.index - if abs(x-x_i)