Skip to content

Commit

Permalink
Merge pull request #31 from gregvw/unsupportedPyROL
Browse files Browse the repository at this point in the history
pyrol: Allow to import unsupported classes
  • Loading branch information
aj463 authored Dec 15, 2023
2 parents 58f077f + 873a3ce commit 593e6b3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/rol/pyrol/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import importlib
from types import SimpleNamespace

from . getTypeName import getTypeName, getDefaultScalarType, ROL_classes, ROL_members


__version__ = '0.1.0'
def version():
return 'PyROL version: ' + __version__
Expand All @@ -19,10 +17,10 @@ def wrapper(scalarType=getDefaultScalarType()):
defaultScalarType = getDefaultScalarType()

supported_objects = {"Bounds", "Constraint", "LinearOperator",
"LinearConstraint", "Objective", "Problem", "Solver",
"LinearConstraint", "Objective", "Problem", "Solver",
"Vector", "getCout", "getParametersFromXmlFile"}

unsupported = SimpleNamespace()
unsupported = importlib.import_module('.unsupported', 'pyrol')

for classnameLong in ROL_members:
class_obj, _ = ROL_members[classnameLong]
Expand All @@ -43,8 +41,5 @@ def wrapper(scalarType=getDefaultScalarType()):
setattr(unsupported, classname, getTypeName(classname, defaultScalarType))
setattr(unsupported, classname + '_forScalar', getWrapper(classname))

locals().update({'unsupported': unsupported})

del importlib, SimpleNamespace, getTypeName, getDefaultScalarType, ROL_classes, ROL_members
del importlib, getTypeName, getDefaultScalarType, ROL_classes, ROL_members
del class_obj, classname, classnameLong, getWrapper, pos

2 changes: 2 additions & 0 deletions packages/rol/pyrol/python/unsupported.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# A sub-module that holds the unsupported classes.
# Content gets populated automatically.
2 changes: 2 additions & 0 deletions packages/rol/pyrol/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ENABLE_TESTING()

ADD_SUBDIRECTORY(algorithm)
FILE(COPY algorithm DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ADD_SUBDIRECTORY(unsupported)
FILE(COPY unsupported DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
3 changes: 3 additions & 0 deletions packages/rol/pyrol/test/unsupported/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INCLUDE(PythonTest)

PYTHON_ADD_TEST(testUnsupported)
1 change: 1 addition & 0 deletions packages/rol/pyrol/test/unsupported/testUnsupported.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from pyrol.unsupported import Reduced_Objective_SimOpt

0 comments on commit 593e6b3

Please sign in to comment.