Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/Terminal/AngouriMath.Terminal.Lib/FSharpInteractive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ JsonFSharpConverter () |> options.Converters.Add
let private objectEncode (o : obj) =
match o with
| :? ILatexiseable as latexiseable ->
let toSerialize = LatexSuccess (latexiseable.Latexise (), o.ToString ())
let toSerialize = LatexSuccess (latexiseable.Latexise (), string o)
EncodingLatexPrefix + JsonSerializer.Serialize(toSerialize, options)
| _ ->
let toSerialize = PlainTextSuccess (o.ToString ())
let toSerialize = PlainTextSuccess (string o)
EncodingPlainPrefix + JsonSerializer.Serialize(toSerialize, options)


let private objectDecode (s : string Option) =
match s with
| None -> VoidSuccess
| Some plain when plain.StartsWith EncodingPlainPrefix ->
JsonSerializer.Deserialize<ExecutionResult> (plain.[EncodingPlainPrefix.Length..], options)
JsonSerializer.Deserialize<ExecutionResult> (plain.[EncodingPlainPrefix.Length..], options) |> nonNull
| Some latex when latex.StartsWith EncodingLatexPrefix ->
JsonSerializer.Deserialize<ExecutionResult> (latex.[EncodingLatexPrefix.Length..], options)
JsonSerializer.Deserialize<ExecutionResult> (latex.[EncodingLatexPrefix.Length..], options) |> nonNull
| _ -> VoidSuccess

let execute (kernel : FSharpKernel) code =
Expand Down Expand Up @@ -82,7 +82,7 @@ let createKernel () =
|> Chart.withSize (1200., 900.)
|> Chart.show
"Showing in the browser")
|> (fun f -> Func<GenericChart.GenericChart, string> f)
|> (fun f -> Func<GenericChart, string> f)
|> (fun f ->
Formatter.Register<GenericChart.GenericChart> (f, "text/plain"))
Formatter.Register<GenericChart> (f, "text/plain"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

<ItemGroup>
<PackageReference Include="AngouriMath.FSharp" Version="1.4.0-preview.3" />
<PackageReference Include="Microsoft.DotNet.Interactive" Version="1.0.0-beta.25323.1" />
<PackageReference Include="Microsoft.DotNet.Interactive.Formatting" Version="1.0.0-beta.25323.1" />
<PackageReference Include="Plotly.NET" Version="2.0.0-preview.16" />
<PackageReference Include="Microsoft.DotNet.Interactive" Version="1.0.0-beta.23611.1" />
<PackageReference Include="Microsoft.DotNet.Interactive.Formatting" Version="1.0.0-beta.23611.1" />
<PackageReference Include="Plotly.NET" Version="6.0.0-preview.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -51,5 +51,4 @@
<PackagePath>interactive-extensions/dotnet</PackagePath>
</None>
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions Sources/Wrappers/AngouriMath.Interactive/KernelExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open System.Threading.Tasks
open PeterO.Numbers
open System
open Plotly.NET
open Plotly.NET.GenericChart
open type Plotly.NET.GenericChart
open AngouriMath.FSharp.Functions

type KernelExtension() =
Expand Down Expand Up @@ -43,8 +43,6 @@ type KernelExtension() =
Formatter.SetPreferredMimeTypesFor(typeof<GenericChart>, "text/html")
Formatter.Register<GenericChart> (toChartHTML, "text/html")



interface IKernelExtension with
member _.OnLoadAsync _ =
KernelExtension.applyMagic()
Expand Down
8 changes: 4 additions & 4 deletions Sources/Wrappers/AngouriMath.Interactive/Plot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ let private castAs<'a, 'b when 'a : not null> (a : 'a) : 'b =
let up : obj = a :> obj
up :?> 'b

let private withSliderND<'a, 'b> n (chartPlotter : 'a -> obj -> GenericChart.GenericChart) (ranges : 'a) (paramRange : double seq) (param : obj) (func : obj) =
let private withSliderND<'a, 'b> n (chartPlotter : 'a -> obj -> GenericChart) (ranges : 'a) (paramRange : double seq) (param : obj) (func : obj) =
let var = symbol param
let compiled =
match n with
Expand All @@ -210,7 +210,7 @@ let private withSliderND<'a, 'b> n (chartPlotter : 'a -> obj -> GenericChart.Gen
|> Seq.map (fun step ->
let newFunc = compiled step
chartPlotter ranges newFunc
|> Chart.withTraceName(Visible = if step = Seq.head paramRange then StyleParam.Visible.True else StyleParam.Visible.False)
|> Chart.withTraceInfo(Visible = if step = Seq.head paramRange then StyleParam.Visible.True else StyleParam.Visible.False)
)
|> GenericChart.combine
let slider = getSlider paramRange
Expand All @@ -219,10 +219,10 @@ let private withSliderND<'a, 'b> n (chartPlotter : 'a -> obj -> GenericChart.Gen
|> Chart.withSlider slider
|> withTransparency

let withSlider2D (chartPlotter : double seq -> obj -> GenericChart.GenericChart) (range : double seq) (paramRange : double seq) (param : obj) (func : obj) =
let withSlider2D (chartPlotter : double seq -> obj -> GenericChart) (range : double seq) (paramRange : double seq) (param : obj) (func : obj) =
withSliderND<double seq, double> 1 chartPlotter range paramRange param func

let withSlider3D (chartPlotter : double seq -> double seq -> obj -> GenericChart.GenericChart) (range1 : double seq) (range2 : double seq) (paramRange : double seq) (param : obj) (func : obj) =
let withSlider3D (chartPlotter : double seq -> double seq -> obj -> GenericChart) (range1 : double seq) (range2 : double seq) (paramRange : double seq) (param : obj) (func : obj) =
withSliderND<double seq * double seq, (double * double)> 2 (fun (r1, r2) f -> chartPlotter r1 r2 f) (range1, range2) paramRange param func

let linear (range : double seq) (func : obj) =
Expand Down
Loading