Comments (7)
FWIW, I can't think of a single function in R that overloads arguments like that - i.e., takes either a vector of indices or a vector of booleans. Indexing works like that, but only indexing. Overloading can lead to nasty corner cases.
from tskit.
It's a bunch of work to do, and not that much different? Seems to me that you'd have to explain more by adding the boolean selector for nodes as well as the list of nodes option.
from tskit.
It's only a 5 line addition at the top of tables.simplify()
, isn't it?
try:
if len(samples) == ts.num_nodes and samples.dtype == bool:
samples = np.where(samples)[0]
except AttributeError:
pass
You're right that it's not that different, and it's not really a priority, but I'm finding that every extra barrier to new tskit users puts some of them off (and takes an extra few minutes to explain). There's a reason why numpy allows both boolean and numerical indexing. I'm not sure I would actually explain in a practical that you can use both: it's obvious from the context, right?
from tskit.
As usual with these things, implementation is by far the easiest thing and something like 5% of the actual effort. Testing, documenting and making sure there are no regressions against existing code make the majority of the work.
from tskit.
I agree. Higher on my list would be adding an individuals
argument.
from tskit.
I guess part of the problem is nothing to do with tskit
, but the very unintuitive np.where
syntax which requires the [0]
at the end (which I always forget). The other option is
ts.simplify(np.flatnonzero(ts.nodes_time == 0))
but that's hardly more intuitive, IMO. Or alternatively
ts.simplify((ts.nodes_time == 0).nonzero()[0])
Which is equally cryptic, but at least doesn't need you to use the np
prefix, which again requires explanation when it's in the first few lines of a beginner's tutorial.
Anyway, if no-one thinks it's a good idea, I'll close this. However, it's worth pointing out that I'm finding it hard to introduce tskit
to new users (especially from R, and if they don't know numpy).
from tskit.
Another option is
today_nodes = np.arange(ts.num_nodes)[ts.nodes_time == 0]
ts.simplify(today_nodes)
from tskit.
Related Issues (20)
- edges lost after merging two trees HOT 20
- Codecov upload issues HOT 1
- keep_intervals() giving _tskit.LibraryError: Can't squash, flush, simplify or link ancestors... HOT 7
- Update GitHub upload/download artefacts
- Add XTable.drop_metadata HOT 1
- trees.c Compilation Error HOT 2
- Split large numbers in html/cli print out.
- Post release for 0.5.7 HOT 1
- Fixup tests for lshmm 0.0.6 HOT 7
- Fix tests for numpy 2.0 HOT 1
- Drop "benchmark" CI job?
- Cannot pickle '_tskit.Tree' object HOT 3
- Trivial wording change HOT 1
- clarify that genetic_relatedness includes self comparisons HOT 1
- set default for genetic_relatedness to polarised=True and remove a factor of 1/2
- "mutation" mode for statistics HOT 1
- inconsistent handling of non-ancestral material in non-strict, unpolarised branch stats HOT 2
- wrong output for genetic_relatedness(... indexes=None, proportion=True)
- Clarification on pairwise coalescent rates HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tskit.