Skip to content

Commit

Permalink
Revert changes to underscore's isEqual (#2125)
Browse files Browse the repository at this point in the history
## Summary:
[Original comment](#2113 (comment))

I made a separate PR because I made this mistake in a couple of PRs so I thought I'd knock them out all at once.

Issue: LEMS-2737

## Test plan:

Author: handeyeco

Reviewers: jeremywiebe, benchristel

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ❌ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2125
  • Loading branch information
handeyeco authored Jan 17, 2025
1 parent 1bc9acd commit ecd7c1c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/perseus-core/src/utils/grapher-util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import _ from "underscore";

import {approximateDeepEqual} from "./equality";

import type {
LinearType,
QuadraticType,
Expand Down Expand Up @@ -95,7 +97,7 @@ const PlotDefaults = {
coeffs1: ReadonlyArray<number>,
coeffs2: ReadonlyArray<number>,
): boolean {
return _.isEqual(coeffs1, coeffs2);
return approximateDeepEqual(coeffs1, coeffs2);
},
movable: MOVABLES.PLOT,
getPropsForCoeffs: function (coeffs: ReadonlyArray<number>): {fn: any} {
Expand Down Expand Up @@ -269,7 +271,7 @@ const Sinusoid: SinusoidType = _.extend({}, PlotDefaults, {
coeffs1: ReadonlyArray<number>,
coeffs2: ReadonlyArray<number>,
) {
return _.isEqual(
return approximateDeepEqual(
canonicalSineCoefficients(coeffs1),
canonicalSineCoefficients(coeffs2),
);
Expand Down Expand Up @@ -326,7 +328,7 @@ const Tangent: TangentType = _.extend({}, PlotDefaults, {
coeffs1: ReadonlyArray<number>,
coeffs2: ReadonlyArray<number>,
) {
return _.isEqual(
return approximateDeepEqual(
canonicalTangentCoefficients(coeffs1),
canonicalTangentCoefficients(coeffs2),
);
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-score/src/widgets/plotter/score-plotter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {approximateDeepEqual} from "@khanacademy/perseus-core";
import _ from "underscore";

import validatePlotter from "./validate-plotter";
Expand All @@ -18,7 +19,7 @@ function scorePlotter(
}
return {
type: "points",
earned: _.isEqual(userInput, scoringData.correct) ? 1 : 0,
earned: approximateDeepEqual(userInput, scoringData.correct) ? 1 : 0,
total: 1,
message: null,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {approximateDeepEqual} from "@khanacademy/perseus-core";
import _ from "underscore";

import type {
Expand All @@ -16,7 +17,7 @@ function validatePlotter(
userInput: PerseusPlotterUserInput,
validationData: PerseusPlotterValidationData,
): ValidationResult {
if (_.isEqual(userInput, validationData.starting)) {
if (approximateDeepEqual(userInput, validationData.starting)) {
return {
type: "invalid",
message: null,
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-score/src/widgets/sorter/score-sorter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {approximateDeepEqual} from "@khanacademy/perseus-core";
import _ from "underscore";

import validateSorter from "./validate-sorter";
Expand All @@ -17,7 +18,7 @@ function scoreSorter(
return validationError;
}

const correct = _.isEqual(userInput.options, rubric.correct);
const correct = approximateDeepEqual(userInput.options, rubric.correct);
return {
type: "points",
earned: correct ? 1 : 0,
Expand Down

0 comments on commit ecd7c1c

Please sign in to comment.