-
Notifications
You must be signed in to change notification settings - Fork 73
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
Document TableRow.replace() ? #1503
Comments
As a data point I have typed the second (currently incorrect) version almost every time I've written this piece of code! |
I thought we had done this? As well as Yan's point (which I agree with) I wasn't keen on the long-term API dependency on dataclasses implied by the |
That's a good point too. Looks like we should just implement it then? Simply this?
I don't know what the "/" in the replace docs parameter list is though: https://docs.python.org/3/library/dataclasses.html#dataclasses.replace |
That means the first parameter is positional only. I.e., the keyword cannot be used to specify that param. |
I'm clearly losing my mind as I implemented this already: https://github.com/tskit-dev/tskit/blob/main/python/tskit/util.py#L37 But then I'm sure @hyanwong got an error trying to use |
I thought I did too. But it works now. Hmmm. |
Reopening because I think this should be documented somewhere? |
The most common thing to want to do when using e.g.
NodeTable.append()
is to want to change one variable, e.g.time
. At the moment this requires you toIs it worth having the syntactic sugar
to avoid having to import dataclasses and remember the syntax? This could be a lightweight method on a TableRow class, but is it worth duplicating the data class functionality here? I think on balance it might be, especially for newbies to the wonderful world of tree sequences (it might also encourage using
.append()
instead of.add_row(x, y, z)
).The text was updated successfully, but these errors were encountered: