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

load_rdm() to accept file handle #373

Open
caiw opened this issue Nov 22, 2023 · 1 comment
Open

load_rdm() to accept file handle #373

caiw opened this issue Nov 22, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@caiw
Copy link
Member

caiw commented Nov 22, 2023

load_rdm(filename, filetype) actually accepts an open file passed in as filename, though this is not documented. In other words, the following works:

with open(rdm_path, mode="rb") as f:
    rdm = load_rdm(f, file_type="hdf5")

However the documentation says the file_type can be None (and is by default), in which case it is inferred from the extension of the filename. But this of course breaks when supplying a file handle because the inference is done by inspecting the filename string.

The same is true of with open(rdm_path, mode="wb") as f: RDMs.save(filename=f), but the file type inference doesn't break because it has a default value of 'hdf5'.

I propose load_rdms() and RDMs.save() both be bolstered to officially accept file handles (and Paths) in their first arguments, and the documentation and error messages slightly rewritten to make it clear when filetype is optional.

@caiw caiw added enhancement New feature or request good first issue Good for newcomers labels Nov 22, 2023
@JasperVanDenBosch
Copy link
Contributor

Seconded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants