using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Text; using Tensorflow; using Tensorflow.NumPy; namespace TensorFlowNET.UnitTest.NumPy { /// /// https://numpy.org/doc/stable/user/basics.indexing.html /// [TestClass] public class ArraySortingTest : EagerModeTestBase { /// /// https://numpy.org/doc/stable/reference/generated/numpy.argsort.html /// [TestMethod] public void argsort() { var x = np.array(new[] { 3, 1, 2 }); var ind = np.argsort(x); Assert.AreEqual(ind, new[] { 1, 2, 0 }); var y = np.array(new[,] { { 0, 3 }, { 2, 2 } }); ind = np.argsort(y, axis: 0); Assert.AreEqual(ind[0], new[] { 0, 1 }); Assert.AreEqual(ind[1], new[] { 1, 0 }); } /// /// https://numpy.org/doc/stable/reference/generated/numpy.sort.html /// [TestMethod] public void sort() { var x = np.array(new int[] { 3, 1, 2 }); var sorted = np.sort(x); // Assert.IsTrue(sorted.ToArray() is [1, 2, 3]); } } }