Skip to content

Commit

Permalink
Merge pull request #23589 from Tobias-Fischer/pymorton
Browse files Browse the repository at this point in the history
Add pymorton
  • Loading branch information
ocefpaf authored Aug 8, 2023
2 parents bc1f466 + 36361a7 commit f41f5da
Show file tree
Hide file tree
Showing 3 changed files with 500 additions and 0 deletions.
14 changes: 14 additions & 0 deletions recipes/pymorton/fix-64-bit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/pymorton/pymorton.py b/pymorton/pymorton.py
index 895d9c7..d787307 100644
--- a/pymorton/pymorton.py
+++ b/pymorton/pymorton.py
@@ -89,7 +89,7 @@ def __unpart1by2_64(n):
return n


-if getattr(sys, 'maxint', 0) and sys.maxint <= 2 ** 31 - 1:
+if sys.version_info[0] == 2 and getattr(sys, 'maxint', 0) and sys.maxint <= 2 ** 31 - 1:
__part1by1 = __part1by1_32
__part1by2 = __part1by2_32
__unpart1by1 = __unpart1by1_32

56 changes: 56 additions & 0 deletions recipes/pymorton/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% set name = "pymorton" %}
{% set version = "1.0.7" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/trevorprater/{{ name }}/archive/refs/tags/1.0.5.tar.gz
sha256: f22ebe8c1f69ef4001c59f277dbe5403cb18f6bd3004ef19ac0e5fbdf5f865f6
patches:
# Upstream has tagged version 1.0.7 on main but did not release it on PyPi / GitHub
# See https://github.com/trevorprater/pymorton/issues/4
# This patch was created by https://github.com/trevorprater/pymorton/compare/1.0.5...master.diff
- v1.0.7.patch
# pymorton was mainly tested on Python2, where it correctly detects 32/64 bit machines.
# On Python3 however, it always default to 32bit. See https://github.com/trevorprater/pymorton/issues/5
# Upstream PR: https://github.com/trevorprater/pymorton/pull/6
- fix-64-bit.patch

build:
noarch: python
number: 0
script: "{{ PYTHON }} -m pip install . -vv"

requirements:
host:
- python >=3.6
- pip
run:
- python >=3.6

test:
imports:
- pymorton

about:
home: https://github.com/trevorprater/pymorton
license: MIT
license_file: LICENSE.md
summary: 'Ordinal hashing of multidimensional data and geographic coordinates via Morton coding / Z-ordering.'
description: |
In mathematical analysis and computer science, Z-order, Morton-order, or a Morton-code
is a function which maps multidimensional data to one dimension while preserving locality
of the data points. It was introduced in 1966 by IBM researcher, G. M. Morton. The z-value
of a point in multidimensions is calculated by interleaving the binary representations of
its coordinate values. Once the data are sorted into this ordering, any one-dimensional data
structure can be used, such as binary search trees, B-trees, skip lists, or hash tables.
The resulting ordering can equivalently be described as the order one would achieve from a
depth-first traversal of a quadtree, where {x, y, …, K} are combined into a single ordinal
value that is easily compared, searched, and indexed against other Morton numbers.
dev_url: https://github.com/trevorprater/pymorton

extra:
recipe-maintainers:
- Tobias-Fischer
Loading

0 comments on commit f41f5da

Please sign in to comment.