-
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.
✨ Use OCaml bindings for Python with seaborn instead of PLplot
- Loading branch information
Showing
6 changed files
with
39 additions
and
15 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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
open! Core | ||
|
||
let () = Py.initialize () | ||
|
||
let draw ~plot_path ~title ~samples ~num_samples = | ||
let m = Py.Import.add_module "ocaml" in | ||
List.iter2_exn ~f:(Py.Module.set m) | ||
[ "plot_path"; "title"; "samples"; "num_samples" ] | ||
[ | ||
Py.String.of_string plot_path; | ||
Py.String.of_string title; | ||
Py.Array.numpy samples; | ||
Py.Int.of_int num_samples; | ||
]; | ||
|
||
Py.Run.eval ~start:Py.File | ||
{| | ||
from ocaml import plot_path, title, samples, num_samples | ||
import seaborn as sns | ||
|
||
sns.set_theme() | ||
|
||
g = sns.displot(samples, element="step", stat="probability", bins=num_samples // 1500) | ||
g.set_titles(title) | ||
g.tight_layout() | ||
g.savefig(plot_path) |} | ||
|> ignore |
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,4 +1,4 @@ | ||
pin-depends: [ | ||
[ "owl.1.1" "git+https://github.com/owlbarn/owl#06943b0267e7e80dd0eba94ebf63ca4d25c71910" ] | ||
[ "owl-plplot.1.0" "git+https://github.com/owlbarn/owl-plplot#ebc73c09a907c1c6ca2c4b970bdb70202ec90b50" ] | ||
[ "pyml.20231101" "git+https://github.com/Zeta611/pyml#d62a7b9c2e3a856121c9cc850d71a11b00243b0c" ] | ||
] |