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

Refactor package #39

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Install package
run: python -m pip install .[opensimplex]
- name: Test package
run: python -c "import topotoolbox as topo; dem = topo.GridObject.gen_random(); assert (dem.fillsinks() >= dem).z.all()"
run: python -c "import topotoolbox as topo; dem = topo.gen_random(); assert (dem.fillsinks() >= dem).z.all()"
17 changes: 14 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ SOURCEDIR = .
BUILDDIR = _build

EXAMPLEDIR = ../examples
DOCEXAMPLEDIR = $(SOURCEDIR)/_examples
DOCEXAMPLEDIR = _examples
AUTOSUMMARYDIR = _autosummary

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -22,8 +23,18 @@ html:
@echo "Copying examples directory..."
@cp -r $(EXAMPLEDIR) $(DOCEXAMPLEDIR)
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Cleaning up examples directory..."
@rm -rf $(DOCEXAMPLEDIR)
@echo "Cleaning up _examples directory..."
@rm -rf $(DOCEXAMPLEDIR)/*
@echo "Cleaning up _autosummary directory..."
@rm -rf $(AUTOSUMMARYDIR)/*

clean:
@echo "Removing everything under '_build'..."
@rm -rf $(BUILDDIR)/*
@echo "Cleaning up '_autosummary' directory..."
@rm -rf $(AUTOSUMMARYDIR)/*
@echo "Cleaning up '_examples' directory..."
@rm -rf $(DOCEXAMPLEDIR)/*

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand Down
9 changes: 8 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ API Documentation
:toctree: _autosummary
:recursive:

topotoolbox
topotoolbox.GridObject
topotoolbox.read_tif
topotoolbox.load_dem
topotoolbox.get_dem_names
topotoolbox.get_cache_contents
topotoolbox.clear_cache
topotoolbox.gen_random
topotoolbox.gen_random_bool
14 changes: 7 additions & 7 deletions examples/example_magic_funcs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"dem = topo.GridObject.gen_random_bool(rows=4, columns=4)\n",
"dem = topo.gen_random_bool(rows=4, columns=4)\n",
"for i in dem:\n",
" print(i)\n",
"\n",
Expand Down Expand Up @@ -59,8 +59,8 @@
"metadata": {},
"outputs": [],
"source": [
"dem1 = topo.GridObject.gen_random(rows=32, columns=32, hillsize=24)\n",
"dem2 = topo.GridObject.gen_random(rows=32, columns=32, hillsize=32)\n",
"dem1 = topo.gen_random(rows=32, columns=32, hillsize=24)\n",
"dem2 = topo.gen_random(rows=32, columns=32, hillsize=32)\n",
"\n",
"fig, (ax1, ax2, ax3, ax4, ax5, ax6) = plt.subplots(1, 6, figsize=(14,4))\n",
"im1 = ax1.imshow(dem1, cmap='terrain')\n",
Expand All @@ -86,8 +86,8 @@
"metadata": {},
"outputs": [],
"source": [
"dem1 = topo.GridObject.gen_random_bool()\n",
"dem2 = topo.GridObject.gen_random_bool()\n",
"dem1 = topo.gen_random_bool()\n",
"dem2 = topo.gen_random_bool()\n",
"\n",
"fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(1, 5, figsize=(12,4))\n",
"im1 = ax1.imshow(dem1, cmap='binary')\n",
Expand Down Expand Up @@ -118,8 +118,8 @@
"metadata": {},
"outputs": [],
"source": [
"dem1 = topo.GridObject.gen_random(rows=32, columns=32, hillsize=32)\n",
"dem2 = topo.GridObject.gen_random(rows=32, columns=32, hillsize=16)\n",
"dem1 = topo.gen_random(rows=32, columns=32, hillsize=32)\n",
"dem2 = topo.gen_random(rows=32, columns=32, hillsize=16)\n",
"\n",
"fig, (ax1, ax2, ax3) = plt.subplots(1, 3)\n",
"ax1.imshow(dem1, cmap='terrain')\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/test_GridObject.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"metadata": {},
"outputs": [],
"source": [
"dem = topo.GridObject.gen_random()\n",
"dem = topo.gen_random()\n",
"dem.info()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/test_genGrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"from matplotlib.colors import LightSource\n",
"\n",
"# generating Gridobject with random terrain\n",
"dem = topo.GridObject.gen_random()\n",
"dem = topo.gen_random()\n",
"\n",
"# plotting dem with hillshade\n",
"ls = LightSource(azdeg=270, altdeg=60)\n",
Expand Down
2 changes: 1 addition & 1 deletion src/topotoolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .grid_object import GridObject
from .grid_object import *
from .utils import *
Loading