Repository navigation
Patch: Save NPY files by default, CSV with filetype="csv" - #16
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
saveToFile()gets afiletypeargument,"npy"(the default) or"csv", so results can be saved in both formats, just as the input files can be read in both."npy"writes a NumPy.npyfile with one entry per state:int64for the policy,float64for the value vector.np.loadgives the same array asgetPolicy()/getValueVector(), and the file is byte-identical to whatnp.savewrites."csv"writes the same comma-separated file as before.filetypeis accepted in any case, e.g."NPY".fileNamenow defaults toNone, which meansresult.npy, orresult.csvwithfiletype="csv"..csvwithfiletype="npy", or in.npywithfiletype="csv", raises aValueErrorthat names the filetype to use.Breaking change: The default output is now NPY. Existing calls like
saveToFile("policy.csv")raise aValueError; addfiletype="csv"to keep CSV output.Tests: Case 1 of
test_output.pycovers both file types, the default names, upper-case filetypes and the error cases, also on the compiled module.test_order.pynow reads the saved policy as.npy. All 12 tests pass locally (macOS, Python 3.14).Docs: The wiki's Classes and methods page is updated to match; the wiki is a separate repository and is pushed separately.