-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sampling-output-take-3
- Loading branch information
Showing
14 changed files
with
25,964 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: test stan-playground | ||
|
||
on: | ||
pull_request: | ||
branches: ['main'] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: 'tests' | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
frontend-tests: | ||
name: yarn tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
cache-dependency-path: gui/yarn.lock | ||
- name: Install dependencies | ||
run: cd gui; yarn | ||
- name: Test | ||
run: cd gui; yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,33 @@ | ||
import { Done } from "@mui/icons-material"; | ||
import { FunctionComponent, useEffect, useState } from "react"; | ||
import runStanc from "./runStanc"; | ||
import { FunctionComponent } from "react"; | ||
import { StancErrors } from "../Stanc/Types"; | ||
|
||
type Props = { | ||
width: number | ||
height: number | ||
mainStanText: string | undefined | ||
onValidityChanged?: (valid: boolean) => void | ||
stancErrors: StancErrors, | ||
} | ||
|
||
type CompiledModel = { | ||
errors?: string[] | ||
warnings?: string[] | ||
result: string | ||
} | ||
|
||
const StanCompileResultWindow: FunctionComponent<Props> = ({width, height, mainStanText, onValidityChanged}) => { | ||
const [model, setModel] = useState<CompiledModel | undefined>(undefined) | ||
useEffect(() => { | ||
setModel(undefined) | ||
if (mainStanText === undefined) return | ||
;(async () => { | ||
const m = await runStanc('main.stan', mainStanText, ["auto-format", "max-line-length=78"]) | ||
setModel(m) | ||
})() | ||
}, [mainStanText]) | ||
|
||
useEffect(() => { | ||
if (!model) { | ||
onValidityChanged && onValidityChanged(false) | ||
return | ||
} | ||
onValidityChanged && onValidityChanged(model.errors === undefined) | ||
}, [model, onValidityChanged]) | ||
const StanCompileResultWindow: FunctionComponent<Props> = ({ width, height, stancErrors }) => { | ||
|
||
if (!model) return <div /> | ||
if ((model.errors) && (model.errors.length > 0)) { | ||
if ((stancErrors.errors) && (stancErrors.errors.length > 0)) { | ||
return ( | ||
<div style={{width, height, color: 'red', padding: 0, overflow: 'auto'}}> | ||
<div style={{ width, height, color: 'red', padding: 0, overflow: 'auto' }}> | ||
<h3>Errors</h3> | ||
{model.errors.map((error, i) => <div key={i} style={{font: 'courier', fontSize: 13}}><pre>{error}</pre></div>)} | ||
{stancErrors.errors.slice(1).map((error, i) => <div key={i} style={{ font: 'courier', fontSize: 13 }}><pre>{error}</pre></div>)} | ||
</div> | ||
) | ||
} | ||
if ((model.warnings) && (model.warnings.length > 0)) { | ||
if ((stancErrors.warnings) && (stancErrors.warnings.length > 0)) { | ||
return ( | ||
<div style={{width, height, color: 'blue', padding: 0, overflow: 'auto'}}> | ||
<div style={{ width, height, color: 'blue', padding: 0, overflow: 'auto' }}> | ||
<h3>Warnings</h3> | ||
{model.warnings.map((warning, i) => <div key={i} style={{font: 'courier', fontSize: 13}}><pre>{warning}</pre></div>)} | ||
{stancErrors.warnings.map((warning, i) => <div key={i} style={{ font: 'courier', fontSize: 13 }}><pre>{warning}</pre></div>)} | ||
</div> | ||
) | ||
} | ||
if (model.result === mainStanText) { | ||
return (<div style={{color: 'green'}}><Done /> canonical format</div>) | ||
} | ||
return (<div style={{color: 'green'}}><Done /></div>) | ||
|
||
return (<div style={{ color: 'green' }}><Done /></div>) | ||
} | ||
|
||
export default StanCompileResultWindow | ||
export default StanCompileResultWindow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export type StancErrors = { | ||
errors?: string[]; | ||
warnings?: string[]; | ||
}; | ||
|
||
type StancReturn = { result?: string } & StancErrors; | ||
|
||
export type StancFunction = ( | ||
name: string, | ||
code: string, | ||
args: string[], | ||
) => StancReturn; | ||
|
||
export type StancReplyMessage = { fatal: string } | StancReturn; | ||
|
||
export enum StancWorkerRequests { | ||
FormatStanCode = "format", | ||
CheckSyntax = "check", | ||
} | ||
|
||
export type StancRequestMessage = { | ||
purpose: StancWorkerRequests; | ||
name: string; | ||
code: string; | ||
}; |
Oops, something went wrong.