Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/TensorFlowNET.UnitTest/Basics/VariableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public void SliceAssign()
Assert.AreEqual(nd[2], x[2].numpy());
}

[TestMethod, Ignore]
public void TypeMismatchedSliceAssign()
{
NDArray intNd = new int[]
{
1, -2, 3
};
NDArray doubleNd = new double[]
{
-5, 6, -7
};
var x = tf.Variable(doubleNd);

var slice = x[":"];
Assert.ThrowsException<System.Exception>(
Copy link
Member

@Esther2013 Esther2013 Dec 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more clear if changing to ExpectedExceptionAttribute like below:

[TestMethod, Ignore]
[ExpectedException(typeof(System.Exception), "A userId of null was inappropriately allowed.")]
public void NullUserIdInConstructor()
{
   slice.assign(intNd);
}

// this statement exit without throwing any exception but the "test execution summary" seems not able to detect that.
() => slice.assign(intNd)
);
}

[TestMethod]
public void Accumulation()
{
Expand Down
12 changes: 11 additions & 1 deletion test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ namespace TensorFlowNET.UnitTest.ManagedAPI
[TestClass]
public class TensorOperate
{
[TestMethod]
[TestMethod, Ignore]
public void TransposeTest()
{
// https://www.tensorflow.org/api_docs/python/tf/transpose#for_example_2
var x = tf.constant(new int[,] {
{ 1, 2, 3 },
{ 4, 5, 6 }
});
var transpose_x = tf.transpose(x);
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 1, 4 }, transpose_x[0].numpy().ToArray<int>()));
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 2, 5 }, transpose_x[1].numpy().ToArray<int>()));
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 3, 6 }, transpose_x[2].numpy().ToArray<int>()));

var a = tf.constant(np.array(new[, , ,] { { { { 1, 11, 2, 22 } }, { { 3, 33, 4, 44 } } },
{ { { 5, 55, 6, 66 } }, { { 7, 77, 8, 88 } } } }));
var b = tf.transpose(a, new[] { 3, 1, 2, 0 });
Expand Down