From 595847363de8ac77d57d23652a8ae6002f3999ad Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 14:18:16 +0100 Subject: [PATCH 01/59] Add testing on MacOS (intel and m1) --- .github/workflows/test.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2ccb34e..e68386f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,22 +7,32 @@ on: branches: [ "develop", "master" ] jobs: - build: - - runs-on: ubuntu-22.04 + test: + name: Test PyMEOS for Python ${{ matrix.python-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + os: [ ubuntu-latest, macos-13, macos-14 ] steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - uses: awalsh128/cache-apt-pkgs-action@latest + - name: Get dependencies from apt (cache) + uses: awalsh128/cache-apt-pkgs-action@latest + if: $RUNNER_OS == 'Linux' with: packages: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev version: 1.0 + - name: Get dependencies from homebrew (cache) + uses: tecolicom/actions-use-homebrew-tools@v1 + if: $RUNNER_OS == 'macOS' + with: + tools: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -39,11 +49,13 @@ jobs: cmake .. -DMEOS=on make -j sudo make install + - name: Install python dependencies run: | python -m pip install --upgrade pip pip install -r pymeos_cffi/dev-requirements.txt pip install -r pymeos/dev-requirements.txt + - name: Install pymeos_cffi run: | cd pymeos_cffi @@ -51,6 +63,7 @@ jobs: python ./pymeos_cffi/builder/build_pymeos_functions.py pip install . cd .. + - name: Test PyMEOS with pytest run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib From ff7fd7aa1f361a2c8b80b6f18735da63c609a73b Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 14:24:00 +0100 Subject: [PATCH 02/59] Fix use of env variable --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e68386f3..e6c2928a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,14 +22,14 @@ jobs: - name: Get dependencies from apt (cache) uses: awalsh128/cache-apt-pkgs-action@latest - if: $RUNNER_OS == 'Linux' + if: ${{ env.RUNNER_OS }} == 'Linux' with: packages: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev version: 1.0 - name: Get dependencies from homebrew (cache) uses: tecolicom/actions-use-homebrew-tools@v1 - if: $RUNNER_OS == 'macOS' + if: ${{ env.RUNNER_OS }} == 'macOS' with: tools: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev From 9450e29989db8795330cb8b46a5d607cdada8f06 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 14:27:38 +0100 Subject: [PATCH 03/59] Use runner.os instead of env.RUNNER_OS --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e6c2928a..a1b1a215 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,14 +22,14 @@ jobs: - name: Get dependencies from apt (cache) uses: awalsh128/cache-apt-pkgs-action@latest - if: ${{ env.RUNNER_OS }} == 'Linux' + if: runner.os == 'Linux' with: packages: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev version: 1.0 - name: Get dependencies from homebrew (cache) uses: tecolicom/actions-use-homebrew-tools@v1 - if: ${{ env.RUNNER_OS }} == 'macOS' + if: runner.os == 'macOS' with: tools: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev From 0b256affee6ad9651a4c7a9b1201d4dd766ca434 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 14:44:12 +0100 Subject: [PATCH 04/59] Fix macOS C dependencies --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1b1a215..21ef0f3a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: uses: tecolicom/actions-use-homebrew-tools@v1 if: runner.os == 'macOS' with: - tools: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev + tools: cmake libpq proj json-c gsl geos - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 From f5d331a32428e394e95f74bec957a5f46398cf8c Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 14:58:03 +0100 Subject: [PATCH 05/59] Add temporary fix for macOS runner issue --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21ef0f3a..b0a13325 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,14 @@ jobs: packages: build-essential cmake postgresql-server-dev-14 libproj-dev libjson-c-dev libgsl-dev libgeos-dev version: 1.0 + - name: Update brew + if: ${{ matrix.os }} == "macos-13" + # Necessary to avoid issue with macOS runners. See + # https://github.com/actions/runner-images/issues/4020 + run: | + brew reinstall python@3 || brew link --overwrite python@3 + brew update + - name: Get dependencies from homebrew (cache) uses: tecolicom/actions-use-homebrew-tools@v1 if: runner.os == 'macOS' From a09341bec679d4f5e1219ae82814b4f10ba0df6c Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 15:01:41 +0100 Subject: [PATCH 06/59] Fix use of matrix.os variable --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0a13325..d0966e78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: version: 1.0 - name: Update brew - if: ${{ matrix.os }} == "macos-13" + if: matrix.os == "macos-13" # Necessary to avoid issue with macOS runners. See # https://github.com/actions/runner-images/issues/4020 run: | From 84694440d97419e7b151fa1851098a035a930702 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 15:13:41 +0100 Subject: [PATCH 07/59] Fix use of matrix.os variable --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0966e78..9a03c8ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: version: 1.0 - name: Update brew - if: matrix.os == "macos-13" + if: matrix.os == 'macos-13' # Necessary to avoid issue with macOS runners. See # https://github.com/actions/runner-images/issues/4020 run: | From 10a9a1264d0682f4afb466ce39a0538170de047f Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 15:24:01 +0100 Subject: [PATCH 08/59] Add patches for MacOS --- .github/workflows/test.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a03c8ba..25e2b887 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,11 +47,28 @@ jobs: python-version: ${{ matrix.python-version }} cache: "pip" - - name: Install MEOS + - name: Fetch MEOS sources env: BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB + + - name: Patch MEOS for macOS + if: runner.os == 'macOS' + run: | + cd MobilityDB + sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h + sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h + + - name: Patch MEOS for arm macOS + if: matrix.os == 'macos-14' + run: | + cd MobilityDB + sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h + sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h + + - name: Install MEOS + run: | mkdir MobilityDB/build cd MobilityDB/build cmake .. -DMEOS=on From 1f1c159e7174b99beec3b033a00147b18802129b Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 16:53:05 +0100 Subject: [PATCH 09/59] Add filters to avoid running tests when only docs are updated --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25e2b887..eb0fdfa3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,16 @@ name: Test PyMEOS on: push: branches: [ "develop", "master" ] + paths-ignore: + - "docs/**" + - ".readthedocs.yml" + - "README.md" pull_request: branches: [ "develop", "master" ] + paths-ignore: + - "docs/**" + - ".readthedocs.yml" + - "README.md" jobs: test: From 3893deb979b51d18b1baad52c09e384b752bfe3e Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 17:08:23 +0100 Subject: [PATCH 10/59] Skip python 3.8 and 3.9 for arm macos due to issue with runners. Update brew reinstall to avoid brew issue in intel macos --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb0fdfa3..55e5edb0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,15 @@ jobs: matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] os: [ ubuntu-latest, macos-13, macos-14 ] + exclude: + # Necessary due to issue with macOS runners. See + # https://github.com/actions/setup-python/issues/808 + # Can be removed once this PR is merged: + # https://github.com/actions/python-versions/pull/259 + - os: macos-14 + python-version: "3.8" + - os: macos-14 + python-version: "3.9" steps: - name: Checkout @@ -40,7 +49,8 @@ jobs: # Necessary to avoid issue with macOS runners. See # https://github.com/actions/runner-images/issues/4020 run: | - brew reinstall python@3 || brew link --overwrite python@3 + brew reinstall python@3.12 || brew link --overwrite python@3.12 + brew reinstall python@3.11 || brew link --overwrite python@3.11 brew update - name: Get dependencies from homebrew (cache) From 540a60a2efe5196cee20d7b776e24de10ccb1fb9 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 17:33:13 +0100 Subject: [PATCH 11/59] Remove -D flag in nm check to avoid issues in macOS (outputs are identical in linux) --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index c7885a9a..a1fb09d8 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -7,7 +7,7 @@ def get_defined_functions(library_path): - result = subprocess.check_output(["nm", "-gD", library_path]) + result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} From db05ac509dd8d7b1fb90f507d0afbc85572fc9e9 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 18:53:37 +0100 Subject: [PATCH 12/59] Add system-dependent LD_LIBRARY_PATH --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55e5edb0..2ae81448 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,10 @@ jobs: python-version: "3.8" - os: macos-14 python-version: "3.9" + include: + - ld_path: "/usr/local/lib" + - os: macos-14 + ld_path: "/opt/homebrew/lib" steps: - name: Checkout @@ -109,6 +113,6 @@ jobs: - name: Test PyMEOS with pytest run: | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos pytest From 35d5b0bc365c2a291d2859b2f68123095a084d46 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 18:53:48 +0100 Subject: [PATCH 13/59] Add explicit include dirs --- pymeos_cffi/pymeos_cffi/builder/build_pymeos.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py index 9757b22a..4ed34d47 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py @@ -12,6 +12,8 @@ def get_library_dirs(): + print(sys.platform) + print(platform.processor()) if sys.platform == "linux": return ["/usr/local/lib"] elif sys.platform == "darwin": @@ -23,11 +25,24 @@ def get_library_dirs(): raise NotImplementedError("Unsupported platform") +def get_include_dirs(): + if sys.platform == "linux": + return ["/usr/local/include"] + elif sys.platform == "darwin": + if platform.processor() == "arm": + return ["/opt/homebrew/include"] + else: + return ["/usr/local/include"] + else: + raise NotImplementedError("Unsupported platform") + + ffibuilder.set_source( "_meos_cffi", '#include "meos.h"\n' '#include "meos_catalog.h"\n' '#include "meos_internal.h"', libraries=["meos"], library_dirs=get_library_dirs(), + include_dirs=get_include_dirs(), ) # library name, for the linker if __name__ == "__main__": # not when running with setuptools From b90e924eafc4338e3051dc07ac2cbef0399264e3 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 19:09:45 +0100 Subject: [PATCH 14/59] Add log in get_defined_functions --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index a1fb09d8..c9652050 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,6 +9,7 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") + print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined From f9830adb1a68355aa181d3872d16956b03718d72 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 19:19:12 +0100 Subject: [PATCH 15/59] Update defined symbol search to take into account that symbols in macOS have and underscore prepended --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index c9652050..8c521e7a 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,7 +9,6 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") - print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined @@ -21,7 +20,7 @@ def remove_undefined_functions(content, so_path): def remove_if_not_defined(m): function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") - if function in defined: + if function in defined or (sys.platform == "darwin" and ("_" + function) in defined): for t in undefined_types: if t in m.group(0): print(f"Removing function due to undefined type {t}: {function}") From 1b308cadc1c0bfddf58b20f3ab1dfcde8a44bdd5 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 19:30:25 +0100 Subject: [PATCH 16/59] Add log again --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 8c521e7a..973a64e5 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,6 +9,7 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") + print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined From 4016e35c1c9b935c81ccb6c3a0895d237c206ccd Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 19:41:37 +0100 Subject: [PATCH 17/59] Set DYLD_LIBRARY_PATH --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ae81448..79d6b229 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -114,5 +114,6 @@ jobs: - name: Test PyMEOS with pytest run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos pytest From ee89a997e21428eb213405187400f6c906798aab Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 19:48:03 +0100 Subject: [PATCH 18/59] Add underscore to meos calls in macos --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 9 +++++---- .../pymeos_cffi/builder/build_pymeos_functions.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 973a64e5..de092f11 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,7 +9,6 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") - print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined @@ -21,7 +20,9 @@ def remove_undefined_functions(content, so_path): def remove_if_not_defined(m): function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") - if function in defined or (sys.platform == "darwin" and ("_" + function) in defined): + if function in defined or ( + sys.platform == "darwin" and ("_" + function) in defined + ): for t in undefined_types: if t in m.group(0): print(f"Removing function due to undefined type {t}: {function}") @@ -38,7 +39,7 @@ def remove_if_not_defined(m): def remove_repeated_functions( - content: str, seen_functions: set + content: str, seen_functions: set ) -> Tuple[str, Set[str]]: def remove_if_repeated(m): function = m.group(0).replace("\n", "").strip() @@ -106,7 +107,7 @@ def main(include_dir, so_path=None, destination_path="pymeos_cffi/builder/meos.h if sys.platform == "linux": main("/usr/local/include", "/usr/local/lib/libmeos.so") elif sys.platform == "darwin": - if platform.processor() == 'arm': + if platform.processor() == "arm": main("/opt/homebrew/include", "/opt/homebrew/lib/libmeos.dylib") else: main("/usr/local/include", "/usr/local/lib/libmeos.dylib") diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index 0915f0a9..1f88014c 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -524,10 +524,16 @@ def build_function_string( ) # If the function didn't return anything, just add the function call to the base if return_type.return_type == "None": - function_string = f"{base}" f" _lib.{function_name}({inner_params})" + function_string = ( + f"{base}" + f" {'_' if sys.platform == 'darwin' else ''}_lib.{function_name}({inner_params})" + ) # Otherwise, store the result in a variable else: - function_string = f"{base}" f" result = _lib.{function_name}({inner_params})" + function_string = ( + f"{base}" + f" result = {'_' if sys.platform == 'darwin' else ''}_lib.{function_name}({inner_params})" + ) # Add error handling function_string += f"\n _check_error()" From 36cac0454f4c3b3b15b0d2a622bc6db3946f170e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Div=C3=AD?= <43449526+Diviloper@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:57:18 +0100 Subject: [PATCH 19/59] Fix underscore position --- pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index 1f88014c..cc324c6d 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -526,13 +526,13 @@ def build_function_string( if return_type.return_type == "None": function_string = ( f"{base}" - f" {'_' if sys.platform == 'darwin' else ''}_lib.{function_name}({inner_params})" + f" _lib.{'_' if sys.platform == 'darwin' else ''}{function_name}({inner_params})" ) # Otherwise, store the result in a variable else: function_string = ( f"{base}" - f" result = {'_' if sys.platform == 'darwin' else ''}_lib.{function_name}({inner_params})" + f" result = _lib.{'_' if sys.platform == 'darwin' else ''}{function_name}({inner_params})" ) # Add error handling From 675e07c2bb52a4359a2cf58f35889f7f7f05eb40 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 23:14:01 +0100 Subject: [PATCH 20/59] Add underscore to meos calls in macos --- .../pymeos_cffi/builder/build_header.py | 19 +++++++++++++++++-- .../builder/build_pymeos_functions.py | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index de092f11..517aa40f 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -21,7 +21,7 @@ def remove_undefined_functions(content, so_path): def remove_if_not_defined(m): function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") if function in defined or ( - sys.platform == "darwin" and ("_" + function) in defined + sys.platform == "darwin" and ("_" + function) in defined ): for t in undefined_types: if t in m.group(0): @@ -39,7 +39,7 @@ def remove_if_not_defined(m): def remove_repeated_functions( - content: str, seen_functions: set + content: str, seen_functions: set ) -> Tuple[str, Set[str]]: def remove_if_repeated(m): function = m.group(0).replace("\n", "").strip() @@ -56,6 +56,17 @@ def remove_if_repeated(m): return content, seen_functions +def add_underscore_prefix(content: str) -> str: + def add_underscore(m): + function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") + return m.group(0).replace(function, "_" + function) + + content = re.sub( + r"extern .*?;", add_underscore, content, flags=re.RegexFlag.MULTILINE + ) + return content + + def main(include_dir, so_path=None, destination_path="pymeos_cffi/builder/meos.h"): files = ["meos.h", "meos_catalog.h", "meos_internal.h"] global_content = "" @@ -90,6 +101,10 @@ def main(include_dir, so_path=None, destination_path="pymeos_cffi/builder/meos.h content, functions = remove_repeated_functions(content, functions) + if sys.platform == "darwin": + # In macOS, functions are prefixed with an underscore + content = add_underscore_prefix(content) + global_content += f"//-------------------- {file_name} --------------------\n" global_content += content diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index cc324c6d..17ec8f69 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -266,6 +266,9 @@ def main(header_path="pymeos_cffi/builder/meos.h"): for match in matches: named = match.groupdict() function = named["function"] + if sys.platform == "darwin": + # In macOS, functions are prefixed with an underscore + function = function.lstrip("_") inner_return_type = named["returnType"] if function in skipped_functions: continue From 42013b7334062f091fbf7fb0fc3f15c11d227441 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Thu, 28 Mar 2024 23:27:15 +0100 Subject: [PATCH 21/59] Revert last commits --- .../pymeos_cffi/builder/build_header.py | 20 +++---------------- .../builder/build_pymeos_functions.py | 13 ++---------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 517aa40f..054e324b 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,6 +9,7 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") + print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined @@ -21,7 +22,7 @@ def remove_undefined_functions(content, so_path): def remove_if_not_defined(m): function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") if function in defined or ( - sys.platform == "darwin" and ("_" + function) in defined + sys.platform == "darwin" and ("_" + function) in defined ): for t in undefined_types: if t in m.group(0): @@ -39,7 +40,7 @@ def remove_if_not_defined(m): def remove_repeated_functions( - content: str, seen_functions: set + content: str, seen_functions: set ) -> Tuple[str, Set[str]]: def remove_if_repeated(m): function = m.group(0).replace("\n", "").strip() @@ -56,17 +57,6 @@ def remove_if_repeated(m): return content, seen_functions -def add_underscore_prefix(content: str) -> str: - def add_underscore(m): - function = m.group(0).split("(")[0].strip().split(" ")[-1].strip("*") - return m.group(0).replace(function, "_" + function) - - content = re.sub( - r"extern .*?;", add_underscore, content, flags=re.RegexFlag.MULTILINE - ) - return content - - def main(include_dir, so_path=None, destination_path="pymeos_cffi/builder/meos.h"): files = ["meos.h", "meos_catalog.h", "meos_internal.h"] global_content = "" @@ -101,10 +91,6 @@ def main(include_dir, so_path=None, destination_path="pymeos_cffi/builder/meos.h content, functions = remove_repeated_functions(content, functions) - if sys.platform == "darwin": - # In macOS, functions are prefixed with an underscore - content = add_underscore_prefix(content) - global_content += f"//-------------------- {file_name} --------------------\n" global_content += content diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py index 17ec8f69..0915f0a9 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos_functions.py @@ -266,9 +266,6 @@ def main(header_path="pymeos_cffi/builder/meos.h"): for match in matches: named = match.groupdict() function = named["function"] - if sys.platform == "darwin": - # In macOS, functions are prefixed with an underscore - function = function.lstrip("_") inner_return_type = named["returnType"] if function in skipped_functions: continue @@ -527,16 +524,10 @@ def build_function_string( ) # If the function didn't return anything, just add the function call to the base if return_type.return_type == "None": - function_string = ( - f"{base}" - f" _lib.{'_' if sys.platform == 'darwin' else ''}{function_name}({inner_params})" - ) + function_string = f"{base}" f" _lib.{function_name}({inner_params})" # Otherwise, store the result in a variable else: - function_string = ( - f"{base}" - f" result = _lib.{'_' if sys.platform == 'darwin' else ''}{function_name}({inner_params})" - ) + function_string = f"{base}" f" result = _lib.{function_name}({inner_params})" # Add error handling function_string += f"\n _check_error()" From eca8a4ec7be32ac2ebbd2379c1f53a10e59eebd9 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:02:25 +0100 Subject: [PATCH 22/59] Add prints to MEOS --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79d6b229..71289b0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,6 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h + sed -i "" "393i printf(\"Hey 1\")" ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i "" "165i printf(\"Hey 2\")" ./meos/src/general/tnumber_mathfuncs.c + sed -i "" "344i printf(\"Hey 3\")" ./meos/src/general/type_util.c - name: Install MEOS run: | From 8e7c6e644ab4809dbfb5c3a26b0478af03df7419 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:05:22 +0100 Subject: [PATCH 23/59] Add prints to MEOS --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71289b0d..4b9db639 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,9 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i "" "393i printf(\"Hey 1\")" ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i "" "165i printf(\"Hey 2\")" ./meos/src/general/tnumber_mathfuncs.c - sed -i "" "344i printf(\"Hey 3\")" ./meos/src/general/type_util.c + sed -i "" "393i\ printf(\"Hey 1\")" ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i "" "165i\ printf(\"Hey 2\")" ./meos/src/general/tnumber_mathfuncs.c + sed -i "" "344i\ printf(\"Hey 3\")" ./meos/src/general/type_util.c - name: Install MEOS run: | From ea8fa963d0811a35529de4887ae3d8f0862e0fcf Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:13:52 +0100 Subject: [PATCH 24/59] Add prints to MEOS --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b9db639..0bc72d23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,9 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i "" "393i\ printf(\"Hey 1\")" ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i "" "165i\ printf(\"Hey 2\")" ./meos/src/general/tnumber_mathfuncs.c - sed -i "" "344i\ printf(\"Hey 3\")" ./meos/src/general/type_util.c + sed -i '' '392s;.*;&\nprintf("Hey 1"); ;' ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i '' '165s;.*;&\nprintf("Hey 2"); ;' ./meos/src/general/tnumber_mathfuncs.c + sed -i '' '343s;.*;&\nprintf("Hey 3"); ;' ./meos/src/general/type_util.c - name: Install MEOS run: | From 583fbf6fefc57b03a09480819b1db38068b3cad5 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:15:55 +0100 Subject: [PATCH 25/59] Add prints to MEOS --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0bc72d23..11e2bcfc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,9 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i '' '392s;.*;&\nprintf("Hey 1"); ;' ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i '' '165s;.*;&\nprintf("Hey 2"); ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nprintf("Hey 3"); ;' ./meos/src/general/type_util.c + sed -i '' '392s;.*;&\nprintf("Hey 1")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i '' '165s;.*;&\nprintf("Hey 2")\; ;' ./meos/src/general/tnumber_mathfuncs.c + sed -i '' '343s;.*;&\nprintf("Hey 3")\; ;' ./meos/src/general/type_util.c - name: Install MEOS run: | From c67271aecc12726989c95bc8a8ad67093a9805c9 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:18:02 +0100 Subject: [PATCH 26/59] Remove prints --- pymeos_cffi/pymeos_cffi/builder/build_header.py | 1 - pymeos_cffi/pymeos_cffi/builder/build_pymeos.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/pymeos_cffi/pymeos_cffi/builder/build_header.py b/pymeos_cffi/pymeos_cffi/builder/build_header.py index 054e324b..de092f11 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_header.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_header.py @@ -9,7 +9,6 @@ def get_defined_functions(library_path): result = subprocess.check_output(["nm", "-g", library_path]) output = result.decode("utf-8") - print(output) lines = output.splitlines() defined = {line.split(" ")[-1] for line in lines if " T " in line} return defined diff --git a/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py b/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py index 4ed34d47..0ffb0d4e 100644 --- a/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py +++ b/pymeos_cffi/pymeos_cffi/builder/build_pymeos.py @@ -12,8 +12,6 @@ def get_library_dirs(): - print(sys.platform) - print(platform.processor()) if sys.platform == "linux": return ["/usr/local/lib"] elif sys.platform == "darwin": From ffaca1721a0d124caf333864ecb84b0bc759ddcb Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:26:05 +0100 Subject: [PATCH 27/59] Add log --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11e2bcfc..522bf3ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,6 +91,7 @@ jobs: sed -i '' '392s;.*;&\nprintf("Hey 1")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c sed -i '' '165s;.*;&\nprintf("Hey 2")\; ;' ./meos/src/general/tnumber_mathfuncs.c sed -i '' '343s;.*;&\nprintf("Hey 3")\; ;' ./meos/src/general/type_util.c + cat ./meos/src/general/tnumber_mathfuncs_meos.c - name: Install MEOS run: | From 75b4cece856f83516e0ee4ec44fb543690084a0b Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:31:57 +0100 Subject: [PATCH 28/59] Add pymeos function to test division --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 522bf3ba..49404893 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -113,11 +113,11 @@ jobs: python ./pymeos_cffi/builder/build_header.py python ./pymeos_cffi/builder/build_pymeos_functions.py pip install . - cd .. - name: Test PyMEOS with pytest run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos + python -m "from pymeos import *;pymeos_initialize();print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From 2872b47c8e5e665421df9534954747107428cf1f Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:38:51 +0100 Subject: [PATCH 29/59] Fix test mini program --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49404893..32aba93c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,5 +119,5 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos - python -m "from pymeos import *;pymeos_initialize();print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" + python -m "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From f578e63501e2e271cb37a5a24cf0cac540023b59 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:43:58 +0100 Subject: [PATCH 30/59] Fix command --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32aba93c..d3e7c2da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,5 +119,5 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos - python -m "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" + python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From 776e46f69059b5ec4f938bc8c2ac51f606ea49e1 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 00:50:26 +0100 Subject: [PATCH 31/59] Add etra test to check where's the crash --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3e7c2da..627746ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,5 +119,6 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos + python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") + 2)" python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From c9073cf0bee79639c3509a1aec53d49d15aef447 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:01:41 +0100 Subject: [PATCH 32/59] More tests --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 627746ca..bd3904a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,6 +119,8 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos - python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") + 2)" + python -c "from pymeos import *" + python -c "from pymeos import *; pymeos_initialize()" + python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\"))" python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From b62303a8695e299df8c362d7eea7dc93d52c1f15 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:27:09 +0100 Subject: [PATCH 33/59] Update logs --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd3904a6..f33164ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,9 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i '' '392s;.*;&\nprintf("Hey 1")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i '' '165s;.*;&\nprintf("Hey 2")\; ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nprintf("Hey 3")\; ;' ./meos/src/general/type_util.c + sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2")\; ;' ./meos/src/general/tnumber_mathfuncs.c + sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3")\; ;' ./meos/src/general/type_util.c cat ./meos/src/general/tnumber_mathfuncs_meos.c - name: Install MEOS From ca78fb947e65ddb0ad81bed40e1937d233ff1f5f Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:30:54 +0100 Subject: [PATCH 34/59] Update logs --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f33164ac..188544ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,9 +88,9 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2")\; ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3")\; ;' ./meos/src/general/type_util.c + sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c + sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 %d\\n", type)\; ;' ./meos/src/general/type_util.c cat ./meos/src/general/tnumber_mathfuncs_meos.c - name: Install MEOS From 7cb9e70d01d0c0f0729f1c29003fb57f0ece9bc1 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:33:11 +0100 Subject: [PATCH 35/59] Update logs --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 188544ab..dc317dbe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,6 +91,7 @@ jobs: sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 %d\\n", type)\; ;' ./meos/src/general/type_util.c + sed -i '' '351s;.*;&\nfprintf(stderr, "Hey 4 %f\\n", DatumGetFloat8(r))\; ;' ./meos/src/general/type_util.c cat ./meos/src/general/tnumber_mathfuncs_meos.c - name: Install MEOS From e161716d9d5400c1a7119433ad9911d1b9dda5b4 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:42:25 +0100 Subject: [PATCH 36/59] Update logs --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc317dbe..1f088d54 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,7 +90,7 @@ jobs: sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 %d\\n", type)\; ;' ./meos/src/general/type_util.c + sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 Type: %d (Float: %d)\\n", type, T_FLOAT8)\; ;' ./meos/src/general/type_util.c sed -i '' '351s;.*;&\nfprintf(stderr, "Hey 4 %f\\n", DatumGetFloat8(r))\; ;' ./meos/src/general/type_util.c cat ./meos/src/general/tnumber_mathfuncs_meos.c From 6217e9075b8e1441bc43e6fd91470a4a779c0419 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 01:56:59 +0100 Subject: [PATCH 37/59] Move logs to all mac to compare results --- .github/workflows/test.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f088d54..bb9571bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,6 +81,10 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h + sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c + sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c + sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 Type: %d (Float: %d)\\n", type, T_FLOAT8)\; ;' ./meos/src/general/type_util.c + sed -i '' '351s;.*;&\nfprintf(stderr, "Hey 4 %f\\n", DatumGetFloat8(r))\; ;' ./meos/src/general/type_util.c - name: Patch MEOS for arm macOS if: matrix.os == 'macos-14' @@ -88,11 +92,6 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 Type: %d (Float: %d)\\n", type, T_FLOAT8)\; ;' ./meos/src/general/type_util.c - sed -i '' '351s;.*;&\nfprintf(stderr, "Hey 4 %f\\n", DatumGetFloat8(r))\; ;' ./meos/src/general/type_util.c - cat ./meos/src/general/tnumber_mathfuncs_meos.c - name: Install MEOS run: | From c1c7f8b184881c23e5854a60e7a3a0bd3854bff2 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 02:19:05 +0100 Subject: [PATCH 38/59] Update MEOS repo to try fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb9571bc..6dd2f093 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,7 +73,7 @@ jobs: env: BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB - name: Patch MEOS for macOS if: runner.os == 'macOS' From 0fad20c9349190f6ba1a062d7b333240e34e45a6 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 02:55:47 +0100 Subject: [PATCH 39/59] Change USE_FLOAT8_BYVAL macro value to try --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6dd2f093..fe43ff54 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,6 +92,7 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h + sed -i "" "s,#define USE_FLOAT8_BYVAL 1,#define USE_FLOAT8_BYVAL 0,g" ./meos/postgres/pg_config.h - name: Install MEOS run: | From 86ec09ee423e96952ffe9eec78ea02e7982fa51c Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 11:15:33 +0100 Subject: [PATCH 40/59] Remove all tests from workflow --- .github/workflows/test.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe43ff54..ca64bdc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ on: jobs: test: - name: Test PyMEOS for Python ${{ matrix.python-version }} on ${{ matrix.os }} + name: Test PyMEOS - Python ${{ matrix.python-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -81,10 +81,6 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h - sed -i '' '392s;.*;&\nfprintf(stderr, "Hey 1\\n")\; ;' ./meos/src/general/tnumber_mathfuncs_meos.c - sed -i '' '165s;.*;&\nfprintf(stderr, "Hey 2\\n")\; ;' ./meos/src/general/tnumber_mathfuncs.c - sed -i '' '343s;.*;&\nfprintf(stderr, "Hey 3 Type: %d (Float: %d)\\n", type, T_FLOAT8)\; ;' ./meos/src/general/type_util.c - sed -i '' '351s;.*;&\nfprintf(stderr, "Hey 4 %f\\n", DatumGetFloat8(r))\; ;' ./meos/src/general/type_util.c - name: Patch MEOS for arm macOS if: matrix.os == 'macos-14' @@ -92,7 +88,6 @@ jobs: cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - sed -i "" "s,#define USE_FLOAT8_BYVAL 1,#define USE_FLOAT8_BYVAL 0,g" ./meos/postgres/pg_config.h - name: Install MEOS run: | @@ -120,8 +115,4 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos - python -c "from pymeos import *" - python -c "from pymeos import *; pymeos_initialize()" - python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\"))" - python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeqSet(\"Interp=Step;{[1.4142135623730951@2019-09-01, 1.4142135623730951@2019-09-02], [0@2019-09-03, 0@2019-09-05]}\") / 2)" pytest From 543cb949c783252493fc796f9f3240dd12fd9f61 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Fri, 29 Mar 2024 11:28:18 +0100 Subject: [PATCH 41/59] Move python setup action down --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca64bdc5..151a0a77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,12 +63,6 @@ jobs: with: tools: cmake libpq proj json-c gsl geos - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: "pip" - - name: Fetch MEOS sources env: BRANCH_NAME: ${{ github.base_ref || github.ref_name }} @@ -97,6 +91,12 @@ jobs: make -j sudo make install + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + - name: Install python dependencies run: | python -m pip install --upgrade pip From 1f967a00ded9d599fbb8dc221ee688c8d0ee1f11 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sat, 30 Mar 2024 21:32:27 +0100 Subject: [PATCH 42/59] Test only on macos-14 to speedup debugging --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 151a0a77..cabb5eaf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,8 @@ jobs: fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] - os: [ ubuntu-latest, macos-13, macos-14 ] +# os: [ ubuntu-latest, macos-13, macos-14 ] + os: [ macos-14 ] exclude: # Necessary due to issue with macOS runners. See # https://github.com/actions/setup-python/issues/808 From bd9853ac67e6ee85e64aba6c4442f3690d9c0e44 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sat, 30 Mar 2024 21:57:25 +0100 Subject: [PATCH 43/59] Add MEOS and PyMEOS scripts --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cabb5eaf..48b4ecb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,6 +92,13 @@ jobs: make -j sudo make install + - name: Run MEOS example + if: matrix.os == 'macos-14' + run: | + cd MobilityDB/meos/examples + clang -Wall -g -I/opt/homebrew/include -o arithmetic arithmetic.c -L/opt/homebrew/lib -lmeos + ./arithmetic + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -111,6 +118,11 @@ jobs: python ./pymeos_cffi/builder/build_pymeos_functions.py pip install . + - name: Run PyMEOS example + run: | + cd pymeos_cffi + python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeq(\"[1@2020-03-01, 10@2020-03-10]\") / 2)" + - name: Test PyMEOS with pytest run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} From b35b3c0bebc0e430d048e7a5e54399005773fa4c Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sat, 30 Mar 2024 21:59:30 +0100 Subject: [PATCH 44/59] Set LD path in test scripts --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48b4ecb1..8588c609 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,6 +95,7 @@ jobs: - name: Run MEOS example if: matrix.os == 'macos-14' run: | + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd MobilityDB/meos/examples clang -Wall -g -I/opt/homebrew/include -o arithmetic arithmetic.c -L/opt/homebrew/lib -lmeos ./arithmetic @@ -120,6 +121,7 @@ jobs: - name: Run PyMEOS example run: | + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} cd pymeos_cffi python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeq(\"[1@2020-03-01, 10@2020-03-10]\") / 2)" From aacbefec4cc2f22506c5980b998e3929910e1c40 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sun, 31 Mar 2024 14:44:42 +0200 Subject: [PATCH 45/59] Use lifting branch of MobilityDB --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8588c609..21e088ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,9 +66,10 @@ jobs: - name: Fetch MEOS sources env: - BRANCH_NAME: ${{ github.base_ref || github.ref_name }} +# BRANCH_NAME: ${{ github.base_ref || github.ref_name }} + BRANCH_NAME: lifting run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB - name: Patch MEOS for macOS if: runner.os == 'macOS' From cc728e12c37802c9ce78bd910097d2a5a375682a Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sun, 31 Mar 2024 14:51:08 +0200 Subject: [PATCH 46/59] Use lifting branch of MobilityDB --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21e088ef..caf29e7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,8 +66,8 @@ jobs: - name: Fetch MEOS sources env: -# BRANCH_NAME: ${{ github.base_ref || github.ref_name }} BRANCH_NAME: lifting +# BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB From 1f5b46087c315119a67c6db32512aafa501ef1f2 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sun, 31 Mar 2024 14:56:46 +0200 Subject: [PATCH 47/59] Use estebanzimanyi/MobilityDB --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index caf29e7a..3db45e5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,7 +69,7 @@ jobs: BRANCH_NAME: lifting # BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/estebanzimanyi/MobilityDB - name: Patch MEOS for macOS if: runner.os == 'macOS' From 1aa2ba44e57fec3e14c645835cb8c109bab6de6e Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:12:26 +0200 Subject: [PATCH 48/59] Use new changes and don't patch --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3db45e5c..6d3c4b90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,20 +66,20 @@ jobs: - name: Fetch MEOS sources env: - BRANCH_NAME: lifting + BRANCH_NAME: pg_config_cmake # BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/estebanzimanyi/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB - name: Patch MEOS for macOS - if: runner.os == 'macOS' + if: runner.os == 'macOS' and false run: | cd MobilityDB sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h - name: Patch MEOS for arm macOS - if: matrix.os == 'macos-14' + if: matrix.os == 'macos-14' and false run: | cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h From 4a89ce80f577413270ad4bd1a2a0df9131723258 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:13:15 +0200 Subject: [PATCH 49/59] Fix conditions --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d3c4b90..9074210f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,14 +72,14 @@ jobs: git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB - name: Patch MEOS for macOS - if: runner.os == 'macOS' and false + if: runner.os == 'macOS' && false run: | cd MobilityDB sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h - name: Patch MEOS for arm macOS - if: matrix.os == 'macos-14' and false + if: matrix.os == 'macos-14' && false run: | cd MobilityDB sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h From 43082e11132a60325a79696c2d15aed915a2f9c6 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:22:55 +0200 Subject: [PATCH 50/59] Switch branch --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9074210f..5937e3aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,7 +66,7 @@ jobs: - name: Fetch MEOS sources env: - BRANCH_NAME: pg_config_cmake + BRANCH_NAME: test_pymeos # BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB From a851e7034f6db3dd090fc0ac10c40c53fea1ffb7 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:25:49 +0200 Subject: [PATCH 51/59] Fix pymeos example path --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5937e3aa..4d971525 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -122,8 +122,9 @@ jobs: - name: Run PyMEOS example run: | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} - cd pymeos_cffi + cd pymeos python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeq(\"[1@2020-03-01, 10@2020-03-10]\") / 2)" - name: Test PyMEOS with pytest From ed5dd76bd52fa87c3beb42f75f69c7abe2d8deec Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:34:12 +0200 Subject: [PATCH 52/59] Try with CRC patch --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d971525..76b5cc47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,10 +79,9 @@ jobs: sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h - name: Patch MEOS for arm macOS - if: matrix.os == 'macos-14' && false + if: matrix.os == 'macos-14' run: | cd MobilityDB - sed -i "" "s,#define HAVE_X86_64_POPCNTQ 1,//#define HAVE_X86_64_POPCNTQ 1,g" ./meos/postgres/pg_config.h sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h - name: Install MEOS From d9139b8297d168bd3d3ead1bee4ae1bdad5bfb63 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 19:36:29 +0200 Subject: [PATCH 53/59] Fix patch --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76b5cc47..83dd4880 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,14 +75,14 @@ jobs: if: runner.os == 'macOS' && false run: | cd MobilityDB - sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h - sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h + sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h.in + sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h.in - name: Patch MEOS for arm macOS if: matrix.os == 'macos-14' run: | cd MobilityDB - sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h + sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h.in - name: Install MEOS run: | From 2bc83a70c381042962de5d97b4b8d04b64a80b2a Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 22:26:01 +0200 Subject: [PATCH 54/59] Add transformation tests --- pymeos/tests/main/tgeogpoint_test.py | 1873 +++++++++++++------------- pymeos/tests/main/tgeompoint_test.py | 47 + 2 files changed, 1006 insertions(+), 914 deletions(-) diff --git a/pymeos/tests/main/tgeogpoint_test.py b/pymeos/tests/main/tgeogpoint_test.py index e39fe515..69f51a13 100644 --- a/pymeos/tests/main/tgeogpoint_test.py +++ b/pymeos/tests/main/tgeogpoint_test.py @@ -54,29 +54,27 @@ class TestTGeogPointConstructors(TestTGeogPoint): "source, type, interpolation", [ ( - TGeogPointInst("Point(1.5 1.5)@2019-09-01"), - TGeogPointInst, - TInterpolation.NONE, + TGeogPointInst("Point(1.5 1.5)@2019-09-01"), + TGeogPointInst, + TInterpolation.NONE, ), ( - TGeogPointSeq( - "{Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02}"), - TGeogPointSeq, - TInterpolation.DISCRETE, + TGeogPointSeq("{Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02}"), + TGeogPointSeq, + TInterpolation.DISCRETE, ), ( - TGeogPointSeq( - "[Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02]"), - TGeogPointSeq, - TInterpolation.LINEAR, + TGeogPointSeq("[Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02]"), + TGeogPointSeq, + TInterpolation.LINEAR, ), ( - TGeogPointSeqSet( - "{[Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02]," - "[Point(1.5 1.5)@2019-09-03, Point(1.5 1.5)@2019-09-05]}" - ), - TGeogPointSeqSet, - TInterpolation.LINEAR, + TGeogPointSeqSet( + "{[Point(1.5 1.5)@2019-09-01, Point(2.5 2.5)@2019-09-02]," + "[Point(1.5 1.5)@2019-09-03, Point(1.5 1.5)@2019-09-05]}" + ), + TGeogPointSeqSet, + TInterpolation.LINEAR, ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -93,19 +91,19 @@ def test_from_base_constructor(self, source, type, interpolation): [ (datetime(2000, 1, 1), TGeogPointInst, TInterpolation.NONE), ( - TsTzSet("{2019-09-01, 2019-09-02}"), - TGeogPointSeq, - TInterpolation.DISCRETE, + TsTzSet("{2019-09-01, 2019-09-02}"), + TGeogPointSeq, + TInterpolation.DISCRETE, ), ( - TsTzSpan("[2019-09-01, 2019-09-02]"), - TGeogPointSeq, - TInterpolation.LINEAR, + TsTzSpan("[2019-09-01, 2019-09-02]"), + TGeogPointSeq, + TInterpolation.LINEAR, ), ( - TsTzSpanSet("{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}"), - TGeogPointSeqSet, - TInterpolation.LINEAR, + TsTzSpanSet("{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}"), + TGeogPointSeqSet, + TInterpolation.LINEAR, ), ], ids=["Instant", "Sequence", "Discrete Sequence", "SequenceSet"], @@ -121,29 +119,29 @@ def test_from_base_time_constructor(self, source, type, interpolation): "source, type, interpolation, expected", [ ( - "Point(1 1)@2019-09-01", - TGeogPointInst, - TInterpolation.NONE, - "POINT(1 1)@2019-09-01 00:00:00+00", + "Point(1 1)@2019-09-01", + TGeogPointInst, + TInterpolation.NONE, + "POINT(1 1)@2019-09-01 00:00:00+00", ), ( - "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}", - TGeogPointSeq, - TInterpolation.DISCRETE, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", + "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}", + TGeogPointSeq, + TInterpolation.DISCRETE, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", ), ( - "[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]", - TGeogPointSeq, - TInterpolation.LINEAR, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", + "[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]", + TGeogPointSeq, + TInterpolation.LINEAR, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", ), ( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}", - TGeogPointSeqSet, - TInterpolation.LINEAR, - "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " - "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}", + TGeogPointSeqSet, + TInterpolation.LINEAR, + "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " + "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -158,16 +156,16 @@ def test_string_constructor(self, source, type, interpolation, expected): "source, type, expected", [ ( - "[Point(1 1)@2019-09-01, Point(1.249919068145015 1.250040436011492)@2019-09-02, Point(2 2)@2019-09-05]", - TGeogPointSeq, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-05 00:00:00+00]", + "[Point(1 1)@2019-09-01, Point(1.249919068145015 1.250040436011492)@2019-09-02, Point(2 2)@2019-09-05]", + TGeogPointSeq, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-05 00:00:00+00]", ), ( - "{[Point(1 1)@2019-09-01, POINT(1.249919068145015 1.250040436011492)@2019-09-02, Point(2 2)@2019-09-05]," - "[Point(1 1)@2019-09-07, Point(1 1)@2019-09-08, Point(1 1)@2019-09-09]}", - TGeogPointSeqSet, - "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-05 00:00:00+00], " - "[POINT(1 1)@2019-09-07 00:00:00+00, POINT(1 1)@2019-09-09 00:00:00+00]}", + "{[Point(1 1)@2019-09-01, POINT(1.249919068145015 1.250040436011492)@2019-09-02, Point(2 2)@2019-09-05]," + "[Point(1 1)@2019-09-07, Point(1 1)@2019-09-08, Point(1 1)@2019-09-09]}", + TGeogPointSeqSet, + "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-05 00:00:00+00], " + "[POINT(1 1)@2019-09-07 00:00:00+00, POINT(1 1)@2019-09-09 00:00:00+00]}", ), ], ids=["Sequence", "SequenceSet"], @@ -195,78 +193,78 @@ def test_value_timestamp_instant_constructor(self, value, timestamp): "list, interpolation, normalize, expected", [ ( - ["Point(1 1)@2019-09-01", "Point(2 2)@2019-09-03"], - TInterpolation.DISCRETE, - False, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", + ["Point(1 1)@2019-09-01", "Point(2 2)@2019-09-03"], + TInterpolation.DISCRETE, + False, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", ), ( - ["Point(1 1)@2019-09-01", "Point(2 2)@2019-09-03"], - TInterpolation.LINEAR, - False, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + ["Point(1 1)@2019-09-01", "Point(2 2)@2019-09-03"], + TInterpolation.LINEAR, + False, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ( - [ - TGeogPointInst("Point(1 1)@2019-09-01"), - TGeogPointInst("Point(2 2)@2019-09-03"), - ], - TInterpolation.DISCRETE, - False, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", + [ + TGeogPointInst("Point(1 1)@2019-09-01"), + TGeogPointInst("Point(2 2)@2019-09-03"), + ], + TInterpolation.DISCRETE, + False, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", ), ( - [ - TGeogPointInst("Point(1 1)@2019-09-01"), - TGeogPointInst("Point(2 2)@2019-09-03"), - ], - TInterpolation.LINEAR, - False, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + [ + TGeogPointInst("Point(1 1)@2019-09-01"), + TGeogPointInst("Point(2 2)@2019-09-03"), + ], + TInterpolation.LINEAR, + False, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ( - ["Point(1 1)@2019-09-01", TGeogPointInst("Point(2 2)@2019-09-03")], - TInterpolation.DISCRETE, - False, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", + ["Point(1 1)@2019-09-01", TGeogPointInst("Point(2 2)@2019-09-03")], + TInterpolation.DISCRETE, + False, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00}", ), ( - ["Point(1 1)@2019-09-01", TGeogPointInst("Point(2 2)@2019-09-03")], - TInterpolation.LINEAR, - False, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + ["Point(1 1)@2019-09-01", TGeogPointInst("Point(2 2)@2019-09-03")], + TInterpolation.LINEAR, + False, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ( - [ - "Point(1 1)@2019-09-01", - "Point(1.499885736561676 1.500057091479197)@2019-09-02", - "Point(2 2)@2019-09-03", - ], - TInterpolation.LINEAR, - True, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + [ + "Point(1 1)@2019-09-01", + "Point(1.499885736561676 1.500057091479197)@2019-09-02", + "Point(2 2)@2019-09-03", + ], + TInterpolation.LINEAR, + True, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ( - [ - TGeogPointInst("Point(1 1)@2019-09-01"), - TGeogPointInst( - "Point(1.499885736561676 1.500057091479197)@2019-09-02" - ), - TGeogPointInst("Point(2 2)@2019-09-03"), - ], - TInterpolation.LINEAR, - True, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + [ + TGeogPointInst("Point(1 1)@2019-09-01"), + TGeogPointInst( + "Point(1.499885736561676 1.500057091479197)@2019-09-02" + ), + TGeogPointInst("Point(2 2)@2019-09-03"), + ], + TInterpolation.LINEAR, + True, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ( - [ - "Point(1 1)@2019-09-01", - "Point(1.499885736561676 1.500057091479197)@2019-09-02", - TGeogPointInst("Point(2 2)@2019-09-03"), - ], - TInterpolation.LINEAR, - True, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", + [ + "Point(1 1)@2019-09-01", + "Point(1.499885736561676 1.500057091479197)@2019-09-02", + TGeogPointInst("Point(2 2)@2019-09-03"), + ], + TInterpolation.LINEAR, + True, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-03 00:00:00+00]", ), ], ids=[ @@ -282,7 +280,7 @@ def test_value_timestamp_instant_constructor(self, value, timestamp): ], ) def test_instant_list_sequence_constructor( - self, list, interpolation, normalize, expected + self, list, interpolation, normalize, expected ): tps = TGeogPointSeq( instant_list=list, @@ -352,17 +350,17 @@ class TestTGeogPointOutputs(TestTGeogPoint): [ (tpi, "POINT(1 1)@2019-09-01 00:00:00+00"), ( - tpds, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", + tpds, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", ), ( - tps, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", + tps, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", ), ( - tpss, - "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " - "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", + tpss, + "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " + "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -375,17 +373,17 @@ def test_str(self, temporal, expected): [ (tpi, "TGeogPointInst(POINT(1 1)@2019-09-01 00:00:00+00)"), ( - tpds, - "TGeogPointSeq({POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00})", + tpds, + "TGeogPointSeq({POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00})", ), ( - tps, - "TGeogPointSeq([POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00])", + tps, + "TGeogPointSeq([POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00])", ), ( - tpss, - "TGeogPointSeqSet({[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " - "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]})", + tpss, + "TGeogPointSeqSet({[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " + "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]})", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -398,17 +396,17 @@ def test_repr(self, temporal, expected): [ (tpi, "POINT(1 1)@2019-09-01 00:00:00+00"), ( - tpds, - "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", + tpds, + "{POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00}", ), ( - tps, - "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", + tps, + "[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00]", ), ( - tpss, - "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " - "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", + tpss, + "{[POINT(1 1)@2019-09-01 00:00:00+00, POINT(2 2)@2019-09-02 00:00:00+00], " + "[POINT(1 1)@2019-09-03 00:00:00+00, POINT(1 1)@2019-09-05 00:00:00+00]}", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -421,20 +419,20 @@ def test_as_wkt(self, temporal, expected): [ (tpi, "01290061E6100000000000000000F03F000000000000F03F00A01E4E71340200"), ( - tpds, - "01290066E61000000200000003000000000000F03F000000000000F03F00A01E4E71340200" - "000000000000004000000000000000400000F66B85340200", + tpds, + "01290066E61000000200000003000000000000F03F000000000000F03F00A01E4E71340200" + "000000000000004000000000000000400000F66B85340200", ), ( - tps, - "0129006EE61000000200000003000000000000F03F000000000000F03F00A01E4E71340200" - "000000000000004000000000000000400000F66B85340200", + tps, + "0129006EE61000000200000003000000000000F03F000000000000F03F00A01E4E71340200" + "000000000000004000000000000000400000F66B85340200", ), ( - tpss, - "0129006FE6100000020000000200000003000000000000F03F000000000000F03F00A01E4E71340200" - "000000000000004000000000000000400000F66B853402000200000003000000000000F03F000000000" - "000F03F0060CD8999340200000000000000F03F000000000000F03F00207CC5C1340200", + tpss, + "0129006FE6100000020000000200000003000000000000F03F000000000000F03F00A01E4E71340200" + "000000000000004000000000000000400000F66B853402000200000003000000000000F03F000000000" + "000F03F0060CD8999340200000000000000F03F000000000000F03F00207CC5C1340200", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -446,175 +444,175 @@ def test_as_hexwkb(self, temporal, expected): "temporal, expected", [ ( - tpi, - "{\n" - ' "type": "MovingPoint",\n' - ' "bbox": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 1,\n" - " 1\n" - " ]\n" - " ],\n" - ' "period": {\n' - ' "begin": "2019-09-01T00:00:00+00",\n' - ' "end": "2019-09-01T00:00:00+00",\n' - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " },\n" - ' "coordinates": [\n' - " [\n" - " 1,\n" - " 1\n" - " ]\n" - " ],\n" - ' "datetimes": [\n' - ' "2019-09-01T00:00:00+00"\n' - " ],\n" - ' "interpolation": "None"\n' - "}", - ), - ( - tpds, - "{\n" - ' "type": "MovingPoint",\n' - ' "bbox": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "period": {\n' - ' "begin": "2019-09-01T00:00:00+00",\n' - ' "end": "2019-09-02T00:00:00+00",\n' - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " },\n" - ' "coordinates": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "datetimes": [\n' - ' "2019-09-01T00:00:00+00",\n' - ' "2019-09-02T00:00:00+00"\n' - " ],\n" - ' "lower_inc": true,\n' - ' "upper_inc": true,\n' - ' "interpolation": "Discrete"\n' - "}", - ), - ( - tps, - "{\n" - ' "type": "MovingPoint",\n' - ' "bbox": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "period": {\n' - ' "begin": "2019-09-01T00:00:00+00",\n' - ' "end": "2019-09-02T00:00:00+00",\n' - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " },\n" - ' "coordinates": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "datetimes": [\n' - ' "2019-09-01T00:00:00+00",\n' - ' "2019-09-02T00:00:00+00"\n' - " ],\n" - ' "lower_inc": true,\n' - ' "upper_inc": true,\n' - ' "interpolation": "Linear"\n' - "}", - ), - ( - tpss, - "{\n" - ' "type": "MovingPoint",\n' - ' "bbox": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "period": {\n' - ' "begin": "2019-09-01T00:00:00+00",\n' - ' "end": "2019-09-05T00:00:00+00",\n' - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " },\n" - ' "sequences": [\n' - " {\n" - ' "coordinates": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 2,\n" - " 2\n" - " ]\n" - " ],\n" - ' "datetimes": [\n' - ' "2019-09-01T00:00:00+00",\n' - ' "2019-09-02T00:00:00+00"\n' - " ],\n" - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " },\n" - " {\n" - ' "coordinates": [\n' - " [\n" - " 1,\n" - " 1\n" - " ],\n" - " [\n" - " 1,\n" - " 1\n" - " ]\n" - " ],\n" - ' "datetimes": [\n' - ' "2019-09-03T00:00:00+00",\n' - ' "2019-09-05T00:00:00+00"\n' - " ],\n" - ' "lower_inc": true,\n' - ' "upper_inc": true\n' - " }\n" - " ],\n" - ' "interpolation": "Linear"\n' - "}", + tpi, + "{\n" + ' "type": "MovingPoint",\n' + ' "bbox": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 1,\n" + " 1\n" + " ]\n" + " ],\n" + ' "period": {\n' + ' "begin": "2019-09-01T00:00:00+00",\n' + ' "end": "2019-09-01T00:00:00+00",\n' + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " },\n" + ' "coordinates": [\n' + " [\n" + " 1,\n" + " 1\n" + " ]\n" + " ],\n" + ' "datetimes": [\n' + ' "2019-09-01T00:00:00+00"\n' + " ],\n" + ' "interpolation": "None"\n' + "}", + ), + ( + tpds, + "{\n" + ' "type": "MovingPoint",\n' + ' "bbox": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "period": {\n' + ' "begin": "2019-09-01T00:00:00+00",\n' + ' "end": "2019-09-02T00:00:00+00",\n' + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " },\n" + ' "coordinates": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "datetimes": [\n' + ' "2019-09-01T00:00:00+00",\n' + ' "2019-09-02T00:00:00+00"\n' + " ],\n" + ' "lower_inc": true,\n' + ' "upper_inc": true,\n' + ' "interpolation": "Discrete"\n' + "}", + ), + ( + tps, + "{\n" + ' "type": "MovingPoint",\n' + ' "bbox": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "period": {\n' + ' "begin": "2019-09-01T00:00:00+00",\n' + ' "end": "2019-09-02T00:00:00+00",\n' + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " },\n" + ' "coordinates": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "datetimes": [\n' + ' "2019-09-01T00:00:00+00",\n' + ' "2019-09-02T00:00:00+00"\n' + " ],\n" + ' "lower_inc": true,\n' + ' "upper_inc": true,\n' + ' "interpolation": "Linear"\n' + "}", + ), + ( + tpss, + "{\n" + ' "type": "MovingPoint",\n' + ' "bbox": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "period": {\n' + ' "begin": "2019-09-01T00:00:00+00",\n' + ' "end": "2019-09-05T00:00:00+00",\n' + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " },\n" + ' "sequences": [\n' + " {\n" + ' "coordinates": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 2,\n" + " 2\n" + " ]\n" + " ],\n" + ' "datetimes": [\n' + ' "2019-09-01T00:00:00+00",\n' + ' "2019-09-02T00:00:00+00"\n' + " ],\n" + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " },\n" + " {\n" + ' "coordinates": [\n' + " [\n" + " 1,\n" + " 1\n" + " ],\n" + " [\n" + " 1,\n" + " 1\n" + " ]\n" + " ],\n" + ' "datetimes": [\n' + ' "2019-09-03T00:00:00+00",\n' + ' "2019-09-05T00:00:00+00"\n' + " ],\n" + ' "lower_inc": true,\n' + ' "upper_inc": true\n' + " }\n" + " ],\n" + ' "interpolation": "Linear"\n' + "}", ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -872,13 +870,13 @@ def test_instant_n(self, temporal, n, expected): (tpds, [tpi, TGeogPointInst("Point(2 2)@2019-09-02")]), (tps, [tpi, TGeogPointInst("Point(2 2)@2019-09-02")]), ( - tpss, - [ - tpi, - TGeogPointInst("Point(2 2)@2019-09-02"), - TGeogPointInst("Point(1 1)@2019-09-03"), - TGeogPointInst("Point(1 1)@2019-09-05"), - ], + tpss, + [ + tpi, + TGeogPointInst("Point(2 2)@2019-09-02"), + TGeogPointInst("Point(1 1)@2019-09-03"), + TGeogPointInst("Point(1 1)@2019-09-05"), + ], ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -943,27 +941,27 @@ def test_timestamp_n(self, temporal, n, expected): [ (tpi, [datetime(year=2019, month=9, day=1, tzinfo=timezone.utc)]), ( - tpds, - [ - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), - ], + tpds, + [ + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), + ], ), ( - tps, - [ - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), - ], + tps, + [ + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), + ], ), ( - tpss, - [ - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), - datetime(year=2019, month=9, day=3, tzinfo=timezone.utc), - datetime(year=2019, month=9, day=5, tzinfo=timezone.utc), - ], + tpss, + [ + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), + datetime(year=2019, month=9, day=3, tzinfo=timezone.utc), + datetime(year=2019, month=9, day=5, tzinfo=timezone.utc), + ], ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -975,19 +973,19 @@ def test_timestamps(self, temporal, expected): "temporal, expected", [ ( - tpds, - [ - TGeogPointSeq("[Point(1 1)@2019-09-01]"), - TGeogPointSeq("[Point(2 2)@2019-09-02]"), - ], + tpds, + [ + TGeogPointSeq("[Point(1 1)@2019-09-01]"), + TGeogPointSeq("[Point(2 2)@2019-09-02]"), + ], ), (tps, [TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]")]), ( - tpss, - [ - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), - ], + tpss, + [ + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), + ], ), ], ids=["Discrete Sequence", "Sequence", "SequenceSet"], @@ -1076,11 +1074,11 @@ def test_length(self, temporal, expected): (tpds, TFloatSeq("{0@2019-09-01, 0@2019-09-02}")), (tps, TFloatSeq("[0@2019-09-01, 156876.1494@2019-09-02]")), ( - tpss, - TFloatSeqSet( - "{[0@2019-09-01, 156876.1494@2019-09-02]," - "[156876.1494@2019-09-03, 156876.1494@2019-09-05]}" - ), + tpss, + TFloatSeqSet( + "{[0@2019-09-01, 156876.1494@2019-09-02]," + "[156876.1494@2019-09-03, 156876.1494@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1093,11 +1091,11 @@ def test_cumulative_length(self, temporal, expected): [ (tps, TFloatSeq("Interp=Step;[1.8157@2019-09-01, 1.8157@2019-09-02]")), ( - tpss, - TFloatSeqSet( - "Interp=Step;{[1.8157@2019-09-01, 1.8157@2019-09-02]," - "[0@2019-09-03, 0@2019-09-05]}" - ), + tpss, + TFloatSeqSet( + "Interp=Step;{[1.8157@2019-09-01, 1.8157@2019-09-02]," + "[0@2019-09-03, 0@2019-09-05]}" + ), ), ], ids=["Sequence", "SequenceSet"], @@ -1124,10 +1122,10 @@ def test_speed_without_linear_interpolation_throws(self, temporal): (tpds, TFloatSeq("{1@2019-09-01, 2@2019-09-02}")), (tps, TFloatSeq("[1@2019-09-01, 2@2019-09-02]")), ( - tpss, - TFloatSeqSet( - "{[1@2019-09-01, 2@2019-09-02]," "[1@2019-09-03, 1@2019-09-05]}" - ), + tpss, + TFloatSeqSet( + "{[1@2019-09-01, 2@2019-09-02]," "[1@2019-09-03, 1@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1143,10 +1141,10 @@ def test_x_y(self, temporal, expected): (tpds3d, TFloatSeq("{1@2019-09-01, 2@2019-09-02}")), (tps3d, TFloatSeq("[1@2019-09-01, 2@2019-09-02]")), ( - tpss3d, - TFloatSeqSet( - "{[1@2019-09-01, 2@2019-09-02]," "[1@2019-09-03, 1@2019-09-05]}" - ), + tpss3d, + TFloatSeqSet( + "{[1@2019-09-01, 2@2019-09-02]," "[1@2019-09-03, 1@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1202,11 +1200,11 @@ def test_has_z(self, temporal, expected): (tpds, []), (tps, [STBox("GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])")]), ( - tpss, - [ - STBox("GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])"), - STBox("GEODSTBOX XT(((1,1),(1,1)),[2019-09-03, 2019-09-05])"), - ], + tpss, + [ + STBox("GEODSTBOX XT(((1,1),(2,2)),[2019-09-01, 2019-09-02])"), + STBox("GEODSTBOX XT(((1,1),(1,1)),[2019-09-03, 2019-09-05])"), + ], ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1234,19 +1232,19 @@ def test_is_simple(self, temporal, expected): (tpds, TFloatSeq("{0.7846@2019-09-01,0.7846@2019-09-02}")), (tps, TFloatSeq("[0.7846@2019-09-01,0.7846@2019-09-02]")), ( - tpss, - TFloatSeqSet( - "{[0.7846@2019-09-01,0.7846@2019-09-02]," - "[0.7846@2019-09-03,0.7846@2019-09-05]}" - ), + tpss, + TFloatSeqSet( + "{[0.7846@2019-09-01,0.7846@2019-09-02]," + "[0.7846@2019-09-03,0.7846@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], ) def test_bearing(self, temporal, expected): assert ( - temporal.bearing(shapely.set_srid(shapely.Point(3, 3), 4326)).round(4) - == expected + temporal.bearing(shapely.set_srid(shapely.Point(3, 3), 4326)).round(4) + == expected ) @pytest.mark.parametrize( @@ -1315,16 +1313,24 @@ class TestTGeogPointConversions(TestTGeogPoint): "temporal, expected", [ (tpi, TGeomPointInst("SRID=4326;Point(1 1)@2019-09-01")), - (tpds, - TGeomPointSeq("SRID=4326;{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}")), - (tps, - TGeomPointSeq("SRID=4326;[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]")), - ( - tpss, - TGeomPointSeqSet( - "SRID=4326;{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]," - "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + ( + tpds, + TGeomPointSeq( + "SRID=4326;{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}" + ), + ), + ( + tps, + TGeomPointSeq( + "SRID=4326;[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]" + ), + ), + ( + tpss, + TGeomPointSeqSet( + "SRID=4326;{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]," + "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1373,25 +1379,24 @@ def test_to_instant(self, temporal, expected): "temporal, interpolation, expected", [ ( - TGeogPointInst("Point(1 1)@2019-09-01"), - TInterpolation.LINEAR, - TGeogPointSeq("[Point(1 1)@2019-09-01]"), + TGeogPointInst("Point(1 1)@2019-09-01"), + TInterpolation.LINEAR, + TGeogPointSeq("[Point(1 1)@2019-09-01]"), ), ( - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - TInterpolation.DISCRETE, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + TInterpolation.DISCRETE, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), ), ( - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - TInterpolation.LINEAR, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + TInterpolation.LINEAR, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), ), ( - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), - TInterpolation.LINEAR, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + TInterpolation.LINEAR, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1405,28 +1410,24 @@ def test_to_sequence(self, temporal, interpolation, expected): "temporal, interpolation, expected", [ ( - TGeogPointInst("Point(1 1)@2019-09-01"), - TInterpolation.LINEAR, - TGeogPointSeqSet("{[Point(1 1)@2019-09-01]}"), + TGeogPointInst("Point(1 1)@2019-09-01"), + TInterpolation.LINEAR, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01]}"), ), ( - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}"), + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + TInterpolation.LINEAR, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}"), ), ( - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + TInterpolation.LINEAR, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + TInterpolation.LINEAR, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1443,58 +1444,57 @@ def test_to_sequenceset(self, temporal, interpolation, expected): (tpds, TInterpolation.DISCRETE, tpds), (tps_d, TInterpolation.DISCRETE, TGeogPointSeq("{Point(1 1)@2019-09-01}")), ( - tpss_d, - TInterpolation.DISCRETE, - TGeogPointSeq("{Point(1 1)@2019-09-01,Point(2 2)@2019-09-03}"), + tpss_d, + TInterpolation.DISCRETE, + TGeogPointSeq("{Point(1 1)@2019-09-01,Point(2 2)@2019-09-03}"), ), ( - tpi, - TInterpolation.STEPWISE, - TGeogPointSeq("Interp=Step;[Point(1 1)@2019-09-01]"), + tpi, + TInterpolation.STEPWISE, + TGeogPointSeq("Interp=Step;[Point(1 1)@2019-09-01]"), ), ( - tpds, - TInterpolation.STEPWISE, - TGeogPointSeqSet( - "Interp=Step;{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}" - ), + tpds, + TInterpolation.STEPWISE, + TGeogPointSeqSet( + "Interp=Step;{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}" + ), ), ( - tps_s, - TInterpolation.STEPWISE, - TGeogPointSeq( - "Interp=Step;[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]" - ), + tps_s, + TInterpolation.STEPWISE, + TGeogPointSeq( + "Interp=Step;[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]" + ), ), ( - tpss_s, - TInterpolation.STEPWISE, - TGeogPointSeqSet( - "Interp=Step;{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," - "[Point(2 2)@2019-09-03, Point(2 2)@2019-09-05]}" - ), + tpss_s, + TInterpolation.STEPWISE, + TGeogPointSeqSet( + "Interp=Step;{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," + "[Point(2 2)@2019-09-03, Point(2 2)@2019-09-05]}" + ), ), (tpi, TInterpolation.LINEAR, TGeogPointSeq("[Point(1 1)@2019-09-01]")), ( - tpds, - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}"), + tpds, + TInterpolation.LINEAR, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01], [Point(2 2)@2019-09-02]}"), ), ( - tps_l, - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02), [Point(2 2)@2019-09-02]}" - ), + tps_l, + TInterpolation.LINEAR, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02), [Point(2 2)@2019-09-02]}" + ), ), ( - tpss_l, - TInterpolation.LINEAR, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02)," - "[Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss_l, + TInterpolation.LINEAR, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02)," + "[Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=[ @@ -1522,87 +1522,87 @@ def test_set_interpolation(self, temporal, interpolation, expected): (tpi, timedelta(days=-4), TGeogPointInst("Point(1 1)@2019-08-28")), (tpi, timedelta(hours=2), TGeogPointInst("Point(1 1)@2019-09-01 02:00:00")), ( - tpi, - timedelta(hours=-2), - TGeogPointInst("Point(1 1)@2019-08-31 22:00:00"), + tpi, + timedelta(hours=-2), + TGeogPointInst("Point(1 1)@2019-08-31 22:00:00"), ), ( - tpds, - timedelta(days=4), - TGeogPointSeq("{Point(1 1)@2019-09-05, Point(2 2)@2019-09-06}"), + tpds, + timedelta(days=4), + TGeogPointSeq("{Point(1 1)@2019-09-05, Point(2 2)@2019-09-06}"), ), ( - tpds, - timedelta(days=-4), - TGeogPointSeq("{Point(1 1)@2019-08-28, Point(2 2)@2019-08-29}"), + tpds, + timedelta(days=-4), + TGeogPointSeq("{Point(1 1)@2019-08-28, Point(2 2)@2019-08-29}"), ), ( - tpds, - timedelta(hours=2), - TGeogPointSeq( - "{Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00}" - ), + tpds, + timedelta(hours=2), + TGeogPointSeq( + "{Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00}" + ), ), ( - tpds, - timedelta(hours=-2), - TGeogPointSeq( - "{Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00}" - ), + tpds, + timedelta(hours=-2), + TGeogPointSeq( + "{Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00}" + ), ), ( - tps, - timedelta(days=4), - TGeogPointSeq("[Point(1 1)@2019-09-05, Point(2 2)@2019-09-06]"), + tps, + timedelta(days=4), + TGeogPointSeq("[Point(1 1)@2019-09-05, Point(2 2)@2019-09-06]"), ), ( - tps, - timedelta(days=-4), - TGeogPointSeq("[Point(1 1)@2019-08-28, Point(2 2)@2019-08-29]"), + tps, + timedelta(days=-4), + TGeogPointSeq("[Point(1 1)@2019-08-28, Point(2 2)@2019-08-29]"), ), ( - tps, - timedelta(hours=2), - TGeogPointSeq( - "[Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00]" - ), + tps, + timedelta(hours=2), + TGeogPointSeq( + "[Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00]" + ), ), ( - tps, - timedelta(hours=-2), - TGeogPointSeq( - "[Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00]" - ), + tps, + timedelta(hours=-2), + TGeogPointSeq( + "[Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00]" + ), ), ( - tpss, - timedelta(days=4), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-05, Point(2 2)@2019-09-06],[Point(1 1)@2019-09-07, Point(1 1)@2019-09-09]}" - ), + tpss, + timedelta(days=4), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-05, Point(2 2)@2019-09-06],[Point(1 1)@2019-09-07, Point(1 1)@2019-09-09]}" + ), ), ( - tpss, - timedelta(days=-4), - TGeogPointSeqSet( - "{[Point(1 1)@2019-08-28, Point(2 2)@2019-08-29],[Point(1 1)@2019-08-30, Point(1 1)@2019-09-01]}" - ), + tpss, + timedelta(days=-4), + TGeogPointSeqSet( + "{[Point(1 1)@2019-08-28, Point(2 2)@2019-08-29],[Point(1 1)@2019-08-30, Point(1 1)@2019-09-01]}" + ), ), ( - tpss, - timedelta(hours=2), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00]," - "[Point(1 1)@2019-09-03 02:00:00, Point(1 1)@2019-09-05 02:00:00]}" - ), + tpss, + timedelta(hours=2), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01 02:00:00, Point(2 2)@2019-09-02 02:00:00]," + "[Point(1 1)@2019-09-03 02:00:00, Point(1 1)@2019-09-05 02:00:00]}" + ), ), ( - tpss, - timedelta(hours=-2), - TGeogPointSeqSet( - "{[Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00]," - "[Point(1 1)@2019-09-02 22:00:00, Point(1 1)@2019-09-04 22:00:00]}" - ), + tpss, + timedelta(hours=-2), + TGeogPointSeqSet( + "{[Point(1 1)@2019-08-31 22:00:00, Point(2 2)@2019-09-01 22:00:00]," + "[Point(1 1)@2019-09-02 22:00:00, Point(1 1)@2019-09-04 22:00:00]}" + ), ), ], ids=[ @@ -1633,43 +1633,43 @@ def test_shift_time(self, tpoint, delta, expected): (tpi, timedelta(days=4), TGeogPointInst("Point(1 1)@2019-09-01")), (tpi, timedelta(hours=2), TGeogPointInst("Point(1 1)@2019-09-01")), ( - tpds, - timedelta(days=4), - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-05}"), + tpds, + timedelta(days=4), + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-05}"), ), ( - tpds, - timedelta(hours=2), - TGeogPointSeq( - "{Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 02:00:00}" - ), + tpds, + timedelta(hours=2), + TGeogPointSeq( + "{Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 02:00:00}" + ), ), ( - tps, - timedelta(days=4), - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-05]"), + tps, + timedelta(days=4), + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-05]"), ), ( - tps, - timedelta(hours=2), - TGeogPointSeq( - "[Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 02:00:00]" - ), + tps, + timedelta(hours=2), + TGeogPointSeq( + "[Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 02:00:00]" + ), ), ( - tpss, - timedelta(days=4), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + timedelta(days=4), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ( - tpss, - timedelta(hours=2), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 00:30:00]," - "[Point(1 1)@2019-09-01 01:00:00, Point(1 1)@2019-09-01 02:00:00]}" - ), + tpss, + timedelta(hours=2), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01 00:00:00, Point(2 2)@2019-09-01 00:30:00]," + "[Point(1 1)@2019-09-01 01:00:00, Point(1 1)@2019-09-01 02:00:00]}" + ), ), ], ids=[ @@ -1701,31 +1701,31 @@ def test_shift_scale_time(self): (tpi, timedelta(hours=12), TGeogPointInst("Point(1 1)@2019-09-01")), (tpds, timedelta(days=4), TGeogPointSeq("{Point(1 1)@2019-09-01}")), ( - tpds, - timedelta(hours=12), - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + tpds, + timedelta(hours=12), + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), ), (tps, timedelta(days=4), TGeogPointSeq("{Point(1 1)@2019-09-01}")), ( - tps, - timedelta(hours=12), - TGeogPointSeq( - "{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00, Point(2 2)@2019-09-02}" - ), + tps, + timedelta(hours=12), + TGeogPointSeq( + "{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00, Point(2 2)@2019-09-02}" + ), ), ( - tpss, - timedelta(days=4), - TGeogPointSeq("{Point(1 1)@2019-09-01,Point(1 1)@2019-09-05}"), + tpss, + timedelta(days=4), + TGeogPointSeq("{Point(1 1)@2019-09-01,Point(1 1)@2019-09-05}"), ), ( - tpss, - timedelta(hours=12), - TGeogPointSeq( - "{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00," - "Point(2 2)@2019-09-02, Point(1 1)@2019-09-03, Point(1 1)@2019-09-03 12:00:00, " - "Point(1 1)@2019-09-04, Point(1 1)@2019-09-04 12:00:00, Point(1 1)@2019-09-05}" - ), + tpss, + timedelta(hours=12), + TGeogPointSeq( + "{Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00," + "Point(2 2)@2019-09-02, Point(1 1)@2019-09-03, Point(1 1)@2019-09-03 12:00:00, " + "Point(1 1)@2019-09-04, Point(1 1)@2019-09-04 12:00:00, Point(1 1)@2019-09-05}" + ), ), ], ids=[ @@ -1749,9 +1749,9 @@ def test_temporal_sample(self, tpoint, delta, expected): (tps, timedelta(hours=12), None), (tpss, timedelta(days=4), None), ( - tpss, - timedelta(hours=12), - TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), + tpss, + timedelta(hours=12), + TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), ), ], ids=[ @@ -1768,44 +1768,101 @@ def test_stops(self, tpoint, delta, expected): "temporal, expected", [ ( - TGeogPointInst("Point(1.123456789 1.123456789)@2019-09-01"), - TGeogPointInst("Point(1.12 1.12)@2019-09-01"), + TGeogPointInst("Point(1.123456789 1.123456789)@2019-09-01"), + TGeogPointInst("Point(1.12 1.12)@2019-09-01"), ), ( - TGeogPointSeq( - "{Point(1.123456789 1.123456789)@2019-09-01," - "Point(2.123456789 2.123456789)@2019-09-02}" - ), - TGeogPointSeq( - "{Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02}" - ), + TGeogPointSeq( + "{Point(1.123456789 1.123456789)@2019-09-01," + "Point(2.123456789 2.123456789)@2019-09-02}" + ), + TGeogPointSeq( + "{Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02}" + ), ), ( - TGeogPointSeq( - "[Point(1.123456789 1.123456789)@2019-09-01," - "Point(2.123456789 2.123456789)@2019-09-02]" - ), - TGeogPointSeq( - "[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02]" - ), + TGeogPointSeq( + "[Point(1.123456789 1.123456789)@2019-09-01," + "Point(2.123456789 2.123456789)@2019-09-02]" + ), + TGeogPointSeq( + "[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02]" + ), ), ( - TGeogPointSeqSet( - "{[Point(1.123456789 1.123456789)@2019-09-01," - "Point(2.123456789 2.123456789)@2019-09-02]," - "[Point(1.123456789 1.123456789)@2019-09-03," - "Point(1.123456789 1.123456789)@2019-09-05]}" - ), - TGeogPointSeq( - "{[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02]," - "[Point(1.12 1.12)@2019-09-03,Point(1.12 1.12)@2019-09-05]}" - ), + TGeogPointSeqSet( + "{[Point(1.123456789 1.123456789)@2019-09-01," + "Point(2.123456789 2.123456789)@2019-09-02]," + "[Point(1.123456789 1.123456789)@2019-09-03," + "Point(1.123456789 1.123456789)@2019-09-05]}" + ), + TGeogPointSeq( + "{[Point(1.12 1.12)@2019-09-01,Point(2.12 2.12)@2019-09-02]," + "[Point(1.12 1.12)@2019-09-03,Point(1.12 1.12)@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], ) def test_round(self, temporal, expected): - assert temporal.round(max_decimals=2) + assert temporal.round(max_decimals=2) == expected + + @pytest.mark.parametrize( + "temporal, expected", + [ + ( + TGeogPointInst("Point(42.84979 42.38153)@2019-09-01"), + TGeogPointInst( + "SRID=8426;" + "Point(42.84979 42.38153)@2019-09-01" + ), + ), + ( + TGeogPointSeq( + "{Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02}" + ), + TGeogPointSeq( + "SRID=8426;" + "{Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02}" + ), + ), + ( + TGeogPointSeq( + "[Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02]" + ), + TGeogPointSeq( + "SRID=8426;" + "[Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02]" + ), + ), + ( + TGeogPointSeqSet( + "{[Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02]," + "[Point(42.28948 41.83545)@2019-09-03," + "Point(44.24505 41.53187)@2019-09-05]}" + ), + TGeogPointSeq( + "SRID=8426;" + "{[Point(42.84979 42.38153)@2019-09-01," + "Point(44.31646 41.77403)@2019-09-02]," + "[Point(42.28948 41.83545)@2019-09-03," + "Point(44.24505 41.53187)@2019-09-05]}" + ), + ), + ], + ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], + ) + def test_transform(self, temporal, expected): + srid = 8426 + transformed = temporal.transform(srid) + + assert transformed == expected + assert transformed.srid() == srid class TestTGeogPointModifications(TestTGeogPoint): @@ -1820,30 +1877,30 @@ class TestTGeogPointModifications(TestTGeogPoint): "temporal, sequence, expected", [ ( - tpi, - TGeogPointSeq("{Point(1 1)@2019-09-03}"), - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-03}"), + tpi, + TGeogPointSeq("{Point(1 1)@2019-09-03}"), + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-03}"), ), ( - tpds, - TGeogPointSeq("{Point(1 1)@2019-09-03}"), - TGeogPointSeq( - "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" - ), + tpds, + TGeogPointSeq("{Point(1 1)@2019-09-03}"), + TGeogPointSeq( + "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" + ), ), ( - tps, - TGeogPointSeq("[Point(1 1)@2019-09-03]"), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03]}" - ), + tps, + TGeogPointSeq("[Point(1 1)@2019-09-03]"), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03]}" + ), ), ( - tpss, - TGeogPointSeq("[Point(1 1)@2019-09-06]"), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05],[Point(1 1)@2019-09-06]}" - ), + tpss, + TGeogPointSeq("[Point(1 1)@2019-09-06]"), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05],[Point(1 1)@2019-09-06]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1855,28 +1912,28 @@ def test_insert(self, temporal, sequence, expected): "temporal, instant, expected", [ ( - tpi, - TGeogPointInst("Point(2 2)@2019-09-01"), - TGeogPointInst("Point(2 2)@2019-09-01"), + tpi, + TGeogPointInst("Point(2 2)@2019-09-01"), + TGeogPointInst("Point(2 2)@2019-09-01"), ), ( - tpds, - TGeogPointInst("Point(2 2)@2019-09-01"), - TGeogPointSeq("{Point(2 2)@2019-09-01, Point(2 2)@2019-09-02}"), + tpds, + TGeogPointInst("Point(2 2)@2019-09-01"), + TGeogPointSeq("{Point(2 2)@2019-09-01, Point(2 2)@2019-09-02}"), ), ( - tps, - TGeogPointInst("Point(2 2)@2019-09-01"), - TGeogPointSeqSet( - "{[Point(2 2)@2019-09-01], (Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}" - ), + tps, + TGeogPointInst("Point(2 2)@2019-09-01"), + TGeogPointSeqSet( + "{[Point(2 2)@2019-09-01], (Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}" + ), ), ( - tpss, - TGeogPointInst("Point(2 2)@2019-09-01"), - TGeogPointSeqSet( - "{[Point(2 2)@2019-09-01], (Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + TGeogPointInst("Point(2 2)@2019-09-01"), + TGeogPointSeqSet( + "{[Point(2 2)@2019-09-01], (Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1890,22 +1947,21 @@ def test_update(self, temporal, instant, expected): (tpi, datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), None), (tpi, datetime(year=2019, month=9, day=2, tzinfo=timezone.utc), tpi), ( - tpds, - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - TGeogPointSeq("{Point(2 2)@2019-09-02}"), + tpds, + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + TGeogPointSeq("{Point(2 2)@2019-09-02}"), ), ( - tps, - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tps, + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + TGeogPointSeqSet("{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - tpss, - datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + datetime(year=2019, month=9, day=1, tzinfo=timezone.utc), + TGeogPointSeqSet( + "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=[ @@ -1923,30 +1979,30 @@ def test_delete(self, temporal, time, expected): "temporal, instant, expected", [ ( - tpi, - TGeogPointInst("Point(1 1)@2019-09-02"), - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), + tpi, + TGeogPointInst("Point(1 1)@2019-09-02"), + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), ), ( - tpds, - TGeogPointInst("Point(1 1)@2019-09-03"), - TGeogPointSeq( - "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" - ), + tpds, + TGeogPointInst("Point(1 1)@2019-09-03"), + TGeogPointSeq( + "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" + ), ), ( - tps, - TGeogPointInst("Point(1 1)@2019-09-03"), - TGeogPointSeq( - "[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03]" - ), + tps, + TGeogPointInst("Point(1 1)@2019-09-03"), + TGeogPointSeq( + "[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03]" + ), ), ( - tpss, - TGeogPointInst("Point(1 1)@2019-09-06"), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-06]}" - ), + tpss, + TGeogPointInst("Point(1 1)@2019-09-06"), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-06]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1958,25 +2014,25 @@ def test_append_instant(self, temporal, instant, expected): "temporal, sequence, expected", [ ( - tpds, - TGeogPointSeq("{Point(1 1)@2019-09-03}"), - TGeogPointSeq( - "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" - ), + tpds, + TGeogPointSeq("{Point(1 1)@2019-09-03}"), + TGeogPointSeq( + "{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02, Point(1 1)@2019-09-03}" + ), ), ( - tps, - TGeogPointSeq("[Point(1 1)@2019-09-03]"), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02], [Point(1 1)@2019-09-03]}" - ), + tps, + TGeogPointSeq("[Point(1 1)@2019-09-03]"), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02], [Point(1 1)@2019-09-03]}" + ), ), ( - tpss, - TGeogPointSeq("[Point(1 1)@2019-09-06]"), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05],[Point(1 1)@2019-09-06]}" - ), + tpss, + TGeogPointSeq("[Point(1 1)@2019-09-06]"), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05],[Point(1 1)@2019-09-06]}" + ), ), ], ids=["Discrete Sequence", "Sequence", "SequenceSet"], @@ -2006,86 +2062,85 @@ class TestTGeogPointRestrictors(TestTGeogPoint): (tpi, tstzspan, TGeogPointInst("Point(1 1)@2019-09-01")), (tpi, tstzspan_set, TGeogPointInst("Point(1 1)@2019-09-01")), ( - tpi, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointInst("Point(1 1)@2019-09-01"), + tpi, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointInst("Point(1 1)@2019-09-01"), ), (tpi, shapely.set_srid(shapely.Point(2, 2), 4326), None), (tpds, timestamp, TGeogPointSeq("{Point(1 1)@2019-09-01}")), (tpds, timestamp_set, TGeogPointSeq("{Point(1 1)@2019-09-01}")), ( - tpds, - tstzspan, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + tpds, + tstzspan, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), ), ( - tpds, - tstzspan_set, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + tpds, + tstzspan_set, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), ), ( - tpds, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeq("{Point(1 1)@2019-09-01}"), + tpds, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeq("{Point(1 1)@2019-09-01}"), ), ( - tpds, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeq("{Point(2 2)@2019-09-02}"), + tpds, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeq("{Point(2 2)@2019-09-02}"), ), (tps, timestamp, TGeogPointSeq("[Point(1 1)@2019-09-01]")), (tps, timestamp_set, TGeogPointSeq("{Point(1 1)@2019-09-01}")), ( - tps, - tstzspan, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + tps, + tstzspan, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), ), ( - tps, - tstzspan_set, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + tps, + tstzspan_set, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), ), ( - tps, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeq("[Point(1 1)@2019-09-01]"), + tps, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeq("[Point(1 1)@2019-09-01]"), ), ( - tps, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeq("[Point(2 2)@2019-09-02]"), + tps, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeq("[Point(2 2)@2019-09-02]"), ), (tpss, timestamp, TGeogPointSeqSet("[Point(1 1)@2019-09-01]")), ( - tpss, - timestamp_set, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-03}"), + tpss, + timestamp_set, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-03}"), ), ( - tpss, - tstzspan, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tpss, + tstzspan, + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - tpss, - tstzspan_set, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]," - "[Point(1 1)@2019-09-03,Point(1 1)@2019-09-05]}" - ), + tpss, + tstzspan_set, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]," + "[Point(1 1)@2019-09-03,Point(1 1)@2019-09-05]}" + ), ), ( - tpss, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ( - tpss, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeqSet("{[Point(2 2)@2019-09-02]}"), + tpss, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeqSet("{[Point(2 2)@2019-09-02]}"), ), ], ids=[ @@ -2127,83 +2182,77 @@ def test_at(self, temporal, restrictor, expected): (tpi, tstzspan_set, None), (tpi, shapely.set_srid(shapely.Point(1, 1), 4326), None), ( - tpi, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointInst("Point(1 1)@2019-09-01"), + tpi, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointInst("Point(1 1)@2019-09-01"), ), (tpds, timestamp, TGeogPointSeq("{Point(2 2)@2019-09-02}")), (tpds, timestamp_set, TGeogPointSeq("{Point(2 2)@2019-09-02}")), (tpds, tstzspan, None), (tpds, tstzspan_set, None), ( - tpds, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeq("{Point(2 2)@2019-09-02}"), + tpds, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeq("{Point(2 2)@2019-09-02}"), ), ( - tpds, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeq("{Point(1 1)@2019-09-01}"), + tpds, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeq("{Point(1 1)@2019-09-01}"), ), ( - tps, - timestamp, - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tps, + timestamp, + TGeogPointSeqSet("{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - tps, - timestamp_set, - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tps, + timestamp_set, + TGeogPointSeqSet("{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), (tps, tstzspan, None), (tps, tstzspan_set, None), ( - tps, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tps, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeqSet("{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - tps, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02)}"), + tps, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeqSet("{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02)}"), ), ( - tpss, - timestamp, - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + timestamp, + TGeogPointSeqSet( + "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ( - tpss, - timestamp_set, - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],(Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + timestamp_set, + TGeogPointSeqSet( + "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],(Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ( - tpss, - tstzspan, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}"), + tpss, + tstzspan, + TGeogPointSeqSet("{[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}"), ), (tpss, tstzspan_set, None), ( - tpss, - shapely.set_srid(shapely.Point(1, 1), 4326), - TGeogPointSeqSet( - "{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), + tpss, + shapely.set_srid(shapely.Point(1, 1), 4326), + TGeogPointSeqSet("{(Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]}"), ), ( - tpss, - shapely.set_srid(shapely.Point(2, 2), 4326), - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02),[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + shapely.set_srid(shapely.Point(2, 2), 4326), + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02),[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=[ @@ -2293,9 +2342,8 @@ def test_minus(self, temporal, restrictor, expected): ) def test_at_minus(self, temporal, restrictor): assert ( - TGeogPoint.from_merge(temporal.at(restrictor), - temporal.minus(restrictor)) - == temporal + TGeogPoint.from_merge(temporal.at(restrictor), temporal.minus(restrictor)) + == temporal ) @pytest.mark.parametrize( @@ -2305,12 +2353,10 @@ def test_at_minus(self, temporal, restrictor): ) def test_at_minus_min_max(self, temporal): assert ( - TGeogPoint.from_merge(temporal.at_min(), - temporal.minus_min()) == temporal + TGeogPoint.from_merge(temporal.at_min(), temporal.minus_min()) == temporal ) assert ( - TGeogPoint.from_merge(temporal.at_max(), - temporal.minus_max()) == temporal + TGeogPoint.from_merge(temporal.at_max(), temporal.minus_max()) == temporal ) @@ -2335,14 +2381,13 @@ class TestTGeogPointEverSpatialOperations(TestTGeogPoint): def test_temporal_ever_contained_withindist_intersects(self, temporal, expected): assert temporal.is_ever_within_distance(Point(1, 1), 1) == expected assert ( - temporal.is_ever_within_distance( - TGeogPointInst("Point(1 1)@2019-09-01"), 1) - == expected + temporal.is_ever_within_distance(TGeogPointInst("Point(1 1)@2019-09-01"), 1) + == expected ) assert temporal.ever_intersects(Point(1, 1)) == expected assert ( - temporal.ever_intersects(TGeogPointInst("Point(1 1)@2019-09-01")) - == expected + temporal.ever_intersects(TGeogPointInst("Point(1 1)@2019-09-01")) + == expected ) @pytest.mark.parametrize( @@ -2358,8 +2403,8 @@ def test_temporal_ever_contained_withindist_intersects(self, temporal, expected) def test_temporal_ever_disjoint(self, temporal, expected): assert temporal.is_ever_disjoint(Point(3, 3)) == expected assert ( - temporal.is_ever_disjoint(TGeogPointInst("Point(3 3)@2019-09-01")) - == expected + temporal.is_ever_disjoint(TGeogPointInst("Point(3 3)@2019-09-01")) + == expected ) @@ -2377,17 +2422,17 @@ class TestTGeogPointTemporalSpatialOperations(TestTGeogPoint): (tpi, TBoolInst("True@2019-09-01")), (tpds, TBoolSeq("{True@2019-09-01, False@2019-09-02}")), ( - tps, - TBoolSeqSet( - "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]}" - ), + tps, + TBoolSeqSet( + "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]}" + ), ), ( - tpss, - TBoolSeqSet( - "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]," - "[True@2019-09-03, True@2019-09-05]}" - ), + tpss, + TBoolSeqSet( + "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]," + "[True@2019-09-03, True@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -2404,11 +2449,11 @@ def test_temporal_intersects_disjoint(self, temporal, expected): (tpds, TBoolSeq("{False@2019-09-01, False@2019-09-02}")), (tps, TBoolSeqSet("[False@2019-09-01, False@2019-09-02]")), ( - tpss, - TBoolSeqSet( - "{[False@2019-09-01, False@2019-09-02]," - "[False@2019-09-03, False@2019-09-05]}" - ), + tpss, + TBoolSeqSet( + "{[False@2019-09-01, False@2019-09-02]," + "[False@2019-09-03, False@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -2423,38 +2468,38 @@ def test_temporal_touches(self, temporal, expected): (tpds, Point(1, 1), TBoolSeq("{True@2019-09-01, True@2019-09-02}")), (tps, Point(1, 1), TBoolSeqSet("{[True@2019-09-01, True@2019-09-02]}")), ( - tpss, - Point(1, 1), - TBoolSeqSet( - "{[True@2019-09-01, True@2019-09-02]," - "[True@2019-09-03, True@2019-09-05]}" - ), + tpss, + Point(1, 1), + TBoolSeqSet( + "{[True@2019-09-01, True@2019-09-02]," + "[True@2019-09-03, True@2019-09-05]}" + ), ), ( - tpi, - TGeogPointInst("Point(1 1)@2019-09-01"), - TBoolInst("True@2019-09-01"), + tpi, + TGeogPointInst("Point(1 1)@2019-09-01"), + TBoolInst("True@2019-09-01"), ), ( - tpds, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}"), - TBoolSeq("{True@2019-09-01, False@2019-09-02}"), + tpds, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}"), + TBoolSeq("{True@2019-09-01, False@2019-09-02}"), ), ( - tps, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), - TBoolSeqSet("{[True@2019-09-01, True@2019-09-02]}"), + tps, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), + TBoolSeqSet("{[True@2019-09-01, True@2019-09-02]}"), ), ( - tpss, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," - "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - TBoolSeqSet( - "{[True@2019-09-01, True@2019-09-02]," - "[True@2019-09-03, True@2019-09-05]}" - ), + tpss, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," + "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + TBoolSeqSet( + "{[True@2019-09-01, True@2019-09-02]," + "[True@2019-09-03, True@2019-09-05]}" + ), ), ], ids=[ @@ -2487,53 +2532,53 @@ class TestTGeogPointDistanceOperations(TestTGeogPoint): (tpds, Point(1, 1), TFloatSeq("{0@2019-09-01, 156876.149@2019-09-02}")), (tps, Point(1, 1), TFloatSeq("[0@2019-09-01, 156876.149@2019-09-02]")), ( - tpss, - Point(1, 1), - TFloatSeqSet( - "{[0@2019-09-01, 156876.149@2019-09-02]," - "[0@2019-09-03, 0@2019-09-05]}" - ), + tpss, + Point(1, 1), + TFloatSeqSet( + "{[0@2019-09-01, 156876.149@2019-09-02]," + "[0@2019-09-03, 0@2019-09-05]}" + ), ), (tpi, STBox("GEODSTBOX X((1,1),(1,1))"), TFloatInst("0@2019-09-01")), ( - tpds, - STBox("GEODSTBOX X((1,1),(1,1))"), - TFloatSeq("{0@2019-09-01, 156876.149@2019-09-02}"), + tpds, + STBox("GEODSTBOX X((1,1),(1,1))"), + TFloatSeq("{0@2019-09-01, 156876.149@2019-09-02}"), ), ( - tps, - STBox("GEODSTBOX X((1,1),(1,1))"), - TFloatSeq("[0@2019-09-01, 156876.149@2019-09-02]"), + tps, + STBox("GEODSTBOX X((1,1),(1,1))"), + TFloatSeq("[0@2019-09-01, 156876.149@2019-09-02]"), ), ( - tpss, - STBox("GEODSTBOX X((1,1),(1,1))"), - TFloatSeqSet( - "{[0@2019-09-01, 156876.149@2019-09-02]," - "[0@2019-09-03, 0@2019-09-05]}" - ), + tpss, + STBox("GEODSTBOX X((1,1),(1,1))"), + TFloatSeqSet( + "{[0@2019-09-01, 156876.149@2019-09-02]," + "[0@2019-09-03, 0@2019-09-05]}" + ), ), (tpi, TGeogPointInst("Point(1 1)@2019-09-01"), TFloatInst("0@2019-09-01")), ( - tpds, - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}"), - TFloatSeq("{0@2019-09-01, 156876.149@2019-09-02}"), + tpds, + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}"), + TFloatSeq("{0@2019-09-01, 156876.149@2019-09-02}"), ), ( - tps, - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), - TFloatSeq("[0@2019-09-01, 156876.149@2019-09-02]"), + tps, + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]"), + TFloatSeq("[0@2019-09-01, 156876.149@2019-09-02]"), ), ( - tpss, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," - "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - TFloatSeqSet( - "{[0@2019-09-01, 156876.149@2019-09-02]," - "[0@2019-09-03, 0@2019-09-05]}" - ), + tpss, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," + "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + TFloatSeqSet( + "{[0@2019-09-01, 156876.149@2019-09-02]," + "[0@2019-09-03, 0@2019-09-05]}" + ), ), ], ids=[ @@ -2566,11 +2611,11 @@ def test_distance(self, temporal, argument, expected): (tpds, TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}")), (tps, TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]")), ( - tpss, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," - "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," + "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=[ @@ -2600,11 +2645,11 @@ def test_nearest_approach_instant(self, temporal, argument): (tpds, TGeogPointSeq("{Point(1 1)@2019-09-01, Point(1 1)@2019-09-02}")), (tps, TGeogPointSeq("[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]")), ( - tpss, - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," - "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), + tpss, + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(1 1)@2019-09-02]," + "[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), ), ], ids=[ @@ -2686,11 +2731,11 @@ class TestTGeogPointSplitOperations(TestTGeogPoint): (tpds, [TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}")]), (tps, [TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]")]), ( - tpss, - [ - TGeogPointSeq("[Point(1 1)@2019-09-01,Point(2 2)@2019-09-02]"), - TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), - ], + tpss, + [ + TGeogPointSeq("[Point(1 1)@2019-09-01,Point(2 2)@2019-09-02]"), + TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), + ], ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -2703,29 +2748,29 @@ def test_time_split(self, temporal, expected): [ (tpi, [TGeogPointInst("Point(1 1)@2019-09-01")]), ( - tpds, - [ - TGeogPointSeq("{Point(1 1)@2019-09-01}"), - TGeogPointSeq("{Point(2 2)@2019-09-02}"), - ], + tpds, + [ + TGeogPointSeq("{Point(1 1)@2019-09-01}"), + TGeogPointSeq("{Point(2 2)@2019-09-02}"), + ], ), ( - tps, - [ - TGeogPointSeq( - "[Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00+00)" - ), - TGeogPointSeq( - "[Point(1.5 1.5)@2019-09-01 12:00:00+00, Point(2 2)@2019-09-02]" - ), - ], + tps, + [ + TGeogPointSeq( + "[Point(1 1)@2019-09-01, Point(1.5 1.5)@2019-09-01 12:00:00+00)" + ), + TGeogPointSeq( + "[Point(1.5 1.5)@2019-09-01 12:00:00+00, Point(2 2)@2019-09-02]" + ), + ], ), ( - tpss, - [ - TGeogPointSeq("[Point(1 1)@2019-09-01,Point(2 2)@2019-09-02]"), - TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), - ], + tpss, + [ + TGeogPointSeq("[Point(1 1)@2019-09-01,Point(2 2)@2019-09-02]"), + TGeogPointSeq("[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]"), + ], ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -2843,18 +2888,18 @@ class TestTGeogPointTemporalComparisons(TestTGeogPoint): (tpi, TBoolInst("False@2019-09-01")), (tpds, TBoolSeq("{False@2019-09-01, False@2019-09-02}")), ( - tps, - TBoolSeqSet( - "{[False@2019-09-01, True@2019-09-01 12:00:00+00]," - "(False@2019-09-01 12:00:00+00, False@2019-09-02]}" - ), + tps, + TBoolSeqSet( + "{[False@2019-09-01, True@2019-09-01 12:00:00+00]," + "(False@2019-09-01 12:00:00+00, False@2019-09-02]}" + ), ), ( - tpss, - TBoolSeqSet( - "{[False@2019-09-01, True@2019-09-01 12:00:00+00]," - "(False@2019-09-01 12:00:00+00, False@2019-09-02],[True@2019-09-03]}" - ), + tpss, + TBoolSeqSet( + "{[False@2019-09-01, True@2019-09-01 12:00:00+00]," + "(False@2019-09-01 12:00:00+00, False@2019-09-02],[True@2019-09-03]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -2867,50 +2912,50 @@ def test_temporal_equal_temporal(self, temporal, expected): "temporal, argument, expected", [ ( - tpi, - shapely.set_srid(shapely.Point(1, 1), 4326), - TBoolInst("True@2019-09-01"), + tpi, + shapely.set_srid(shapely.Point(1, 1), 4326), + TBoolInst("True@2019-09-01"), ), ( - tpds, - shapely.set_srid(shapely.Point(1, 1), 4326), - TBoolSeq("{True@2019-09-01, False@2019-09-02}"), + tpds, + shapely.set_srid(shapely.Point(1, 1), 4326), + TBoolSeq("{True@2019-09-01, False@2019-09-02}"), ), ( - tps, - shapely.set_srid(shapely.Point(1, 1), 4326), - TBoolSeqSet( - "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]}" - ), + tps, + shapely.set_srid(shapely.Point(1, 1), 4326), + TBoolSeqSet( + "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02]}" + ), ), ( - tpss, - shapely.set_srid(shapely.Point(1, 1), 4326), - TBoolSeqSet( - "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02],[True@2019-09-03, True@2019-09-05]}" - ), + tpss, + shapely.set_srid(shapely.Point(1, 1), 4326), + TBoolSeqSet( + "{[True@2019-09-01], (False@2019-09-01, False@2019-09-02],[True@2019-09-03, True@2019-09-05]}" + ), ), ( - tpi, - shapely.set_srid(shapely.Point(2, 2), 4326), - TBoolInst("False@2019-09-01"), + tpi, + shapely.set_srid(shapely.Point(2, 2), 4326), + TBoolInst("False@2019-09-01"), ), ( - tpds, - shapely.set_srid(shapely.Point(2, 2), 4326), - TBoolSeq("{False@2019-09-01, True@2019-09-02}"), + tpds, + shapely.set_srid(shapely.Point(2, 2), 4326), + TBoolSeq("{False@2019-09-01, True@2019-09-02}"), ), ( - tps, - shapely.set_srid(shapely.Point(2, 2), 4326), - TBoolSeq("[False@2019-09-01, True@2019-09-02]"), + tps, + shapely.set_srid(shapely.Point(2, 2), 4326), + TBoolSeq("[False@2019-09-01, True@2019-09-02]"), ), ( - tpss, - shapely.set_srid(shapely.Point(2, 2), 4326), - TBoolSeqSet( - "{[False@2019-09-01, True@2019-09-02],[False@2019-09-03, False@2019-09-05]}" - ), + tpss, + shapely.set_srid(shapely.Point(2, 2), 4326), + TBoolSeqSet( + "{[False@2019-09-01, True@2019-09-02],[False@2019-09-03, False@2019-09-05]}" + ), ), ], ids=[ diff --git a/pymeos/tests/main/tgeompoint_test.py b/pymeos/tests/main/tgeompoint_test.py index 0ae0cc5a..54e29e05 100644 --- a/pymeos/tests/main/tgeompoint_test.py +++ b/pymeos/tests/main/tgeompoint_test.py @@ -1904,6 +1904,53 @@ def test_make_simple(self, temporal, expected): def test_expand(self, temporal, expected): assert temporal.expand(2) == expected + @pytest.mark.parametrize( + "temporal, expected", + [ + ( + TGeomPointInst("SRID=4326;Point(2.05455 41.62840)@2019-09-01"), + TGeomPointInst( + "SRID=2062;Point(1077794.3091235077 796037.0089003219)@2019-09-01"), + ), + ( + TGeomPointSeq( + "SRID=4326;{Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02}" + ), + TGeomPointSeq( + "SRID=2062;{Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02}" + ), + ), + ( + TGeomPointSeq( + "SRID=4326;[Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02]" + ), + TGeomPointSeq( + "SRID=2062;[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]" + ), + ), + ( + TGeomPointSeqSet( + "SRID=4326;{[Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02]," + "[Point(1.74064 41.48158)@2019-09-03," + "Point(2.54287 41.70331)@2019-09-05]}" + ), + TGeomPointSeq( + "SRID=2062;{[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]," + "[Point(1052698.1755408798 778137.4310070301)@2019-09-03,Point(1117783.9536644723 807058.9808454381)@2019-09-05]}" + ), + ), + ], + ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], + ) + def test_transform(self, temporal, expected): + srid = 2062 + transformed = temporal.transform(srid) + + assert transformed == expected + assert transformed.srid() == srid class TestTGeomPointModifications(TestTGeomPoint): tpi = TGeomPointInst("Point(1 1)@2019-09-01") From 91d24451b7563b98ea825cf4aac4ffb4956673d2 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 22:36:35 +0200 Subject: [PATCH 55/59] Remove patches and examples --- .github/workflows/test.yml | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83dd4880..7b40d0b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,7 @@ jobs: fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] -# os: [ ubuntu-latest, macos-13, macos-14 ] - os: [ macos-14 ] + os: [ ubuntu-latest, macos-13, macos-14 ] exclude: # Necessary due to issue with macOS runners. See # https://github.com/actions/setup-python/issues/808 @@ -71,19 +70,6 @@ jobs: run: | git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB - - name: Patch MEOS for macOS - if: runner.os == 'macOS' && false - run: | - cd MobilityDB - sed -i "" "s,#define HAVE_STRCHRNUL 1,//#define HAVE_STRCHRNUL 1,g" ./meos/postgres/pg_config.h.in - sed -i "" "s,#define HAVE__GET_CPUID 1,//#define HAVE__GET_CPUID 1,g" ./meos/postgres/pg_config.h.in - - - name: Patch MEOS for arm macOS - if: matrix.os == 'macos-14' - run: | - cd MobilityDB - sed -i "" "s,/* #undef USE_ARMV8_CRC32C */,#define USE_ARMV8_CRC32C 1,g" ./meos/postgres/pg_config.h.in - - name: Install MEOS run: | mkdir MobilityDB/build @@ -92,14 +78,6 @@ jobs: make -j sudo make install - - name: Run MEOS example - if: matrix.os == 'macos-14' - run: | - export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} - cd MobilityDB/meos/examples - clang -Wall -g -I/opt/homebrew/include -o arithmetic arithmetic.c -L/opt/homebrew/lib -lmeos - ./arithmetic - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -119,13 +97,6 @@ jobs: python ./pymeos_cffi/builder/build_pymeos_functions.py pip install . - - name: Run PyMEOS example - run: | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} - export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_path }} - cd pymeos - python -c "from pymeos import *; pymeos_initialize(); print(TFloatSeq(\"[1@2020-03-01, 10@2020-03-10]\") / 2)" - - name: Test PyMEOS with pytest run: | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_path }} From e287602b347a97668f30a590dc42796e2a8aa55b Mon Sep 17 00:00:00 2001 From: Diviloper Date: Tue, 2 Apr 2024 22:45:51 +0200 Subject: [PATCH 56/59] Add rounding in srid transformation tests to account for floating point precision differences --- pymeos/tests/main/tgeogpoint_test.py | 2 +- pymeos/tests/main/tgeompoint_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pymeos/tests/main/tgeogpoint_test.py b/pymeos/tests/main/tgeogpoint_test.py index 69f51a13..fcdc2601 100644 --- a/pymeos/tests/main/tgeogpoint_test.py +++ b/pymeos/tests/main/tgeogpoint_test.py @@ -1861,7 +1861,7 @@ def test_transform(self, temporal, expected): srid = 8426 transformed = temporal.transform(srid) - assert transformed == expected + assert transformed.round(5) == expected.round(5) assert transformed.srid() == srid diff --git a/pymeos/tests/main/tgeompoint_test.py b/pymeos/tests/main/tgeompoint_test.py index 54e29e05..68952793 100644 --- a/pymeos/tests/main/tgeompoint_test.py +++ b/pymeos/tests/main/tgeompoint_test.py @@ -1949,7 +1949,7 @@ def test_transform(self, temporal, expected): srid = 2062 transformed = temporal.transform(srid) - assert transformed == expected + assert transformed.round(5) == expected.round(5) assert transformed.srid() == srid class TestTGeomPointModifications(TestTGeomPoint): From 5c877de785378a2b875eb7deebefb226ed53a7ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Div=C3=AD?= <43449526+Diviloper@users.noreply.github.com> Date: Sun, 7 Apr 2024 12:22:43 +0200 Subject: [PATCH 57/59] Change branch repo to test last changes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b40d0b3..c094a269 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,10 +65,10 @@ jobs: - name: Fetch MEOS sources env: - BRANCH_NAME: test_pymeos + BRANCH_NAME: pg_config # BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/Diviloper/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/mschoema/MobilityDB - name: Install MEOS run: | From 9a5397060782606c5a754e171a8da0f0d856209e Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sun, 7 Apr 2024 20:58:48 +0200 Subject: [PATCH 58/59] Use proper remote and branch for getting meos sources --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c094a269..65456aec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,10 +65,9 @@ jobs: - name: Fetch MEOS sources env: - BRANCH_NAME: pg_config -# BRANCH_NAME: ${{ github.base_ref || github.ref_name }} + BRANCH_NAME: ${{ github.base_ref || github.ref_name }} run: | - git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/mschoema/MobilityDB + git clone --branch ${{ env.BRANCH_NAME }} --depth 1 https://github.com/MobilityDB/MobilityDB - name: Install MEOS run: | From 4206d360457cbcb0e9d819e2043947715963a4e0 Mon Sep 17 00:00:00 2001 From: Diviloper Date: Sun, 7 Apr 2024 22:55:09 +0200 Subject: [PATCH 59/59] Move is_ever_disjoint to TGeomPoint for comparisons with base geometries. Remove corresponding tests of TGeogPoint --- pymeos/pymeos/main/tpoint.py | 46 ++++++++++++++----- pymeos/tests/main/tgeogpoint_test.py | 17 ------- pymeos_cffi/pymeos_cffi/__init__.py | 2 +- pymeos_cffi/pymeos_cffi/builder/meos.h | 5 +- .../pymeos_cffi/builder/templates/init.py | 2 +- 5 files changed, 40 insertions(+), 32 deletions(-) diff --git a/pymeos/pymeos/main/tpoint.py b/pymeos/pymeos/main/tpoint.py index 031a2a20..48291bd3 100644 --- a/pymeos/pymeos/main/tpoint.py +++ b/pymeos/pymeos/main/tpoint.py @@ -51,7 +51,7 @@ class TPoint(Temporal[shp.Point, TG, TI, TS, TSS], TSimplifiable, ABC): Abstract class for temporal points. """ - _projection_cache: dict[tuple[int, int], 'LWPROJ'] = {} + _projection_cache: dict[tuple[int, int], "LWPROJ"] = {} # ------------------------- Constructors ---------------------------------- def __init__(self, _inner) -> None: @@ -502,9 +502,10 @@ def transform(self: Self, srid: int) -> Self: MEOS Functions: tpoint_transform """ - if (self.srid(), srid) not in self._projection_cache: - self._projection_cache[(self.srid(), srid)] = lwproj_transform(self.srid(), srid) - result = tpoint_transform_pj(self._inner, srid, self._projection_cache[(self.srid(), srid)]) + srids = (self.srid(), srid) + if srids not in self._projection_cache: + self._projection_cache[srids] = lwproj_transform(*srids) + result = tpoint_transform_pj(self._inner, srid, self._projection_cache[srids]) return Temporal._factory(result) # ------------------------- Restrictions ---------------------------------- @@ -774,7 +775,7 @@ def is_ever_contained_in(self, container: Union[shpb.BaseGeometry, STBox]) -> bo raise TypeError(f"Operation not supported with type {container.__class__}") return result == 1 - def is_ever_disjoint(self, other: Union[shpb.BaseGeometry, TPoint, STBox]) -> bool: + def is_ever_disjoint(self, other: TPoint) -> bool: """ Returns whether the temporal point is ever disjoint from `other`. @@ -789,12 +790,7 @@ def is_ever_disjoint(self, other: Union[shpb.BaseGeometry, TPoint, STBox]) -> bo """ from ..boxes import STBox - if isinstance(other, shpb.BaseGeometry): - gs = geo_to_gserialized(other, isinstance(self, TGeogPoint)) - result = edisjoint_tpoint_geo(self._inner, gs) - elif isinstance(other, STBox): - result = edisjoint_tpoint_geo(self._inner, stbox_to_geo(other._inner)) - elif isinstance(other, TPoint): + if isinstance(other, TPoint): result = edisjoint_tpoint_tpoint(self._inner, other._inner) else: raise TypeError(f"Operation not supported with type {other.__class__}") @@ -1651,6 +1647,34 @@ def never_not_equal(self, value: Union[shpb.BaseGeometry, TGeomPoint]) -> bool: """ return not self.ever_not_equal(value) + def is_ever_disjoint( + self, other: Union[shpb.BaseGeometry, TGeomPoint, STBox] + ) -> bool: + """ + Returns whether the temporal point is ever disjoint from `other`. + + Args: + other: An object to check for disjointness with. + + Returns: + A :class:`bool` indicating whether the temporal point is ever disjoint from `other`. + + MEOS Functions: + edisjoint_tpoint_geo, edisjoint_tpoint_tpoint + """ + from ..boxes import STBox + + if isinstance(other, shpb.BaseGeometry): + gs = geo_to_gserialized(other, isinstance(self, TGeogPoint)) + result = edisjoint_tpoint_geo(self._inner, gs) + elif isinstance(other, STBox): + result = edisjoint_tpoint_geo(self._inner, stbox_to_geo(other._inner)) + elif isinstance(other, TGeomPoint): + result = edisjoint_tpoint_tpoint(self._inner, other._inner) + else: + raise TypeError(f"Operation not supported with type {other.__class__}") + return result == 1 + # ------------------------- Temporal Comparisons -------------------------- def temporal_equal(self, other: Union[shp.Point, TGeomPoint]) -> TBool: """ diff --git a/pymeos/tests/main/tgeogpoint_test.py b/pymeos/tests/main/tgeogpoint_test.py index fcdc2601..1818c74e 100644 --- a/pymeos/tests/main/tgeogpoint_test.py +++ b/pymeos/tests/main/tgeogpoint_test.py @@ -2390,23 +2390,6 @@ def test_temporal_ever_contained_withindist_intersects(self, temporal, expected) == expected ) - @pytest.mark.parametrize( - "temporal, expected", - [ - (tpi, True), - (tpds, True), - (tps, True), - (tpss, True), - ], - ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], - ) - def test_temporal_ever_disjoint(self, temporal, expected): - assert temporal.is_ever_disjoint(Point(3, 3)) == expected - assert ( - temporal.is_ever_disjoint(TGeogPointInst("Point(3 3)@2019-09-01")) - == expected - ) - class TestTGeogPointTemporalSpatialOperations(TestTGeogPoint): tpi = TGeogPointInst("Point(1 1)@2019-09-01") diff --git a/pymeos_cffi/pymeos_cffi/__init__.py b/pymeos_cffi/pymeos_cffi/__init__.py index 150b8071..847cff76 100644 --- a/pymeos_cffi/pymeos_cffi/__init__.py +++ b/pymeos_cffi/pymeos_cffi/__init__.py @@ -2,7 +2,7 @@ from .enums import * from .errors import * -__version__ = "1.1.0" +__version__ = "1.1.1" __all__ = [ # Exceptions "MeosException", diff --git a/pymeos_cffi/pymeos_cffi/builder/meos.h b/pymeos_cffi/pymeos_cffi/builder/meos.h index b22df1fc..8c44f8ad 100644 --- a/pymeos_cffi/pymeos_cffi/builder/meos.h +++ b/pymeos_cffi/pymeos_cffi/builder/meos.h @@ -428,6 +428,7 @@ typedef enum INTERSECTS = 0, CONTAINS = 1, TOUCHES = 2, + COVERS = 3, } spatialRel; typedef struct @@ -544,9 +545,9 @@ extern int meos_errno_reset(void); typedef void (*error_handler_fn)(int, int, char *); -extern void meos_initialize_timezone(const char *name); +/* extern void meos_initialize_timezone(const char *name); (undefined) */ extern void meos_initialize_error_handler(error_handler_fn err_handler); -extern void meos_finalize_timezone(void); +/* extern void meos_finalize_timezone(void); (undefined) */ extern bool meos_set_datestyle(char *newval, void *extra); extern bool meos_set_intervalstyle(char *newval, int extra); diff --git a/pymeos_cffi/pymeos_cffi/builder/templates/init.py b/pymeos_cffi/pymeos_cffi/builder/templates/init.py index e07acbb9..49f146eb 100644 --- a/pymeos_cffi/pymeos_cffi/builder/templates/init.py +++ b/pymeos_cffi/pymeos_cffi/builder/templates/init.py @@ -2,7 +2,7 @@ from .enums import * from .errors import * -__version__ = "1.1.0" +__version__ = "1.1.1" __all__ = [ # Exceptions "MeosException",