Skip to content

Commit

Permalink
Create dt_geo.py (#2858)
Browse files Browse the repository at this point in the history
* Create dt_geo.py

creating python code snippets for the geospatial data type page

* Update dt_geo.py

update for linter

* Update dt_geo.py

local lint of `black --line-length 80 dt_geo.py` passes

* add remove keywords

remove the cleanup code from ever being visible to the user

* add newline for linter
  • Loading branch information
sav-norem authored Jul 21, 2023
1 parent 5d69ec7 commit 4251f12
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions doctests/dt_geo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# EXAMPLE: geo_tutorial
# HIDE_START
import redis

r = redis.Redis(decode_responses=True)
# HIDE_END
# REMOVE_START
r.delete("bikes:rentable")
# REMOVE_END

# STEP_START geoadd
res1 = r.geoadd("bikes:rentable", [-122.27652, 37.805186, "station:1"])
print(res1) # >>> 1

res2 = r.geoadd("bikes:rentable", [-122.2674626, 37.8062344, "station:2"])
print(res2) # >>> 1

res3 = r.geoadd("bikes:rentable", [-122.2469854, 37.8104049, "station:3"])
print(res3) # >>> 1
# STEP_END

# REMOVE_START
assert res1 == 1
assert res2 == 1
assert res3 == 1
# REMOVE_END

# STEP_START geosearch
res4 = r.geosearch(
"bikes:rentable",
longitude=-122.27652,
latitude=37.805186,
radius=5,
unit="km",
)
print(res4) # >>> ['station:1', 'station:2', 'station:3']
# STEP_END

# REMOVE_START
assert res4 == ["station:1", "station:2", "station:3"]
# REMOVE_END

0 comments on commit 4251f12

Please sign in to comment.