Skip to content
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

[MLA-1879] culture-invariant sorting for sensors and actuators #5194

Merged
merged 3 commits into from
Mar 30, 2021

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Mar 29, 2021

Proposed change(s)

Previously, sensors and actuators were sorted using the local culture for string comparisons (i.e. using string.CompareTo with default arguments). A potential bug with this is that sensors would be sorted one way during training, but differently when performance inference on a different end user's system. This changes sorting to use StringComparison.InvariantCulture, which is consistent everywhere (this was initially using Ordinal sorting, but that differs a lot from from the local en-US sorting)

Note that this might break existing models after upgrading if the sensor names are sorted differently. I believe that this is preferable to not making the change, since the alternative would end up causing more breakages further in the future, in a harder-to-diagnose way (i.e. after a game ships).

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

https://docs.microsoft.com/en-us/dotnet/api/system.globalization.compareoptions?view=net-5.0
https://docs.microsoft.com/en-us/globalization/locale/sorting-and-string-comparison
https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.invariantculture?view=net-5.0

Types of change(s)

  • Bug fix
  • Breaking change

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@chriselion chriselion marked this pull request as ready for review March 29, 2021 22:01
@chriselion chriselion changed the title [MLA-1879] culture-agnostic sorting for sensors and actuators [MLA-1879] culture-invariant sorting for sensors and actuators Mar 30, 2021
@chriselion chriselion merged commit 2ca6a87 into main Mar 30, 2021
@delete-merged-branch delete-merged-branch bot deleted the MLA-1879-sort-agnostic branch March 30, 2021 22:27
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants