Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor LDS Package #25

Merged
merged 13 commits into from
Sep 23, 2024
Merged
5 changes: 4 additions & 1 deletion src/Bonsai.ML.Design/MultidimensionalArrayVisualizer.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Windows.Forms;
using Bonsai;
using Bonsai.Design;

[assembly: TypeVisualizer(typeof(Bonsai.ML.Design.MultidimensionalArrayVisualizer),
Target = typeof(double[,]))]

namespace Bonsai.ML.Design
{
/// <summary>
/// Provides a type visualizer to display multi dimensional array data as a heatmap.
/// </summary>
[TypeVisualizer(typeof(MultidimensionalArrayVisualizer), Target = typeof(double[,]))]
public class MultidimensionalArrayVisualizer : DialogTypeVisualizer
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bonsai.Core" Version="2.8.1" />
<PackageReference Include="Bonsai.Scripting.Expressions" Version="2.8.0" />
<PackageReference Include="Bonsai.Scripting.Python" Version="0.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<PackageTags>Bonsai Rx ML KalmanFilter LinearDynamicalSystems</PackageTags>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bonsai.Core" Version="2.8.1" />
<PackageReference Include="Bonsai.Scripting.Python" Version="0.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="*.py" />
<EmbeddedResource Include="**\*.bonsai" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bonsai.ML\Bonsai.ML.csproj" />
<ProjectReference Include="..\Bonsai.ML.Python\Bonsai.ML.Python.csproj" />
<ProjectReference Include="..\Bonsai.ML.Data\Bonsai.ML.Data.csproj" />
</ItemGroup>
</Project>
33 changes: 0 additions & 33 deletions src/Bonsai.ML.LinearDynamicalSystems/CreateModelReference.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
Expand All @@ -12,9 +12,7 @@
<Property Name="Name" Category="ModelReference" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:CreateModelReference">
<p1:Name>model</p1:Name>
</Combinator>
<Combinator xsi:type="p1:CreateModelReference" />
</Expression>
<Expression xsi:type="rx:BehaviorSubject">
<Name>model</Name>
Expand Down
3 changes: 1 addition & 2 deletions src/Bonsai.ML.LinearDynamicalSystems/Kinematics/Forecast.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using System.ComponentModel;
using Newtonsoft.Json;
using Python.Runtime;
using System.Collections.Generic;
using Bonsai.ML.Python;

namespace Bonsai.ML.LinearDynamicalSystems.Kinematics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reactive.Linq;
using Python.Runtime;
using Newtonsoft.Json;
using Bonsai.ML.Python;

namespace Bonsai.ML.LinearDynamicalSystems.Kinematics
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns="https://bonsai-rx.org/2018/workflow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p3="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
Expand Down Expand Up @@ -127,10 +128,10 @@
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:State" />
<Combinator xsi:type="p2:State" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p2:KinematicState" />
<Combinator xsi:type="p3:KinematicState" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems.LinearRegression;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p2="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns="https://bonsai-rx.org/2018/workflow">
Expand Down Expand Up @@ -31,9 +31,7 @@
<Property Name="Name" Category="ModelReference" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p2:CreateModelReference">
<p2:Name>model</p2:Name>
</Combinator>
<Combinator xsi:type="p2:CreateModelReference" />
</Expression>
<Expression xsi:type="rx:BehaviorSubject">
<Name>model</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<WorkflowBuilder Version="2.8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.LinearRegression;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns="https://bonsai-rx.org/2018/workflow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reactive.Linq;
using Newtonsoft.Json;
using Python.Runtime;
using Bonsai.ML.Python;

namespace Bonsai.ML.LinearDynamicalSystems.LinearRegression
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Reactive.Linq;
using Bonsai.ML.Python;
using Python.Runtime;
using System.Xml.Serialization;

Expand Down Expand Up @@ -105,7 +106,7 @@ public int NumFeatures
set
{
_x = value;
_xString = _x == null ? "None" : NumpyHelper.NumpyParser.ParseArray(_x);
_xString = _x == null ? "None" : StringFormatter.FormatToPython(_x);
}
}

Expand All @@ -125,7 +126,7 @@ public int NumFeatures
set
{
_p = value;
_pString = _p == null ? "None" : NumpyHelper.NumpyParser.ParseArray(_p);
_pString = _p == null ? "None" : StringFormatter.FormatToPython(_p);
}
}

Expand Down Expand Up @@ -188,10 +189,10 @@ public IObservable<KFModelParameters> Process<TSource>(IObservable<TSource> sour
P = _p
});
}


/// <inheritdoc/>
public override string ToString()
{

return $"likelihood_precision_coef={_likelihood_precision_coefString}, prior_precision_coef={_prior_precision_coefString}, n_features={_n_featuresString}, x={_xString}, P={_pString}";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reactive.Linq;
using Python.Runtime;
using System.Xml.Serialization;
using Bonsai.ML.Python;

namespace Bonsai.ML.LinearDynamicalSystems.LinearRegression
{
Expand Down Expand Up @@ -35,7 +36,7 @@ public IObservable<MultivariatePDF> Process(IObservable<PyObject> source)
return Observable.Select(source, pyObject =>
{
var gridParameters = GridParameters.ConvertPyObject(pyObject);
var values = (double[,])pyObject.GetArrayAttribute("pdf_values");
var values = (double[,])pyObject.GetArrayAttr("pdf_values");
return new MultivariatePDF {
GridParameters = gridParameters,
Values = values
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1"
<WorkflowBuilder Version="2.8.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python"
xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
Expand Down Expand Up @@ -126,7 +127,7 @@
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:State" />
<Combinator xsi:type="p2:State" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
Expand Down
26 changes: 0 additions & 26 deletions src/Bonsai.ML.LinearDynamicalSystems/ModelReference.cs

This file was deleted.

Loading