Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed RV Plot #2927

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/lazy-lies-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@quri/squiggle-lang": patch
"@quri/squiggle-components": patch
---

Fixed RelativeValues plot display
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,20 @@ const Cell: FC<{
return <ErrorCell />;
}
const jsItem = itemResult.value.asJS();
if (!(jsItem instanceof Map)) {
if (!(jsItem instanceof Object)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many things in JS are instanceof Object:

> class X {}; (new X()) instanceof Object
true
> [] instanceof Object
true

OTOH, you do try/catch below, and rvSchema.parse is still there, so it should be fine.

return <ErrorCell />;
}
const item = rvSchema.parse(Object.fromEntries(jsItem.entries()));

return (
<CellBox>
<RelativeValueCell item={item} showMedian={true} />
</CellBox>
);
try {
const item = rvSchema.parse(jsItem["value"]);
return (
<CellBox>
<RelativeValueCell item={item} showMedian={true} />
</CellBox>
);
} catch (e) {
return <ErrorCell />;
}
};

type Props = {
Expand Down
6 changes: 3 additions & 3 deletions packages/squiggle-lang/src/fr/relativeValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export function makeSquiggleDefinitions(builtins: Bindings) {
{
|x,y|
findUncertainty(dist) = {
absDist = dist -> SampleSet.fromDist -> SampleSet.map(abs)
absDist = SampleSet(dist) -> SampleSet.map(abs)
p5 = inv(absDist, 0.05)
p95 = inv(absDist, 0.95)
log10(p95 / p5)
}
dists = fn(x,y)
dist1 = dists[0] -> SampleSet.fromDist
dist2 = dists[1] -> SampleSet.fromDist
dist1 = SampleSet(dists[0])
dist2 = SampleSet(dists[1])
dist = dists[0] / dists[1]
{
median: inv(dist, 0.5),
Expand Down