8000 Combine iter records range into iter records by JamesParrott · Pull Request #310 · GeospatialPython/pyshp · GitHub
[go: up one dir, main page]

Skip to content

Combine iter records range into iter records #310

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

Merged
merged 15 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test for iterRecords new start and stop args; ensure same Records…
… returned as from Reader.record
  • Loading branch information
JamesParrott committed Oct 17, 2024
commit cc82ec82c4c14dda4b6bb802b46633504dc3ed15
24 changes: 24 additions & 0 deletions test_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import datetime
import itertools
import json
import os.path

Expand Down Expand Up @@ -968,10 +969,33 @@ def test_record_oid():
for i, record in enumerate(sf.iterRecords()):
assert record.oid == i


for i, shaperec in enumerate(sf.iterShapeRecords()):
assert shaperec.record.oid == i


def test_iterRecords_start_stop():
"""
Assert that Reader.iterRecords(start, stop)
returns the correct records, as if searched for
by Reader..
"""


with shapefile.Reader("shapefiles/blockgroups") as sf:

N = len(sf)

# Arbitrary selection of start values
for start in [0, 1, 2, 3, 5, 11, 17, 33, 51, 103, 170, 234, 435, 543, N-3, N-2, N-1]:
for stop in range(start, len(sf)):
# test negative indexing from end, as well as
# positive values of stop, and its default
for stop_arg in (stop, stop - len(sf), None):
for record in sf.iterRecords(start = start, stop = stop):
assert record == sf.record(record.oid)


def test_shape_oid():
"""
Assert that the shape's oid attribute returns
Expand Down
0