Skip to content

Commit

Permalink
Set to correct name and version
Browse files Browse the repository at this point in the history
  • Loading branch information
jterry64 committed Feb 27, 2024
1 parent 67fbd5f commit ee2163c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions notebooks/tutorial/compute indicators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -796,15 +796,15 @@
"evalue": "local variable 'stats_funcs_dict' referenced before assignment",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mUnboundLocalError\u001b[0m Traceback (most recent call last)",
"File \u001b[1;32m<timed exec>:2\u001b[0m\n",
"File \u001b[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\metrics\\built_land_without_tree_cover.py:16\u001b[0m, in \u001b[0;36mbuilt_land_without_tree_cover\u001b[1;34m(zones)\u001b[0m\n\u001b[0;32m 13\u001b[0m built_up_land \u001b[38;5;241m=\u001b[39m EsaWorldCover(land_cover_class\u001b[38;5;241m=\u001b[39mEsaWorldCoverClass\u001b[38;5;241m.\u001b[39mBUILT_UP)\n\u001b[0;32m 14\u001b[0m tree_cover \u001b[38;5;241m=\u001b[39m TreeCover(min_tree_cover\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m---> 16\u001b[0m built_land \u001b[38;5;241m=\u001b[39m \u001b[43mbuilt_up_land\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgroupby\u001b[49m\u001b[43m(\u001b[49m\u001b[43mzones\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcount\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 17\u001b[0m tree_cover_in_built_land \u001b[38;5;241m=\u001b[39m tree_cover\u001b[38;5;241m.\u001b[39mmask(built_up_land)\u001b[38;5;241m.\u001b[39mgroupby(zones)\u001b[38;5;241m.\u001b[39mcount()\n\u001b[0;32m 19\u001b[0m percent_tree_cover_in_built_up_land \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;241m-\u001b[39m (tree_cover_in_built_land\u001b[38;5;241m.\u001b[39mfillna(\u001b[38;5;241m0\u001b[39m) \u001b[38;5;241m/\u001b[39m built_land)\n",
"File \u001b[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:64\u001b[0m, in \u001b[0;36mLayerGroupBy.count\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 63\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcount\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m---> 64\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_zonal_stats\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcount\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:68\u001b[0m, in \u001b[0;36mLayerGroupBy._zonal_stats\u001b[1;34m(self, stats_func)\u001b[0m\n\u001b[0;32m 66\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_zonal_stats\u001b[39m(\u001b[38;5;28mself\u001b[39m, stats_func):\n\u001b[0;32m 67\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m box(\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mzones\u001b[38;5;241m.\u001b[39mtotal_bounds)\u001b[38;5;241m.\u001b[39marea \u001b[38;5;241m<\u001b[39m\u001b[38;5;241m=\u001b[39m MAX_TILE_SIZE\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m:\n\u001b[1;32m---> 68\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_zonal_stats_tile\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mzones\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstats_func\u001b[49m\u001b[43m)\u001b[49m[stats_func]\n\u001b[0;32m 69\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 70\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_zonal_stats_fishnet(stats_func)\n",
"File \u001b[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:116\u001b[0m, in \u001b[0;36mLayerGroupBy._zonal_stats_tile\u001b[1;34m(self, tile_gdf, stats_func)\u001b[0m\n\u001b[0;32m 113\u001b[0m aggregate_data \u001b[38;5;241m=\u001b[39m aggregate_data\u001b[38;5;241m.\u001b[39mwhere(\u001b[38;5;241m~\u001b[39mnp\u001b[38;5;241m.\u001b[39misnan(mask))\n\u001b[0;32m 115\u001b[0m zones \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_rasterize(tile_gdf, align_to)\n\u001b[1;32m--> 116\u001b[0m stats \u001b[38;5;241m=\u001b[39m \u001b[43mzonal_stats\u001b[49m\u001b[43m(\u001b[49m\u001b[43mzones\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maggregate_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstats_funcs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstats_func\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 118\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m stats\n",
"File \u001b[1;32m~\\anaconda3\\envs\\citymetrix_env\\lib\\site-packages\\xrspatial\\zonal.py:579\u001b[0m, in \u001b[0;36mstats\u001b[1;34m(zones, values, zone_ids, stats_funcs, nodata_values, return_type)\u001b[0m\n\u001b[0;32m 568\u001b[0m stats_funcs_dict \u001b[38;5;241m=\u001b[39m stats_funcs\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[0;32m 570\u001b[0m mapper \u001b[38;5;241m=\u001b[39m ArrayTypeFunctionMapping(\n\u001b[0;32m 571\u001b[0m numpy_func\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mlambda\u001b[39;00m \u001b[38;5;241m*\u001b[39margs: _stats_numpy(\u001b[38;5;241m*\u001b[39margs, return_type\u001b[38;5;241m=\u001b[39mreturn_type),\n\u001b[0;32m 572\u001b[0m dask_func\u001b[38;5;241m=\u001b[39m_stats_dask_numpy,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 576\u001b[0m ),\n\u001b[0;32m 577\u001b[0m )\n\u001b[0;32m 578\u001b[0m result \u001b[38;5;241m=\u001b[39m mapper(values)(\n\u001b[1;32m--> 579\u001b[0m zones\u001b[38;5;241m.\u001b[39mdata, values\u001b[38;5;241m.\u001b[39mdata, zone_ids, \u001b[43mstats_funcs_dict\u001b[49m, nodata_values,\n\u001b[0;32m 580\u001b[0m )\n\u001b[0;32m 582\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m return_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mxarray.DataArray\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m 583\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m xr\u001b[38;5;241m.\u001b[39mDataArray(\n\u001b[0;32m 584\u001b[0m result,\n\u001b[0;32m 585\u001b[0m coords\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mstats\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;28mlist\u001b[39m(stats_funcs_dict\u001b[38;5;241m.\u001b[39mkeys()), \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mvalues\u001b[38;5;241m.\u001b[39mcoords},\n\u001b[0;32m 586\u001b[0m dims\u001b[38;5;241m=\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mstats\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;241m*\u001b[39mvalues\u001b[38;5;241m.\u001b[39mdims),\n\u001b[0;32m 587\u001b[0m attrs\u001b[38;5;241m=\u001b[39mvalues\u001b[38;5;241m.\u001b[39mattrs\n\u001b[0;32m 588\u001b[0m )\n",
"\u001b[1;31mUnboundLocalError\u001b[0m: local variable 'stats_funcs_dict' referenced before assignment"
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[1;31mUnboundLocalError\u001B[0m Traceback (most recent call last)",
"File \u001B[1;32m<timed exec>:2\u001B[0m\n",
"File \u001B[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\metrics\\built_land_without_tree_cover.py:16\u001B[0m, in \u001B[0;36mbuilt_land_without_tree_cover\u001B[1;34m(zones)\u001B[0m\n\u001B[0;32m 13\u001B[0m built_up_land \u001B[38;5;241m=\u001B[39m EsaWorldCover(land_cover_class\u001B[38;5;241m=\u001B[39mEsaWorldCoverClass\u001B[38;5;241m.\u001B[39mBUILT_UP)\n\u001B[0;32m 14\u001B[0m tree_cover \u001B[38;5;241m=\u001B[39m TreeCover(min_tree_cover\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m1\u001B[39m)\n\u001B[1;32m---> 16\u001B[0m built_land \u001B[38;5;241m=\u001B[39m \u001B[43mbuilt_up_land\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mgroupby\u001B[49m\u001B[43m(\u001B[49m\u001B[43mzones\u001B[49m\u001B[43m)\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcount\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 17\u001B[0m tree_cover_in_built_land \u001B[38;5;241m=\u001B[39m tree_cover\u001B[38;5;241m.\u001B[39mmask(built_up_land)\u001B[38;5;241m.\u001B[39mgroupby(zones)\u001B[38;5;241m.\u001B[39mcount()\n\u001B[0;32m 19\u001B[0m percent_tree_cover_in_built_up_land \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m1\u001B[39m \u001B[38;5;241m-\u001B[39m (tree_cover_in_built_land\u001B[38;5;241m.\u001B[39mfillna(\u001B[38;5;241m0\u001B[39m) \u001B[38;5;241m/\u001B[39m built_land)\n",
"File \u001B[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:64\u001B[0m, in \u001B[0;36mLayerGroupBy.count\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 63\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mcount\u001B[39m(\u001B[38;5;28mself\u001B[39m):\n\u001B[1;32m---> 64\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_zonal_stats\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mcount\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\n",
"File \u001B[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:68\u001B[0m, in \u001B[0;36mLayerGroupBy._zonal_stats\u001B[1;34m(self, stats_func)\u001B[0m\n\u001B[0;32m 66\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_zonal_stats\u001B[39m(\u001B[38;5;28mself\u001B[39m, stats_func):\n\u001B[0;32m 67\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m box(\u001B[38;5;241m*\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mzones\u001B[38;5;241m.\u001B[39mtotal_bounds)\u001B[38;5;241m.\u001B[39marea \u001B[38;5;241m<\u001B[39m\u001B[38;5;241m=\u001B[39m MAX_TILE_SIZE\u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39m\u001B[38;5;241m2\u001B[39m:\n\u001B[1;32m---> 68\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_zonal_stats_tile\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mzones\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mstats_func\u001B[49m\u001B[43m)\u001B[49m[stats_func]\n\u001B[0;32m 69\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[0;32m 70\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_zonal_stats_fishnet(stats_func)\n",
"File \u001B[1;32m~\\OneDrive - World Resources Institute\\Documents\\cities-indicators-framework\\citymetrix\\cities-cif\\city_metrix\\layers\\layer.py:116\u001B[0m, in \u001B[0;36mLayerGroupBy._zonal_stats_tile\u001B[1;34m(self, tile_gdf, stats_func)\u001B[0m\n\u001B[0;32m 113\u001B[0m aggregate_data \u001B[38;5;241m=\u001B[39m aggregate_data\u001B[38;5;241m.\u001B[39mwhere(\u001B[38;5;241m~\u001B[39mnp\u001B[38;5;241m.\u001B[39misnan(mask))\n\u001B[0;32m 115\u001B[0m zones \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_rasterize(tile_gdf, align_to)\n\u001B[1;32m--> 116\u001B[0m stats \u001B[38;5;241m=\u001B[39m \u001B[43mzonal_stats\u001B[49m\u001B[43m(\u001B[49m\u001B[43mzones\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43maggregate_data\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mstats_funcs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mstats_func\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 118\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m stats\n",
"File \u001B[1;32m~\\anaconda3\\envs\\citymetrix_env\\lib\\site-packages\\xrspatial\\zonal.py:579\u001B[0m, in \u001B[0;36mstats\u001B[1;34m(zones, values, zone_ids, stats_funcs, nodata_values, return_type)\u001B[0m\n\u001B[0;32m 568\u001B[0m stats_funcs_dict \u001B[38;5;241m=\u001B[39m stats_funcs\u001B[38;5;241m.\u001B[39mcopy()\n\u001B[0;32m 570\u001B[0m mapper \u001B[38;5;241m=\u001B[39m ArrayTypeFunctionMapping(\n\u001B[0;32m 571\u001B[0m numpy_func\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mlambda\u001B[39;00m \u001B[38;5;241m*\u001B[39margs: _stats_numpy(\u001B[38;5;241m*\u001B[39margs, return_type\u001B[38;5;241m=\u001B[39mreturn_type),\n\u001B[0;32m 572\u001B[0m dask_func\u001B[38;5;241m=\u001B[39m_stats_dask_numpy,\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 576\u001B[0m ),\n\u001B[0;32m 577\u001B[0m )\n\u001B[0;32m 578\u001B[0m result \u001B[38;5;241m=\u001B[39m mapper(values)(\n\u001B[1;32m--> 579\u001B[0m zones\u001B[38;5;241m.\u001B[39mdata, values\u001B[38;5;241m.\u001B[39mdata, zone_ids, \u001B[43mstats_funcs_dict\u001B[49m, nodata_values,\n\u001B[0;32m 580\u001B[0m )\n\u001B[0;32m 582\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m return_type \u001B[38;5;241m==\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mxarray.DataArray\u001B[39m\u001B[38;5;124m'\u001B[39m:\n\u001B[0;32m 583\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m xr\u001B[38;5;241m.\u001B[39mDataArray(\n\u001B[0;32m 584\u001B[0m result,\n\u001B[0;32m 585\u001B[0m coords\u001B[38;5;241m=\u001B[39m{\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstats\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;28mlist\u001B[39m(stats_funcs_dict\u001B[38;5;241m.\u001B[39mkeys()), \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mvalues\u001B[38;5;241m.\u001B[39mcoords},\n\u001B[0;32m 586\u001B[0m dims\u001B[38;5;241m=\u001B[39m(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstats\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;241m*\u001B[39mvalues\u001B[38;5;241m.\u001B[39mdims),\n\u001B[0;32m 587\u001B[0m attrs\u001B[38;5;241m=\u001B[39mvalues\u001B[38;5;241m.\u001B[39mattrs\n\u001B[0;32m 588\u001B[0m )\n",
"\u001B[1;31mUnboundLocalError\u001B[0m: local variable 'stats_funcs_dict' referenced before assignment"
]
}
],
Expand Down Expand Up @@ -1228,4 +1228,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from setuptools import setup

setup(
name="cities-indicators_old",
version="0.2",
name="city_metrix",
version="0.1.0",
description="Module to calculate various metrics on cities.",
packages=["city_metrix", "city_metrix.layers"],
author="Justin Terry",
Expand Down

0 comments on commit ee2163c

Please sign in to comment.