Skip to content

Commit

Permalink
Update configuration, metadata and tests
Browse files Browse the repository at this point in the history
- Update pyproject.toml to sync with Mesa approach (e.g. use of Hatch)
- Remove setup files
- Update README badging
- fix ruff failures with updates
- minimize pytests failures
- update build_lint
- update .gitignore
  • Loading branch information
tpike3 authored and rht committed Jun 25, 2024
1 parent 0b98b20 commit 7fbd751
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 287 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ on:
paths-ignore:
- '**.md'
- '**.rst'
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'

# This will cancel previous run if a newer job that obsoletes the said previous
# run, is started.
# Based on https://github.com/zulip/zulip/commit/4a11642cee3c8aec976d305d51a86e60e5d70522
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}-latest
# We need an explicit timeout because sometimes the batch_runner test never
# completes.
timeout-minutes: 6
strategy:
fail-fast: False
matrix:
Expand All @@ -26,8 +39,6 @@ jobs:
python-version: "3.11"
- os: ubuntu
python-version: "3.10"
- os: ubuntu
python-version: "3.9"
# Disabled for now. See https://github.com/projectmesa/mesa/issues/1253
#- os: ubuntu
# python-version: 'pypy-3.8'
Expand All @@ -38,14 +49,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('Pipfile.lock') }}
- name: Install dependencies
run: pip install wheel && pip install .[dev]
cache: 'pip'
- name: Install uv
run: pip install uv
- name: Install Mesa-Geo
# See https://github.com/astral-sh/uv/issues/1945
run: uv pip install --system .[dev]
- name: Test with pytest
run: pytest --cov=mesa_geo tests/ --cov-report=xml
run: pytest --durations=10 --cov=mesa_geo tests/ --cov-report=xml
- if: matrix.os == 'ubuntu'
name: Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ target/

# Jupyter Notebook
.ipynb_checkpoints
.virtual_documents

# pyenv
.python-version
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Mesa-Geo: GIS Extension for Mesa Agent-Based Modeling

[![GitHub CI](https://github.com/projectmesa/mesa-geo/workflows/build/badge.svg)](https://github.com/projectmesa/mesa-geo/actions)
[![Read the Docs](https://readthedocs.org/projects/mesa-geo/badge/?version=main)](https://mesa-geo.readthedocs.io/en/main)
[![Codecov](https://codecov.io/gh/projectmesa/mesa-geo/branch/main/graph/badge.svg)](https://codecov.io/gh/projectmesa/mesa-geo)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI](https://img.shields.io/pypi/v/mesa-geo.svg)](https://pypi.org/project/mesa-geo)
[![PyPI - License](https://img.shields.io/pypi/l/mesa-geo)](https://pypi.org/project/mesa-geo/)
[![PyPI - Downloads](https://img.shields.io/pypi/dw/mesa-geo)](https://pypistats.org/packages/mesa-geo)
[![Matrix Chat](https://img.shields.io/matrix/mesa-geo:matrix.org?label=chat&logo=Matrix)](https://matrix.to/#/#mesa-geo:matrix.org)
[![DOI](https://zenodo.org/badge/DOI/10.1145/3557989.3566157.svg)](https://doi.org/10.1145/3557989.3566157)
| | |
| --- | --- |
| CI/CD | ![GitHub CI](https://github.com/projectmesa/mesa-geo/workflows/build/badge.svg)](https://github.com/projectmesa/mesa-geo/actions) [![Read the Docs](https://readthedocs.org/projects/mesa-geo/badge/?version=main)](https://mesa-geo.readthedocs.io/en/main) [![Codecov](https://codecov.io/gh/projectmesa/mesa-geo/branch/main/graph/badge.svg)](https://codecov.io/gh/projectmesa/mesa-geo) |
| Package | [![PyPI](https://img.shields.io/pypi/v/mesa-geo.svg)](https://pypi.org/project/mesa-geo) [![PyPI - License](https://img.shields.io/pypi/l/mesa-geo)](https://pypi.org/project/mesa-geo/) [![PyPI - Downloads](https://img.shields.io/pypi/dw/mesa-geo)](https://pypistats.org/packages/mesa-geo) |
| Meta | [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![PyPI - Downloads](https://img.shields.io/pypi/dw/mesa-geo)](https://pypistats.org/packages/mesa-geo) |
| Chat | [![chat](https://img.shields.io/matrix/project-mesa:matrix.org?label=chat&logo=Matrix)](https://matrix.to/#/#project-mesa:matrix.org) [![DOI](https://zenodo.org/badge/DOI/10.1145/3557989.3566157.svg)](https://doi.org/10.1145/3557989.3566157) |

Mesa-Geo implements a `GeoSpace` that can host GIS-based `GeoAgents`, which are like normal Agents, except they have a `geometry` attribute that is a [Shapely object](https://shapely.readthedocs.io/en/latest/manual.html) and a `crs` attribute for its Coordinate Reference System. You can use `Shapely` directly to create arbitrary geometries, but in most cases you will want to import your geometries from a file. Mesa-Geo allows you to create GeoAgents from any vector data file (e.g. shapefiles), valid GeoJSON objects or a GeoPandas GeoDataFrame.

Expand Down
98 changes: 23 additions & 75 deletions docs/tutorials/intro_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "6c026625",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.247846Z",
"start_time": "2022-10-17T18:18:29.927694Z"
}
},
"has_explanation": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -61,13 +62,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "c07e7a9a",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.256884Z",
"start_time": "2022-10-17T18:18:56.251192Z"
}
},
"has_explanation": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -98,36 +100,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "ebee624a",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.466576Z",
"start_time": "2022-10-17T18:18:56.260255Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Arizona\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"300\" height=\"300\" viewBox=\"-12811538.549834093 3645460.9480513427 703225.4665732495 824731.5925292019\" preserveAspectRatio=\"xMinYMin meet\"><g transform=\"matrix(1,0,0,-1,0,8115653.488631887)\"><path fill-rule=\"evenodd\" fill=\"#66cc99\" stroke=\"#555555\" stroke-width=\"5498.210616861345\" opacity=\"0.6\" d=\"M -12527738.867351461,4439200.734574991 L -12527288.246052729,4439202.128458479 L -12508853.849696854,4439263.598902545 L -12507600.837508487,4439249.659995082 L -12402414.382740978,4439312.803392472 L -12401644.60846214,4439313.221561922 L -12401605.424001383,4439315.451799259 L -12377601.71352112,4439240.4603261985 L -12328710.415803697,4439552.417190642 L -12300275.966950879,4439646.926042426 L -12281996.304687208,4438858.123574448 L -12245219.350555358,4438823.556440097 L -12176262.380663976,4438988.030103449 L -12175907.605446817,4438986.218091559 L -12163891.556971611,4439004.477610167 L -12163681.831050957,4439001.132352496 L -12163144.93714686,4439004.059452901 L -12161311.171175022,4439015.628476699 L -12159856.336749844,4439004.477610167 L -12153995.142920597,4439005.174538982 L -12138858.697798962,4438979.109432516 L -12138861.03550827,4434854.800186487 L -12138864.152454013,4434768.693846577 L -12138879.180585269,4421697.413502837 L -12138882.074892031,4421640.497765424 L -12138942.187417058,4300943.082007708 L -12138946.417557709,4290429.560855451 L -12138951.204295812,4290424.611958336 L -12138951.315615302,4285320.336593203 L -12138947.864711089,4284094.6171630565 L -12138978.032293094,4247982.192967179 L -12138978.143612584,4247671.901197422 L -12139001.854664123,4238390.353000166 L -12138998.737718381,4238374.756001986 L -12138954.321241556,4187642.8262025095 L -12138928.606439183,4158408.32769392 L -12138962.558883874,4106854.4344574283 L -12138965.453190634,4099185.8168169623 L -12138965.453190634,4099164.1988623403 L -12139014.990364037,3999062.865649208 L -12139042.0410003,3944872.6562480466 L -12139061.521911187,3944422.9137555277 L -12139046.382460441,3943928.4037631657 L -12139037.254262196,3943888.6839293553 L -12139082.895253422,3923073.5324423336 L -12139069.425595036,3913634.848547376 L -12139069.536914526,3913576.886157746 L -12139057.959687484,3907643.645384339 L -12139045.937182477,3907512.63296163 L -12139106.940263433,3904522.866389148 L -12139109.945889683,3904389.0993861244 L -12139069.536914526,3865817.18090144 L -12139069.536914526,3865817.0485009616 L -12139127.53436923,3854683.4546742523 L -12139128.313605664,3854226.9805454374 L -12139129.204161592,3853742.7483730856 L -12139129.204161592,3853088.319175208 L -12139159.594382579,3819410.1558157373 L -12139199.669399263,3775013.9171607606 L -12139200.78259417,3774354.209039173 L -12139249.206572667,3767009.4708955996 L -12139234.51239988,3765102.6664412734 L -12139233.510524465,3746361.86263323 L -12139253.436713316,3745128.714029015 L -12139252.768796371,3738497.585949321 L -12139300.858816393,3736634.312432 L -12139369.654261705,3697793.7068425557 L -12139372.993846428,3697792.0095896753 L -12139395.369064078,3676006.5625894614 L -12181350.237990683,3676206.092807694 L -12296370.099977415,3676078.1115890103 L -12329857.785795301,3676040.8382876213 L -12353883.982812705,3676014.1214804426 L -12367383.586141713,3676962.4082727795 L -12397277.09956036,3688182.1592043405 L -12420976.462552793,3697084.40625387 L -12495178.918169845,3724543.950376014 L -12564305.205006728,3749599.607987923 L -12593124.374019725,3759738.1092736498 L -12616260.237749763,3768368.1698088534 L -12634004.787221193,3774991.448910919 L -12718338.09573687,3805904.3521594447 L -12780992.935295975,3828368.480567442 L -12780523.167044828,3844592.4940302284 L -12780300.194104766,3845149.3085231413 L -12779399.842063231,3845649.314054805 L -12777459.543338707,3845640.722716037 L -12774257.883464,3850036.866988943 L -12773688.929546557,3850814.36699118 L -12770531.129551224,3858033.676238337 L -12765966.919109209,3860395.833940602 L -12765795.375773897,3860343.427574881 L -12763763.683747428,3860027.406244647 L -12763699.118442768,3860023.3038458633 L -12758948.559173163,3859314.933604102 L -12758965.034457803,3859444.7475712867 L -12745728.479085537,3871716.9674616302 L -12745668.032602036,3871744.3881293572 L -12742265.107087977,3879279.5458527766 L -12742265.107087977,3879309.900315507 L -12741950.629526487,3882806.75570255 L -12742586.820416369,3891541.4466610663 L -12747344.392813891,3898417.6363337105 L -12747964.33105812,3898871.1825972656 L -12748706.386783747,3899414.239742722 L -12754058.071303634,3900166.196418312 L -12754796.564805558,3900000.3448533243 L -12755517.692466917,3899051.7562595773 L -12756075.737074262,3898785.809402031 L -12757912.953950314,3898716.1039113267 L -12759870.841154387,3899116.68379423 L -12765574.18394569,3901614.742219522 L -12769216.00108699,3907402.4826803324 L -12769032.991844127,3909293.7836326603 L -12767992.599883173,3912732.7417851854 L -12766906.678250484,3914193.349537933 L -12766047.848379014,3916496.6343536265 L -12765602.681735331,3919950.4862068305 L -12765238.444361458,3929665.8619766864 L -12768357.05989603,3940659.9696776783 L -12770709.240736492,3948106.6772526456 L -12764480.358629154,3950566.459966926 L -12760233.186096918,3952993.4170166734 L -12759764.864999153,3956062.7871248517 L -12756605.172572473,3961200.6380486544 L -12752638.191198567,3966108.672229196 L -12750051.794149475,3971046.7161940904 L -12750085.301316205,3971095.6143169287 L -12750567.871308792,3972626.9251847556 L -12750603.159587374,3974069.704668992 L -12749460.019736419,3985813.354842345 L -12748748.79950974,3986700.836075745 L -12748209.345257357,3987047.874045162 L -12745690.85309765,3988175.4852888873 L -12745435.708824752,3989650.189864889 L -12746564.822419867,3996136.66764514 L -12748682.675732208,4002798.294046462 L -12748924.684305193,4007152.3603233555 L -12748133.759323107,4017732.078576477 L -12746068.6714494,4023672.3756940747 L -12742030.779559856,4027920.0040317164 L -12739209.498385193,4031838.2666098424 L -12738840.25163423,4033876.62325128 L -12738893.68498981,4039512.4448533054 L -12738665.591353176,4040679.9191492046 L -12737231.684992269,4042703.457578847 L -12736250.069722453,4043586.0874017654 L -12735100.25070205,4043804.0328953606 L -12733899.44735486,4043593.2132525407 L -12731222.88151823,4044734.8859865684 L -12726224.302423138,4047359.648611627 L -12725219.532699237,4048215.0664864476 L -12717605.168209488,4052946.8521037837 L -12715564.681943247,4055927.6300045527 L -12708731.3350009,4062645.0228721146 L -12705256.831054261,4063560.182383234 L -12705059.238958105,4063819.457344355 L -12705815.432259062,4069591.4444121025 L -12710115.370229933,4075802.2819173853 L -12712628.185095612,4077429.4231002294 L -12719845.584281195,4082818.852477109 L -12728229.055132834,4089580.99424453 L -12740799.252033211,4116891.498298443 L -12742253.084582971,4122138.7514968473 L -12751946.229243796,4132244.802374223 L -12760892.865399359,4146224.7321709464 L -12761129.419317296,4146907.498589872 L -12761301.853208533,4148821.4211966754 L -12760650.856826374,4151285.686766206 L -12760443.579934517,4161998.871891516 L -12760463.060845407,4162778.674420359 L -12760888.63525871,4164164.490845962 L -12760947.745908322,4166007.3044528225 L -12761162.035928097,4167723.0443192003 L -12759657.775649007,4176754.961223444 L -12757115.683757253,4180343.547569859 L -12755465.928903697,4180881.0101952776 L -12754822.947524875,4181391.5489661167 L -12754179.854826562,4182749.3344816417 L -12753826.08148482,4186061.5317369737 L -12753789.23473337,4188843.3826896804 L -12756760.685901111,4208167.453566348 L -12757693.877192434,4212036.22041949 L -12760234.521930808,4219671.295674917 L -12763002.815027855,4222356.982092465 L -12764129.368274683,4224416.803099634 L -12765856.824132815,4230635.906608026 L -12765755.52339619,4231910.340833609 L -12765560.49164832,4233483.044177306 L -12765133.69272062,4234861.207917779 L -12763203.301430775,4245650.837902819 L -12763158.773634456,4247197.85369304 L -12763615.183546709,4248224.845613195 L -12765752.62908943,4251333.794879019 L -12767166.386622507,4252761.605177897 L -12768379.880391644,4259473.015198671 L -12769203.867262496,4274767.815063527 L -12768970.20765132,4279847.916481287 L -12768814.360364208,4280273.665684558 L -12769027.982467042,4283945.138575711 L -12771829.448772345,4293077.681456979 L -12773196.452119287,4298381.637881596 L -12774536.96142742,4312621.917256397 L -12773339.052386994,4314209.888034963 L -12772371.463373018,4314991.6293707555 L -12760744.253879152,4320220.166873574 L -12754100.150071153,4321502.777301461 L -12747557.34699978,4321448.59689165 L -12732884.324918319,4320131.806902749 L -12731146.516347544,4319036.947532578 L -12727021.238657726,4315147.874186631 L -12725026.393382711,4312156.4670527065 L -12724623.19418706,4311158.826299924 L -12724220.106310895,4309769.472300368 L -12723001.04656722,4307657.411589617 L -12719715.229157476,4304190.850392381 L -12718546.931101598,4303400.253554336 L -12717004.93351513,4302625.128204554 L -12716391.563120859,4302587.694575585 L -12714209.812420802,4302769.909485565 L -12707579.623549154,4303905.243387924 L -12706983.396356467,4304379.836897414 L -12705806.5266998,4306303.474701652 L -12704425.497097017,4311294.768900073 L -12703801.773990102,4314696.919759348 L -12697437.41606247,4326374.885471538 L -12697134.738367002,4326708.809840202 L -12695635.932742963,4327357.929867772 L -12695665.766366495,4335157.317790335 L -12695822.615529023,4340543.126947723 L -12695587.508764468,4351911.910904246 L -12695596.970921185,4365964.312284584 L -12696050.486526676,4391301.4182878155 L -12696052.267638529,4411289.961142117 L -12696052.824235983,4417265.160257648 L -12696054.716667328,4439161.984687458 L -12686626.735033574,4439110.271928755 L -12686626.735033574,4439103.44196062 L -12575370.028433105,4439137.313070294 L -12567899.934003422,4439151.251829995 L -12535664.147178998,4439211.746259531 L -12530007.66989332,4439203.2435654 L -12528462.555361109,4439209.097878661 L -12527936.45944762,4439200.037633317 L -12527738.867351461,4439200.734574991 z\" /></g></svg>"
],
"text/plain": [
"<shapely.geometry.polygon.Polygon at 0x1345e2c70>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"has_explanation": false
},
"outputs": [],
"source": [
"m = GeoModel()\n",
"\n",
Expand All @@ -148,26 +130,16 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "0f7c0ee6",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.473375Z",
"start_time": "2022-10-17T18:18:56.469477Z"
}
},
"has_explanation": false
},
"outputs": [
{
"data": {
"text/plain": [
"113594.084"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"agent.CENSUSAREA"
]
Expand All @@ -182,23 +154,16 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "154e56b2",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.759515Z",
"start_time": "2022-10-17T18:18:56.475418Z"
}
},
"has_explanation": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['California', 'Colorado', 'Utah', 'Nevada', 'New Mexico']\n"
]
}
],
"outputs": [],
"source": [
"neighbors = m.space.get_neighbors(agent)\n",
"print([a.unique_id for a in neighbors])"
Expand All @@ -214,33 +179,16 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "63b36a85",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-17T18:18:56.769281Z",
"start_time": "2022-10-17T18:18:56.761925Z"
}
},
"has_explanation": false
},
"outputs": [
{
"data": {
"text/plain": [
"['California',\n",
" 'Nevada',\n",
" 'Arizona',\n",
" 'Utah',\n",
" 'Wyoming',\n",
" 'New Mexico',\n",
" 'Colorado',\n",
" 'Texas']"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"[a.unique_id for a in m.space.get_neighbors_within_distance(agent, 600000)]"
]
Expand Down Expand Up @@ -282,7 +230,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.12.3"
},
"toc": {
"base_numbering": 1,
Expand Down
3 changes: 1 addition & 2 deletions mesa_geo/tile_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

import dataclasses
from dataclasses import dataclass
from typing import Union

import xyzservices

LeafletOption = Union[str, bool, int, float]
LeafletOption = str | bool | int | float


@dataclass
Expand Down
Loading

0 comments on commit 7fbd751

Please sign in to comment.