Skip to content

Commit 7e0959d

Browse files
authored
Merge pull request #7 from bonsai-rx/package-metadata
Add README file to package metadata
2 parents fe810f3 + eb540b4 commit 7e0959d

9 files changed

+135
-45
lines changed

src/Bonsai.ML.LinearDynamicalSystems/CreateModelReference.cs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
using System.ComponentModel;
1+
using System.ComponentModel;
22
using System;
33
using System.Reactive.Linq;
44

55
namespace Bonsai.ML.LinearDynamicalSystems
66
{
77
/// <summary>
8-
/// Provides a Bonsai.ML model with a name that can be referenced
8+
/// Represents an operator that creates a reference for a named model.
99
/// </summary>
10-
[Description("Name of a Bonsai.ML model")]
11-
[Combinator()]
10+
[Combinator]
11+
[Description("Creates a reference for a named model.")]
1212
[WorkflowElementCategory(ElementCategory.Source)]
1313
public class CreateModelReference : INamedElement
1414
{
15-
1615
/// <summary>
17-
/// The name of the model
16+
/// Gets or sets the name of the model to reference.
1817
/// </summary>
19-
[Description("Name of the model")]
18+
[Description("The name of the model to reference.")]
2019
public string Name { get ; set; }
2120

21+
/// <summary>
22+
/// Generates an observable sequence that contains the model reference object.
23+
/// </summary>
24+
/// <returns>
25+
/// A sequence containing a single instance of the <see cref="ModelReference"/>
26+
/// class.
27+
/// </returns>
2228
public IObservable<ModelReference> Process()
2329
{
2430
return Observable.Defer(() => Observable.Return(new ModelReference(Name)));

src/Bonsai.ML.LinearDynamicalSystems/DeserializeFromJson.cs

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Reactive.Linq;
44
using Bonsai.Expressions;
5+
using Bonsai.ML.LinearDynamicalSystems.Kinematics;
56
using System.Xml.Serialization;
67
using System.Collections.Generic;
78
using System.Linq.Expressions;
@@ -13,24 +14,32 @@ namespace Bonsai.ML.LinearDynamicalSystems
1314
/// <summary>
1415
/// Deserializes a sequence of JSON strings into data model objects.
1516
/// </summary>
16-
[DefaultProperty("Type")]
17+
[DefaultProperty(nameof(Type))]
1718
[WorkflowElementCategory(ElementCategory.Transform)]
18-
[XmlInclude(typeof(TypeMapping<Kinematics.KFModelParameters>))]
19-
[XmlInclude(typeof(TypeMapping<Kinematics.Observation2D>))]
19+
[XmlInclude(typeof(TypeMapping<KFModelParameters>))]
20+
[XmlInclude(typeof(TypeMapping<Observation2D>))]
2021
[XmlInclude(typeof(TypeMapping<State>))]
2122
[XmlInclude(typeof(TypeMapping<StateComponent>))]
22-
[XmlInclude(typeof(TypeMapping<Kinematics.KinematicState>))]
23-
[XmlInclude(typeof(TypeMapping<Kinematics.KinematicComponent>))]
23+
[XmlInclude(typeof(TypeMapping<KinematicState>))]
24+
[XmlInclude(typeof(TypeMapping<KinematicComponent>))]
2425
[Description("Deserializes a sequence of JSON strings into data model objects.")]
2526
public partial class DeserializeFromJson : SingleArgumentExpressionBuilder
2627
{
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="DeserializeFromJson"/> class.
30+
/// </summary>
2731
public DeserializeFromJson()
2832
{
29-
Type = new TypeMapping<Kinematics.KFModelParameters>();
33+
Type = new TypeMapping<KFModelParameters>();
3034
}
3135

36+
/// <summary>
37+
/// Gets or sets the type of the object to deserialize.
38+
/// </summary>
39+
[Description("The type of the object to deserialize.")]
3240
public TypeMapping Type { get; set; }
3341

42+
/// <inheritdoc/>
3443
public override Expression Build(IEnumerable<Expression> arguments)
3544
{
3645
TypeMapping typeMapping = Type;

src/Bonsai.ML.LinearDynamicalSystems/Kinematics/KFModelParameters.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Bonsai.ML.LinearDynamicalSystems.Kinematics
1010
/// <summary>
1111
/// Model parameters for a Kalman Filter Kinematics python class
1212
/// </summary>
13-
[Description("Model parameters for a Kalman Filter Kinematics (KFK) model")]
14-
[Combinator()]
13+
[Combinator]
1514
[WorkflowElementCategory(ElementCategory.Source)]
15+
[Description("Model parameters for a Kalman Filter Kinematics (KFK) model")]
1616
public class KFModelParameters
1717
{
1818

@@ -247,6 +247,9 @@ public int Fps
247247
}
248248
}
249249

250+
/// <summary>
251+
/// Initializes a new instance of the <see cref="KFModelParameters"/> class.
252+
/// </summary>
250253
public KFModelParameters ()
251254
{
252255
Sigma_a = 10000;
@@ -332,10 +335,10 @@ public IObservable<KFModelParameters> Process<TSource>(IObservable<TSource> sour
332335
Fps = _fps
333336
});
334337
}
335-
338+
339+
/// <inheritdoc/>
336340
public override string ToString()
337341
{
338-
339342
return $"pos_x0={pos_x0String},pos_y0={pos_y0String},vel_x0={vel_x0String},vel_y0={vel_y0String},acc_x0={acc_x0String},acc_y0={acc_y0String},sigma_a={sigma_aString},sigma_x={sigma_xString},sigma_y={sigma_yString},sqrt_diag_V0_value={sqrt_diag_V0_valueString},fps={fpsString}";
340343
}
341344
}

src/Bonsai.ML.LinearDynamicalSystems/Kinematics/Observation2D.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public IObservable<Observation2D> Process<TSource>(IObservable<TSource> source)
8181
});
8282
}
8383

84+
/// <inheritdoc/>
8485
public override string ToString()
8586
{
86-
8787
return $"x={xString},y={yString}";
8888
}
8989
}

src/Bonsai.ML.LinearDynamicalSystems/ModelReference.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel;
1+
using System.ComponentModel;
22

33
namespace Bonsai.ML.LinearDynamicalSystems
44
{
@@ -9,11 +9,15 @@ namespace Bonsai.ML.LinearDynamicalSystems
99
public class ModelReference
1010
{
1111
/// <summary>
12-
/// The name of the model
12+
/// Gets or sets the name of the referenced model.
1313
/// </summary>
14-
[Description("Name of the model")]
1514
public string Name { get ; set; }
1615

16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="ModelReference"/> class
18+
/// with the specified name.
19+
/// </summary>
20+
/// <param name="name">The name of the referenced model.</param>
1721
public ModelReference(string name)
1822
{
1923
Name = name;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System;
22
using System.ComponentModel;
33
using System.Reactive.Linq;
4+
using Bonsai.ML.LinearDynamicalSystems.Kinematics;
45
using Newtonsoft.Json;
56

67
namespace Bonsai.ML.LinearDynamicalSystems
78
{
89
/// <summary>
910
/// Serializes a sequence of data model objects into JSON strings.
1011
/// </summary>
11-
[Combinator()]
12+
[Combinator]
1213
[WorkflowElementCategory(ElementCategory.Transform)]
1314
[Description("Serializes a sequence of data model objects into JSON strings.")]
1415
public class SerializeToJson
@@ -18,34 +19,100 @@ private IObservable<string> Process<T>(IObservable<T> source)
1819
return source.Select(value => JsonConvert.SerializeObject(value));
1920
}
2021

21-
public IObservable<string> Process(IObservable<Kinematics.KFModelParameters> source)
22+
/// <summary>
23+
/// Serializes each <see cref="KFModelParameters"/> object in the sequence to
24+
/// a JSON string.
25+
/// </summary>
26+
/// <param name="source">
27+
/// A sequence of <see cref="KFModelParameters"/> objects.
28+
/// </param>
29+
/// <returns>
30+
/// A sequence of JSON strings representing the corresponding
31+
/// <see cref="KFModelParameters"/> object.
32+
/// </returns>
33+
public IObservable<string> Process(IObservable<KFModelParameters> source)
2234
{
23-
return Process<Kinematics.KFModelParameters>(source);
35+
return Process<KFModelParameters>(source);
2436
}
2537

26-
public IObservable<string> Process(IObservable<Kinematics.Observation2D> source)
38+
/// <summary>
39+
/// Serializes each <see cref="Observation2D"/> object in the sequence to
40+
/// a JSON string.
41+
/// </summary>
42+
/// <param name="source">
43+
/// A sequence of <see cref="Observation2D"/> objects.
44+
/// </param>
45+
/// <returns>
46+
/// A sequence of JSON strings representing the corresponding
47+
/// <see cref="Observation2D"/> object.
48+
/// </returns>
49+
public IObservable<string> Process(IObservable<Observation2D> source)
2750
{
28-
return Process<Kinematics.Observation2D>(source);
51+
return Process<Observation2D>(source);
2952
}
3053

54+
/// <summary>
55+
/// Serializes each <see cref="State"/> object in the sequence to
56+
/// a JSON string.
57+
/// </summary>
58+
/// <param name="source">
59+
/// A sequence of <see cref="State"/> objects.
60+
/// </param>
61+
/// <returns>
62+
/// A sequence of JSON strings representing the corresponding
63+
/// <see cref="State"/> object.
64+
/// </returns>
3165
public IObservable<string> Process(IObservable<State> source)
3266
{
3367
return Process<State>(source);
3468
}
3569

70+
/// <summary>
71+
/// Serializes each <see cref="StateComponent"/> object in the sequence to
72+
/// a JSON string.
73+
/// </summary>
74+
/// <param name="source">
75+
/// A sequence of <see cref="StateComponent"/> objects.
76+
/// </param>
77+
/// <returns>
78+
/// A sequence of JSON strings representing the corresponding
79+
/// <see cref="StateComponent"/> object.
80+
/// </returns>
3681
public IObservable<string> Process(IObservable<StateComponent> source)
3782
{
3883
return Process<StateComponent>(source);
3984
}
4085

41-
public IObservable<string> Process(IObservable<Kinematics.KinematicState> source)
86+
/// <summary>
87+
/// Serializes each <see cref="KinematicState"/> object in the sequence to
88+
/// a JSON string.
89+
/// </summary>
90+
/// <param name="source">
91+
/// A sequence of <see cref="KinematicState"/> objects.
92+
/// </param>
93+
/// <returns>
94+
/// A sequence of JSON strings representing the corresponding
95+
/// <see cref="KinematicState"/> object.
96+
/// </returns>
97+
public IObservable<string> Process(IObservable<KinematicState> source)
4298
{
43-
return Process<Kinematics.KinematicState>(source);
99+
return Process<KinematicState>(source);
44100
}
45101

46-
public IObservable<string> Process(IObservable<Kinematics.KinematicComponent> source)
102+
/// <summary>
103+
/// Serializes each <see cref="KinematicComponent"/> object in the sequence to
104+
/// a JSON string.
105+
/// </summary>
106+
/// <param name="source">
107+
/// A sequence of <see cref="KinematicComponent"/> objects.
108+
/// </param>
109+
/// <returns>
110+
/// A sequence of JSON strings representing the corresponding
111+
/// <see cref="KinematicComponent"/> object.
112+
/// </returns>
113+
public IObservable<string> Process(IObservable<KinematicComponent> source)
47114
{
48-
return Process<Kinematics.KinematicComponent>(source);
115+
return Process<KinematicComponent>(source);
49116
}
50117
}
51118
}

src/Bonsai.ML.Visualizers/KinematicComponentVisualizer.cs

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Windows.Forms;
33
using System.Collections.Generic;
44
using System.Reflection;
@@ -14,6 +14,9 @@
1414

1515
namespace Bonsai.ML.Visualizers
1616
{
17+
/// <summary>
18+
/// Provides a type visualizer to display the state components of a Kalman Filter kinematics model.
19+
/// </summary>
1720
public class KinematicComponentVisualizer : BufferedVisualizer
1821
{
1922

@@ -25,15 +28,6 @@ public class KinematicComponentVisualizer : BufferedVisualizer
2528

2629
private TimeSeriesOxyPlotBase Plot;
2730

28-
/// <summary>
29-
/// Constructs a KinematicComponentVisualizer object.
30-
/// </summary>
31-
public KinematicComponentVisualizer ()
32-
{
33-
Capacity = 10;
34-
Size = new Size(320, 240);
35-
}
36-
3731
/// <summary>
3832
/// The selected index of the state component to be visualized
3933
/// </summary>
@@ -42,13 +36,14 @@ public KinematicComponentVisualizer ()
4236
/// <summary>
4337
/// Size of the window when loaded
4438
/// </summary>
45-
public Size Size { get; set; }
39+
public Size Size { get; set; } = new Size(320, 240);
4640

4741
/// <summary>
4842
/// Capacity or length of time shown along the x axis of the plot during automatic updating
4943
/// </summary>
50-
public int Capacity { get; set; }
44+
public int Capacity { get; set; } = 10;
5145

46+
/// <inheritdoc/>
5247
public override void Load(IServiceProvider provider)
5348
{
5449
var stateComponents = GetStateComponents();
@@ -78,10 +73,12 @@ public override void Load(IServiceProvider provider)
7873
}
7974
}
8075

76+
/// <inheritdoc/>
8177
public override void Show(object value)
8278
{
8379
}
8480

81+
/// <inheritdoc/>
8582
protected override void Show(DateTime time, object value)
8683
{
8784
if (!_startTime.HasValue)
@@ -111,6 +108,7 @@ protected override void Show(DateTime time, object value)
111108

112109
}
113110

111+
/// <inheritdoc/>
114112
protected override void ShowBuffer(IList<Timestamped<object>> values)
115113
{
116114
base.ShowBuffer(values);
@@ -138,6 +136,7 @@ private List<string> GetStateComponents()
138136
return stateComponents;
139137
}
140138

139+
/// <inheritdoc/>
141140
public override void Unload()
142141
{
143142
_startTime = null;
@@ -161,4 +160,4 @@ private void ComponentChanged(object sender, EventArgs e)
161160
Plot.ResetSeries();
162161
}
163162
}
164-
}
163+
}

src/Bonsai.ML.Visualizers/TimeSeriesOxyPlotBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Windows.Forms;
1+
using System.Windows.Forms;
22
using OxyPlot;
33
using OxyPlot.Series;
44
using OxyPlot.WindowsForms;
@@ -9,7 +9,7 @@
99

1010
namespace Bonsai.ML.Visualizers
1111
{
12-
public class TimeSeriesOxyPlotBase : UserControl
12+
internal class TimeSeriesOxyPlotBase : UserControl
1313
{
1414
private PlotView view;
1515
private PlotModel model;

src/Directory.Build.props

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageOutputPath>..\bin\$(Configuration)</PackageOutputPath>
1010
<PackageProjectUrl>https://bonsai-rx.org/machinelearning</PackageProjectUrl>
1111
<RepositoryUrl>https://github.com/bonsai-rx/machinelearning.git</RepositoryUrl>
12+
<PackageReadmeFile>README.md</PackageReadmeFile>
1213
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1314
<PackageIcon>icon.png</PackageIcon>
1415
<IncludeSymbols>true</IncludeSymbols>
@@ -20,5 +21,6 @@
2021
<ItemGroup>
2122
<Content Include="..\..\LICENSE" PackagePath="/" />
2223
<Content Include="..\..\icon.png" PackagePath="/" />
24+
<None Include="..\..\README.md" Pack="True" PackagePath="/" />
2325
</ItemGroup>
2426
</Project>

0 commit comments

Comments
 (0)