-
Notifications
You must be signed in to change notification settings - Fork 46
Add python testing. #71
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
Open
hsorby
wants to merge
3
commits into
LungNoodle:develop
Choose a base branch
from
hsorby:add_python_testing
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -43,3 +43,6 @@ CMakeLists.txt.user | |
| *.pyc | ||
| __pycache__/ | ||
|
|
||
| # PyCharm | ||
| .idea/ | ||
|
|
||
This file contains hidden or 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,50 @@ | ||
|
|
||
|
|
||
| set(VIRTUALENV_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/venv_for_tests" | ||
| CACHE INTERNAL "Path to virtualenv" ) | ||
| if (WIN32) | ||
| set(PYTHON_PLATFORM_BIN_DIR Scripts) | ||
| else () | ||
| set(PYTHON_PLATFORM_BIN_DIR bin) | ||
| endif () | ||
|
|
||
| find_program(VIRTUALENV_PYTHON_EXECUTABLE python PATHS "${VIRTUALENV_DIRECTORY}/${PYTHON_PLATFORM_BIN_DIR}" NO_DEFAULT_PATH) | ||
| mark_as_advanced(VIRTUALENV_PYTHON_EXECTUABLE) | ||
|
|
||
| if (NOT EXISTS "${VIRTUALENV_PYTHON_EXECTUABLE}") | ||
| function(_create_virtualenv_from_exec call) | ||
| execute_process(COMMAND | ||
| ${call} --python=${PYTHON_EXECUTABLE} ${VIRTUALENV_DIRECTORY} | ||
| RESULT_VARIABLE RESULT | ||
| ERROR_VARIABLE ERROR | ||
| OUTPUT_VARIABLE OUTPUT | ||
| ) | ||
| if(NOT "${RESULT}" STREQUAL "0") | ||
| message(STATUS "${RESULT}") | ||
| message(STATUS "${OUTPUT}") | ||
| message(STATUS "${ERROR}") | ||
| message(FATAL_ERROR "Could not create virtual environment.") | ||
| endif() | ||
| endfunction() | ||
|
|
||
| get_filename_component(_PYTHON_BIN "${PYTHON_EXECUTABLE}" PATH) | ||
| find_program(VIRTUALENV_EXECUTABLE virtualenv) | ||
| mark_as_advanced(VIRTUALENV_EXECUTABLE) | ||
|
|
||
| # Could also check for 'venv' and 'virtualenv' Python packages as we could use these instead of | ||
| # the virtualenv executable. | ||
| if (VIRTUALENV_EXECUTABLE) | ||
| message(STATUS "Creating virtual environment ...") | ||
| _create_virtualenv_from_exec("${VIRTUALENV_EXECUTABLE}") | ||
| else () | ||
| message(FATAL_ERROR "Could not find virtualenv.") | ||
| endif () | ||
|
|
||
| find_program(VIRTUALENV_PYTHON_EXECUTABLE python PATHS "${VIRTUALENV_DIRECTORY}/${PYTHON_PLATFORM_BIN_DIR}" NO_DEFAULT_PATH) | ||
|
|
||
| if (VIRTUALENV_PYTHON_EXECUTABLE) | ||
| message(STATUS "Creating virtual environment ... success") | ||
| else () | ||
| message(FATAL_ERROR "Virtual environment Python executable does not exist.") | ||
| endif () | ||
| endif () |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,3 @@ | ||
|
|
||
| add_subdirectory(python) | ||
|
|
This file contains hidden or 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,25 @@ | ||
|
|
||
| # Create a Python virtual environment to use for testing. This is only done once. | ||
| include(PythonVirtualEnv) | ||
|
|
||
| set(TEST_SRCS | ||
| geometry_test.py | ||
| ) | ||
|
|
||
| foreach(_TEST ${TEST_SRCS}) | ||
| # We'll actually take a copy of the test and run it from the build directory and not the source directory. | ||
| configure_file(${_TEST} ${_TEST} COPYONLY) | ||
|
|
||
| # Set up the test. | ||
| get_filename_component(_TEST_NAME ${_TEST} NAME_WE) | ||
| set(_TEST_NAME python_${_TEST_NAME}) | ||
| add_test(NAME ${_TEST_NAME} COMMAND ${VIRTUALENV_PYTHON_EXECUTABLE} ${_TEST}) | ||
| if (WIN32) | ||
| set_tests_properties(${_TEST_NAME} PROPERTIES | ||
| ENVIRONMENT "PATH=$<TARGET_FILE_DIR:aether>\;%PATH%;PYTHONPATH=${PROJECT_BINARY_DIR}/src/bindings/python;TEST_RESOURCES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/resources") | ||
| else () | ||
| set_tests_properties(${_TEST_NAME} PROPERTIES | ||
| ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/src/bindings/python;TEST_RESOURCES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/resources") | ||
| endif () | ||
|
|
||
| endforeach() |
This file contains hidden or 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,27 @@ | ||
| import os | ||
| import unittest | ||
|
|
||
| from aether.diagnostics import set_diagnostics_on | ||
| from aether.geometry import define_node_geometry_2d | ||
| from aether.arrays import check_node_xyz_2d | ||
|
|
||
| # Look to see if the 'TEST_RESOURCES_DIR' is set otherwise fallback to a path | ||
| # relative to this file. | ||
| if 'TEST_RESOURCES_DIR' in os.environ: | ||
| resources_dir = os.environ['TEST_RESOURCES_DIR'] | ||
| else: | ||
| here = os.path.abspath(os.path.dirname(__file__)) | ||
| resources_dir = os.path.join(here, 'resources') | ||
|
|
||
|
|
||
| class GeometryTestCase(unittest.TestCase): | ||
|
|
||
| def test_read_square(self): | ||
| set_diagnostics_on(False) | ||
| define_node_geometry_2d(os.path.join(resources_dir, 'square.ipnode')) | ||
| value = check_node_xyz_2d(1, 1) | ||
| self.assertEqual(100, value) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
This file contains hidden or 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,68 @@ | ||
| CMISS Version 1.21 ipnode File Version 2 | ||
| Heading: 52 | ||
|
|
||
| The number of nodes is [ 35]: 4 | ||
| Number of coordinates [ 3]: 3 | ||
| Do you want prompting for different versions of nj=1 [N]? N | ||
| Do you want prompting for different versions of nj=2 [N]? N | ||
| Do you want prompting for different versions of nj=3 [N]? N | ||
| The number of derivatives for coordinate 1 is [0]: 3 | ||
| The number of derivatives for coordinate 2 is [0]: 3 | ||
| The number of derivatives for coordinate 3 is [0]: 3 | ||
|
|
||
| Node number [ 52]: 52 | ||
| The Xj(1) coordinate is [ 0.00000E+00]: 1.00000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 1.0000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The Xj(2) coordinate is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.00000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: -1.00000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The Xj(3) coordinate is [ 0.00000E+00]: 0.00000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.000000001e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
|
|
||
| Node number [ 53]: 53 | ||
| The Xj(1) coordinate is [ 0.00000E+00]: 2.00000000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 1.000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.000000000e-00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The Xj(2) coordinate is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: -1.000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The Xj(3) coordinate is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
|
|
||
| Node number [ 54]: 54 | ||
| The Xj(1) coordinate is [ 0.00000E+00]: 1.000000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 1.0000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The Xj(2) coordinate is [ 0.00000E+00]: -1.00000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.00000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: -1.00000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.00000000000e+00 | ||
| The Xj(3) coordinate is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.0000000000e+00 | ||
|
|
||
| Node number [ 56]: 56 | ||
| The Xj(1) coordinate is [ 0.00000E+00]: 2.00000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 1.000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The Xj(2) coordinate is [ 0.00000E+00]: -1.00000000e+02 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: -1.000000001e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.000000000e+00 | ||
| The Xj(3) coordinate is [ 0.00000E+00]: 0.00000000e+00 | ||
| The derivative wrt direction 1 is [ 0.00000E+00]: 0.0000000e+00 | ||
| The derivative wrt direction 2 is [ 0.00000E+00]: 0.0000000e+00 | ||
| The derivative wrt directions 1 & 2 is [ 0.00000E+00]: 0.0000000e+00 | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should probably be called get_node_xyz_2d.