-
Notifications
You must be signed in to change notification settings - Fork 54
Write scientific defaults upon close (Iteration::close or Series::close) #1834
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
base: dev
Are you sure you want to change the base?
Conversation
| // for (size_t i = 0; i < udims.size(); ++i) | ||
| // { | ||
| // res[7 * i] = 1; | ||
| // } |
Check notice
Code scanning / CodeQL
Commented-out code Note
| // TODO: unitSI | ||
| // REQUIRE(r["x"].numAttributes() == 0); | ||
| // REQUIRE(r["y"].numAttributes() == 0); | ||
| // REQUIRE(r["z"].numAttributes() == 0); |
Check notice
Code scanning / CodeQL
Commented-out code Note test
|
TODO: Move this check into finalize, maybe only print a warning throw std::runtime_error(
"A Record can not be written without any contained "
"RecordComponents: " +
name); |
|
@franzpoeschel is this for 0.18.0? :) |
Yup, this is still under development |
Moved to finalize(), degraded to warning
0f1d020 to
2115ede
Compare
prep for reading
941b3fd to
03b283b
Compare
| switch (wor) | ||
| { | ||
| case WriteOrRead::Write: | ||
| break; | ||
| case WriteOrRead::Read: { | ||
| Parameter<Operation::READ_ATT> aRead; | ||
| aRead.name = this->attrName; | ||
| auto IOHandler = this->child.IOHandler(); | ||
| IOHandler->enqueue(IOTask(&this->child, aRead)); | ||
| try | ||
| { | ||
| IOHandler->flush(defaultFlushParams); | ||
| } | ||
| catch (error::ReadError const &e) | ||
| { | ||
| std::cerr << "Could not read expected attribute '" | ||
| << this->attrName << "' in '" | ||
| << this->child.myPath().openPMDPath() | ||
| << ". Will initialize it with a default value. " | ||
| "Original error: " | ||
| << e.what() << std::endl; | ||
| this->set(this->get()); | ||
| return; | ||
| } | ||
|
|
||
| Attribute attribute( | ||
| Attribute::from_any, std::move(*aRead.m_resource)); | ||
| auto dt = attribute.dtype; | ||
| AttributeReadResult readResult = | ||
| attributeReader(this->child, attribute); | ||
| std::visit( | ||
| auxiliary::overloaded{ | ||
| [&](attribute_read_result::TypeUnmatched) { | ||
| std::cerr << "Unexpected type '" << dt | ||
| << "' for attribute '" << this->attrName | ||
| << "' in '" | ||
| << this->child.myPath().openPMDPath() | ||
| << "' with value '"; | ||
| write_to_stderr(attribute) | ||
| << "'. Expected one of [UNIMPLEMENTED: PRINT TYPES " | ||
| "HERE] or convertible to such a type." | ||
| << std::endl; | ||
| }, | ||
| [&](error::ReadError const &err) { | ||
| std::cerr << "Unexpected error while trying to read " | ||
| "attribute '" | ||
| << this->attrName << "' in '" | ||
| << this->child.myPath().openPMDPath() | ||
| << "'' with value '"; | ||
| write_to_stderr(attribute) | ||
| << "': " << err.what() << std::endl; | ||
| }, | ||
| [](attribute_read_result::Success) { /* no-op */ }}, | ||
| std::move(readResult)); | ||
| } | ||
| break; | ||
| } |
Check notice
Code scanning / CodeQL
Long switch case Note
Read (51 lines)
| template <typename ExpectedAttributeType, typename... Args> | ||
| [[nodiscard]] auto | ||
| ConfigAttributeWithSetter<RecordType, GetDefaultValue, SetDefaultValue>:: | ||
| withReader(Args &&...args) && |
Check notice
Code scanning / CodeQL
Unused static variable Note
| template <typename ExpectedAttributeType, typename... Args> | ||
| [[nodiscard]] auto | ||
| ConfigAttributeWithSetter<RecordType, GetDefaultValue, SetDefaultValue>:: | ||
| withReader(Args &&...args) && |
Check notice
Code scanning / CodeQL
Unused local variable Note
Close #1439
This PR focuses on Iteration-level attributes (including attributes included below Iteration level)
Needed for introducing a synchronous mode
TODO:
finalize()method publically, so users can request openPMD to set defaults now