From 610a89d39c8ca6f8e3b86450119b8675bed9f073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=B9=8F=E7=A8=8B?= <15464973+golden-sparrow-journey@user.noreply.gitee.com> Date: Thu, 20 Mar 2025 14:54:21 +0800 Subject: [PATCH 1/6] numpy-ex3 --- .idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 +++ .idea/numpy-ex3.iml | 12 ++++ .idea/vcs.xml | 6 ++ pakistan.py | 69 ++++++++++--------- 7 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/numpy-ex3.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6218fe --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..be364f5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/numpy-ex3.iml b/.idea/numpy-ex3.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/numpy-ex3.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pakistan.py b/pakistan.py index f2720fc..6bf07ee 100644 --- a/pakistan.py +++ b/pakistan.py @@ -1,51 +1,54 @@ import numpy as np import csv + def load_data(file_path): - """ - Load repository data and calculate activity metrics - Columns: repo_name,owner,stars,forks,language,created_at,last_commit,description - Return: 2D NumPy array of shape (repos, 3) containing [stars, forks, active_days] - - 加载仓库数据并计算活跃天数 - 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 - 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] - """ - pass + + with open(file_path, 'r') as file: + reader = csv.reader(file) + next(reader) # Skip header + data = list(reader) + + stars = np.array([int(row[2]) for row in data], dtype=int) + forks = np.array([int(row[3]) for row in data], dtype=int) + created_at = np.array([np.datetime64(row[5]) for row in data]) + last_commit = np.array([np.datetime64(row[6]) for row in data]) + active_days = (last_commit - created_at).astype('timedelta64[D]').astype(int) + + return np.column_stack((stars, forks, active_days)) + def calculate_statistics(data): - """ - Calculate repository metrics statistics - Return: Dictionary containing { - 'means': [stars_mean, forks_mean, days_mean], - 'medians': [stars_median, forks_median, days_median], - 'variances': [stars_var, forks_var, days_var], - 'stds': [stars_std, forks_std, days_std] + + means = np.mean(data, axis=0).round(1) + medians = np.median(data, axis=0).round(1) + variances = np.var(data, axis=0).round(1) + stds = np.std(data, axis=0).round(1) + + return { + 'means': means, + 'medians': medians, + 'variances': variances, + 'stds': stds } - - 计算仓库指标统计量 - 返回:包含平均值、中位数、方差、标准差的字典 - """ - pass + def print_results(stats): - """ - Print formatted results with proper indentation - - 按严格格式打印结果,保持正确缩进 - """ + metrics = ['Stars', 'Forks', 'Active Days'] - for metric, mean, med, var, std in zip(metrics, - stats['means'], - stats['medians'], - stats['variances'], - stats['stds']): + for metric, mean, med, var, std in zip(metrics, + stats['means'], + stats['medians'], + stats['variances'], + stats['stds']): print(f"{metric}:") print(f" Average: {mean:.1f}") print(f" Median: {med:.1f}") print(f" Variance: {var:.1f}") print(f" Standard Deviation: {std:.1f}") + +# Load data and calculate statistics repo_data = load_data('pakistan-repos.csv') stats = calculate_statistics(repo_data) -print_results(stats) +print_results(stats) \ No newline at end of file -- Gitee From a293da1e04c41e7fe2e4a738a07ba8ac1cbd626a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9B=A8=E6=9D=AD?= <15470909+liyuhang-147@user.noreply.gitee.com> Date: Thu, 20 Mar 2025 14:59:43 +0800 Subject: [PATCH 2/6] numpy-ex3 --- .idea/.gitignore | 3 ++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 +++ .idea/modules.xml | 8 ++++ .idea/numpy-ex3.iml | 12 +++++ .idea/vcs.xml | 6 +++ china.py | 48 ++++++++++++++----- 7 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/numpy-ex3.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6218fe --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..be364f5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/numpy-ex3.iml b/.idea/numpy-ex3.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/numpy-ex3.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/china.py b/china.py index 59e5547..6eb43b3 100644 --- a/china.py +++ b/china.py @@ -1,51 +1,75 @@ import numpy as np import csv + def load_data(file_path): """ Load repository data and calculate activity metrics Columns: repo_name,owner,stars,forks,language,created_at,last_commit,description Return: 2D NumPy array of shape (repos, 3) containing [stars, forks, active_days] - + 加载仓库数据并计算活跃天数 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] """ - pass + data = [] + with open(file_path, 'r', encoding='utf-8') as file: + reader = csv.reader(file) + next(reader) # 跳过标题行 + for row in reader: + stars = int(row[2]) + forks = int(row[3]) + created_at = np.datetime64(row[5]) + last_commit = np.datetime64(row[6]) + active_days = (last_commit - created_at).astype(float) + data.append([stars, forks, active_days]) + return np.array(data) + def calculate_statistics(data): """ Calculate repository metrics statistics Return: Dictionary containing { 'means': [stars_mean, forks_mean, days_mean], - 'medians': [stars_median, forks_median, days_median], - 'variances': [stars_var, forks_var, days_var], + 'medians': [stars_median, forks_median, days_median], + 'variances': [stars_var, forks_var, days_var], 'stds': [stars_std, forks_std, days_std] } - + 计算仓库指标统计量 返回:包含平均值、中位数、方差、标准差的字典 """ - pass + means = np.round(np.mean(data, axis=0), 1) + medians = np.round(np.median(data, axis=0), 1) + variances = np.round(np.var(data, axis=0), 1) + stds = np.round(np.std(data, axis=0), 1) + return { + 'means': means, + 'medians': medians, + 'variances': variances, + 'stds': stds + } + def print_results(stats): """ Print formatted results with proper indentation - + 按严格格式打印结果,保持正确缩进 """ metrics = ['Stars', 'Forks', 'Active Days'] - for metric, mean, med, var, std in zip(metrics, - stats['means'], - stats['medians'], - stats['variances'], - stats['stds']): + for metric, mean, med, var, std in zip(metrics, + stats['means'], + stats['medians'], + stats['variances'], + stats['stds']): print(f"{metric}:") print(f" Average: {mean:.1f}") print(f" Median: {med:.1f}") print(f" Variance: {var:.1f}") print(f" Standard Deviation: {std:.1f}") + repo_data = load_data('china-repos.csv') stats = calculate_statistics(repo_data) print_results(stats) \ No newline at end of file -- Gitee From 4263561567e2eb96bceb2c97833bc130f5075c33 Mon Sep 17 00:00:00 2001 From: Huang Pengcheng <15464973+golden-sparrow-journey@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 15:07:44 +0800 Subject: [PATCH 3/6] pakistan.py --- pakistan.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pakistan.py b/pakistan.py index 6bf07ee..c96a668 100644 --- a/pakistan.py +++ b/pakistan.py @@ -51,4 +51,5 @@ def print_results(stats): # Load data and calculate statistics repo_data = load_data('pakistan-repos.csv') stats = calculate_statistics(repo_data) -print_results(stats) \ No newline at end of file +print_results(stats) +# test \ No newline at end of file -- Gitee From dbf3a9fcf69a51248d0f1e9ab995fe8ed8c9c379 Mon Sep 17 00:00:00 2001 From: Huang Pengcheng <15464973+golden-sparrow-journey@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 15:26:16 +0800 Subject: [PATCH 4/6] remove .idea --- .idea/.gitignore | 3 --- .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/misc.xml | 7 ------- .idea/modules.xml | 8 -------- .idea/numpy-ex3.iml | 12 ------------ .idea/vcs.xml | 6 ------ 6 files changed, 42 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/numpy-ex3.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index a6218fe..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index be364f5..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/numpy-ex3.iml b/.idea/numpy-ex3.iml deleted file mode 100644 index 8b8c395..0000000 --- a/.idea/numpy-ex3.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file -- Gitee From cbc3005bc07b04959316e1847350e10c4747c584 Mon Sep 17 00:00:00 2001 From: Huang Pengcheng <15464973+golden-sparrow-journey@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 15:35:20 +0800 Subject: [PATCH 5/6] ignore idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ -- Gitee From 660633615b6fe1799a3517deb58595fae4f4a1a5 Mon Sep 17 00:00:00 2001 From: Huang Pengcheng <15464973+golden-sparrow-journey@user.noreply.gitee.com> Date: Thu, 3 Apr 2025 15:34:32 +0800 Subject: [PATCH 6/6] Added folder with name HuangPengcheng --- HuangPengcheng/main.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 HuangPengcheng/main.py diff --git a/HuangPengcheng/main.py b/HuangPengcheng/main.py new file mode 100644 index 0000000..ab4f27b --- /dev/null +++ b/HuangPengcheng/main.py @@ -0,0 +1 @@ +print("DA402") \ No newline at end of file -- Gitee