Skip to content

Commit 93792db

Browse files
authored
refactor: TableCollection now stores internal tables directly (#723)
1 parent 7b843d0 commit 93792db

File tree

6 files changed

+235
-379
lines changed

6 files changed

+235
-379
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ serde = {version = "1.0.203", features = ["derive"], optional = true}
2828
serde_json = {version = "1.0.120", optional = true}
2929
bincode = {version = "1.3.1", optional = true}
3030
tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true}
31-
delegate = "0.12.0"
3231

3332
[dev-dependencies]
3433
anyhow = {version = "1.0.86"}

src/_macros.rs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -120,96 +120,6 @@ macro_rules! build_table_column_slice_mut_getter {
120120
};
121121
}
122122

123-
macro_rules! delegate_table_view_api {
124-
() => {
125-
delegate::delegate! {
126-
to self.views {
127-
/// Get reference to the [``EdgeTable``](crate::EdgeTable).
128-
pub fn edges(&self) -> &crate::EdgeTable;
129-
/// Get reference to the [``IndividualTable``](crate::IndividualTable).
130-
pub fn individuals(&self) -> &crate::IndividualTable;
131-
/// Get reference to the [``MigrationTable``](crate::MigrationTable).
132-
pub fn migrations(&self) -> &crate::MigrationTable;
133-
/// Get reference to the [``MutationTable``](crate::MutationTable).
134-
pub fn mutations(&self) -> &crate::MutationTable;
135-
/// Get reference to the [``NodeTable``](crate::NodeTable).
136-
pub fn nodes(&self) -> &crate::NodeTable;
137-
/// Get reference to the [``PopulationTable``](crate::PopulationTable).
138-
pub fn populations(&self) -> &crate::PopulationTable;
139-
/// Get reference to the [``SiteTable``](crate::SiteTable).
140-
pub fn sites(&self) -> &crate::SiteTable;
141-
142-
#[cfg(feature = "provenance")]
143-
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
144-
/// Get reference to the [``ProvenanceTable``](crate::provenance::ProvenanceTable)
145-
pub fn provenances(&self) -> &crate::provenance::ProvenanceTable ;
146-
147-
/// Return an iterator over the individuals.
148-
pub fn individuals_iter(&self) -> impl Iterator<Item = crate::IndividualTableRow> + '_;
149-
/// Return an iterator over the nodes.
150-
pub fn nodes_iter(&self) -> impl Iterator<Item = crate::NodeTableRow> + '_;
151-
/// Return an iterator over the edges.
152-
pub fn edges_iter(&self) -> impl Iterator<Item = crate::EdgeTableRow> + '_;
153-
/// Return an iterator over the migrations.
154-
pub fn migrations_iter(&self) -> impl Iterator<Item = crate::MigrationTableRow> + '_;
155-
/// Return an iterator over the mutations.
156-
pub fn mutations_iter(&self) -> impl Iterator<Item = crate::MutationTableRow> + '_;
157-
/// Return an iterator over the populations.
158-
pub fn populations_iter(&self) -> impl Iterator<Item = crate::PopulationTableRow> + '_;
159-
/// Return an iterator over the sites.
160-
pub fn sites_iter(&self) -> impl Iterator<Item = crate::SiteTableRow> + '_;
161-
162-
#[cfg(feature = "provenance")]
163-
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
164-
/// Return an iterator over provenances
165-
pub fn provenances_iter(&self,) -> impl Iterator<Item = crate::provenance::ProvenanceTableRow> + '_;
166-
167-
/// Obtain a vector containing the indexes ("ids")
168-
/// of all nodes for which [`crate::NodeFlags::is_sample`]
169-
/// is `true`.
170-
///
171-
/// The provided implementation dispatches to
172-
/// [`crate::NodeTable::samples_as_vector`].
173-
pub fn samples_as_vector(&self) -> Vec<crate::NodeId>;
174-
175-
/// Obtain a vector containing the indexes ("ids") of all nodes
176-
/// satisfying a certain criterion.
177-
///
178-
/// The provided implementation dispatches to
179-
/// [`crate::NodeTable::create_node_id_vector`].
180-
///
181-
/// # Parameters
182-
///
183-
/// * `f`: a function. The function is passed the current table
184-
/// collection and each [`crate::node_table::NodeTableRow`].
185-
/// If `f` returns `true`, the index of that row is included
186-
/// in the return value.
187-
///
188-
/// # Examples
189-
///
190-
/// Get all nodes with time > 0.0:
191-
///
192-
/// ```
193-
/// let mut tables = tskit::TableCollection::new(100.).unwrap();
194-
/// tables
195-
/// .add_node(tskit::NodeFlags::new_sample(), 0.0, tskit::PopulationId::NULL,
196-
/// tskit::IndividualId::NULL)
197-
/// .unwrap();
198-
/// tables
199-
/// .add_node(tskit::NodeFlags::new_sample(), 1.0, tskit::PopulationId::NULL,
200-
/// tskit::IndividualId::NULL)
201-
/// .unwrap();
202-
/// let samples = tables.create_node_id_vector(
203-
/// |row: &tskit::NodeTableRow| row.time > 0.,
204-
/// );
205-
/// assert_eq!(samples[0], 1);
206-
/// ```
207-
pub fn create_node_id_vector(&self, f: impl FnMut(&crate::NodeTableRow) -> bool) -> Vec<crate::NodeId>;
208-
}
209-
}
210-
};
211-
}
212-
213123
#[cfg(test)]
214124
mod test {
215125
use crate::error::TskitError;

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ mod site_table;
9898
mod sys;
9999
mod table_collection;
100100
mod table_iterator;
101-
mod table_views;
102101
mod traits;
103102
mod trees;
104103
pub mod types;

0 commit comments

Comments
 (0)