From 5bcbbbe92f791f1eaff42c618fe4b80a9fdb0cee Mon Sep 17 00:00:00 2001 From: minisbett <39670899+minisbett@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:25:34 +0100 Subject: [PATCH 1/6] Fix both acc and judgements specified --- app/objects/score.py | 2 -- app/usecases/performance.py | 12 ++---------- tools/recalc.py | 1 - 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/objects/score.py b/app/objects/score.py index 1051e18d0..c9c72601a 100644 --- a/app/objects/score.py +++ b/app/objects/score.py @@ -324,8 +324,6 @@ def calculate_performance(self, beatmap_id: int) -> tuple[float, float]: mode=mode_vn, mods=int(self.mods), combo=self.max_combo, - # prefer to use the score's specific params that add up to the acc - acc=self.acc, ngeki=self.ngeki, n300=self.n300, nkatu=self.nkatu, diff --git a/app/usecases/performance.py b/app/usecases/performance.py index 5db4f0299..e531ff4ea 100644 --- a/app/usecases/performance.py +++ b/app/usecases/performance.py @@ -65,16 +65,8 @@ def calculate_performances( results: list[PerformanceResult] = [] for score in scores: - # assert either acc OR 300/100/50/geki/katu/miss is present, but not both - # if (score.acc is None) == ( - # score.n300 is None - # and score.n100 is None - # and score.n50 is None - # and score.ngeki is None - # and score.nkatu is None - # and score.nmiss is None - # ): - # raise ValueError("Either acc OR 300/100/50/geki/katu/miss must be present") + if score.acc and (score.ngeki or score.nkatu or score.n50 or score.n100): + raise ValueError("Must not specify both accuracy and geki/katu/50s/100s.") # rosupp ignores NC and requires DT if score.mods is not None: diff --git a/tools/recalc.py b/tools/recalc.py index 172a5053e..d7c019d33 100644 --- a/tools/recalc.py +++ b/tools/recalc.py @@ -66,7 +66,6 @@ async def recalculate_score( calculator = Calculator( mode=GameMode(score["mode"]).as_vanilla, mods=score["mods"], - acc=score["acc"], combo=score["max_combo"], n_geki=score["ngeki"], # Mania 320s n300=score["n300"], From 4c1146e8d4fba2bb8ef5cad6430213f456e9e380 Mon Sep 17 00:00:00 2001 From: cmyui Date: Mon, 26 Feb 2024 02:25:42 -0500 Subject: [PATCH 2/6] comment --- app/usecases/performance.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/usecases/performance.py b/app/usecases/performance.py index e531ff4ea..b1a085aa3 100644 --- a/app/usecases/performance.py +++ b/app/usecases/performance.py @@ -18,6 +18,7 @@ class ScoreParams: combo: int | None = None # caller may pass either acc OR 300/100/50/geki/katu/miss + # passing both will result in a value error being raised acc: float | None = None n300: int | None = None @@ -60,12 +61,23 @@ def calculate_performances( osu_file_path: str, scores: Iterable[ScoreParams], ) -> list[PerformanceResult]: + """\ + Calculate performance for multiple scores on a single beatmap. + + Typically most useful for mass-recalculation situations. + + TODO: Some level of error handling & returning to caller should be + implemented here to handle cases where e.g. the beatmap file is invalid + or there an issue during calculation. + """ calc_bmap = Beatmap(path=osu_file_path) results: list[PerformanceResult] = [] for score in scores: - if score.acc and (score.ngeki or score.nkatu or score.n50 or score.n100): + if score.acc and ( + score.n300 or score.n100 or score.n50 or score.ngeki or score.nkatu + ): raise ValueError("Must not specify both accuracy and geki/katu/50s/100s.") # rosupp ignores NC and requires DT From 29fcdbd9e852126376864312dccce6f42ec3d9bf Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Mon, 26 Feb 2024 02:26:32 -0500 Subject: [PATCH 3/6] more clear comment --- app/usecases/performance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/usecases/performance.py b/app/usecases/performance.py index b1a085aa3..e9e324f2d 100644 --- a/app/usecases/performance.py +++ b/app/usecases/performance.py @@ -78,7 +78,7 @@ def calculate_performances( if score.acc and ( score.n300 or score.n100 or score.n50 or score.ngeki or score.nkatu ): - raise ValueError("Must not specify both accuracy and geki/katu/50s/100s.") + raise ValueError("Must not specify accuracy AND 300/100/50/geki/katu. Only one or the other.") # rosupp ignores NC and requires DT if score.mods is not None: From 07a41749e5b2ac2a7161ba8aefab0fa6059e7cdb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 07:26:41 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- app/usecases/performance.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/usecases/performance.py b/app/usecases/performance.py index e9e324f2d..2c2ed1015 100644 --- a/app/usecases/performance.py +++ b/app/usecases/performance.py @@ -78,7 +78,9 @@ def calculate_performances( if score.acc and ( score.n300 or score.n100 or score.n50 or score.ngeki or score.nkatu ): - raise ValueError("Must not specify accuracy AND 300/100/50/geki/katu. Only one or the other.") + raise ValueError( + "Must not specify accuracy AND 300/100/50/geki/katu. Only one or the other.", + ) # rosupp ignores NC and requires DT if score.mods is not None: From 85763e365d7a30095b7db6841339b5c81377bc68 Mon Sep 17 00:00:00 2001 From: cmyui Date: Mon, 26 Feb 2024 02:29:08 -0500 Subject: [PATCH 5/6] fix pp snapshot in itest --- tests/integration/domains/osu_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/domains/osu_test.py b/tests/integration/domains/osu_test.py index 49adc7efa..1052d7874 100644 --- a/tests/integration/domains/osu_test.py +++ b/tests/integration/domains/osu_test.py @@ -239,5 +239,5 @@ async def test_score_submission( assert response.status_code == status.HTTP_200_OK assert ( response.read() - == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.041|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" + == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.313|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" ) From 21993cf97426c2ac0b5e653350cf7ac4eb3438ef Mon Sep 17 00:00:00 2001 From: cmyui Date: Mon, 26 Feb 2024 08:13:03 -0500 Subject: [PATCH 6/6] fix itest snapshot --- tests/integration/domains/osu_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/domains/osu_test.py b/tests/integration/domains/osu_test.py index 1052d7874..30c6f086f 100644 --- a/tests/integration/domains/osu_test.py +++ b/tests/integration/domains/osu_test.py @@ -239,5 +239,5 @@ async def test_score_submission( assert response.status_code == status.HTTP_200_OK assert ( response.read() - == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.313|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" + == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.313|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:11|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" )