diff --git a/libE57Format b/libE57Format index dd7d7d7..1914b8e 160000 --- a/libE57Format +++ b/libE57Format @@ -1 +1 @@ -Subproject commit dd7d7d711fa8f6de7017c3f2b2d0b714f1db4908 +Subproject commit 1914b8ea972251d3bb49a33828497dde683205d9 diff --git a/pyproject.toml b/pyproject.toml index 4160815..1014a4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,5 +15,4 @@ build-backend = "setuptools.build_meta" # before-all = "powershell scripts/install_xerces_c.ps1" test-requires = "pytest" build = "cp*-manylinux_x86_64 cp*-win_amd64*" -skip = "cp36*" test-command = "python -m pytest {project}/tests" diff --git a/src/pye57/__version__.py b/src/pye57/__version__.py index f6b7e26..cd1ee63 100644 --- a/src/pye57/__version__.py +++ b/src/pye57/__version__.py @@ -1 +1 @@ -__version__ = "0.4.3" +__version__ = "0.4.4" diff --git a/src/pye57/libe57_wrapper.cpp b/src/pye57/libe57_wrapper.cpp index beee197..3672311 100644 --- a/src/pye57/libe57_wrapper.cpp +++ b/src/pye57/libe57_wrapper.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace py = pybind11; using namespace pybind11::literals; @@ -54,26 +55,27 @@ PYBIND11_MODULE(libe57, m) { m.attr("CHECKSUM_POLICY_SPARSE") = CHECKSUM_POLICY_SPARSE; m.attr("CHECKSUM_POLICY_HALF") = CHECKSUM_POLICY_HALF; m.attr("CHECKSUM_POLICY_ALL") = CHECKSUM_POLICY_ALL; - m.attr("E57_INT8_MIN") = E57_INT8_MIN; - m.attr("E57_INT8_MAX") = E57_INT8_MAX; - m.attr("E57_INT16_MIN") = E57_INT16_MIN; - m.attr("E57_INT16_MAX") = E57_INT16_MAX; - m.attr("E57_INT32_MIN") = E57_INT32_MIN; - m.attr("E57_INT32_MAX") = E57_INT32_MAX; - m.attr("E57_INT64_MIN") = E57_INT64_MIN; - m.attr("E57_INT64_MAX") = E57_INT64_MAX; - m.attr("E57_UINT8_MIN") = E57_UINT8_MIN; - m.attr("E57_UINT8_MAX") = E57_UINT8_MAX; - m.attr("E57_UINT16_MIN") = E57_UINT16_MIN; - m.attr("E57_UINT16_MAX") = E57_UINT16_MAX; - m.attr("E57_UINT32_MIN") = E57_UINT32_MIN; - m.attr("E57_UINT32_MAX") = E57_UINT32_MAX; - m.attr("E57_UINT64_MIN") = E57_UINT64_MIN; - m.attr("E57_UINT64_MAX") = E57_UINT64_MAX; - m.attr("E57_FLOAT_MIN") = E57_FLOAT_MIN; - m.attr("E57_FLOAT_MAX") = E57_FLOAT_MAX; - m.attr("E57_DOUBLE_MIN") = E57_DOUBLE_MIN; - m.attr("E57_DOUBLE_MAX") = E57_DOUBLE_MAX; + m.attr("E57_INT8_MIN") = INT8_MIN; + // for some reason INT8_MAX casts to a string not to an int ! + m.attr("E57_INT8_MAX") = 127; + m.attr("E57_INT16_MIN") = INT16_MIN; + m.attr("E57_INT16_MAX") = INT16_MAX; + m.attr("E57_INT32_MIN") = INT32_MIN; + m.attr("E57_INT32_MAX") = INT32_MAX; + m.attr("E57_INT64_MIN") = INT64_MIN; + m.attr("E57_INT64_MAX") = INT64_MAX; + m.attr("E57_UINT8_MIN") = UINT8_MIN; + m.attr("E57_UINT8_MAX") = UINT8_MAX; + m.attr("E57_UINT16_MIN") = UINT16_MIN; + m.attr("E57_UINT16_MAX") = UINT16_MAX; + m.attr("E57_UINT32_MIN") = UINT32_MIN; + m.attr("E57_UINT32_MAX") = UINT32_MAX; + m.attr("E57_UINT64_MIN") = UINT64_MIN; + m.attr("E57_UINT64_MAX") = UINT64_MAX; + m.attr("E57_FLOAT_MIN") = FLOAT_MIN; + m.attr("E57_FLOAT_MAX") = FLOAT_MAX; + m.attr("E57_DOUBLE_MIN") = DOUBLE_MIN; + m.attr("E57_DOUBLE_MAX") = DOUBLE_MAX; py::enum_(m, "NodeType") .value("E57_STRUCTURE", NodeType::E57_STRUCTURE) .value("E57_VECTOR", NodeType::E57_VECTOR) @@ -357,7 +359,7 @@ PYBIND11_MODULE(libe57, m) { }); py::class_ cls_IntegerNode(m, "IntegerNode"); - cls_IntegerNode.def(py::init(), "destImageFile"_a, "value"_a=0, "minimum"_a=E57_INT64_MIN, "maximum"_a=E57_INT64_MAX); + cls_IntegerNode.def(py::init(), "destImageFile"_a, "value"_a=0, "minimum"_a=INT64_MIN, "maximum"_a=INT64_MAX); cls_IntegerNode.def("value", &IntegerNode::value); cls_IntegerNode.def("minimum", &IntegerNode::minimum); cls_IntegerNode.def("maximum", &IntegerNode::maximum); @@ -399,7 +401,7 @@ PYBIND11_MODULE(libe57, m) { }); py::class_ cls_FloatNode(m, "FloatNode"); - cls_FloatNode.def(py::init(), "destImageFile"_a, "value"_a=0.0, "precision"_a=E57_DOUBLE, "minimum"_a=E57_DOUBLE_MIN, "maximum"_a=E57_DOUBLE_MAX); + cls_FloatNode.def(py::init(), "destImageFile"_a, "value"_a=0.0, "precision"_a=E57_DOUBLE, "minimum"_a=-DBL_MAX, "maximum"_a=DBL_MAX); cls_FloatNode.def("value", &FloatNode::value); cls_FloatNode.def("precision", &FloatNode::precision); cls_FloatNode.def("minimum", &FloatNode::minimum); @@ -486,26 +488,29 @@ PYBIND11_MODULE(libe57, m) { return arr; }); - py::class_ cls_ImageFile(m, "ImageFile"); - cls_ImageFile.def(py::init(), "fname"_a, "mode"_a, "checksumPolicy"_a=CHECKSUM_POLICY_ALL); - cls_ImageFile.def("root", &ImageFile::root); - cls_ImageFile.def("close", &ImageFile::close); - cls_ImageFile.def("cancel", &ImageFile::cancel); - cls_ImageFile.def("isOpen", &ImageFile::isOpen); - cls_ImageFile.def("isWritable", &ImageFile::isWritable); - cls_ImageFile.def("fileName", &ImageFile::fileName); - cls_ImageFile.def("writerCount", &ImageFile::writerCount); - cls_ImageFile.def("readerCount", &ImageFile::readerCount); - cls_ImageFile.def("extensionsAdd", &ImageFile::extensionsAdd, "prefix"_a, "uri"_a); - cls_ImageFile.def("extensionsLookupPrefix", &ImageFile::extensionsLookupPrefix, "prefix"_a, "uri"_a); - cls_ImageFile.def("extensionsLookupUri", &ImageFile::extensionsLookupUri, "uri"_a, "prefix"_a); - cls_ImageFile.def("extensionsCount", &ImageFile::extensionsCount); - cls_ImageFile.def("extensionsPrefix", &ImageFile::extensionsPrefix, "index"_a); - cls_ImageFile.def("extensionsUri", &ImageFile::extensionsUri, "index"_a); - cls_ImageFile.def("isElementNameExtended", &ImageFile::isElementNameExtended, "elementName"_a); - cls_ImageFile.def("elementNameParse", &ImageFile::elementNameParse, "elementName"_a, "prefix"_a, "localPart"_a); - cls_ImageFile.def("checkInvariant", &ImageFile::checkInvariant, "doRecurse"_a=true); - cls_ImageFile.def("__repr__", [](const ImageFile &im) { + py::class_ (m, "ImageFile") + .def(py::init(), "fname"_a, "mode"_a, "checksumPolicy"_a=CHECKSUM_POLICY_ALL) + .def("root", &ImageFile::root) + .def("close", &ImageFile::close) + .def("cancel", &ImageFile::cancel) + .def("isOpen", &ImageFile::isOpen) + .def("isWritable", &ImageFile::isWritable) + .def("fileName", &ImageFile::fileName) + .def("writerCount", &ImageFile::writerCount) + .def("readerCount", &ImageFile::readerCount) + .def("extensionsAdd", &ImageFile::extensionsAdd, "prefix"_a, "uri"_a) +// I couldn't wrap the overloaded function so I call it directly + .def("extensionsLookupPrefix", [](const ImageFile &im, std::string &prefix, std::string &uri) { + return im.extensionsLookupPrefix(prefix, uri); + }, "prefix"_a, "uri"_a) + .def("extensionsLookupUri", &ImageFile::extensionsLookupUri, "uri"_a, "prefix"_a) + .def("extensionsCount", &ImageFile::extensionsCount) + .def("extensionsPrefix", &ImageFile::extensionsPrefix, "index"_a) + .def("extensionsUri", &ImageFile::extensionsUri, "index"_a) + .def("isElementNameExtended", &ImageFile::isElementNameExtended, "elementName"_a) + .def("elementNameParse", &ImageFile::elementNameParse, "elementName"_a, "prefix"_a, "localPart"_a) + .def("checkInvariant", &ImageFile::checkInvariant, "doRecurse"_a=true) + .def("__repr__", [](const ImageFile &im) { return ""; }); diff --git a/tests/test_main.py b/tests/test_main.py index 9a1c1b9..c7d5366 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -6,7 +6,6 @@ import pye57 from pye57 import libe57 -from pye57.utils import get_fields try: from exceptions import WindowsError @@ -19,7 +18,7 @@ def test_hi(): assert libe57.__doc__ -def test_data(*args): +def sample_data(*args): here = os.path.split(__file__)[0] return os.path.join(here, "test_data", *args) @@ -36,15 +35,15 @@ def delete_retry(path): @pytest.fixture def e57_path(): - return test_data("test.e57") + return sample_data("test.e57") @pytest.fixture def e57_spherical_path(): - return test_data("testSpherical.e57") + return sample_data("testSpherical.e57") @pytest.fixture def temp_e57_write(request): - path = test_data("test_write.e57") + path = sample_data("test_write.e57") request.addfinalizer(lambda: delete_retry(path)) return path