Spaces:
Running
Running
Download frontends/react/src/python.ts from nhamid289/optimization-dev: direct link, hf CLI and curl.
- Browser
- Download file 813 Bytes
-
https://huggingface.co/spaces/nhamid289/optimization-dev/resolve/main/frontends/react/src/python.ts
- Command line
-
hf download hf://spaces/nhamid289/optimization-dev/frontends/react/src/python.ts
-
curl -L -o python.ts https://huggingface.co/spaces/nhamid289/optimization-dev/resolve/main/frontends/react/src/python.ts
813 Bytes
| import { createPython } from "@elvis/pyodide"; | |
| import type { FunctionValues, RunSettings, State } from "./types"; | |
| // The methods of backend/src/manager.py's Manager | |
| export type OptimisationApi = { | |
| // variables is 1 or 2; clears the runs | |
| handle_set_function: { args: { variables: number; expression: string }; result: null }; | |
| // null when no function is set | |
| handle_function_values: { args: { x_range: number[]; y_range: number[] }; result: FunctionValues | null }; | |
| handle_set_runs: { args: { runs: RunSettings[] }; result: null }; | |
| // null once every run has stopped (or there are none) | |
| handle_state: { args: { iteration: number }; result: State | null }; | |
| }; | |
| export const python = createPython<OptimisationApi>( | |
| new Worker(new URL("./pyodide.worker.ts", import.meta.url), { type: "module" }), | |
| ); | |