From d6b12899f71a2c8f947f97996f06a949f9e395db Mon Sep 17 00:00:00 2001 From: tangyijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 20 Mar 2025 11:38:40 +0800 Subject: [PATCH 01/12] worked --- china.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/china.py b/china.py index 59e5547..5383f13 100644 --- a/china.py +++ b/china.py @@ -1,17 +1,29 @@ 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, newline='') as csvfile: + reader = csv.DictReader(csvfile) + for row in reader: + stars = int(row['stars']) + forks = int(row['forks']) + created_at = np.datetime64(row['created_at']) + last_commit = np.datetime64(row['last_commit']) + active_days = (last_commit - created_at).astype('timedelta64[D]').astype(int) + data.append([stars, forks, active_days]) + return np.array(data) + def calculate_statistics(data): """ @@ -22,30 +34,42 @@ def calculate_statistics(data): 'variances': [stars_var, forks_var, days_var], 'stds': [stars_std, forks_std, days_std] } - + 计算仓库指标统计量 返回:包含平均值、中位数、方差、标准差的字典 """ - pass + means = np.mean(data, axis=0) + medians = np.median(data, axis=0) + variances = np.var(data, axis=0) + stds = np.std(data, axis=0) + + 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 4909774a5af126f9acbe025b5d47efdad87bc712 Mon Sep 17 00:00:00 2001 From: Bridget <2939383906@qq.com> Date: Thu, 20 Mar 2025 11:42:39 +0800 Subject: [PATCH 02/12] Worked on pakistan.py --- pakistan.py | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/pakistan.py b/pakistan.py index f2720fc..57a9f92 100644 --- a/pakistan.py +++ b/pakistan.py @@ -1,17 +1,32 @@ 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) + + # Extract relevant columns and calculate active days + stars = np.array([int(row[2]) for row in data]) + forks = np.array([int(row[3]) for row in data]) + 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) + + # Combine into a 2D array + return np.column_stack((stars, forks, active_days)) + def calculate_statistics(data): """ @@ -22,30 +37,43 @@ def calculate_statistics(data): 'variances': [stars_var, forks_var, days_var], 'stds': [stars_std, forks_std, days_std] } - + 计算仓库指标统计量 返回:包含平均值、中位数、方差、标准差的字典 """ - pass + 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 + } + 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 cbeb52ba144cdd1178d698a3ce6fa9b226472fab Mon Sep 17 00:00:00 2001 From: tangyijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 10:46:17 +0800 Subject: [PATCH 03/12] finish work on china.py --- china.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/china.py b/china.py index 5383f13..a58f93a 100644 --- a/china.py +++ b/china.py @@ -10,7 +10,7 @@ def load_data(file_path): 加载仓库数据并计算活跃天数 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 - 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] + 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数 """ data = [] with open(file_path, newline='') as csvfile: -- Gitee From 8847816de035b12b33a5beea5e9de0511938753e Mon Sep 17 00:00:00 2001 From: Bridget <2939383906@qq.com> Date: Thu, 27 Mar 2025 10:51:49 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E5=96=84pakistan.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pakistan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pakistan.py b/pakistan.py index 57a9f92..a82c4c2 100644 --- a/pakistan.py +++ b/pakistan.py @@ -9,7 +9,7 @@ def load_data(file_path): Return: 2D NumPy array of shape (repos, 3) containing [stars, forks, active_days] 加载仓库数据并计算活跃天数 - 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 + 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述。 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] """ with open(file_path, 'r') as file: -- Gitee From fded40a23e711999377e0d77cee0860fbbf29a21 Mon Sep 17 00:00:00 2001 From: tangyijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 10:58:25 +0800 Subject: [PATCH 05/12] finish work on china.py --- china.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/china.py b/china.py index a58f93a..5383f13 100644 --- a/china.py +++ b/china.py @@ -10,7 +10,7 @@ def load_data(file_path): 加载仓库数据并计算活跃天数 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 - 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数 + 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] """ data = [] with open(file_path, newline='') as csvfile: -- Gitee From eaf3767ed9187816564352e3f3047510413659ae Mon Sep 17 00:00:00 2001 From: tangyijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 27 Mar 2025 11:00:46 +0800 Subject: [PATCH 06/12] finish work on china.py --- china.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/china.py b/china.py index 5383f13..a58f93a 100644 --- a/china.py +++ b/china.py @@ -10,7 +10,7 @@ def load_data(file_path): 加载仓库数据并计算活跃天数 列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述 - 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数] + 返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数 """ data = [] with open(file_path, newline='') as csvfile: -- Gitee From c175be444534760197bfa0fd56a662a090ddf68a Mon Sep 17 00:00:00 2001 From: Wang Yiqiao <2939383906@qq.com> Date: Fri, 28 Mar 2025 15:16:28 +0800 Subject: [PATCH 07/12] Added 2.txt --- .gitignore | 1 + 2.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 .gitignore create mode 100644 2.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/2.txt b/2.txt new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/2.txt @@ -0,0 +1 @@ +2 \ No newline at end of file -- Gitee From 3873e050a6fa62e7fa5fb3e8a8386d0a00858866 Mon Sep 17 00:00:00 2001 From: Wang Yiqiao <2939383906@qq.com> Date: Fri, 28 Mar 2025 07:25:54 +0000 Subject: [PATCH 08/12] update 1.txt. Signed-off-by: Wang Yiqiao <2939383906@qq.com> --- 1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1.txt b/1.txt index 56a6051..3cacc0b 100644 --- a/1.txt +++ b/1.txt @@ -1 +1 @@ -1 \ No newline at end of file +12 \ No newline at end of file -- Gitee From 37d006663a83d74c16792e06a8e43b58f4fc2057 Mon Sep 17 00:00:00 2001 From: Arsala Bangash <15454269+arsalabangash@user.noreply.gitee.com> Date: Thu, 10 Apr 2025 03:23:44 +0000 Subject: [PATCH 09/12] add khan.md. Signed-off-by: Arsala Bangash <15454269+arsalabangash@user.noreply.gitee.com> --- khan.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 khan.md diff --git a/khan.md b/khan.md new file mode 100644 index 0000000..d2e5683 --- /dev/null +++ b/khan.md @@ -0,0 +1 @@ +# Khan \ No newline at end of file -- Gitee From fd8051fd0ca418ec04df40f2ec78d5eed290c6a7 Mon Sep 17 00:00:00 2001 From: Wang Yiqiao <2939383906@qq.com> Date: Thu, 10 Apr 2025 03:23:47 +0000 Subject: [PATCH 10/12] add wyq.md. Signed-off-by: Wang Yiqiao <2939383906@qq.com> --- wyq.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 wyq.md diff --git a/wyq.md b/wyq.md new file mode 100644 index 0000000..6ef5cd5 --- /dev/null +++ b/wyq.md @@ -0,0 +1 @@ +# wyq \ No newline at end of file -- Gitee From bf847754f48b8bb7cbbcafc7ed2596601fecb04a Mon Sep 17 00:00:00 2001 From: Tang Yijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 10 Apr 2025 03:24:53 +0000 Subject: [PATCH 11/12] add tangyijun.md. Signed-off-by: Tang Yijun <15469986+tangyijun123@user.noreply.gitee.com> --- tangyijun.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 tangyijun.md diff --git a/tangyijun.md b/tangyijun.md new file mode 100644 index 0000000..4282729 --- /dev/null +++ b/tangyijun.md @@ -0,0 +1 @@ +# tangyijun \ No newline at end of file -- Gitee From 6470d3d31025d87585e8d8323b0397648e2b9de4 Mon Sep 17 00:00:00 2001 From: Tang Yijun <15469986+tangyijun123@user.noreply.gitee.com> Date: Thu, 10 Apr 2025 03:46:44 +0000 Subject: [PATCH 12/12] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!3?= =?UTF-8?q?=20:=20add=20tangyijun.md.'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tangyijun.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tangyijun.md diff --git a/tangyijun.md b/tangyijun.md deleted file mode 100644 index 4282729..0000000 --- a/tangyijun.md +++ /dev/null @@ -1 +0,0 @@ -# tangyijun \ No newline at end of file -- Gitee