Feature request: User control for argument default values
See original GitHub issueI think it would be nice if it was possible to do:
with h5py.File(pth, "w") as f, h5py.defaults(compression="lzf", chunks=True):
f["X"] = X
f["Y"] = Y
with h5py.defaults(maxshape=None):
f["foo/Z"] = Z
Instead of
with h5py.File(pth, "w") as f:
f.create_dataset("X", data=X, compression="lzf", chunks=True)
f.create_dataset("Y", data=Y, compression="lzf", chunks=True)
f.create_dataset("foo/Z", data=Z, compression="lzf", chunks=True, maxshape=None)
The second is much more verbose, and makes it much easier to forget to pass some kwargs (which inspired this 😊).
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
documenting default argument values · Issue #819 · r-lib ...
Is there any possibility that roxygen2 can automatically add the default values for function arguments in the .Rd files?
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >Can I give a default value to parameters or optional ...
Yes, but you'll need to be using .NET 3.5 and C# 4.0 to get this functionality.
Read more >Dynamic default values on user input controls
Need the ability to set the default value of a user input control to something dynamic. In my case, I'm creating a date...
Read more >Creating parameter defaults in Amazon QuickSight
If there are multiple values a default field for a user entity, the single-value control for that field displays the static default instead....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d prefer not to expand the use of the global config for this kind of thing. I don’t think it’s a particularly good API - but it smooths over things like how we represent types that HDF5 can’t natively store (complex & bool) and changing default settings with a deprecation cycle. I’m not convinced it’s a good idea for
track_order
, and I don’t think the fact that we already have some global mutable state should set a precedent that we should have more.I’d still like to make the case for doing this with some flavour of the
GroupMapWrap
orDefaultSetter
idea, without using any extra mutable state. @ivirshup , can you go into more detail about what was ‘weird’ when you tried this?That is exactly the spooky action-at-a-distance @takluyver is concerned about. My concern about global state for this sort of thing is driven by being on the developer side of
mpl.rcParams
!I think the order of operations here:
default_ds_kwargs
state toh5py._hl.group.Group
object. These should propogate down to sub-groups opened / created from their parent.Group
to set / unset defaultsI think 1. addresses most of @ivirshup initial request using only “local” state. So long as you can pass an h5py object into the third-party code it also catches that case (which I hope is most but I know not all casse). 2. is a nice API (and light weight to implement). 3. is the action-at-a-distance that I see the case for, but do not like (would rather ask you to push on the third party code to either take a
Group
or at least kwargs to pass to File along with the filename to make use of 1.)