From 1122fb9db064c5552684a662f3551764ac0cb9f6 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 19 Nov 2026 21:14:43 -0500 Subject: [PATCH] refactor: drop scipy from the course quality API The course quality view only used scipy for stats.mode(). Replace it with min(statistics.multimode(...)) from the standard library, which keeps the same tie-breaking (the smallest of the most common values). Co-Authored-By: Claude Opus 5.5 --- cms/djangoapps/contentstore/api/views/course_quality.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/api/views/course_quality.py b/cms/djangoapps/contentstore/api/views/course_quality.py index a83abe675a65..99c7a65ac45e 100644 --- a/cms/djangoapps/contentstore/api/views/course_quality.py +++ b/cms/djangoapps/contentstore/api/views/course_quality.py @@ -1,5 +1,6 @@ # pylint: disable=missing-module-docstring import logging +import statistics import time import numpy as np @@ -7,7 +8,6 @@ from openedx_authz.authz import COURSES_VIEW_COURSE from rest_framework.generics import GenericAPIView from rest_framework.response import Response -from scipy import stats from openedx.core.djangoapps.authz.constants import LegacyAuthoringPermission from openedx.core.djangoapps.authz.decorators import authz_permission_required @@ -278,5 +278,6 @@ def _stats_dict(self, data): # pylint: disable=missing-function-docstring max=max(data), mean=np.around(np.mean(data)), median=np.around(np.median(data)), - mode=stats.mode(data, axis=None)[0], + # On a tie, report the smallest of the most common values. + mode=min(statistics.multimode(data)), )