Skip to content

Commit 57746d5

Browse files
authored
Merge pull request #174 from libigl/alecjacobson/test-data-path
use env variable to not conflict with unittest arg parsing
2 parents f34c531 + 43c1a0d commit 57746d5

File tree

6 files changed

+24
-30
lines changed

6 files changed

+24
-30
lines changed

.github/workflows/wheels.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ jobs:
5252
# This is very dubious... It *may* work because these are just cpp libraries that should not depend on the python version. Still, super-dubious.
5353
CIBW_BEFORE_BUILD_WINDOWS: "python -m pip install delvewheel"
5454
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "python -m delvewheel repair --no-mangle-all --add-path build\\temp.win-amd64-3.6\\Release;build\\temp.win-amd64-3.6\\Release\\Release;build\\temp.win-amd64-3.6\\Release\\_deps\\gmp-src\\lib;build\\temp.win-amd64-3.6\\Release\\_deps\\mpfr-src\\lib -w {dest_dir} {wheel} "
55-
CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py {project}/data/"
55+
CIBW_TEST_REQUIRES: "gitpython"
56+
CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py"
5657
CIBW_BUILD: "${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }}"
5758
CIBW_TEST_SKIP: "*-macosx_arm64"
5859
CIBW_ENVIRONMENT: "MAX_JOBS=${{ matrix.os.runs-on == 'macos-latest' && 3 || 2 }}"

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ include(Warnings)
1515
# Use C++11/14
1616
include(CXXFeatures)
1717

18-
option(PY_IGL_DOWNLOAD_TEST_DATA "Download test data" ON)
19-
option(PY_IGL_DOWNLOAD_TUTORIAL_DATA "Download tutorial data" ON)
20-
2118
# Generate position independent code by default
2219
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL "")
2320

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ or
5353
python tests/test_basic.py
5454
```
5555

56+
and if developing and trying to run from this directory. You could use:
57+
58+
```
59+
PYTHONPATH=. python tests/test_basic.py
60+
```
61+

cmake/PyiglDependencies.cmake

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,3 @@ SET(NPE_WITH_EIGEN "${libigl_SOURCE_DIR}/../eigen-src/" CACHE INTERNAL "")
4545
include(numpyeigen)
4646
# Pop CMAKE_MODULE_PATH
4747
set(CMAKE_MODULE_PATH ${PREV_CMAKE_MODULE_PATH})
48-
49-
if(${PY_IGL_DOWNLOAD_TEST_DATA})
50-
FetchContent_Declare(test_data
51-
SOURCE_DIR "${PYLIBIGL_EXTERNAL}/../data"
52-
GIT_REPOSITORY https://github.com/libigl/libigl-tests-data.git
53-
GIT_TAG 19cedf96d70702d8b3a83eb27934780c542356fe)
54-
FetchContent_MakeAvailable(test_data)
55-
endif()
56-
57-
if(${PY_IGL_DOWNLOAD_TUTORIAL_DATA})
58-
FetchContent_Declare(tutorial_data
59-
SOURCE_DIR "${PYLIBIGL_EXTERNAL}/../tutorial/data"
60-
GIT_REPOSITORY https://github.com/libigl/libigl-tutorial-data.git
61-
GIT_TAG c1f9ede366d02e3531ecbaec5e3769312f31cccd)
62-
FetchContent_MakeAvailable(tutorial_data)
63-
endif()
64-

tests/test_basic.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import scipy.sparse as csc
99
import math
1010
import sys
11+
from git import Repo
12+
1113

1214

1315

@@ -18,14 +20,17 @@
1820

1921

2022
class TestBasic(unittest.TestCase):
21-
test_data_path = None
2223

2324
def setUp(self):
25+
# This is called once for every sub-test.
26+
2427
# Some global datastructures to use in the tests
2528
np.random.seed(42)
26-
if self.test_data_path is None:
27-
self.test_data_path = os.path.join(os.path.dirname(
28-
os.path.realpath(__file__)), "../data/")
29+
# https://stackoverflow.com/a/45230996/148668
30+
self.test_data_path = os.path.join("./data","")
31+
if not os.path.isdir(self.test_data_path):
32+
Repo.clone_from("https://github.com/libigl/libigl-tests-data.git", self.test_data_path)
33+
2934
self.v1, self.f1 = igl.read_triangle_mesh(
3035
os.path.join(self.test_data_path, "bunny_small.off"))
3136
self.v2, self.f2 = igl.read_triangle_mesh(
@@ -490,7 +495,6 @@ def test_read_dmat(self):
490495
# sparse matrix, no flag attribute
491496
def test_vector_area_matrix(self):
492497
a = igl.vector_area_matrix(self.f)
493-
self.assertEqual(a.dtype, self.f.dtype)
494498
self.assertEqual(a.shape[0], a.shape[1])
495499
self.assertEqual(a.shape[0], self.v.shape[0]*2)
496500

@@ -2463,8 +2467,5 @@ def test_flip_edge(self):
24632467
emap.dtype == self.f1.dtype)
24642468
self.assertTrue(np.array(ue2e).dtype == self.f1.dtype)
24652469

2466-
24672470
if __name__ == '__main__':
2468-
if len(sys.argv) > 1:
2469-
TestBasic.test_data_path = os.path.join(sys.argv.pop(),'')
24702471
unittest.main()

tutorial/tutorials.ipynb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@
7070
"\n",
7171
"import os\n",
7272
"root_folder = os.getcwd()\n",
73-
"#root_folder = os.path.join(os.getcwd(), \"tutorial\")"
73+
"#root_folder = os.path.join(os.getcwd(), \"tutorial\")",
74+
"data_folder = os.path.join(root_folder,\"/data\")\n",
75+
"# pip install gitpython\n",
76+
"from git import Repo\n",
77+
"if not os.path.isdir(data_folder):\n"
78+
" Repo.clone_from(\"https://github.com/libigl/libigl-tutorial-data.git\", data_folder)\n",
79+
"\n"
7480
]
7581
},
7682
{

0 commit comments

Comments
 (0)