diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 0ffffa0c17..bb6b11e453 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - The method `GetStepCount()` on the Agent class has been replaced with the property getter `StepCount` - `RayPerceptionSensorComponent` and related classes now display the debug gizmos whenever the Agent is selected (not just Play mode). - Most fields on `RayPerceptionSensorComponent` can now be changed while the editor is in Play mode. The exceptions to this are fields that affect the number of observations. + - Unused static methods from the `Utilities` class (ShiftLeft, ReplaceRange, AddRangeNoAlloc, and GetSensorFloatObservationSize) were removed. ### Bugfixes - Fixed an issue which caused self-play training sessions to consume a lot of memory. (#3451) diff --git a/com.unity.ml-agents/Runtime/Utilities.cs b/com.unity.ml-agents/Runtime/Utilities.cs index 4bc78d8919..661607affb 100644 --- a/com.unity.ml-agents/Runtime/Utilities.cs +++ b/com.unity.ml-agents/Runtime/Utilities.cs @@ -1,6 +1,5 @@ using System; using UnityEngine; -using System.Collections.Generic; namespace MLAgents { @@ -20,7 +19,7 @@ internal static class Utilities /// being stored in the tensor. /// /// The number of floats written - public static int TextureToTensorProxy( + internal static int TextureToTensorProxy( Texture2D texture, WriteAdapter adapter, bool grayScale) @@ -63,7 +62,7 @@ public static int TextureToTensorProxy( /// Input array whose elements will be cumulatively added /// /// The cumulative sum of the input array. - public static int[] CumSum(int[] input) + internal static int[] CumSum(int[] input) { var runningSum = 0; var result = new int[input.Length + 1]; @@ -75,83 +74,6 @@ public static int[] CumSum(int[] input) return result; } - /// - /// Shifts list elements to the left by the specified amount (in-place). - /// - /// List whose elements will be shifted - /// - /// - /// Amount to shift the elements to the left by - /// - /// - public static void ShiftLeft(List list, int shiftAmount) - { - for (var i = shiftAmount; i < list.Count; i++) - { - list[i - shiftAmount] = list[i]; - } - } - - /// - /// Replaces target list elements with source list elements starting at specified position - /// in target list. - /// - /// Target list, where the elements are added to - /// - /// - /// Source array, where the elements are copied from - /// - /// - /// Starting position in target list to copy elements to - /// - /// - public static void ReplaceRange(List dst, List src, int start) - { - for (var i = 0; i < src.Count; i++) - { - dst[i + start] = src[i]; - } - } - - /// - /// Adds elements to list without extra temp allocations (assuming it fits pre-allocated - /// capacity of the list). The built-in List/.AddRange() unfortunately allocates - /// a temporary list to add items (even if the original array has sufficient capacity): - /// https://stackoverflow.com/questions/2123161/listt-addrange-implementation-suboptimal - /// Note: this implementation might be slow with a large source array. - /// - /// Target list, where the elements are added to - /// - /// - /// Source array, where the elements are copied from - /// - /// - // ReSharper disable once ParameterTypeCanBeEnumerable.Global - public static void AddRangeNoAlloc(List dst, T[] src) - { - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var item in src) - { - dst.Add(item); - } - } - - /// - /// Calculates the number of uncompressed floats in a list of ISensor - /// - public static int GetSensorFloatObservationSize(this List sensors) - { - int numFloatObservations = 0; - for (var i = 0; i < sensors.Count; i++) - { - if (sensors[i].GetCompressionType() == SensorCompressionType.None) - { - numFloatObservations += sensors[i].ObservationSize(); - } - } - return numFloatObservations; - } - #if DEBUG internal static void DebugCheckNanAndInfinity(float value, string valueCategory, string caller) {