Skip to content

Commit

Permalink
fix off-by-1 and docstring error in noextract.py
Browse files Browse the repository at this point in the history
  • Loading branch information
renae-r committed Jun 11, 2024
1 parent 82b8d2c commit b96c7a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/ipumspy/noextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read_noextract_codebook(collection: str) -> Codebook:
val["record_type"],
{v["label"]: v["value"] for v in val["values"]},
val["start_column"] - 1,
val["start_column"] + val["width"],
val["start_column"] + val["width"] - 1,
val["label"],
val["label"],
"", # No concept tracked
Expand All @@ -79,11 +79,11 @@ def download_noextract_data(collection: str, filename: Optional[FilenameType] =
Suggested usage to retrieve YRBSS data:
>>> from ipumspy.readers import read_microdata
>>> from ipumspy.noextract_collections import read_noextract_codebook, download_noextract_data
>>> from ipumspy.noextract import read_noextract_codebook, download_noextract_data
>>>
>>> yrbss_codebook = read_noextract_codebook("yrbss")
>>> download_noextract_data("yrbss")
>>> read_microdata(yrbss_codebook, "yrbss.dat.gz")
>>> read_microdata(yrbss_codebook, "ipums-yrbss.dat.gz")
N.B. You **must** use `read_noextract_codebook()` to parse the codebook provided in this package or else
`read_microdata` will fail.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_noextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_read_noextract_codebook():
assert codebook.data_description[0].rectype == "P"
assert codebook.data_description[0].codes == {}
assert codebook.data_description[0].start == 0
assert codebook.data_description[0].end == 2
assert codebook.data_description[0].end == 1
assert codebook.data_description[0].label == "Record type"

assert len(codebook.samples_description) == 0
Expand Down

0 comments on commit b96c7a5

Please sign in to comment.