Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#327)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.6.9](astral-sh/ruff-pre-commit@v0.5.0...v0.6.9)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Change per-file-ignores to lint.per-file-ignores in ruff.toml

* Fix E501 line too long lint errors

* Fix F821 Undefined name `predicted`

Use %%time cell magic instead of %time line magic.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wei Ji <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and weiji14 authored Oct 7, 2024
1 parent cdd3029 commit fbc7923
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [ '--maxkb=512', '--enforce-all' ]
Expand All @@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.6.9
hooks:
- id: ruff # Run the linter
args: [ --fix ]
Expand Down
25 changes: 13 additions & 12 deletions docs/finetune/finetune-on-embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"metadata": {},
"outputs": [],
"source": [
"# If not already installed, add lonboard to the environment by uncommenting the following line.\n",
"# If not installed, add lonboard to the environment by uncommenting the following line\n",
"# ! pip install lonboard"
]
},
Expand All @@ -31,17 +31,15 @@
"source": [
"from pathlib import Path\n",
"\n",
"import requests\n",
"import geopandas as gpd\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import svm\n",
"from sklearn.metrics import accuracy_score, precision_score, recall_score\n",
"from sklearn.model_selection import train_test_split\n",
"import requests\n",
"from lonboard import Map, PolygonLayer\n",
"from lonboard.colormap import apply_categorical_cmap\n",
"from sklearn.ensemble import RandomForestClassifier\n",
"\n",
"from lonboard import Map, PolygonLayer, ScatterplotLayer\n",
"from lonboard.colormap import apply_categorical_cmap"
"from sklearn.metrics import accuracy_score, precision_score, recall_score\n",
"from sklearn.model_selection import train_test_split"
]
},
{
Expand Down Expand Up @@ -558,11 +556,13 @@
"source": [
"# Open marinas training data\n",
"points = gpd.read_file(\n",
" f\"../../data/classify-embeddings-sf-baseball-marinas/marinas.geojson\"\n",
" \"../../data/classify-embeddings-sf-baseball-marinas/marinas.geojson\"\n",
")\n",
"\n",
"# Uncomement this to use the baseball training dataset.\n",
"# points = gpd.read_file(f\"../../data/classify-embeddings-sf-baseball-marinas/baseball.geojson\")\n",
"# Uncomment this to use the baseball training dataset.\n",
"# points = gpd.read_file(\n",
"# \"../../data/classify-embeddings-sf-baseball-marinas/baseball.geojson\"\n",
"# )\n",
"\n",
"# Spatial join of training data with embeddings\n",
"merged = embeddings.sjoin(points)\n",
Expand Down Expand Up @@ -692,9 +692,10 @@
}
],
"source": [
"%%time\n",
"# Make inference on entire embedding dataset\n",
"X = np.array([x for x in embeddings[\"embeddings\"]])\n",
"%time predicted = model.predict(X)\n",
"predicted = model.predict(X)\n",
"print(f\"Found {np.sum(predicted)} locations\")\n",
"\n",
"# Add inference to geopandas df and export\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/v1-inference-simsearch-naip-stacchip.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@
"import math\n",
"import os\n",
"import random\n",
"import requests\n",
"\n",
"import geopandas as gpd\n",
"import lancedb\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pystac_client\n",
"import requests\n",
"import shapely\n",
"from shapely.geometry import box, Polygon\n",
"import torch\n",
"import yaml\n",
"from box import Box\n",
"from pyproj import Transformer\n",
"from rasterio.io import MemoryFile\n",
"from shapely.geometry import box\n",
"from stacchip.chipper_mod import Chipper\n",
"from stacchip.indexer import NoStatsChipIndexer\n",
"from stacchip.processors.prechip import normalize_timestamp\n",
Expand Down Expand Up @@ -214,7 +214,7 @@
" # Obtain the item bounds and centroid\n",
" bounds, centroid_x, centroid_y = get_bounds_centroid(item.assets[\"image\"].href)\n",
" print(\n",
" f\"Bounds coordinates: {bounds}, centroid coordinates: {centroid_x}, {centroid_y}\"\n",
" f\"Bbox coordinates: {bounds}, centroid coordinates: {centroid_x}, {centroid_y}\"\n",
" )\n",
"\n",
" # Instantiate the chipper\n",
Expand Down
8 changes: 4 additions & 4 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[per-file-ignores]
"docs/clay_over_aoi.ipynb" = ["E501"]
"scripts/worldcover/worldcover_vrt.py" = ["E501"]

[format]
# https://docs.astral.sh/ruff/settings/#format
line-ending = "lf" # Use UNIX `\n` line endings for all files
Expand All @@ -18,5 +14,9 @@ select = [
"W", # pycodestyle warnings
]

[lint.per-file-ignores]
"docs/clay_over_aoi.ipynb" = ["E501"]
"scripts/worldcover/worldcover_vrt.py" = ["E501"]

[lint.pylint]
max-args = 6

0 comments on commit fbc7923

Please sign in to comment.