mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
938 stars 191 forks source link

Some tests fail when EZDXF_DISABLE_C_EXT=1 is set #1042

Closed musicinmybrain closed 9 months ago

musicinmybrain commented 9 months ago

Describe the bug

When EZDXF_DISABLE_C_EXT=1 is set, a number of tests that use is_point_in_polygon_cy fail with

E       TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)

The tests have historically worked both with and without the C extensions, so presumably this should be conditionalized to avoid assuming the accelerated/Cython types.

To Reproduce

$ gh repo clone mozman/ezdxf
$ cd ezdxf
$ python3.12 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -e .[dev]
(_e) $ EZDXF_DISABLE_C_EXT=1 python -m pytest

Confidential Data

N/A

Expected behavior A clear and concise description of what you expected to happen.

Screenshots

========================================================================================== short test summary info ==========================================================================================
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point0] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point1] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point2] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point3] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point4] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point5] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point6] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point7] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_inside_ccw_polygon[point8] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point0] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point1] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point2] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point3] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point4] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point5] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point6] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_on_boundary_ccw_polygon[point7] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point0] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point1] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point2] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point3] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point4] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point5] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point6] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point7] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point8] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point9] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point10] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point11] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point12] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point13] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
FAILED tests/test_06_math/test_613_is_point_in_polygon_2d.py::TestCythonImplementation::test_is_outside_ccw_polygon[point14] - TypeError: Argument 'point' has incorrect type (expected ezdxf.acc.vector.Vec2, got Vec2)
musicinmybrain commented 9 months ago

It looks like there is a reasonable attempt to test for this in

https://github.com/mozman/ezdxf/blob/ff20ccc983f08ed2b497d9a5c7bf310716aa0a9e/tests/test_06_math/test_613_is_point_in_polygon_2d.py#L8-L12

and

https://github.com/mozman/ezdxf/blob/ff20ccc983f08ed2b497d9a5c7bf310716aa0a9e/tests/test_06_math/test_613_is_point_in_polygon_2d.py#L196-L199

but the environment variable and the corresponding variable ezdxf.options.use_c_ext are never checked when importing ezdxf.acc.construct directly, and the import succeeds when the C extensions are present, regardless of whether they are enabled.

musicinmybrain commented 9 months ago

Thank you!