Skip to main content

Wikidata powered comparisons

Project description

    pyversions pypi pypistatus license coc codestyle

    Wikidata powered comparisons

    howmany is a Python package that uses Wikidata entity properties to easily compare the dimensions of any object. The package leverages the Wikidata REST API to easily derive amount values and then compare them given unit ratios.

    You can use howmany to find the answers to questions including:

    • How many association football pitches would fit inside Germany?
    • How many Germanys would fit inside an association football pitch?
    • And eventually anything else that Wikidata has dimensions for!

    Contents

    Installation

    howmany can be downloaded from PyPI via pip or sourced directly from this repository:

    pip install howmany
    
    git clone https://github.com/andrewtavis/howmany.git
    cd howmany
    python setup.py install
    
    import howmany
    

    Environment Setup

    The development environment for howmany can be installed via the following steps:

    1. Fork the howmany repo, clone your fork, and configure the remotes:

    [!NOTE]

    Consider using SSH

    Alternatively to using HTTPS as in the instructions below, consider SSH to interact with GitHub from the terminal. SSH allows you to connect without a user-pass authentication flow.

    To run git commands with SSH, remember then to substitute the HTTPS URL, https://github.com/..., with the SSH one, git@github.com:....

    • e.g. Cloning now becomes git clone git@github.com:<your-username>/howmany.git

    GitHub also has their documentation on how to Generate a new SSH key 🔑

    # Clone your fork of the repo into the current directory.
    git clone https://github.com/<your-username>/howmany.git
    # Navigate to the newly cloned directory.
    cd howmany
    # Assign the original repo to a remote called "upstream".
    git remote add upstream https://github.com/andrewtavis/howmany.git
    
    • Now, if you run git remote -v you should see two remote repositories named:
      • origin (forked repository)
      • upstream (howmany repository)
    1. Use Anaconda to create the local development environment within your howmany directory:

      conda env create -f environment.yml
      

    Examples

    See the examples directory for example Jupyter notebooks.

    A basic howmany workflow is:

    import howmany
    from howmany.utils import float_to_str
    
    soccer_fields_in_germany_dict = howmany.compare(
        containers="Q183", entities="Q8524", pid="P2046", iso="en"
    )
    
    for k in soccer_fields_in_germany_dict.keys():
        amount = round(soccer_fields_in_germany_dict[k]["amount"], 2)
        print(
            f"You could fit {amount:,} {soccer_fields_in_germany_dict[k]['entity']}es inside {k}."
        )
    
    # You could fit 50,453,300.88 association football pitches inside Germany.
    
    germanies_in_soccer_fields_dict = howmany.compare(
        containers="Q8524", entities="Q183", pid="P2046", iso="en"
    )
    
    for k in germanies_in_soccer_fields_dict.keys():
        amount = float_to_str(germanies_in_soccer_fields_dict[k]["amount"])
        print(
            f"You could fit {amount} {germanies_in_soccer_fields_dict[k]['entity']}s inside an {k}."
        )
    
    # You could fit 0.000000019820308731475912 Germanys inside an association football pitch.
    

    To-Do

    Please see the contribution guidelines if you are interested in contributing to this project. Work that is in progress or could be implemented includes:

    • Work to be done is a work in progress, but suggestions welcome!

    Powered By


    Wikidata

    Project details


    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distributions

    No source distribution files available for this release.See tutorial on generating distribution archives.

    Built Distribution

    howmany-0.1.0-py3-none-any.whl (7.2 kB view hashes)

    Uploaded Python 3

    Supported by

    AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page