Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve documentation #1116

Merged
merged 42 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5c21170
bump to v1.9.0
gboeing Jan 20, 2024
e997203
disable typehints in function signatures in documentation for now
gboeing Jan 20, 2024
23f7f96
pull documentation param/return types from function signature annotat…
gboeing Jan 23, 2024
3b80941
improve docstrings and remove redundant type info
gboeing Jan 23, 2024
c6c60a7
add sphinx_autodoc_typehints to requirements
gboeing Jan 23, 2024
83da83b
fix package name
gboeing Jan 23, 2024
3eea5c6
add sphinx-autodoc-typehints to rtd environment
gboeing Jan 23, 2024
6deb57b
update changelog
gboeing Jan 26, 2024
1bee3c7
add endpoint_attrs param to flexibly relax simplification strictness
gboeing Jan 26, 2024
8e3c61b
improve docstrings in elevation module
gboeing Jan 27, 2024
e468a08
improve docstrings in geocoder module
gboeing Jan 27, 2024
dbe60b0
code cleanup
gboeing Jan 27, 2024
690838a
fix docstring
gboeing Jan 27, 2024
2ed9270
increase test coverage
gboeing Jan 27, 2024
424d056
improve docstrings in features and graph modules
gboeing Jan 29, 2024
1682471
improve docstrings of _http and io modules
gboeing Jan 29, 2024
80c11dc
improve docstrings of _nominatim module
gboeing Jan 29, 2024
9a908ec
replace iteration counter with enumerate
gboeing Jan 29, 2024
b814772
update ruff version
gboeing Jan 29, 2024
b8715e1
improve docstrings of _osm_xml and _overpass modules
gboeing Jan 29, 2024
70b97ce
update ruff version
gboeing Jan 30, 2024
89fd2ff
Add Dependabot configuration for GitHub Actions updates
EwoutH Jan 30, 2024
2e39e19
Merge branch 'main' into simplify
gboeing Jan 30, 2024
fb6e328
Merge pull request #1119 from EwoutH/patch-5
gboeing Jan 30, 2024
9e1f3a7
Bump actions/checkout from 3 to 4
dependabot[bot] Jan 30, 2024
498b49a
Merge pull request #1120 from gboeing/dependabot/github_actions/actio…
gboeing Jan 30, 2024
ee0dccc
improve docstrings of projection module
gboeing Jan 30, 2024
d34a2c8
improve docstrings of plot module and improve handling of save/show/c…
gboeing Jan 30, 2024
e98d1a6
deprecate address, point, network_type, edge_color, and smooth_joints…
gboeing Jan 30, 2024
99c55e1
Merge pull request #1117 from gboeing/simplify
gboeing Jan 30, 2024
5c27133
Merge pull request #1121 from gboeing/plot
gboeing Jan 30, 2024
488297f
Merge branch 'main' into dep
gboeing Jan 30, 2024
c7c191a
fix tests and docstrings
gboeing Jan 30, 2024
b545bdb
code cleanup
gboeing Jan 30, 2024
9b24303
update changelog
gboeing Jan 30, 2024
335b141
Merge pull request #1122 from gboeing/dep
gboeing Jan 30, 2024
bb920db
improve docstrings of routing, settings, and simplification modules
gboeing Jan 30, 2024
96319f4
fix docstring
gboeing Jan 30, 2024
40be9b2
improve docstrings of speed, stats, and truncate modules
gboeing Jan 31, 2024
34d7d9d
improve docstrings of the utility modules
gboeing Jan 31, 2024
6eb380a
fix docstrings
gboeing Jan 31, 2024
a87f667
docstring cleanup
gboeing Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
types_or: [markdown, yaml]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.13"
rev: "v0.1.15"
hooks:
- id: ruff
args: [--fix]
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## 2.0.0 (Unreleased)

- add type annotations to all public and private functions throughout the package (#1107)
- remove functionality previously deprecated in v1 (#1113)
- improve docstrings throughout the package (#1116)
- remove functionality previously deprecated in v1 (#1113 #1122)
- drop Python 3.8 support (#1106)
- increase add_node_elevations_google default batch_size to 512 to match Google's limit (#1115)
- make which_result function parameter consistently able to accept a list throughout package (#1113)
Expand All @@ -17,12 +18,15 @@

## 1.9.0 (Unreleased)

- add endpoint_attrs argument to simplification.simplify_graph function to flexibly relax strictness (#1117)
- fix a bug in the features module's polygon handling (#1104)
- update obsolete numpy random number generation (#1108)
- update warning messages to note that deprecated code will be removed in v2.0.0 (#1111)
- deprecate strict argument in simplification.simplify_graph function in favor of new endpoint_attrs argument (#1117)
- deprecate north, south, east, west arguments throughout package in favor of bbox tuple argument (#1112)
- deprecate return_coords argument in graph.graph_from_address function (#1105)
- deprecate return_hex argument in plot.get_colors function (#1109)
- deprecate address, point, network_type, edge_color, and smooth_joints arguments in plot.plot_figure_ground function (#1121)

## 1.8.1 (2023-12-31)

Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
furo
sphinx == 7.* # same value as needs_sphinx in /docs/source/conf.py
sphinx-autodoc-typehints
9 changes: 8 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@
"sklearn",
]

autodoc_typehints = "description"
napoleon_use_param = True
napoleon_use_rtype = False
typehints_document_rtype = True
typehints_use_rtype = False
typehints_fully_qualified = False

# general configuration and options for HTML output
# see https://www.sphinx-doc.org/en/master/usage/configuration.html
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx_autodoc_typehints"]
html_static_path: list[str] = []
html_theme = "furo"
language = "en"
Expand Down
1 change: 1 addition & 0 deletions environments/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ statsmodels
# docs
furo
sphinx
sphinx-autodoc-typehints

# packaging
conda-smithy
Expand Down
2 changes: 1 addition & 1 deletion osmnx/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class CacheOnlyInterruptError(InterruptedError):
"""Exception for settings.cache_only_mode=True interruption."""
"""Exception for `settings.cache_only_mode=True` interruption."""


class GraphSimplificationError(ValueError):
Expand Down
78 changes: 39 additions & 39 deletions osmnx/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def _save_to_cache(

Parameters
----------
url : string
the URL of the request
response_json : dict or list
the JSON response
ok : bool
requests response.ok value
url
The URL of the request.
response_json
The JSON response from the server.
ok
A `requests.response.ok` value.

Returns
-------
Expand Down Expand Up @@ -80,13 +80,13 @@ def _url_in_cache(url: str) -> Path | None:

Parameters
----------
url : string
the URL to look for in the cache
url
The URL to look for in the cache.

Returns
-------
filepath : pathlib.Path
path to cached response for url if it exists, otherwise None
filepath
Path to cached response for `url` if it exists, otherwise None.
"""
# hash the url to generate the cache filename
filename = sha1(url.encode("utf-8")).hexdigest() + ".json"
Expand All @@ -100,20 +100,20 @@ def _retrieve_from_cache(
url: str, check_remark: bool = True
) -> dict[str, Any] | list[dict[str, Any]] | None:
"""
Retrieve a HTTP response JSON object from the cache, if it exists.
Retrieve a HTTP response JSON object from the cache if it exists.

Parameters
----------
url : string
the URL of the request
check_remark : bool
if True, only return filepath if cached response does not have a
remark key indicating a server warning
url
The URL of the request.
check_remark
If True, only return filepath if cached response does not have a
remark key indicating a server warning.

Returns
-------
response_json : dict or list
cached response for url if it exists in the cache, otherwise None
response_json
Cached response for `url` if it exists in the cache, otherwise None.
"""
# if the tool is configured to use the cache
if settings.use_cache:
Expand Down Expand Up @@ -148,17 +148,17 @@ def _get_http_headers(

Parameters
----------
user_agent : string
the user agent string, if None will set with OSMnx default
referer : string
the referer string, if None will set with OSMnx default
accept_language : string
make accept-language explicit e.g. for consistent nominatim result
sorting
user_agent
The user agent string. If None, use the OSMnx default.
referer
The referer string. If None, use the OSMnx default.
accept_language
The accept language. Make it explicit for consistent Nominatim result
sorting.

Returns
-------
headers : dict
headers
"""
if user_agent is None:
user_agent = settings.default_user_agent
Expand Down Expand Up @@ -187,13 +187,13 @@ def _resolve_host_via_doh(hostname: str) -> str:

Parameters
----------
hostname : string
the hostname to consistently resolve the IP address of
hostname
The hostname to consistently resolve the IP address of.

Returns
-------
ip_address : string
resolved IP address of host, or hostname itself if resolution failed
ip_address
Resolved IP address of host, or hostname itself if resolution failed.
"""
if settings.doh_url_template is None:
# if user has set the url template to None, return hostname itself
Expand Down Expand Up @@ -243,8 +243,8 @@ def _config_dns(url: str) -> None:

Parameters
----------
url : string
the URL to consistently resolve the IP address of
url
The URL to consistently resolve the IP address of.

Returns
-------
Expand Down Expand Up @@ -279,13 +279,13 @@ def _hostname_from_url(url: str) -> str:

Parameters
----------
url : string
the url from which to extract the hostname
url
The url from which to extract the hostname.

Returns
-------
hostname : string
the extracted hostname (domain)
hostname
The extracted hostname (domain).
"""
return urlparse(url).netloc.split(":")[0]

Expand All @@ -296,12 +296,12 @@ def _parse_response(response: requests.Response) -> dict[str, Any] | list[dict[s

Parameters
----------
response : requests.response
the response object
response
The response object.

Returns
-------
response_json : dict or list
response_json
Value will be a dict if the response is from the Google or Overpass
APIs, and a list if the response is from the Nominatim API.
"""
Expand Down
40 changes: 20 additions & 20 deletions osmnx/_nominatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ def _download_nominatim_element(

Parameters
----------
query : string or dict
query string or structured query dict
by_osmid : bool
if True, treat query as an OSM ID lookup rather than text search
limit : int
max number of results to return
polygon_geojson : bool
whether to retrieve the place's geometry from the API
query
Query string or structured query dict.
by_osmid
If True, treat `query` as an OSM ID lookup rather than text search.
limit
Max number of results to return.
polygon_geojson
Whether to retrieve the place's geometry from the API.

Returns
-------
response_json : list
JSON response from the Nominatim server
response_json
"""
# define the parameters
params: OrderedDict[str, int | str] = OrderedDict()
Expand Down Expand Up @@ -87,19 +86,20 @@ def _nominatim_request(

Parameters
----------
params : OrderedDict
key-value pairs of parameters
request_type : string {"search", "reverse", "lookup"}
which Nominatim API endpoint to query
pause : float
how long to pause before request, in seconds. per the nominatim usage
policy: "an absolute maximum of 1 request per second" is allowed
error_pause : float
how long to pause in seconds before re-trying request if error
params
Key-value pairs of parameters.
request_type
{"search", "reverse", "lookup"}
Which Nominatim API endpoint to query.
pause
How long to pause before request, in seconds. Per the Nominatim usage
policy: "an absolute maximum of 1 request per second" is allowed.
error_pause
How long to pause in seconds before re-trying request if error.

Returns
-------
response_json : list
response_json
"""
if request_type not in {"search", "reverse", "lookup"}: # pragma: no cover
msg = 'Nominatim request_type must be "search", "reverse", or "lookup"'
Expand Down
Loading
Loading