Skip to content

Commit e17fc65

Browse files
committed
fixes from pr comments
1 parent 75a4405 commit e17fc65

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

test/Microsoft.ML.Core.Tests/UnitTests/TestResourceDownload.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
using Xunit;
1515
using Xunit.Abstractions;
1616

17-
//[assembly: CollectionBehavior(DisableTestParallelization = true)]
18-
1917
namespace Microsoft.ML.Core.Tests.UnitTests
2018
{
2119
public class TestResourceDownload : BaseTestBaseline

test/Microsoft.ML.Tests/DatabaseLoaderTests.cs

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -227,54 +227,41 @@ public void IrisSdcaMaximumEntropy()
227227
[X86X64FactAttribute("The SQLite un-managed code, SQLite.interop, only supports x86/x64 architectures.")]
228228
public void TestLoadDatetimeColumnWithNullValue()
229229
{
230-
try
230+
var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared";
231+
using (var connection = new SQLiteConnection(connectionString))
231232
{
232-
var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared";
233-
using (var connection = new SQLiteConnection(connectionString))
233+
connection.Open();
234+
using (var command = new SQLiteCommand(connection))
234235
{
235-
connection.Open();
236-
using (var command = new SQLiteCommand(connection))
237-
{
238-
command.CommandText = """
236+
// Make sure the table doesn't exist.
237+
command.CommandText = """
239238
BEGIN;
240-
CREATE TABLE IF NOT EXISTS Datetime (datetime Datetime NULL);
241-
INSERT INTO Datetime VALUES (NULL);
242-
INSERT INTO Datetime VALUES ('2018-01-01 00:00:00');
239+
DROP TABLE IF EXISTS Datetime;
243240
COMMIT;
244241
""";
245-
command.ExecuteNonQuery();
246-
}
247-
}
248-
var mlContext = new MLContext(seed: 1);
249-
var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0));
250-
var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime");
251-
var data = loader.Load(source);
252-
var datetimes = data.GetColumn<DateTime>("datetime").ToArray();
253-
datetimes.Count().Should().Be(2);
254-
255-
// Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00
256-
// This is the default behavior of TextLoader as well.
257-
datetimes[0].Should().Be(DateTime.MinValue);
258-
datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0));
259-
}
260-
finally
261-
{
262-
//Clean up in memory db if anything happens
263-
var connectionString = "DataSource=Dummy;Mode=Memory;Version=3;Timeout=120;Cache=Shared";
264-
using (var connection = new SQLiteConnection(connectionString))
265-
{
266-
connection.Open();
267-
using (var command = new SQLiteCommand(connection))
268-
{
269-
command.CommandText = """
242+
command.ExecuteNonQuery();
243+
244+
command.CommandText = """
270245
BEGIN;
271-
DROP TABLE IF EXISTS Datetime;
246+
CREATE TABLE IF NOT EXISTS Datetime (datetime Datetime NULL);
247+
INSERT INTO Datetime VALUES (NULL);
248+
INSERT INTO Datetime VALUES ('2018-01-01 00:00:00');
272249
COMMIT;
273250
""";
274-
command.ExecuteNonQuery();
275-
}
251+
command.ExecuteNonQuery();
276252
}
277253
}
254+
var mlContext = new MLContext(seed: 1);
255+
var loader = mlContext.Data.CreateDatabaseLoader(new DatabaseLoader.Column("datetime", DbType.DateTime, 0));
256+
var source = new DatabaseSource(SQLiteFactory.Instance, connectionString, "SELECT datetime FROM Datetime");
257+
var data = loader.Load(source);
258+
var datetimes = data.GetColumn<DateTime>("datetime").ToArray();
259+
datetimes.Count().Should().Be(2);
260+
261+
// Convert null value to DateTime.MinValue, aka 0001-01-01 00:00:00
262+
// This is the default behavior of TextLoader as well.
263+
datetimes[0].Should().Be(DateTime.MinValue);
264+
datetimes[1].Should().Be(new DateTime(2018, 1, 1, 0, 0, 0));
278265
}
279266

280267
/// <summary>

test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<StrongNameKeyId>Test</StrongNameKeyId>
55
<NoWarn>$(NoWarn)</NoWarn>
66

7-
<!-- Remove once we have resolved the TorchSharp issue. -->
8-
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
97
</PropertyGroup>
108

119
<!-- Import the test signing certificate -->

0 commit comments

Comments
 (0)