Skip to content
Snippets Groups Projects
Commit bac707bc authored by David Rafferty's avatar David Rafferty
Browse files

Clean up and consolidate tests

parent 5e12887d
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.16)
project(grouper)
set(CMAKE_CXX_STANDARD 14)
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
find_package(OpenMP)
if(Python_FOUND)
message(STATUS "Python Found: ${Python_EXECUTABLE}")
message(STATUS "Python Found: ${Python_INCLUDE_DIRS}")
message(STATUS "Python Found: ${Python_LIBRARIES}")
message(STATUS "Python Found: ${Python_LIBRARY_DIRS}")
include_directories(${Python_INCLUDE_DIRS})
endif()
add_library(grouper SHARED meanshift.cpp)
SET_TARGET_PROPERTIES(grouper PROPERTIES PREFIX "")
if(Python_FOUND)
target_link_libraries(grouper ${Python_LIBRARIES} OpenMP::OpenMP_CXX)
endif()
import grouper
import numpy as np
a = np.array([[1.0, 2.0],[3.0,4.0],[5.0,6.0]])
f = np.array([1.0,2.0,3.0])
g = grouper.Grouper()
g.readCoordinates(a,f)
g.setLookDistance(5.0)
g.setGroupingDistance(5.0)
g.run()
b = []
g.group(b)
print(b)
import lsmtool
s = lsmtool.load('test_large.sky')
s.group('meanshift', byPatch=True,lookDistance=0.075,groupingDistance=0.01)
File moved
import lsmtool
s = lsmtool.load('test_apparent_sky.txt')
s.group('meanshift', byPatch=True,lookDistance=0.075,groupingDistance=0.01)
if (len(s.getPatchPositions()) == 67):
print("Test successful.")
else:
print("Test failed. (Did you build with c++ extensions? This test may fail for the pure python code.)")
......@@ -5,6 +5,7 @@ import os
s = lsmtool.load('tests/no_patches.sky')
s2 = lsmtool.load('tests/apparent.sky')
def test_select():
......@@ -94,3 +95,8 @@ def test_plot():
s.plot('tests/plot.pdf')
assert os.path.exists('tests/plot.pdf')
def test_meanshift():
print('Group the model with the meanshift algorithm')
s2.group('meanshift', byPatch=True, lookDistance=0.075, groupingDistance=0.01)
assert len(s2.getPatchPositions()) == 67
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment