Skip to content

Commit

Permalink
Add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Feb 19, 2024
1 parent b613497 commit 0d0fe2c
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 46 deletions.
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: check-added-large-files
args: ["--maxkb=500"]

- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black-jupyter
language_version: python3.11

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[![image](https://static.pepy.tech/badge/leafmap)](https://pepy.tech/projects/leafmap)
[![image](https://github.com/opengeos/leafmap/workflows/docs/badge.svg)](https://leafmap.org)
[![image](https://github.com/opengeos/leafmap/workflows/Linux%20build/badge.svg)](https://github.com/opengeos/leafmap/actions)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/opengeos/leafmap/master.svg)](https://results.pre-commit.ci/latest/github/opengeos/leafmap/master)
[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![image](https://img.shields.io/badge/YouTube-Channel-red)](https://youtube.com/@giswqs)
[![status](https://joss.theoj.org/papers/10.21105/joss.03414/status.svg)](https://doi.org/10.21105/joss.03414)
Expand Down
4 changes: 2 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
**What's Changed**

- Update GitHub Actions by @giswqs in [#532](https://github.com/opengeos/leafmap/pull/532)
- Add support fot Google Solar API by @giswqs in [#534](https://github.com/opengeos/leafmap/pull/534)
- Add support for Google Solar API by @giswqs in [#534](https://github.com/opengeos/leafmap/pull/534)

**Full Changelog**: [v0.24.0...v0.24.1](https://github.com/opengeos/leafmap/compare/v0.24.0...v0.24.1)

Expand Down Expand Up @@ -1124,7 +1124,7 @@

- Added search basemaps GUI [#93](https://github.com/opengeos/leafmap/issues/93)
- Added get wms layers function
- Made streamlit map width reponsive [#126](https://github.com/opengeos/leafmap/issues/126)
- Made streamlit map width responsive [#126](https://github.com/opengeos/leafmap/issues/126)
- Added function read file from url
- Added streamlit download button
- Added SIGSPATIAL workshop notebook
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[![image](https://static.pepy.tech/badge/leafmap)](https://pepy.tech/projects/leafmap)
[![image](https://github.com/opengeos/leafmap/workflows/docs/badge.svg)](https://leafmap.org)
[![image](https://github.com/opengeos/leafmap/workflows/Linux%20build/badge.svg)](https://github.com/opengeos/leafmap/actions)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/opengeos/leafmap/master.svg)](https://results.pre-commit.ci/latest/github/opengeos/leafmap/master)
[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![image](https://img.shields.io/badge/YouTube-Channel-red)](https://youtube.com/@giswqs)
[![status](https://joss.theoj.org/papers/10.21105/joss.03414/status.svg)](https://doi.org/10.21105/joss.03414)
Expand Down
2 changes: 1 addition & 1 deletion docs/leafmap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# leafmap module

::: leafmap.leafmap
1 change: 0 additions & 1 deletion examples/batch_update.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""This script can do a batch update of notebook examples.
"""


import glob
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions leafmap/colormaps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module for commonly used colormaps and palettes for visualizing geospatial data.
"""

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
Expand Down
12 changes: 6 additions & 6 deletions leafmap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7834,7 +7834,7 @@ def vector_to_gif(
progress_bar_color (str, optional): The color of the progress bar. Defaults to "blue".
progress_bar_height (int, optional): The height of the progress bar. Defaults to 5.
dpi (int, optional): The dpi of the figure. Defaults to 300.
fps (int, optional): The frames per seconc (fps) of the gif. Defaults to 10.
fps (int, optional): The frames per second (fps) of the gif. Defaults to 10.
loop (int, optional): The number of loops of the gif. Defaults to 0, infinite loop.
mp4 (bool, optional): Whether to convert the gif to mp4. Defaults to False.
keep_png (bool, optional): Whether to keep the png files. Defaults to False.
Expand Down Expand Up @@ -9702,7 +9702,7 @@ def get_nhd_basins(
* 'ca_gages' for Streamgage catalog for CA SB19
* 'gfv11_pois' for USGS Geospatial Fabric V1.1 Points of Interest
* 'huc12pp' for HUC12 Pour Points
* 'nmwdi-st' for New Mexico Water Data Initative Sites
* 'nmwdi-st' for New Mexico Water Data Initiative Sites
* 'nwisgw' for NWIS Groundwater Sites
* 'nwissite' for NWIS Surface Water Sites
* 'ref_gage' for geoconnex.us reference gauges
Expand Down Expand Up @@ -10251,13 +10251,13 @@ def install_package(package):


def is_array(x):
"""Test whether x is either a numpy.ndarray or xarray.DataArray
"""
"""Test whether x is either a numpy.ndarray or xarray.DataArray"""
import sys
if isinstance(x, sys.modules['numpy'].ndarray):

if isinstance(x, sys.modules["numpy"].ndarray):
return True
if "xarray" in sys.modules:
if isinstance(x, sys.modules['xarray'].DataArray):
if isinstance(x, sys.modules["xarray"].DataArray):
return True
return False

Expand Down
21 changes: 10 additions & 11 deletions leafmap/foliumap.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ def add_wms_legend(
# HTML template for the legend
legend_html = f"""
{{% macro html(this, kwargs) %}}
<div id="maplegend" style="position: fixed;
<div id="maplegend" style="position: fixed;
bottom: 50px;
right: 50px;
z-index:9999;
z-index:9999;
">
<img src="{ url }" alt="legend" style="width: 100%; height: 100%;">
</div>
Expand Down Expand Up @@ -2598,7 +2598,6 @@ def split_map(
else:
right_name = "Right Layer"


if isinstance(left_layer, str):
if left_layer in basemaps.keys():
left_layer = basemaps[left_layer]
Expand Down Expand Up @@ -3009,11 +3008,11 @@ def add_text(
"""

if background:
text = f"""<div style="font-size: {fontsize}px; color: {fontcolor}; font-weight: {'bold' if bold else 'normal'};
padding: {padding}; background-color: {bg_color};
text = f"""<div style="font-size: {fontsize}px; color: {fontcolor}; font-weight: {'bold' if bold else 'normal'};
padding: {padding}; background-color: {bg_color};
border-radius: {border_radius};">{text}</div>"""
else:
text = f"""<div style="font-size: {fontsize}px; color: {fontcolor}; font-weight: {'bold' if bold else 'normal'};
text = f"""<div style="font-size: {fontsize}px; color: {fontcolor}; font-weight: {'bold' if bold else 'normal'};
padding: {padding};">{text}</div>"""

self.add_html(text, position=position, **kwargs)
Expand Down Expand Up @@ -3094,10 +3093,10 @@ def to_gradio(
else:
output.append(line + "\n")

return f"""<iframe style="width: {width}; height: {height}" name="result" allow="midi; geolocation; microphone; camera;
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
allow-scripts allow-same-origin allow-popups
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
return f"""<iframe style="width: {width}; height: {height}" name="result" allow="midi; geolocation; microphone; camera;
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
allow-scripts allow-same-origin allow-popups
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
allowpaymentrequest="" frameborder="0" srcdoc='{"".join(output)}'></iframe>"""

def oam_search(
Expand Down
7 changes: 4 additions & 3 deletions leafmap/heremap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
For more details about Here Map Widget for Jupyter
please check: https://github.com/heremaps/here-map-widget-for-jupyter
"""

import os
import json
import random
Expand Down Expand Up @@ -249,9 +250,9 @@ def add_geojson(

if not hover_style:
hover_style = {
"fillColor": random.choice(fill_colors)
if fill_colors
else ["rgba(0,0,0,0.5)"],
"fillColor": (
random.choice(fill_colors) if fill_colors else ["rgba(0,0,0,0.5)"]
),
"strokeColor": "black",
"lineWidth": style["lineWidth"] + 1,
}
Expand Down
9 changes: 5 additions & 4 deletions leafmap/osm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""The module contains functions for downloading OpenStreetMap data. It wraps the geometries module of the osmnx package
(see https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.geometries). Credits to Geoff Boeing, the developer of the osmnx package.
Most functions for downloading OpenStreetMap data require tags of map features. The list of commonly used tags can be found at
https://wiki.openstreetmap.org/wiki/Map_features
"""The module contains functions for downloading OpenStreetMap data. It wraps the geometries module of the osmnx package
(see https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.geometries). Credits to Geoff Boeing, the developer of the osmnx package.
Most functions for downloading OpenStreetMap data require tags of map features. The list of commonly used tags can be found at
https://wiki.openstreetmap.org/wiki/Map_features
"""

import warnings
from .common import check_package
from typing import Optional, Union, Tuple, Dict, List
Expand Down
1 change: 1 addition & 0 deletions leafmap/pc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A module for Microsoft Planetary Computer (PC).
"""

import json
import os
from pystac_client import Client
Expand Down
2 changes: 1 addition & 1 deletion leafmap/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6348,7 +6348,7 @@ def nasa_data_gui(

bbox = widgets.Text(
value="Map bounds",
description="Bouding box:",
description="Bounding box:",
placeholder="xmin, ymin, xmax, ymax",
style=style,
layout=widgets.Layout(width="271px", padding=padding),
Expand Down
3 changes: 3 additions & 0 deletions pyproject-codespell.precommit-toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.codespell]
ignore-words-list = "aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask,tre"
skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pystac-client
python-box
scooby
whiteboxgui
xyzservices
xyzservices
11 changes: 6 additions & 5 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ geopandas
googledrivedownloader
gradio
h5py
jupyter_bokeh
jupyterlab>=3.0.0
keplergl
ipygany
ipysheet
ipyvtklink
jupyter_bokeh
jupyterlab>=3.0.0
keplergl
laspy
localtileserver>=0.10.0
localtileserver>=0.10.1
lonboard
mapclassify>=2.4.0
mss
Expand All @@ -30,11 +30,13 @@ palettable
panel
plotly
pmtiles
pre-commit
psycopg2
pycrs
pydeck
pyntcloud[LAS]
pyvista-xarray
PyYAML==6.0.1
rasterio
rasterstats
rio-cogeo
Expand All @@ -43,4 +45,3 @@ sqlalchemy
streamlit-folium
# tippecanoe
xarray_leaflet
PyYAML==6.0.1
22 changes: 11 additions & 11 deletions requirements_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ flake8
grip
ipykernel
livereload
mkdocs
mkdocs-git-revision-date-localized-plugin
mkdocs-git-revision-date-plugin
mkdocs-jupyter>=0.24.0
mkdocs-material>=9.1.3
mkdocs-pdf-export-plugin
mkdocstrings
mkdocstrings-crystal
mkdocstrings-python-legacy
nbconvert
nbformat
pip
pygments
pymdown-extensions
sphinx
tox
twine
watchdog
wheel
mkdocs
mkdocs-git-revision-date-plugin
mkdocs-git-revision-date-localized-plugin
mkdocs-jupyter>=0.24.0
mkdocs-material>=9.1.3
mkdocs-pdf-export-plugin
mkdocstrings
mkdocstrings-crystal
mkdocstrings-python-legacy
pygments
pymdown-extensions

0 comments on commit 0d0fe2c

Please sign in to comment.