{ "info": { "author": "Gabriel Altay", "author_email": "gabriel.altay@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only" ], "description": "============\nIntroduction\n============\n\nThis is a package to convert between one dimensional distance along a\n`Hilbert curve`_, :math:`h`, and :math:`N`-dimensional coordinates,\n:math:`(x_0, x_1, ... x_N-1)`. There are two important parameters,\n\n* :math:`N` -- the number of dimensions (must be > 0)\n* :math:`p` -- the number of iterations used in constructing the Hilbert curve (must be > 0)\n\nWe consider an :math:`N`-dimensional `hypercube`_ of side length :math:`2^p`.\nThis hypercube contains :math:`2^{N p}` unit hypercubes (:math:`2^p` along\neach dimension). The number of unit hypercubes determine the possible\ndiscrete distances along the Hilbert curve (indexed from 0 to\n:math:`2^{N p} - 1`).\n\n\n==========\nQuickstart\n==========\n\nInstall the package with pip,\n\n.. code-block:: bash\n\n pip install hilbertcurve\n\nYou can calculate coordinates given distances along a hilbert curve,\n\n.. code-block:: python\n\n >>> from hilbertcurve.hilbertcurve import HilbertCurve\n >>> p=1; N=2\n >>> hilbert_curve = HilbertCurve(p, N)\n >>> for ii in range(4):\n >>> coords = hilbert_curve.coordinates_from_distance(ii)\n >>> print(f'coords(h={ii}) = {coords}')\n\n coords(h=0) = [0, 0]\n coords(h=1) = [0, 1]\n coords(h=2) = [1, 1]\n coords(h=3) = [1, 0]\n\nYou can also calculate distances along a hilbert curve given coordinates,\n\n.. code-block:: python\n\n >>> for coords in [[0,0], [0,1], [1,1], [1,0]]:\n >>> dist = hilbert_curve.distance_from_coordinates(coords)\n >>> print(f'distance(x={coords}) = {dist}')\n\n distance(x=[0, 0]) = 0\n distance(x=[0, 1]) = 1\n distance(x=[1, 1]) = 2\n distance(x=[1, 0]) = 3\n\n\n=========================\n(Absurdly) Large Integers\n=========================\n\nDue to the magic of `arbitrarily large integers in Python`_,\nthese calculations can be done with ... well ... arbitrarily large integers!\n\n.. code-block:: python\n\n >>> p = 512; N = 10\n >>> hilbert_curve = HilbertCurve(p, N)\n >>> ii = 123456789101112131415161718192021222324252627282930\n >>> coords = hilbert_curve.coordinates_from_distance(ii)\n >>> print(f'coords = {coords}')\n\n coords = [121075, 67332, 67326, 108879, 26637, 43346, 23848, 1551, 68130, 84004]\n\nThe calculations above represent the 512th iteration of the Hilbert curve in 10 dimensions.\nThe maximum value along any coordinate axis is an integer with 155 digits and the maximum\ndistance along the curve is an integer with 1542 digits. For comparison,\n`an estimate of the number of atoms in the observable universe`_\nis :math:`10^{82}` (i.e. an integer with 83 digits).\n\n=======\nVisuals\n=======\n\n\n.. figure:: n2_p3.png\n\n The figure above shows the first three iterations of the Hilbert\n curve in two (:math:`N=2`) dimensions. The :math:`p=1` iteration is shown\n in red, :math:`p=2` in blue, and :math:`p=3` in black.\n For the :math:`p=3` iteration, distances, :math:`h`, along the curve are\n labeled from 0 to 63 (i.e. from 0 to :math:`2^{N p}-1`). This package\n provides methods to translate between :math:`N`-dimensional coordinates and one\n dimensional distance. For example, between (:math:`x_0=4, x_1=6`) and\n :math:`h=36`. Note that the :math:`p=1` and :math:`p=2` iterations have been\n scaled and translated to the coordinate system of the :math:`p=3` iteration.\n\n\nAn animation of the same case in 3-D is available on YouTube. To watch the video,\nclick the link below. Once the YouTube video loads, you can right click on it and\nturn \"Loop\" on to watch the curve rotate continuously.\n\n.. figure:: https://img.youtube.com/vi/TfJEJidwkBQ/0.jpg\n\n 3-D Hilbert Curve Animation https://www.youtube.com/watch?v=TfJEJidwkBQ\n\n=========\nReference\n=========\n\nThis module is based on the C code provided in the 2004 article\n\"Programming the Hilbert Curve\" by John Skilling,\n\n* http://adsabs.harvard.edu/abs/2004AIPC..707..381S\n\nI was also helped by the discussion in the following stackoverflow post,\n\n* `mapping-n-dimensional-value-to-a-point-on-hilbert-curve`_\n\nwhich points out a typo in the source code of the paper. The Skilling code\nprovides two functions ``TransposetoAxes`` and ``AxestoTranspose``. In this\ncase, Transpose refers to a specific packing of the integer that represents\ndistance along the Hilbert curve (see below for details) and\nAxes refer to the N-dimensional coordinates. Below is an excerpt from the\ndocumentation of Skilling's code,\n\n::\n\n //+++++++++++++++++++++++++++ PUBLIC-DOMAIN SOFTWARE ++++++++++++++++++++++++++\n // Functions: TransposetoAxes AxestoTranspose\n // Purpose: Transform in-place between Hilbert transpose and geometrical axes\n // Example: b=5 bits for each of n=3 coordinates.\n // 15-bit Hilbert integer = A B C D E F G H I J K L M N O is stored\n // as its Transpose\n // X[0] = A D G J M X[2]|\n // X[1] = B E H K N <-------> | /X[1]\n // X[2] = C F I L O axes |/\n // high low 0------ X[0]\n // Axes are stored conveniently as b-bit integers.\n // Author: John Skilling 20 Apr 2001 to 11 Oct 2003\n\n\n\n.. _Hilbert curve: https://en.wikipedia.org/wiki/Hilbert_curve\n.. _hypercube: https://en.wikipedia.org/wiki/Hypercube\n.. _arbitrarily large integers in Python: https://docs.python.org/3.3/library/stdtypes.html#numeric-types-int-float-complex\n.. _an estimate of the number of atoms in the observable universe: https://www.universetoday.com/36302/atoms-in-the-universe\n.. _mapping-n-dimensional-value-to-a-point-on-hilbert-curve: http://stackoverflow.com/questions/499166/mapping-n-dimensional-value-to-a-point-on-hilbert-curve\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/galtay/hilbertcurve", "keywords": "fractal space-filling-curves hilbert hilbert-curve python python3 wikidata parser", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hilbertcurve", "package_url": "https://pypi.org/project/hilbertcurve/", "platform": "", "project_url": "https://pypi.org/project/hilbertcurve/", "project_urls": { "Homepage": "https://github.com/galtay/hilbertcurve" }, "release_url": "https://pypi.org/project/hilbertcurve/1.0.1/", "requires_dist": [ "sphinx ; extra == 'dev'", "sphinx-rtd-theme ; extra == 'dev'", "sphinx-autodoc-typehints ; extra == 'dev'", "pytest ; extra == 'dev'" ], "requires_python": ">=3.5", "summary": "Construct Hilbert Curves.", "version": "1.0.1" }, "last_serial": 4891645, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "f3c0a45dc2870600187e756b55482108", "sha256": "bb5968fdb94000b84b8f80f4e91f0fb448ef028b77ddfc62c37c2d16270e9ca9" }, "downloads": -1, "filename": "hilbertcurve-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f3c0a45dc2870600187e756b55482108", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 6250, "upload_time": "2019-03-03T19:32:25", "url": "https://files.pythonhosted.org/packages/70/79/8f7c63284d3bb35eafe9caafbab3429e194726309bde0e03e5cf4958aeb3/hilbertcurve-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff44bfa8158b6d967e163b49edefc8d2", "sha256": "b1ddf58f529219d3b76e8b61ed03e2975a724aff4848b720397c7d5601f49521" }, "downloads": -1, "filename": "hilbertcurve-1.0.1.tar.gz", "has_sig": false, "md5_digest": "ff44bfa8158b6d967e163b49edefc8d2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5648, "upload_time": "2019-03-03T19:32:27", "url": "https://files.pythonhosted.org/packages/0d/37/854cce6c8db1022182316e482d385a388fc69489d894cd9d024963883092/hilbertcurve-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3c0a45dc2870600187e756b55482108", "sha256": "bb5968fdb94000b84b8f80f4e91f0fb448ef028b77ddfc62c37c2d16270e9ca9" }, "downloads": -1, "filename": "hilbertcurve-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f3c0a45dc2870600187e756b55482108", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 6250, "upload_time": "2019-03-03T19:32:25", "url": "https://files.pythonhosted.org/packages/70/79/8f7c63284d3bb35eafe9caafbab3429e194726309bde0e03e5cf4958aeb3/hilbertcurve-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff44bfa8158b6d967e163b49edefc8d2", "sha256": "b1ddf58f529219d3b76e8b61ed03e2975a724aff4848b720397c7d5601f49521" }, "downloads": -1, "filename": "hilbertcurve-1.0.1.tar.gz", "has_sig": false, "md5_digest": "ff44bfa8158b6d967e163b49edefc8d2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5648, "upload_time": "2019-03-03T19:32:27", "url": "https://files.pythonhosted.org/packages/0d/37/854cce6c8db1022182316e482d385a388fc69489d894cd9d024963883092/hilbertcurve-1.0.1.tar.gz" } ] }