Skip to content

Commit 17ee61f

Browse files
Precommit fixes.
1 parent b4122df commit 17ee61f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+109
-109
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ repos:
135135
language: python
136136
entry: ./utils/generate_markdown_docs.py --package_dirs ml-agents-envs ml-agents
137137
pass_filenames: false
138-
additional_dependencies: [pyyaml, pydoc-markdown==3.10.1]
138+
additional_dependencies: [pyyaml==5.3, pydoc-markdown==3.10.1]

com.unity.ml-agents.extensions/Runtime/Sensors/PhysicsBodySensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void Update()
108108
}
109109

110110
/// <inheritdoc/>
111-
public void Reset() {}
111+
public void Reset() { }
112112

113113
/// <inheritdoc/>
114114
public CompressionSpec GetCompressionSpec()

com.unity.ml-agents.extensions/Runtime/Sensors/PoseExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ internal IList<DisplayNode> GetDisplayNodes()
387387

388388
while (stack.Count != 0)
389389
{
390-
var(current, depth) = stack.Pop();
390+
var (current, depth) = stack.Pop();
391391
var obj = GetObjectAt(current);
392392

393393
var node = new DisplayNode

com.unity.ml-agents/Runtime/Academy.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void EnableAutomaticStepping()
314314
// This try-catch is because DontDestroyOnLoad cannot be used in Editor Tests
315315
GameObject.DontDestroyOnLoad(m_StepperObject);
316316
}
317-
catch {}
317+
catch { }
318318
}
319319

320320
/// <summary>
@@ -501,13 +501,13 @@ out var unityRlInitParameters
501501

502502
void ResetActions()
503503
{
504-
DecideAction = () => {};
505-
DestroyAction = () => {};
506-
AgentPreStep = i => {};
507-
AgentSendState = () => {};
508-
AgentAct = () => {};
509-
AgentForceReset = () => {};
510-
OnEnvironmentReset = () => {};
504+
DecideAction = () => { };
505+
DestroyAction = () => { };
506+
AgentPreStep = i => { };
507+
AgentSendState = () => { };
508+
AgentAct = () => { };
509+
AgentForceReset = () => { };
510+
OnEnvironmentReset = () => { };
511511
}
512512

513513
static void OnQuitCommandReceived()

com.unity.ml-agents/Runtime/Actuators/ActionSegment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void CheckParameters(IReadOnlyCollection<T> actionArray, int offset, int
4949
/// </summary>
5050
/// <param name="actionArray">The action array to use for the this segment.</param>
5151
public ActionSegment(T[] actionArray)
52-
: this(actionArray ?? System.Array.Empty<T>(), 0, actionArray?.Length ?? 0) {}
52+
: this(actionArray ?? System.Array.Empty<T>(), 0, actionArray?.Length ?? 0) { }
5353

5454
/// <summary>
5555
/// Construct an <see cref="ActionSegment{T}"/> with an underlying array

com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static ActionBuffers FromDiscreteActions(float[] discreteActions)
4747
/// <param name="continuousActions">The continuous actions to send to an <see cref="IActionReceiver"/>.</param>
4848
/// <param name="discreteActions">The discrete actions to send to an <see cref="IActionReceiver"/>.</param>
4949
public ActionBuffers(float[] continuousActions, int[] discreteActions)
50-
: this(new ActionSegment<float>(continuousActions), new ActionSegment<int>(discreteActions)) {}
50+
: this(new ActionSegment<float>(continuousActions), new ActionSegment<int>(discreteActions)) { }
5151

5252
/// <summary>
5353
/// Construct an <see cref="ActionBuffers"/> instance with the continuous and discrete actions that will
@@ -68,7 +68,7 @@ public ActionBuffers(ActionSegment<float> continuousActions, ActionSegment<int>
6868
public ActionBuffers(ActionSpec actionSpec)
6969
: this(new ActionSegment<float>(new float[actionSpec.NumContinuousActions]),
7070
new ActionSegment<int>(new int[actionSpec.NumDiscreteActions]))
71-
{}
71+
{ }
7272

7373
/// <summary>
7474
/// Create an <see cref="ActionBuffers"/> instance with ActionSpec and all actions stored as a float array.

com.unity.ml-agents/Runtime/Actuators/VectorActuator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal ActionBuffers ActionBuffers
2828
public VectorActuator(IActionReceiver actionReceiver,
2929
ActionSpec actionSpec,
3030
string name = "VectorActuator")
31-
: this(actionReceiver, actionReceiver as IHeuristicProvider, actionSpec, name) {}
31+
: this(actionReceiver, actionReceiver as IHeuristicProvider, actionSpec, name) { }
3232

3333
/// <summary>
3434
/// Create a VectorActuator that forwards to the provided IActionReceiver.

com.unity.ml-agents/Runtime/Agent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public AgentVectorActuator(IActionReceiver actionReceiver,
9191
ActionSpec actionSpec,
9292
string name = "VectorActuator"
9393
) : base(actionReceiver, heuristicProvider, actionSpec, name)
94-
{}
94+
{ }
9595

9696
public override BuiltInActuatorType GetBuiltInActuatorType()
9797
{
@@ -904,7 +904,7 @@ void ResetData()
904904
///
905905
/// [GameObject]: https://docs.unity3d.com/Manual/GameObjects.html
906906
/// </remarks>
907-
public virtual void Initialize() {}
907+
public virtual void Initialize() { }
908908

909909
/// <summary>
910910
/// Implement <see cref="Heuristic"/> to choose an action for this agent using a custom heuristic.
@@ -1241,7 +1241,7 @@ public ReadOnlyCollection<float> GetStackedObservations()
12411241
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_20_docs/docs/Learning-Environment-Design-Agents.md#actions
12421242
/// </remarks>
12431243
/// <seealso cref="IActionReceiver.OnActionReceived"/>
1244-
public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) {}
1244+
public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { }
12451245

12461246
/// <summary>
12471247
/// Implement `OnActionReceived()` to specify agent behavior at every step, based
@@ -1309,15 +1309,15 @@ public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) {}
13091309
/// <param name="actions">
13101310
/// Struct containing the buffers of actions to be executed at this step.
13111311
/// </param>
1312-
public virtual void OnActionReceived(ActionBuffers actions) {}
1312+
public virtual void OnActionReceived(ActionBuffers actions) { }
13131313

13141314
/// <summary>
13151315
/// Implement `OnEpisodeBegin()` to set up an Agent instance at the beginning
13161316
/// of an episode.
13171317
/// </summary>
13181318
/// <seealso cref="Initialize"/>
13191319
/// <seealso cref="EndEpisode"/>
1320-
public virtual void OnEpisodeBegin() {}
1320+
public virtual void OnEpisodeBegin() { }
13211321

13221322
/// <summary>
13231323
/// Gets the most recent ActionBuffer for this agent.

com.unity.ml-agents/Runtime/Inference/TensorProxy.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ public enum TensorType
4949

5050
public long Height
5151
{
52-
get { return shape.Length >= 4 ? shape[^ 2] : 1; }
52+
get { return shape.Length >= 4 ? shape[^2] : 1; }
5353
}
5454

5555
public long Width
5656
{
57-
get { return shape.Length >= 3 ? shape[^ 1] : 1; }
57+
get { return shape.Length >= 3 ? shape[^1] : 1; }
5858
}
5959

6060
public long Channels
6161
{
6262
get
6363
{
64-
return shape.Length >= 4 ? shape[^ 3] :
65-
shape.Length == 3 ? shape[^ 2] :
66-
shape.Length == 2 ? shape[^ 1] : 1;
64+
return shape.Length >= 4 ? shape[^3] :
65+
shape.Length == 3 ? shape[^2] :
66+
shape.Length == 2 ? shape[^1] : 1;
6767
}
6868
}
6969

com.unity.ml-agents/Runtime/InplaceArray.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public override string ToString()
195195
/// <param name="lhs"></param>
196196
/// <param name="rhs"></param>
197197
/// <returns>Whether the arrays are equivalent.</returns>
198-
public static bool operator==(InplaceArray<T> lhs, InplaceArray<T> rhs)
198+
public static bool operator ==(InplaceArray<T> lhs, InplaceArray<T> rhs)
199199
{
200200
return lhs.Equals(rhs);
201201
}
@@ -206,7 +206,7 @@ public override string ToString()
206206
/// <param name="lhs"></param>
207207
/// <param name="rhs"></param>
208208
/// <returns>Whether the arrays are not equivalent</returns>
209-
public static bool operator!=(InplaceArray<T> lhs, InplaceArray<T> rhs) => !lhs.Equals(rhs);
209+
public static bool operator !=(InplaceArray<T> lhs, InplaceArray<T> rhs) => !lhs.Equals(rhs);
210210

211211
/// <summary>
212212
/// Check that the arrays are equivalent.

com.unity.ml-agents/Runtime/Integrations/Match3/AbstractBoard.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct BoardSize
3838
/// <param name="lhs"></param>
3939
/// <param name="rhs"></param>
4040
/// <returns>True if all fields are less than or equal.</returns>
41-
public static bool operator<=(BoardSize lhs, BoardSize rhs)
41+
public static bool operator <=(BoardSize lhs, BoardSize rhs)
4242
{
4343
return lhs.Rows <= rhs.Rows && lhs.Columns <= rhs.Columns && lhs.NumCellTypes <= rhs.NumCellTypes &&
4444
lhs.NumSpecialTypes <= rhs.NumSpecialTypes;
@@ -50,7 +50,7 @@ public struct BoardSize
5050
/// <param name="lhs"></param>
5151
/// <param name="rhs"></param>
5252
/// <returns>True if all fields are greater than or equal.</returns>
53-
public static bool operator>=(BoardSize lhs, BoardSize rhs)
53+
public static bool operator >=(BoardSize lhs, BoardSize rhs)
5454
{
5555
return lhs.Rows >= rhs.Rows && lhs.Columns >= rhs.Columns && lhs.NumCellTypes >= rhs.NumCellTypes &&
5656
lhs.NumSpecialTypes >= rhs.NumSpecialTypes;
@@ -200,7 +200,7 @@ public bool SimpleIsMoveValid(Move move)
200200
using (TimerStack.Instance.Scoped("SimpleIsMoveValid"))
201201
{
202202
var moveVal = GetCellType(move.Row, move.Column);
203-
var(otherRow, otherCol) = move.OtherCell();
203+
var (otherRow, otherCol) = move.OtherCell();
204204
var oppositeVal = GetCellType(otherRow, otherCol);
205205

206206
// Simple check - if the values are the same, don't match

com.unity.ml-agents/Runtime/Integrations/Match3/Move.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static Move FromPositionAndDirection(int row, int col, Direction dir, Boa
212212
/// <returns></returns>
213213
public bool InRangeForBoard(BoardSize boardSize)
214214
{
215-
var(otherRow, otherCol) = OtherCell();
215+
var (otherRow, otherCol) = OtherCell();
216216
// Get the maximum row and column this move would affect.
217217
var maxMoveRow = Mathf.Max(Row, otherRow);
218218
var maxMoveCol = Mathf.Max(Column, otherCol);

com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public string FullyQualifiedBehaviorName
223223

224224
void Awake()
225225
{
226-
OnPolicyUpdated += mode => {};
226+
OnPolicyUpdated += mode => { };
227227
}
228228

229229
internal IPolicy GeneratePolicy(ActionSpec actionSpec, ActuatorManager actuatorManager)
@@ -233,17 +233,17 @@ internal IPolicy GeneratePolicy(ActionSpec actionSpec, ActuatorManager actuatorM
233233
case BehaviorType.HeuristicOnly:
234234
return new HeuristicPolicy(actuatorManager, actionSpec);
235235
case BehaviorType.InferenceOnly:
236-
{
237-
if (m_Model == null)
238236
{
239-
var behaviorType = BehaviorType.InferenceOnly.ToString();
240-
throw new UnityAgentsException(
241-
$"Can't use Behavior Type {behaviorType} without a model. " +
242-
"Either assign a model, or change to a different Behavior Type."
243-
);
237+
if (m_Model == null)
238+
{
239+
var behaviorType = BehaviorType.InferenceOnly.ToString();
240+
throw new UnityAgentsException(
241+
$"Can't use Behavior Type {behaviorType} without a model. " +
242+
"Either assign a model, or change to a different Behavior Type."
243+
);
244+
}
245+
return new SentisPolicy(actionSpec, actuatorManager, m_Model, m_InferenceDevice, m_BehaviorName, m_DeterministicInference);
244246
}
245-
return new SentisPolicy(actionSpec, actuatorManager, m_Model, m_InferenceDevice, m_BehaviorName, m_DeterministicInference);
246-
}
247247
case BehaviorType.Default:
248248
if (Academy.Instance.IsCommunicatorOn)
249249
{

com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void RemoveAt(int index)
113113
public float this[int index]
114114
{
115115
get { return 0.0f; }
116-
set {}
116+
set { }
117117
}
118118
}
119119

com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void Update()
116116
}
117117

118118
/// <inheritdoc/>
119-
public void Reset() {}
119+
public void Reset() { }
120120

121121
/// <inheritdoc/>
122122
public CompressionSpec GetCompressionSpec()

com.unity.ml-agents/Runtime/Sensors/GridSensorBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected string[] DetectableTags
113113
}
114114

115115
/// <inheritdoc/>
116-
public void Reset() {}
116+
public void Reset() { }
117117

118118
/// <summary>
119119
/// Clears the perception buffer before loading in new data.

com.unity.ml-agents/Runtime/Sensors/ObservationWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ObservationWriter
2020

2121
TensorShape m_TensorShape;
2222

23-
public ObservationWriter() {}
23+
public ObservationWriter() { }
2424

2525
/// <summary>
2626
/// Set the writer to write to an IList at the given channelOffset.

com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public int OutputSize()
113113
var startPositionWorld = Transform.TransformPoint(startPositionLocal);
114114
var endPositionWorld = Transform.TransformPoint(endPositionLocal);
115115

116-
return (StartPositionWorld : startPositionWorld, EndPositionWorld : endPositionWorld);
116+
return (StartPositionWorld: startPositionWorld, EndPositionWorld: endPositionWorld);
117117
}
118118

119119
/// <summary>
@@ -329,7 +329,7 @@ public int Write(ObservationWriter writer)
329329
// For each ray, write the information to the observation buffer
330330
for (var rayIndex = 0; rayIndex < numRays; rayIndex++)
331331
{
332-
m_RayPerceptionOutput.RayOutputs ? [rayIndex].ToFloatArray(numDetectableTags, rayIndex, m_Observations);
332+
m_RayPerceptionOutput.RayOutputs?[rayIndex].ToFloatArray(numDetectableTags, rayIndex, m_Observations);
333333
}
334334

335335
// Finally, add the observations to the ObservationWriter
@@ -364,7 +364,7 @@ public void Update()
364364
}
365365

366366
/// <inheritdoc/>
367-
public void Reset() {}
367+
public void Reset() { }
368368

369369
/// <inheritdoc/>
370370
public ObservationSpec GetObservationSpec()

com.unity.ml-agents/Runtime/Sensors/Reflection/BoolReflectionSensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class BoolReflectionSensor : ReflectionSensorBase
88
{
99
public BoolReflectionSensor(ReflectionSensorInfo reflectionSensorInfo)
1010
: base(reflectionSensorInfo, 1)
11-
{}
11+
{ }
1212

1313
internal override void WriteReflectedField(ObservationWriter writer)
1414
{

com.unity.ml-agents/Runtime/Sensors/Reflection/FloatReflectionSensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class FloatReflectionSensor : ReflectionSensorBase
88
{
99
public FloatReflectionSensor(ReflectionSensorInfo reflectionSensorInfo)
1010
: base(reflectionSensorInfo, 1)
11-
{}
11+
{ }
1212

1313
internal override void WriteReflectedField(ObservationWriter writer)
1414
{

com.unity.ml-agents/Runtime/Sensors/Reflection/IntReflectionSensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class IntReflectionSensor : ReflectionSensorBase
88
{
99
public IntReflectionSensor(ReflectionSensorInfo reflectionSensorInfo)
1010
: base(reflectionSensorInfo, 1)
11-
{}
11+
{ }
1212

1313
internal override void WriteReflectedField(ObservationWriter writer)
1414
{

0 commit comments

Comments
 (0)