poetry python build
This commit is contained in:
@@ -3,11 +3,11 @@ import os
|
||||
import unittest
|
||||
import time
|
||||
|
||||
import uLib_python
|
||||
import uLib
|
||||
|
||||
class TestCoreOptions(unittest.TestCase):
|
||||
def test_options(self):
|
||||
opt = uLib_python.Core.Options("Test Options")
|
||||
opt = uLib.Core.Options("Test Options")
|
||||
|
||||
# Test basic config file parsing
|
||||
with open("test_configuration.ini", "w") as f:
|
||||
@@ -18,12 +18,12 @@ class TestCoreOptions(unittest.TestCase):
|
||||
|
||||
class TestCoreObject(unittest.TestCase):
|
||||
def test_object(self):
|
||||
obj = uLib_python.Core.Object()
|
||||
self.assertIsNotNone(obj)
|
||||
obj = uLib.Core.Object()
|
||||
self.assertIsNotN one(obj)
|
||||
|
||||
class TestCoreTimer(unittest.TestCase):
|
||||
def test_timer(self):
|
||||
timer = uLib_python.Core.Timer()
|
||||
timer = uLib.Core.Timer()
|
||||
timer.Start()
|
||||
time.sleep(0.1)
|
||||
val = timer.StopWatch()
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
import unittest
|
||||
import numpy as np
|
||||
|
||||
import uLib_python
|
||||
import uLib
|
||||
|
||||
def vector4f0(v, target):
|
||||
diff = np.array(v) - np.array(target)
|
||||
@@ -12,7 +12,7 @@ def vector4f0(v, target):
|
||||
|
||||
class TestMathGeometry(unittest.TestCase):
|
||||
def test_geometry(self):
|
||||
Geo = uLib_python.Math.Geometry()
|
||||
Geo = uLib.Math.Geometry()
|
||||
|
||||
Geo.SetPosition([1, 1, 1])
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestMathGeometry(unittest.TestCase):
|
||||
|
||||
class TestMathContainerBox(unittest.TestCase):
|
||||
def test_container_box_local(self):
|
||||
Cnt = uLib_python.Math.ContainerBox()
|
||||
Cnt = uLib.Math.ContainerBox()
|
||||
Cnt.SetOrigin([-1, -1, -1])
|
||||
Cnt.SetSize([2, 2, 2])
|
||||
|
||||
@@ -35,7 +35,7 @@ class TestMathContainerBox(unittest.TestCase):
|
||||
self.assertTrue(np.allclose(size, [2, 2, 2]))
|
||||
|
||||
def test_container_box_global(self):
|
||||
Box = uLib_python.Math.ContainerBox()
|
||||
Box = uLib.Math.ContainerBox()
|
||||
Box.SetPosition([1, 1, 1])
|
||||
Box.SetSize([2, 2, 2])
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestMathContainerBox(unittest.TestCase):
|
||||
|
||||
class TestMathStructuredGrid(unittest.TestCase):
|
||||
def test_structured_grid(self):
|
||||
grid = uLib_python.Math.StructuredGrid([10, 10, 10])
|
||||
grid = uLib.Math.StructuredGrid([10, 10, 10])
|
||||
grid.SetSpacing([1, 1, 1])
|
||||
|
||||
spacing = grid.GetSpacing()
|
||||
@@ -53,40 +53,40 @@ class TestMathStructuredGrid(unittest.TestCase):
|
||||
|
||||
class TestMathAccumulator(unittest.TestCase):
|
||||
def test_accumulator_mean(self):
|
||||
acc = uLib_python.Math.Accumulator_Mean_f()
|
||||
acc = uLib.Math.Accumulator_Mean_f()
|
||||
acc(10.0)
|
||||
acc(20.0)
|
||||
self.assertAlmostEqual(acc(), 15.0)
|
||||
|
||||
class TestMathNewTypes(unittest.TestCase):
|
||||
def test_eigen_vectors(self):
|
||||
v1f = uLib_python.Math.Vector1f()
|
||||
v3d = uLib_python.Math.Vector3d()
|
||||
m4f = uLib_python.Math.Matrix4f()
|
||||
v1f = uLib.Math.Vector1f()
|
||||
v3d = uLib.Math.Vector3d()
|
||||
m4f = uLib.Math.Matrix4f()
|
||||
self.assertIsNotNone(v1f)
|
||||
self.assertIsNotNone(v3d)
|
||||
self.assertIsNotNone(m4f)
|
||||
|
||||
def test_ulib_vectors(self):
|
||||
vi = uLib_python.Math.Vector_i()
|
||||
vi = uLib.Math.Vector_i()
|
||||
vi.append(1)
|
||||
vi.append(2)
|
||||
self.assertEqual(len(vi), 2)
|
||||
self.assertEqual(vi[0], 1)
|
||||
self.assertEqual(vi[1], 2)
|
||||
|
||||
vf = uLib_python.Math.Vector_f()
|
||||
vf = uLib.Math.Vector_f()
|
||||
vf.append(1.5)
|
||||
self.assertAlmostEqual(vf[0], 1.5)
|
||||
|
||||
def test_homogeneous(self):
|
||||
p = uLib_python.Math.HPoint3f(1.0, 2.0, 3.0)
|
||||
v = uLib_python.Math.HVector3f(0.0, 1.0, 0.0)
|
||||
p = uLib.Math.HPoint3f(1.0, 2.0, 3.0)
|
||||
v = uLib.Math.HVector3f(0.0, 1.0, 0.0)
|
||||
self.assertIsNotNone(p)
|
||||
self.assertIsNotNone(v)
|
||||
|
||||
def test_vox_image(self):
|
||||
img = uLib_python.Math.VoxImage([2, 2, 2])
|
||||
img = uLib.Math.VoxImage([2, 2, 2])
|
||||
self.assertEqual(img.GetDims()[0], 2)
|
||||
img.SetValue([0, 0, 0], 10.5)
|
||||
# Note: GetValue returns float, and there might be internal scaling (1.E-6 observed in code)
|
||||
@@ -96,11 +96,11 @@ class TestMathNewTypes(unittest.TestCase):
|
||||
|
||||
class TestMathVoxRaytracer(unittest.TestCase):
|
||||
def test_raytracer(self):
|
||||
grid = uLib_python.Math.StructuredGrid([10, 10, 10])
|
||||
grid = uLib.Math.StructuredGrid([10, 10, 10])
|
||||
grid.SetSpacing([1, 1, 1])
|
||||
grid.SetOrigin([0, 0, 0])
|
||||
|
||||
rt = uLib_python.Math.VoxRaytracer(grid)
|
||||
rt = uLib.Math.VoxRaytracer(grid)
|
||||
self.assertIsNotNone(rt)
|
||||
|
||||
# Test TraceBetweenPoints
|
||||
@@ -118,7 +118,7 @@ class TestMathVoxRaytracer(unittest.TestCase):
|
||||
self.assertGreater(elements[i].L, 0)
|
||||
|
||||
def test_ray_data(self):
|
||||
data = uLib_python.Math.VoxRaytracerRayData()
|
||||
data = uLib.Math.VoxRaytracerRayData()
|
||||
data.SetCount(10)
|
||||
data.SetTotalLength(5.5)
|
||||
self.assertEqual(data.Count(), 10)
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
import uLib_python
|
||||
import uLib
|
||||
|
||||
def test_core():
|
||||
print("Testing Core module...")
|
||||
obj = uLib_python.Core.Object()
|
||||
obj = uLib.Core.Object()
|
||||
print("Core Object created:", obj)
|
||||
|
||||
timer = uLib_python.Core.Timer()
|
||||
timer = uLib.Core.Timer()
|
||||
timer.Start()
|
||||
print("Core Timer started")
|
||||
|
||||
options = uLib_python.Core.Options("Test Options")
|
||||
options = uLib.Core.Options("Test Options")
|
||||
print("Core Options created:", options)
|
||||
|
||||
def test_math():
|
||||
print("Testing Math module...")
|
||||
|
||||
# Test AffineTransform
|
||||
transform = uLib_python.Math.AffineTransform()
|
||||
transform = uLib.Math.AffineTransform()
|
||||
print("AffineTransform created")
|
||||
|
||||
# Test Geometry
|
||||
geom = uLib_python.Math.Geometry()
|
||||
geom = uLib.Math.Geometry()
|
||||
print("Geometry created")
|
||||
|
||||
# Test StructuredData
|
||||
data = uLib_python.Math.StructuredData([10, 10, 10])
|
||||
data = uLib.Math.StructuredData([10, 10, 10])
|
||||
print("StructuredData created with dims:", data.GetDims())
|
||||
|
||||
# Test Structured2DGrid
|
||||
grid2d = uLib_python.Math.Structured2DGrid()
|
||||
grid2d = uLib.Math.Structured2DGrid()
|
||||
grid2d.SetDims([100, 100])
|
||||
print("Structured2DGrid created with dims:", grid2d.GetDims())
|
||||
|
||||
# Test TriangleMesh
|
||||
mesh = uLib_python.Math.TriangleMesh()
|
||||
mesh = uLib.Math.TriangleMesh()
|
||||
print("TriangleMesh created")
|
||||
|
||||
print("All tests passed successfully!")
|
||||
|
||||
7
src/Python/uLib/__init__.py
Normal file
7
src/Python/uLib/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
try:
|
||||
from .uLib_python import Core, Math
|
||||
except ImportError:
|
||||
# Handle cases where the binary extension is not yet built
|
||||
pass
|
||||
|
||||
__all__ = ["Core", "Math"]
|
||||
Reference in New Issue
Block a user