Skip to content

Commit e4aaed8

Browse files
Merge pull request #66 from Martin-Molinero/bug-fix-collection-handling
Bug fix collection handling
2 parents 4ff3705 + 9b341b7 commit e4aaed8

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

src/embed_tests/QCTest.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Python.EmbeddingTest
99
{
1010
class QCTests
1111
{
12+
private static dynamic containsTest;
1213
private static dynamic module;
1314
private static string testModule = @"
1415
from clr import AddReference
@@ -22,13 +23,20 @@ def TestA(self):
2223
return True
2324
except:
2425
return False
26+
27+
def ContainsTest(key, collection):
28+
if key in collection.Keys:
29+
return True
30+
return False
2531
";
2632

2733
[OneTimeSetUp]
2834
public void Setup()
2935
{
3036
PythonEngine.Initialize();
31-
module = PyModule.FromString("module", testModule).GetAttr("PythonModule").Invoke();
37+
var pyModule = PyModule.FromString("module", testModule);
38+
containsTest = pyModule.GetAttr("ContainsTest");
39+
module = pyModule.GetAttr("PythonModule").Invoke();
3240
}
3341

3442
[OneTimeTearDown]
@@ -46,6 +54,14 @@ public void ParamTest()
4654
var output = (bool)module.TestA();
4755
Assert.IsTrue(output);
4856
}
57+
58+
[TestCase("AAPL", false)]
59+
[TestCase("SPY", true)]
60+
public void ContainsTest(string key, bool expected)
61+
{
62+
var dic = new Dictionary<string, object> { { "SPY", new object() } };
63+
Assert.AreEqual(expected, (bool)containsTest(key, dic));
64+
}
4965
}
5066

5167
public class Algo

src/perf_tests/Python.PerformanceTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
1515
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
16-
<PackageReference Include="quantconnect.pythonnet" Version="2.0.13" GeneratePathProperty="true">
16+
<PackageReference Include="quantconnect.pythonnet" Version="2.0.14" GeneratePathProperty="true">
1717
<IncludeAssets>compile</IncludeAssets>
1818
</PackageReference>
1919
</ItemGroup>
@@ -25,7 +25,7 @@
2525
</Target>
2626

2727
<Target Name="CopyBaseline" AfterTargets="Build">
28-
<Copy SourceFiles="$(NuGetPackageRoot)quantconnect.pythonnet\2.0.13\lib\net5.0\Python.Runtime.dll" DestinationFolder="$(OutDir)baseline" />
28+
<Copy SourceFiles="$(NuGetPackageRoot)quantconnect.pythonnet\2.0.14\lib\net5.0\Python.Runtime.dll" DestinationFolder="$(OutDir)baseline" />
2929
</Target>
3030

3131
<Target Name="CopyNewBuild" AfterTargets="Build">

src/runtime/InteropConfiguration.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public static InteropConfiguration MakeDefault()
2020
{
2121
PythonBaseTypeProviders =
2222
{
23-
DefaultBaseTypeProvider.Instance,
24-
new CollectionMixinsProvider(new Lazy<PyObject>(() => Py.Import("clr._extras.collections"))),
23+
DefaultBaseTypeProvider.Instance
24+
// see https://github.com/pythonnet/pythonnet/issues/1785
25+
// new CollectionMixinsProvider(new Lazy<PyObject>(() => Py.Import("clr._extras.collections"))),
2526
},
2627
};
2728
}

src/runtime/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
[assembly: InternalsVisibleTo("Python.EmbeddingTest, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]
55
[assembly: InternalsVisibleTo("Python.Test, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]
66

7-
[assembly: AssemblyVersion("2.0.13")]
8-
[assembly: AssemblyFileVersion("2.0.13")]
7+
[assembly: AssemblyVersion("2.0.14")]
8+
[assembly: AssemblyFileVersion("2.0.14")]

src/runtime/Python.Runtime.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<RootNamespace>Python.Runtime</RootNamespace>
66
<AssemblyName>Python.Runtime</AssemblyName>
77
<PackageId>QuantConnect.pythonnet</PackageId>
8-
<Version>2.0.13</Version>
8+
<Version>2.0.14</Version>
99
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1010
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1111
<RepositoryUrl>https://github.com/pythonnet/pythonnet</RepositoryUrl>

0 commit comments

Comments
 (0)