-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[MLA-1634] Remove SensorComponent.GetObservationShape() #5172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ public class Match3SensorTests | |
| public void TestVectorObservations() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
|
||
| 000 | ||
| 010"; | ||
| var gameObj = new GameObject("board"); | ||
|
|
@@ -29,9 +29,8 @@ public void TestVectorObservations() | |
| sensorComponent.ObservationType = Match3ObservationType.Vector; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3 * 3 * 2 }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3 * 3 * 2); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| var expectedObs = new float[] | ||
| { | ||
|
|
@@ -46,11 +45,11 @@ public void TestVectorObservations() | |
| public void TestVectorObservationsSpecial() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
| 000 | ||
| 010"; | ||
| var specialString = | ||
| @"010 | ||
| @"010 | ||
| 200 | ||
| 000"; | ||
|
|
||
|
|
@@ -63,9 +62,8 @@ public void TestVectorObservationsSpecial() | |
| sensorComponent.ObservationType = Match3ObservationType.Vector; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3 * 3 * (2 + 3) }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3 * 3 * (2 + 3)); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| var expectedObs = new float[] | ||
| { | ||
|
|
@@ -76,12 +74,11 @@ public void TestVectorObservationsSpecial() | |
| SensorTestHelper.CompareObservation(sensor, expectedObs); | ||
| } | ||
|
|
||
|
|
||
| [Test] | ||
| public void TestVisualObservations() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
| 000 | ||
| 010"; | ||
| var gameObj = new GameObject("board"); | ||
|
|
@@ -92,9 +89,8 @@ public void TestVisualObservations() | |
| sensorComponent.ObservationType = Match3ObservationType.UncompressedVisual; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3, 3, 2 }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3, 3, 2); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| Assert.AreEqual(SensorCompressionType.None, sensor.GetCompressionSpec().SensorCompressionType); | ||
|
|
||
|
|
@@ -119,11 +115,11 @@ public void TestVisualObservations() | |
| public void TestVisualObservationsSpecial() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
| 000 | ||
| 010"; | ||
| var specialString = | ||
| @"010 | ||
| @"010 | ||
| 200 | ||
| 000"; | ||
|
|
||
|
|
@@ -136,9 +132,8 @@ public void TestVisualObservationsSpecial() | |
| sensorComponent.ObservationType = Match3ObservationType.UncompressedVisual; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3, 3, 2 + 3 }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3, 3, 2 + 3); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| Assert.AreEqual(SensorCompressionType.None, sensor.GetCompressionSpec().SensorCompressionType); | ||
|
|
||
|
|
@@ -163,7 +158,7 @@ public void TestVisualObservationsSpecial() | |
| public void TestCompressedVisualObservations() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
| 000 | ||
| 010"; | ||
| var gameObj = new GameObject("board"); | ||
|
|
@@ -174,9 +169,8 @@ public void TestCompressedVisualObservations() | |
| sensorComponent.ObservationType = Match3ObservationType.CompressedVisual; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3, 3, 2 }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3, 3, 2); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| Assert.AreEqual(SensorCompressionType.PNG, sensor.GetCompressionSpec().SensorCompressionType); | ||
|
|
||
|
|
@@ -191,17 +185,15 @@ public void TestCompressedVisualObservations() | |
| Assert.AreEqual(expectedPng, pngData); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| [Test] | ||
| public void TestCompressedVisualObservationsSpecial() | ||
| { | ||
| var boardString = | ||
| @"000 | ||
| @"000 | ||
| 000 | ||
| 010"; | ||
| var specialString = | ||
| @"010 | ||
| @"010 | ||
| 200 | ||
| 000"; | ||
|
|
||
|
|
@@ -214,9 +206,8 @@ public void TestCompressedVisualObservationsSpecial() | |
| sensorComponent.ObservationType = Match3ObservationType.CompressedVisual; | ||
| var sensor = sensorComponent.CreateSensor(); | ||
|
|
||
| var expectedShape = new[] { 3, 3, 2 + 3 }; | ||
| Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape()); | ||
| Assert.AreEqual(InplaceArray<int>.FromList(expectedShape), sensor.GetObservationSpec().Shape); | ||
| var expectedShape = new InplaceArray<int>(3, 3, 2 + 3); | ||
| Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape); | ||
|
|
||
| Assert.AreEqual(SensorCompressionType.PNG, sensor.GetCompressionSpec().SensorCompressionType); | ||
|
|
||
|
|
@@ -229,7 +220,6 @@ public void TestCompressedVisualObservationsSpecial() | |
| } | ||
| var expectedPng = LoadPNGs(pathPrefix, 2); | ||
| Assert.AreEqual(expectedPng, concatenatedPngData); | ||
|
|
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -306,7 +296,6 @@ byte[] LoadPNGs(string pathPrefix, int numExpected) | |
| } | ||
|
|
||
| return bytesOut.ToArray(); | ||
|
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look correct. (The indent I mean)