-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPyFloat.cs
42 lines (38 loc) · 1.06 KB
/
PyFloat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.ComponentModel;
using System.Reactive.Linq;
using Pythonnet = Python.Runtime;
using System.Linq;
namespace Bonsai.Scripting.Python
{
/// <summary>
/// Represents the creation of a float python data type.
/// </summary>
[Combinator]
[WorkflowElementCategory(ElementCategory.Source)]
public class PyFloat
{
[Description("The value of the float.")]
public double Value { get; set; }
public IObservable<Pythonnet.PyFloat> Process()
{
return Observable.Defer(() =>
{
using (Pythonnet.Py.GIL())
{
return Observable.Return(new Pythonnet.PyFloat(Value));
}
});
}
public IObservable<Pythonnet.PyFloat> Process<TSource>(IObservable<TSource> source)
{
return source.Select(obj =>
{
using (Pythonnet.Py.GIL())
{
return new Pythonnet.PyFloat(Value);
}
});
}
}
}