I have got an error message with the following code: (example code from sudipta mukherjee)
#load "./packages/FsPlot.0.6.6/FsPlotBootstrap.fsx"
open FsPlot.Highcharts.Charting
// Logistic Regression
let z = [for i in -10. .. 10. -> (i,1./(1.+exp -i))]
z
|> Chart.Spline
|> Chart.WithTitle "Sigmoid Function"
|> Chart.WithName "g(z)"
When I execute the code, I have got an error message in FSI:
Loading /eUSB/sync/fsharp/packages/FsPlot.0.6.6/FsPlotBootstrap.fsx]
namespace FSI_0008
System.ComponentModel.Win32Exception: ApplicationName='/eUSB/sync/fsharp/packages/FsPlot.0.6.6/./tools/chromedriver.exe',
CommandLine='--port=53810', CurrentDirectory='', Native error= Access denied
at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process p
rocess) <0x11eab6f10 + 0x006f3> in <filename unknown>:0
Stopped due to error
It seems the error is win32 related and FsPlot doesn't support OSX.
Please feel free to advise. What I should do to fix the error?
Migrated source code to XPlot (part of FsLab package), it is running smoothly.
#load "./packages/FsLab.1.0.2/FsLab.fsx"
open XPlot.GoogleCharts
// Logistic Regression
let z = [for i in -10. .. 10. -> (i,1./(1.+exp -i))]
let options =
Options
( title = "Sigmoid Function", curveType = "function",
legend = Legend(position = "bottom") )
[z]
|> Chart.Line
|> Chart.WithOptions options
|> Chart.WithLabels ["g(z)"]
Related
I am getting this error when running a correlation matrix with the R package ggstatsplo
ggcorrmat(data = d, type = "nonparametric", p.adjust.method = "hochberg",pch = "")
Error: 'data_to_numeric' is not an exported object from 'namespace:datawizard'
Somebody could help me.
I expected to have the script to run normally as I have used it before (around July) without any errors.
Is there anything that has changed about the ggstatsplot package?
I am testing out making a UWP app using the Fabulous framework for writing functional cross-platform apps, and I want to use a FilePicker on a button press and use the selected file for some data processing.
Executing
let fileResult = FilePicker.PickAsync() |> Async.AwaitTask opens the file picker and returns a Async<FileResult> after a file is picked (This to say that the button and subsequent function call executes), but the rest of the code following it will execute before the result can be used. If I append |> Async.RunSynchronously it (as expected) blocks the thread and no file can be chosen in the window that appears, although the return value would be the FileResult.
After looking into how this should be done, I realise that the file picker should be opened on the main thread, which leads me to a solution on the following form
let getFileResultAsync =
async {
let tcs = new TaskCompletionSource<FileResult>()
Device.BeginInvokeOnMainThread(fun () ->
async {
let! fileResult = FilePicker.PickAsync() |> Async.AwaitTask
tcs.SetResult(fileResult)
}
|> Async.StartImmediate
)
return! tcs.Task |> Async.AwaitTask
}
which will return Async<FileResult>, but it appears that the Device.BeginInvokeOnMainThread block is never accessed. How would I go about opening the FilePicker, selecting a file and then subsequently process the file in such an app?
I figured out a way to do what I wanted by further looking into the test example and the Fabulous documentation for Updates and messages https://fsprojects.github.io/Fabulous/Fabulous.XamarinForms/update.html.
Basing it off of the standard app that is generated when creating a new Fabulous project, just have a given string in the model for e.g. the file path (I've called it FilePath) for now, and add three additional messages to type Msg as follows
type Msg =
...
| SelectFile
| PresentFile of FileResult
| ErrorFileNotSelected
where the first is sent whenever the button for selecting a file is pressed, the second is sent with the file upon selected and the third is for if a user exits out of the file dialogue without selecting a file.
You need a function to select the file asynchronously
let selectFileAsync =
async {
let! result = FilePicker.PickAsync() |> Async.AwaitTask
return result
}
and a Fabulous.Cmd which calls the above function and sends the message further in the program (probably a better way of explaining that)
let selectFileCmd = async {
let! file = selectFileAsync
match file with
| null -> return Some(ErrorFileNotSelected)
| _ -> return Some(PresentFile file)
}
and finally, add the three following patterns to the update, where selectFileCmd is called under SelectFile
let update msg model =
...
| SelectFile ->
{model with FilePath = "Selecting file"}, (Cmd.ofAsyncMsgOption selectFileCmd)
| PresentFile file ->
{model with FilePath = file.FullPath}, Cmd.none
| ErrorFileNotSelected ->
{model with FilePath = "Error. Must select a file"}, Cmd.none
I am not sure whether this is considered a good approach, but it seems better than utilising let mutable at least.
I installed the brand new Visual Studio 2017 and now I am seeing this warning in the Error List window:
Analyzer 'Microsoft.VisualStudio.FSharp.Editor.SimplifyNameDiagnosticAnalyzer' threw an exception of type 'System.Threading.Tasks.TaskCanceledException' with message 'A task was canceled.'.
The line of the error is 1.
The warning is generated even after I start a new project with only the following code:
let add x y = x + y
printfn "%i" (add 39999 500000)
[<EntryPoint>]
let main argv =
printfn "%A" argv
0 // return an integer exit code
The warning does not appear immediately after I run the code above. It takes a while to show on the screen.
Any ideas on what is happening?
I am using the Moq framework for unit testing and would like to be able to pass in Action for logging void methods.
let log = new Mock<ILog>()
let quot = <# fun (mock:ILog) -> mock.Info(It.IsAny<string>) #>
let expr = (quot.ToLinqExpression() :?> Expression<Action<ILog>>)
log.Verify(expr)
This code fails with the following error:
System.InvalidCastException : Unable to cast object of type
'System.Linq.Expressions.MethodCallExpressionN' to type
'System.Linq.Expressions.Expression1[System.Action1[log4net.ILog]]'.
I can print the type out using
printfn "%s" (quot.Type.ToString())
which outputs
Microsoft.FSharp.Core.FSharpFunc`2[log4net.ILog,Microsoft.FSharp.Core.Unit]
So, how can I create an Action?
LINQ Expressions are fully supported in F# 3, so you can now pass an Action to Moq as a lambda expression:
let mock = Mock<ILog>()
mock.Verify(fun (log:ILog) -> log.Info(It.IsAny<string>()))
Try:
let quot = <# new Action<_>(fun (mock:ILog) -> mock.Info(It.IsAny<string>)) #>
I was trying to work with Oracle Database from Haskell and have faced with such problem.
So, there is this code.
module Main where
import Database.HDBC
import Database.HDBC.ODBC
main :: IO ()
main = do
let connectionString = "Driver={Microsoft ODBC for Oracle};Server=127.0.0.1;Uid=valera;Pwd=2562525;"
let ioconn = connectODBC connectionString
conn <- ioconn
vals <- quickQuery conn "SELECT * FROM PERSONS_TEST" []
print vals
return ()
Pretty simple, huh? But that won't work. With this connection string the error is
*** Exception: SqlError {seState = "[\"HY090\"]", seNativeError = -1, seErrorMsg = "sqlGetInfo SQL_TXN_CAPABLE: [\"0: [Microsoft][ODBC driver for Oracle]\\65533...
and then 65333 repeats many times. And with this
Provider=msdaora;Data Source=127.0.0.1;User Id=valera;Password=2562525;
the error is
*** Exception: SqlError {seState = "[\"IM002\"]", seNativeError = -1, seErrorMsg = "connectODBC/sqlDriverConnect: [\"0: [Microsoft][\\65533...
and 65333 repeats again till the end
I suppose, that the problem is in connection string, but I had tried a whole bunch of them (I've used http://www.connectionstrings.com/)
I'm using Haskell Platform 2011.4.0.0, GHC 7.0.4, Oracle Database XE 11.2 on Windows 7 64-bit. Microsoft MDAC SDK installed.
\65533 and so on is the symbols of ODBC driver error message string in your locale (RU?). I find the best way so on to develop in english locale system, thus error messages in ghci console shown in english language and can be read.