Reading and writing specialized game formats#470
Reading and writing specialized game formats#470d-kad wants to merge 1 commit intogambitproject:masterfrom
Conversation
|
This is an excellent start. Some suggestions for next steps:
|
|
Two questions at this point:
|
|
Very nice on the refactoring. Yes, we can't at the moment implement write_gbt. We weren't supporting it before, so we don't need to include it now. It's a rather separate discussion to have whether we even want it at all, and if so what arguments it should take. So it deserves its own separate issue. For marking the deprecation and also flagging functions as being new, see the numpydoc style at https://numpydoc.readthedocs.io/en/latest/format.html - also consider See also entries for the new functions
For tests, use parameterised text fixtures (see other test files for examples). This way you can run them with more than one game which would be a good idea - in particular nontrivial games should be tested. For efg/nfg, a good test to focus on is whether the game makes the round trip from game to file back to game correctly. For validating the HTML - it does seem like we ought to do some sort of check but I'm not quite sure we should have our own parser, that feels something like neither here nor there. We might simply at this point confirm that it runs and put the question of the best way to regression test files we don't read in, off for another day. |
df470a5 to
bff297f
Compare
|
Tests on reading and writing nfg files are skipped as the input and output text files are not identical when using C++ read and write functions. One of the efg games is skipped for the same reason. Shall we leave it at that for now? |
|
For the test of .efg/.nfg, it's true that the existing files won't necessarily match what will get written out now because the parser and writer have changed over the years, and there isn't a unique representation of a game in those formats. We can however do two things:
As a smaller note, we prefer not to have commented-out code, so those bits we aren't going to use now should just be removed rather than commented out. (There's indeed plenty of legacy commented-out code in some places, but we've been vigorously either removing or rationalising that!) |
…zed formats Reading * `read_efg` - reads an .efg file format * `read_nfg` - reads an .nfg file format * `read_gbt` - reads a .gbt file (XML files produced by the GUI) * `read_agg` - reads an action-graph games file format Writing * `Game.to_efg` - writes an .efg file * `Game.to_nfg` - writes an .nfg file * `Game.to_html` - writes out HTML tables * `Game.to_latex` - writes a .tex file New tests in test_io.py
|
Merged at ac2ab5d - just added a FutureWarning message to the old functions and an entry in the ChangeLog. |
Add following function:
Reading
read_efg- reads an .efg file formatread_nfg- reads a .nfg file formatread_gbt- reads a .gbt file (XML files produced by the GUI)read_agg- reads an .agg fileWriting
Game.to_efg- writes an .efg fileGame.to_nfg- writes a .nfg fileGame.to_gbt- writes a .gbt fileGame.to_html- writes out HTML tablesGame.to_latex- writes a .tex file