Skip to content

Latest commit

 

History

History
84 lines (65 loc) · 2.79 KB

File metadata and controls

84 lines (65 loc) · 2.79 KB

SearchAThing.Sci.Examples

Examples for SearchAThing.Sci

Build

  • nuget feeds
    • searchathing :https://www.myget.org/F/searchathing-old1/api/v3/index.json
    • imagesharp : https://www.myget.org/F/imagesharp/api/v3/index.json
  • pre-release package : SearchAThing.Sci

Unit Tests

Unit Tests are a good source for misc samples.

Convex Hull 2D

By using great LoycCore library

  • Example08 : create some random point island and compute quick (dummy) hull img

  • Example03 : create a mesh2d given some input points img

Circle tan to 2 line and 1 pt

PythonWrapper

  • Example04 : invoke python using PythonWrapper helper Follow code
static void Main(string[] args)
{
    const string python_imports = @"
import numpy as np
";

    var sb = new StringBuilder();
    sb.AppendLine("print(np.mgrid[0:5,0:5])");

    var python = new PythonPipe(python_imports);

    var res = python.Exec(sb.ToStringWrapper());

    Console.WriteLine($"Execution of [{sb}] result in follow\r\n{res}");

    python.Dispose();
}

produces this output:

Execution of [import numpy as np
np.mgrid[0:5,0:5]] result in follow
array([[[0, 0, 0, 0, 0],
        [1, 1, 1, 1, 1],
        [2, 2, 2, 2, 2],
        [3, 3, 3, 3, 3],
        [4, 4, 4, 4, 4]],

       [[0, 1, 2, 3, 4],
        [0, 1, 2, 3, 4],
        [0, 1, 2, 3, 4],
        [0, 1, 2, 3, 4],
        [0, 1, 2, 3, 4]]])

Python interpreter can be instantiated one time and used at runtime through a pipe resulting in an acceptable responsiveness despite the fact its a process redirection instead of an expected tight integration with the .NET. A recycle method allow you to restart the process if you consider its internal memory growth too much. Follow test results on speed:

First execution 00:00:00.5451368
Second execution 00:00:00.0486802

Discrete space

  • Example05 : create a sample space and query for items in it img img img

Measure Unit

  • Example01 : create a sci project with two measure object inside it and serialize then read back from deserialized data. Here measure serialized contains value and measure unit. Use this type of solution if want to keep track of the measure unit ( eg. user interface )
  • Example02 : create a sci project with two measure object as double thus using a measure unit domain. Use this type of solution if want minimize file size ( eg. many data )