-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add io.define_derived_variable(name, expression, type) function to Py…
…thon API.
- Loading branch information
Showing
13 changed files
with
342 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Distributed under the OSI-approved Apache License, Version 2.0. See | ||
* accompanying file Copyright.txt for details. | ||
* | ||
* py11Variable.cpp | ||
*/ | ||
|
||
#include "py11VariableDerived.h" | ||
|
||
#include "adios2/helper/adiosFunctions.h" | ||
|
||
namespace adios2 | ||
{ | ||
namespace py11 | ||
{ | ||
|
||
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE | ||
VariableDerived::VariableDerived(core::VariableDerived *v) : m_VariableDerived(v) {} | ||
|
||
VariableDerived::operator bool() const noexcept | ||
{ | ||
return (m_VariableDerived == nullptr) ? false : true; | ||
} | ||
|
||
std::string VariableDerived::Name() const | ||
{ | ||
helper::CheckForNullptr(m_VariableDerived, "in call to VariableDerived::Name"); | ||
return m_VariableDerived->m_Name; | ||
} | ||
|
||
DerivedVarType VariableDerived::Type() const | ||
{ | ||
helper::CheckForNullptr(m_VariableDerived, "in call to VariableDerived::Type"); | ||
return m_VariableDerived->GetDerivedType(); | ||
} | ||
|
||
#else | ||
|
||
VariableDerived::operator bool() const noexcept { return false; } | ||
|
||
std::string VariableDerived::Name() const | ||
{ | ||
return "DerivedVariables are not supported in this ADIOS2 build"; | ||
} | ||
|
||
DerivedVarType VariableDerived::Type() const { return DerivedVarType::ExpressionString; } | ||
|
||
#endif | ||
|
||
} // end namespace py11 | ||
} // end namespace adios2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Distributed under the OSI-approved Apache License, Version 2.0. See | ||
* accompanying file Copyright.txt for details. | ||
* | ||
* py11VariableDerived.h | ||
* | ||
*/ | ||
|
||
#ifndef ADIOS2_BINDINGS_PYTHON_VARIABLEDERIVED_H_ | ||
#define ADIOS2_BINDINGS_PYTHON_VARIABLEDERIVED_H_ | ||
|
||
#include "adios2/common/ADIOSConfig.h" | ||
|
||
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE | ||
#include "adios2/core/VariableDerived.h" | ||
#else | ||
#include "adios2/common/ADIOSTypes.h" | ||
#endif | ||
|
||
namespace adios2 | ||
{ | ||
namespace py11 | ||
{ | ||
|
||
class IO; | ||
class Engine; | ||
|
||
class VariableDerived | ||
{ | ||
friend class IO; | ||
friend class Engine; | ||
|
||
public: | ||
VariableDerived() = default; | ||
|
||
~VariableDerived() = default; | ||
|
||
explicit operator bool() const noexcept; | ||
|
||
std::string Name() const; | ||
|
||
DerivedVarType Type() const; | ||
|
||
private: | ||
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE | ||
VariableDerived(adios2::core::VariableDerived *v); | ||
adios2::core::VariableDerived *m_VariableDerived = nullptr; | ||
#endif | ||
}; | ||
|
||
} // end namespace py11 | ||
} // end namespace adios2 | ||
|
||
#endif /* ADIOS2_BINDINGS_PYTHON_VARIABLEDERIVED_H_ */ |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""License: | ||
Distributed under the OSI-approved Apache License, Version 2.0. See | ||
accompanying file Copyright.txt for details. | ||
""" | ||
|
||
|
||
class DerivedVariable: | ||
"""High level representation of the DerivedVariable class in the adios2.bindings""" | ||
|
||
def __init__(self, implementation): | ||
self.impl = implementation | ||
|
||
@property | ||
def impl(self): | ||
"""Bindings implementation of the class""" | ||
return self._impl | ||
|
||
@impl.setter | ||
def impl(self, implementation): | ||
self._impl = implementation | ||
|
||
def __eq__(self, other): | ||
if isinstance(other, DerivedVariable): | ||
return self.name() == other.name() | ||
return False | ||
|
||
def type(self): | ||
""" | ||
Type of the DerivedVariable | ||
Returns: | ||
str: Type of the DerivedVariable. | ||
""" | ||
return self.impl.Type() | ||
|
||
def name(self): | ||
""" | ||
Name of the DerivedVariable | ||
Returns: | ||
str: Name of the DerivedVariable. | ||
""" | ||
return self.impl.Name() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.