From 5299bb68913595fc525ba9826fdf2fa04e9d5e4c Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Fri, 19 Jul 2024 22:54:11 +0800 Subject: [PATCH] 0.1.117 --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan.egg-info/SOURCES.txt | 1 + PyPI/src/guan/__init__.py | 1 + PyPI/src/guan/deprecated.py | 29 +++++++++++++ PyPI/src/guan/figure_plotting.py | 4 +- PyPI/src/guan/others.py | 66 +++++++++++++++++++++++------- 7 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 PyPI/src/guan/deprecated.py diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 241f8d7..4bf3a5a 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.115 +version = 0.1.117 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 47b7d37..29784ab 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.1.115 +Version: 0.1.117 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 18ff90e..7a576a8 100644 --- a/PyPI/src/guan.egg-info/SOURCES.txt +++ b/PyPI/src/guan.egg-info/SOURCES.txt @@ -11,6 +11,7 @@ src/guan/basic_functions.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/machine_learning.py diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index eb0085f..bf3eb8f 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -14,4 +14,5 @@ from .figure_plotting import * from .data_processing import * from .others import * from .decorators import * +from .deprecated import * statistics_of_guan_package() \ No newline at end of file diff --git a/PyPI/src/guan/deprecated.py b/PyPI/src/guan/deprecated.py new file mode 100644 index 0000000..96f54a9 --- /dev/null +++ b/PyPI/src/guan/deprecated.py @@ -0,0 +1,29 @@ +# Module: deprecated + +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 \ No newline at end of file diff --git a/PyPI/src/guan/figure_plotting.py b/PyPI/src/guan/figure_plotting.py index 2346b4c..f68ff78 100644 --- a/PyPI/src/guan/figure_plotting.py +++ b/PyPI/src/guan/figure_plotting.py @@ -13,7 +13,7 @@ def import_plt_and_start_fig_ax(adjust_bottom=0.2, adjust_left=0.2, labelsize=20 return plt, fig, ax # 基于plt, fig, ax画图 -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'): +def plot_without_starting_fig_ax(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'): if color==None: ax.plot(x_array, y_array, style, linewidth=linewidth, markersize=markersize) else: @@ -298,7 +298,7 @@ def plot_pcolor(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', font plt.close('all') # 基于plt, fig, ax,通过坐标画点和线 -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): +def draw_dots_and_lines_without_starting_fig_ax(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 numpy as np coordinate_array = np.array(coordinate_array) if draw_lines==1: diff --git a/PyPI/src/guan/others.py b/PyPI/src/guan/others.py index e16b7d7..2cd25c1 100644 --- a/PyPI/src/guan/others.py +++ b/PyPI/src/guan/others.py @@ -32,6 +32,31 @@ def get_memory_info(): used_memory_percent = memory_info.percent return total_memory, used_memory, available_memory, used_memory_percent +# 每日git commit次数的统计 +def statistics_of_git_commits(print_show=0, str_or_datetime='str'): + import subprocess + import collections + since_date = '100 year ago' + result = subprocess.run( + ['git', 'log', f'--since={since_date}', '--pretty=format:%ad', '--date=short'], + stdout=subprocess.PIPE, + text=True) + commits = result.stdout.strip().split('\n') + counter = collections.Counter(commits) + daily_commit_counts = dict(sorted(counter.items())) + date_array = [] + commit_count_array = [] + for date, count in daily_commit_counts.items(): + if print_show == 1: + print(f"{date}: {count} commits") + if str_or_datetime=='datetime': + import datetime + date_array.append(datetime.datetime.strptime(date, "%Y-%m-%d")) + elif str_or_datetime=='str': + date_array.append(date) + commit_count_array.append(count) + return date_array, commit_count_array + # 将WordPress导出的XML格式文件转换成多个MarkDown格式的文件 def convert_wordpress_xml_to_markdown(xml_file='./a.xml', convert_content=1, replace_more=[]): import xml.etree.ElementTree as ET @@ -94,7 +119,7 @@ def count_number_of_import_statements(filename, file_format='.py', num=1000): return import_statement_counter # 获取本月的所有日期 -def get_days_of_the_current_month(str_or_datetime='str'): +def get_date_array_of_the_current_month(str_or_datetime='str'): import datetime today = datetime.date.today() first_day_of_month = today.replace(day=1) @@ -103,14 +128,25 @@ def get_days_of_the_current_month(str_or_datetime='str'): else: next_month = first_day_of_month.replace(month=first_day_of_month.month + 1) current_date = first_day_of_month - day_array = [] + date_array = [] while current_date < next_month: if str_or_datetime=='str': - day_array.append(str(current_date)) + date_array.append(str(current_date)) elif str_or_datetime=='datetime': - day_array.append(current_date) + date_array.append(current_date) current_date += datetime.timedelta(days=1) - return day_array + return date_array + +# 根据新的日期,填充数组中缺少的数据为零 +def fill_zero_data_for_new_dates(old_dates, new_dates, old_data_array): + new_data_array = [] + for date in new_dates: + if str(date) not in old_dates: + new_data_array.append(0) + else: + index = old_dates.index(date) + new_data_array.append(old_data_array[index]) + return new_data_array # 获取上个月份 def get_last_month(): @@ -142,7 +178,7 @@ def get_the_month_before_last(): return year_of_the_month_before_last, the_month_before_last # 获取上个月的所有日期 -def get_days_of_the_last_month(str_or_datetime='str'): +def get_date_array_of_the_last_month(str_or_datetime='str'): import datetime import guan today = datetime.date.today() @@ -153,17 +189,17 @@ def get_days_of_the_last_month(str_or_datetime='str'): else: next_month = first_day_of_month.replace(month=first_day_of_month.month + 1) current_date = first_day_of_month - day_array = [] + date_array = [] while current_date < next_month: if str_or_datetime=='str': - day_array.append(str(current_date)) + date_array.append(str(current_date)) elif str_or_datetime=='datetime': - day_array.append(current_date) + date_array.append(current_date) current_date += datetime.timedelta(days=1) - return day_array + return date_array # 获取上上个月的所有日期 -def get_days_of_the_month_before_last(str_or_datetime='str'): +def get_date_array_of_the_month_before_last(str_or_datetime='str'): import datetime import guan today = datetime.date.today() @@ -174,14 +210,14 @@ def get_days_of_the_month_before_last(str_or_datetime='str'): else: next_month = first_day_of_month.replace(month=first_day_of_month.month + 1) current_date = first_day_of_month - day_array = [] + date_array = [] while current_date < next_month: if str_or_datetime=='str': - day_array.append(str(current_date)) + date_array.append(str(current_date)) elif str_or_datetime=='datetime': - day_array.append(current_date) + date_array.append(current_date) current_date += datetime.timedelta(days=1) - return day_array + return date_array # 获取所有股票 def all_stocks():