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

File IO improvements #319

Merged
merged 20 commits into from
Nov 16, 2017
Merged

Conversation

smavros
Copy link
Contributor

@smavros smavros commented Oct 4, 2017

addressees #31 #193 and #312

- Modified the Parameters_Method_* and Method_* source files
- Modified Logging, State, Configparser and Configwriter source files
- Modified the default input file and the input files of the unit tests
- Modified the INPUT documentation
@GPMueller
Copy link
Member

This is also related to #166, #220 and #260.

- Added IO test
- Improved OVF writer
- Added IO files of unit tests to gitignore
- Added gitkeep in IO folder of unit tests
@GPMueller GPMueller force-pushed the develop branch 22 times, most recently from 4067c02 to 54cf96f Compare October 8, 2017 13:36
- Improved IO test
- Added Require_Single() method in Filter_File_Handle
@smavros
Copy link
Contributor Author

smavros commented Oct 25, 2017

Many changes must be made so I am making a comprehensive task list (will be extended):

High Priority:

Medium Priority:

  • test with a 2x3x4 system without symmetries for IO validation. Related: Unit Test: add test for input file parsing #300
  • make sure that conversion between IEEE 754 floating types (for OVF IO)
  • include the API changes in the documentation.
  • implement IO API functions using Geometry API to extend the system's geometry before reading in a system with a different geometry.
  • make IO API read functions to return bool for GUI purposes

Low Priority:

- added SPIRIT in name of corresponding VF_FileFormat
- extended OVF to OVF_bin8, OVF_bin4 and OVF_text
- added Save_to_SPIRIT() for every SPIRIT fileformat
- changed parameters to Datawriter.cpp functions for images to
vectorfield and geometry
- added comments to IO test
- improved code formating and indentation
smavros and others added 2 commits November 11, 2017 16:29
- renamed Write_Spin_Configurations_Chain() to
Write_Chain_Spin_Configuration()
- added Write_SPIRIT_Version()
- implemented IO_Chain_Append()
- added comment argument in IO_Chain_Write/Append()
- comment is initialized as dash "-"
- OVF "valuedim" is now called by RequiredSingle() in Read_From_OVF()
- renamed functions IO_Write_System_*() to IO_Chain_Write_*()
- renamed function IO*System*() to IO*Image*()
- extended API IO test
- extended Python API IO test
- modified python wrapping
- modified corresponding documentation
Copy link
Member

@GPMueller GPMueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many things are being done at once, we need to merge this soon and break up the remaining tasks into smaller PRs, or I will not be able to properly review all the changes.

// Data
output_to_file += fmt::format( "# Begin: data {}\n", datatype );

switch ( format ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch statements on the format give a warning such as 4 enumeration values not handled in switch: 'OVF_BIN8', 'OVF_BIN4', 'OVF_TEXT'... [-Wswitch]. When only 3 cases are treated it may be better to just use if/else.

{
// File name
std::string chainFile = preChainFile + suffix + ".txt";

// Chain
IO::Save_SpinChain_Configuration(this->chain, iteration, chainFile);
};
std::string output_comment( "Iteration: " + iteration );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather write std::string output_comment = fmt::format("Iteration: {}", iteration));, see the warning this produces: warning: adding 'const int' to a string does not append to the string [-Wstring-plus-int]

@@ -0,0 +1,9 @@
// This is provided for homogeneous exception handling between core and C++ UIs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this file with e26d546, it should be removed on this branch, too, as no exception should ever pass the API layer.

long int n_iterations, long int n_iterations_log, long int max_walltime_sec,
std::shared_ptr<Pinning> pinning, scalar force_convergence);
Parameters_Method(std::string output_folder, std::string output_file_tag,
std::array<bool,3> output, long int n_iterations, long int n_iterations_log,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said that bundlling some of the parameters toghether, which are passed into several constructors may be a good idea. I guess the config of the output would be a good place to start - something along the lines of:

struct Output_Config
{
    std::string folder;
    bool any;
    bool initial;
    bool final;
}

This would shorten the constructors of the parameters and make them clearer.

Note: indentation in the Parameters files is messed up, please normalize it to spaces.

}
std::string fileTag;

if (this->systems[0]->llg_parameters->output_file_tag == "<time>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the tag has been abstracted as a parameter across all Methods, it would make sense to get this from a function.
However, it's important to use the child class Parameters member, (i.e. gneb_parameters in the GNEB case)!
At least the latter should be fixed in this PR.

@@ -54,10 +58,11 @@ namespace IO
if (readability_toggle) header = separator + line + separator;
else header = line;
if (!readability_toggle) std::replace( header.begin(), header.end(), '|', ' ');
String_to_File(header, fileName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the formatting changes (indentation, where you break lines etc... and now this kind of change... You do too much of this at once! This PR is very hard to keep track of, as you pile a lot of these aesthetic changes on top of the refactoring. Please try to keep this to a minimum and rather create another PR later, where you only do clean-up.

- Implemented OVF binary 4
- OVF binary writing independently of scalar length
- Corrected comments in Datawriter for OVF
- Added all the OVF formats in the unit test
@smavros smavros force-pushed the feature-IO-improvements branch 2 times, most recently from d52ea41 to 4b4e9d3 Compare November 15, 2017 17:37
- Some switch statements converted to ifs
- Changed buffer to array when reading and writing OVF
- Changed output_comment declaration in Method_GNEB.cpp
Copy link
Member

@GPMueller GPMueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say this PR is ready to be merged.
A few issues can be closed with this and the remaining should be tackled with further PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants