Download com.unity.ml-agents.tests/Tests/Runtime/Sensor/SensorUtilTests.cs from ashish2244/ppo-SnowballTarget: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/com.unity.ml-agents.tests/Tests/Runtime/Sensor/SensorUtilTests.cs
- Command line
-
hf download hf://ashish2244/ppo-SnowballTarget/com.unity.ml-agents.tests/Tests/Runtime/Sensor/SensorUtilTests.cs
-
curl -L -o SensorUtilTests.cs https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/com.unity.ml-agents.tests/Tests/Runtime/Sensor/SensorUtilTests.cs
1.72 kB
| using System; | |
| using System.Collections.Generic; | |
| using System.Globalization; | |
| using NUnit.Framework; | |
| using Unity.MLAgents.Sensors; | |
| using Unity.MLAgents.Utils.Tests; | |
| namespace Unity.MLAgents.Tests | |
| { | |
| [] | |
| public class SensorUtilTests | |
| { | |
| internal class TempCulture : IDisposable | |
| { | |
| private CultureInfo m_OriginalCulture; | |
| internal TempCulture(CultureInfo newCulture) | |
| { | |
| m_OriginalCulture = CultureInfo.CurrentCulture; | |
| CultureInfo.CurrentCulture = newCulture; | |
| } | |
| public void Dispose() | |
| { | |
| CultureInfo.CurrentCulture = m_OriginalCulture; | |
| } | |
| } | |
| /// <summary> | |
| /// Test that sensors sort by name consistently across culture settings. | |
| /// Example strings and cultures taken from | |
| /// https://docs.microsoft.com/en-us/globalization/locale/sorting-and-string-comparison | |
| /// </summary> | |
| /// <param name="culture"></param> | |
| [] | |
| [] | |
| public void TestSortCulture(string culture) | |
| { | |
| List<ISensor> sensors = new List<ISensor>(); | |
| var sensor0 = new TestSensor("Apple"); | |
| var sensor1 = new TestSensor("Æble"); | |
| sensors.Add(sensor0); | |
| sensors.Add(sensor1); | |
| var originalCulture = CultureInfo.CurrentCulture; | |
| CultureInfo.CurrentCulture = new CultureInfo(culture); | |
| SensorUtils.SortSensors(sensors); | |
| CultureInfo.CurrentCulture = originalCulture; | |
| Assert.AreEqual(sensor1, sensors[0]); | |
| Assert.AreEqual(sensor0, sensors[1]); | |
| } | |
| } | |
| } | |