Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
AaDalal committed Aug 22, 2023
1 parent 078d15f commit d4a0dd0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
8 changes: 5 additions & 3 deletions backend/review/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ def annotate_with_matching_reviews(
)


def annotate_average_and_recent(qs, match_review_on, match_section_on, extra_metrics=True, fields=None):
def annotate_average_and_recent(
qs, match_review_on, match_section_on, extra_metrics=True, fields=None
):
"""
Annotate queryset with both all reviews and recent reviews.
:param qs: Queryset to annotate.
Expand All @@ -281,7 +283,7 @@ def annotate_average_and_recent(qs, match_review_on, match_section_on, extra_met
most_recent=False,
prefix="average_",
extra_metrics=extra_metrics,
fields=fields
fields=fields,
)
qs = annotate_with_matching_reviews(
qs,
Expand All @@ -290,6 +292,6 @@ def annotate_average_and_recent(qs, match_review_on, match_section_on, extra_met
most_recent=True,
prefix="recent_",
extra_metrics=extra_metrics,
fields=fields
fields=fields,
)
return qs
16 changes: 10 additions & 6 deletions backend/review/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,16 @@ def avg_and_recent_demand_plots(section_map, status_updates_map, bin_size=0.01):
if param_shape is None or param_loc is None or param_scale is None:
rel_demand = csrdv_frac_zero
else:
rel_demand = csrdv_frac_zero + stats.lognorm.cdf(
raw_demand,
param_shape,
param_loc,
param_scale,
) * (1 - csrdv_frac_zero)
rel_demand = (
csrdv_frac_zero
+ stats.lognorm.cdf(
raw_demand,
param_shape,
param_loc,
param_scale,
)
* (1 - csrdv_frac_zero)
)
if change["percent_through"] > bin_start_pct + bin_size:
if num_in_bin > 0:
bin_avg = total_value_in_bin / num_in_bin
Expand Down
11 changes: 9 additions & 2 deletions backend/review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,14 @@ def check_instructor_id(instructor_id):
):
raise Http404("Instructor with given instructor_id not found.")

INSTRUCTOR_COURSE_REVIEW_FIELDS = ["instructor_quality", "course_quality", "work_required", "difficulty"]

INSTRUCTOR_COURSE_REVIEW_FIELDS = [
"instructor_quality",
"course_quality",
"work_required",
"difficulty",
]


@api_view(["GET"])
@schema(
Expand Down Expand Up @@ -420,7 +427,7 @@ def instructor_reviews(request, instructor_id):
)
& section_filters_pcr,
extra_metrics=True,
fields=INSTRUCTOR_COURSE_REVIEW_FIELDS
fields=INSTRUCTOR_COURSE_REVIEW_FIELDS,
).annotate(
most_recent_full_code=F("topic__most_recent__full_code"),
)
Expand Down

0 comments on commit d4a0dd0

Please sign in to comment.