Skip to main content

describe-variable

Describe variables in python. Most useful for complex dicts or arrays.

Motivation: Provide simple methods that describe variables (mainly dicts) and allows to find small differences in highly nested objects.

Install:

pip install describe-variable

Example

from describe_variable import describe, diff

d1 = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                    "coordinates": [102.0, 0.5]
            },
            "properties": {
                "prop0": "value0"
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
                ]
            },
            "properties": {
                "prop0": "value0",
                "prop1": 0.0
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
                        [100.0, 1.0], [100.0, 0.0]
                    ]
                ]
            },
            "properties": {
                "prop0": "value0",
                "prop1": {"this": "that"}
            }
        }
    ]
}

d2 = {
    "type": "FeatureCollectio",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                    "coordinates": [102.0, 0.5]
            },
            "properties": {
                "prop0": "value0"
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
                ]
            },
            "properties": {
                "prop0": "value0",
                "prop1": 0.1
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "Polygn",
                "coordinates": [
                    [
                        [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
                        [100.0, 1.0], [100.0, 0.0]
                    ]
                ]
            },
            "properties": {
                "prop0": "value0",
                "prop1": {"this": "that"}
            }
        }
    ]
}

describe(d1, 3)
#     type: dict, size: 2, components: mixed
#     type -> FeatureCollection, type: str
#     features -> type: list, size: 3, components: dict
#         0 -> type: dict, size: 3, components: mixed
#             type -> Feature, type: str
#             geometry -> type: dict, size: 2, components: mixed
#             properties -> type: dict, size: 1, components: str
#         1 -> type: dict, size: 3, components: mixed
#             type -> Feature, type: str
#             geometry -> type: dict, size: 2, components: mixed
#             properties -> type: dict, size: 2, components: mixed
#         2 -> type: dict, size: 3, components: mixed
#             type -> Feature, type: str
#             geometry -> type: dict, size: 2, components: mixed
#             properties -> type: dict, size: 2, components: mixed

diff(d1, d2, 4)

#       type: dict, size: 2, components: mixed
# -     type -> FeatureCollection, type: str
# ?                             -
# +     type -> FeatureCollectio, type: str
#       features -> type: list, size: 3, components: dict
#           0 -> type: dict, size: 3, components: mixed
#               type -> Feature, type: str
#               geometry -> type: dict, size: 2, components: mixed
#                   type -> Point, type: str
#                   coordinates -> type: list, size: 2, components: float
#               properties -> type: dict, size: 1, components: str
#                   prop0 -> value0, type: str
#           1 -> type: dict, size: 3, components: mixed
#               type -> Feature, type: str
#               geometry -> type: dict, size: 2, components: mixed
#                   type -> LineString, type: str
#                   coordinates -> type: list, size: 4, components: list
#               properties -> type: dict, size: 2, components: mixed
#                   prop0 -> value0, type: str
# -                 prop1 -> 0.0, type: float
# ?                            ^
# +                 prop1 -> 0.1, type: float
# ?                            ^
#           2 -> type: dict, size: 3, components: mixed
#               type -> Feature, type: str
#               geometry -> type: dict, size: 2, components: mixed
# -                 type -> Polygon, type: str
# ?                              -
# +                 type -> Polygn, type: str
#                   coordinates -> type: list, size: 1, components: list
#               properties -> type: dict, size: 2, components: mixed
#                   prop0 -> value0, type: str
#                   prop1 -> type: dict, size: 1, components: str

Release files for describe-variable 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for describe-variable 0.1.3
File Size Uploaded
describe-variable-0.1.3.tar.gz 15.0 kB Details

Release files / describe-variable-0.1.3.tar.gz

Download URL describe-variable-0.1.3.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5090c90e19d1a908adef878363bc10729b5e80218b242aa7c51881eeb2faf0b1
BLAKE2b-256 checksum
How to use checksums
5cc911814126d548dd41f681b1250f8a8e073a8e0c1fde244005441f4022abac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page