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

Add reader for ascii files #34

Merged
merged 14 commits into from
Jan 23, 2024
Merged

Conversation

trossi
Copy link
Contributor

@trossi trossi commented Jan 17, 2024

This PR adds parser for ascii files.

See also #31.

A minimal test is also added for reading the following files generated in R:

data = list(1.1, 2L, 3+4i, NA, 'aä')
save(data, file='test_ascii_v2.rda', ascii=TRUE, compress=FALSE, version=2)
save(data, file='test_ascii_v3.rda', ascii=TRUE, compress=FALSE, version=3)
saveRDS(data, file='test_ascii_v2.rds', ascii=TRUE, compress=FALSE, version=2)
saveRDS(data, file='test_ascii_v3.rds', ascii=TRUE, compress=FALSE, version=3)

These files are generated both on Linux and Windows. Windows-R seems to use \r\n line ending for rds files but \n for rda files (tested on R 4.3.2).

@vnmabus Could you review? Do you think that this kind of testing would be sufficient?

@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (2b927cb) 91.04% compared to head (122f847) 90.08%.
Report is 1 commits behind head on develop.

Files Patch % Lines
rdata/parser/_parser.py 75.00% 5 Missing ⚠️
rdata/parser/_ascii.py 94.44% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #34      +/-   ##
===========================================
- Coverage    91.04%   90.08%   -0.97%     
===========================================
  Files            7        8       +1     
  Lines         1106     1170      +64     
===========================================
+ Hits          1007     1054      +47     
- Misses          99      116      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trossi
Copy link
Contributor Author

trossi commented Jan 17, 2024

@vnmabus I rebased the branch to fix conflicts and fixed some mypy issues found locally. The mypy CI action seems not be working, see a log here.

rdata/parser/_ascii.py Outdated Show resolved Hide resolved
rdata/parser/_parser.py Outdated Show resolved Hide resolved
*,
expand_altrep: bool = True,
altrep_constructor_dict: AltRepConstructorMap = DEFAULT_ALTREP_MAP,
**kwargs: Any,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather keep the parameters everywhere (for type-checking). Alternatively, you could type it with an unpacked TypedDict as in PEP 692, but I think it does not worth it in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the parameters back (d193450), but without default values so that they are not duplicated from _parser.py here.

rdata/tests/test_rdata.py Show resolved Hide resolved
@trossi
Copy link
Contributor Author

trossi commented Jan 22, 2024

Line ending of _parser.py had changed in develop branch, so I rebased this PR again (it seemed clearer approach than resolving merge conflict with the two files with different line endings). Style issues by ruff are fixed also.

@trossi trossi requested a review from vnmabus January 22, 2024 18:16
@vnmabus vnmabus mentioned this pull request Jan 23, 2024
Copy link
Owner

@vnmabus vnmabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vnmabus vnmabus merged commit d1dde29 into vnmabus:develop Jan 23, 2024
15 of 17 checks passed
@trossi
Copy link
Contributor Author

trossi commented Jan 23, 2024

@vnmabus Thanks for reviewing and merging!

@trossi trossi deleted the add-ascii-reader branch October 29, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants