Skip to content

Commit 6c8c779

Browse files
jeromekellehermergify[bot]
authored andcommitted
Add tsk_bool_t and change keep_rows signature
1 parent 7927e2c commit 6c8c779

File tree

7 files changed

+115
-54
lines changed

7 files changed

+115
-54
lines changed

c/tests/test_tables.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ test_node_table_keep_rows(void)
14991499
tsk_size_t j;
15001500
tsk_node_table_t source, t1, t2;
15011501
tsk_node_t row;
1502-
bool keep[3] = { 1, 1, 1 };
1502+
tsk_bool_t keep[3] = { 1, 1, 1 };
15031503
tsk_id_t id_map[3];
15041504
const char *metadata = "ABC";
15051505
tsk_id_t indexes[] = { 0, 1, 2 };
@@ -2142,7 +2142,7 @@ test_edge_table_keep_rows(void)
21422142
tsk_size_t j;
21432143
tsk_edge_table_t source, t1, t2;
21442144
tsk_edge_t row;
2145-
bool keep[3] = { 1, 1, 1 };
2145+
tsk_bool_t keep[3] = { 1, 1, 1 };
21462146
tsk_id_t id_map[3];
21472147
const char *metadata = "ABC";
21482148
tsk_id_t indexes[] = { 0, 1, 2 };
@@ -2242,7 +2242,7 @@ test_edge_table_keep_rows_no_metadata(void)
22422242
tsk_size_t j;
22432243
tsk_edge_table_t source, t1, t2;
22442244
tsk_edge_t row;
2245-
bool keep[3] = { 1, 1, 1 };
2245+
tsk_bool_t keep[3] = { 1, 1, 1 };
22462246
tsk_id_t id_map[3];
22472247
tsk_id_t indexes[] = { 0, 1, 2 };
22482248

@@ -3265,7 +3265,7 @@ test_site_table_keep_rows(void)
32653265
tsk_site_t row;
32663266
const char *ancestral_state = "XYZ";
32673267
const char *metadata = "ABC";
3268-
bool keep[3] = { 1, 1, 1 };
3268+
tsk_bool_t keep[3] = { 1, 1, 1 };
32693269
tsk_id_t id_map[3];
32703270
tsk_id_t indexes[] = { 0, 1, 2 };
32713271

@@ -4051,7 +4051,7 @@ test_mutation_table_keep_rows(void)
40514051
tsk_mutation_t row;
40524052
const char *derived_state = "XYZ";
40534053
const char *metadata = "ABC";
4054-
bool keep[3] = { 1, 1, 1 };
4054+
tsk_bool_t keep[3] = { 1, 1, 1 };
40554055
tsk_id_t id_map[3];
40564056
tsk_id_t indexes[] = { 0, 1, 2 };
40574057

@@ -4154,7 +4154,7 @@ test_mutation_table_keep_rows_parent_references(void)
41544154
int ret;
41554155
tsk_id_t ret_id;
41564156
tsk_mutation_table_t source, t;
4157-
bool keep[4] = { 1, 1, 1, 1 };
4157+
tsk_bool_t keep[4] = { 1, 1, 1, 1 };
41584158
tsk_id_t id_map[4];
41594159

41604160
ret = tsk_mutation_table_init(&source, 0);
@@ -4844,7 +4844,7 @@ test_migration_table_keep_rows(void)
48444844
tsk_migration_table_t source, t1, t2;
48454845
tsk_migration_t row;
48464846
const char *metadata = "ABC";
4847-
bool keep[3] = { 1, 1, 1 };
4847+
tsk_bool_t keep[3] = { 1, 1, 1 };
48484848
tsk_id_t id_map[3];
48494849
tsk_id_t indexes[] = { 0, 1, 2 };
48504850

@@ -5671,7 +5671,7 @@ test_individual_table_keep_rows(void)
56715671
double location[] = { 0, 1, 2 };
56725672
tsk_id_t parents[] = { -1, 1, -1 };
56735673
const char *metadata = "ABC";
5674-
bool keep[3] = { 1, 1, 1 };
5674+
tsk_bool_t keep[3] = { 1, 1, 1 };
56755675
tsk_id_t indexes[] = { 0, 1, 2 };
56765676
tsk_id_t id_map[3];
56775677
tsk_individual_table_t source, t1, t2;
@@ -5776,7 +5776,7 @@ test_individual_table_keep_rows_parent_references(void)
57765776
int ret;
57775777
tsk_id_t ret_id;
57785778
tsk_individual_table_t source, t;
5779-
bool keep[] = { 1, 1, 1, 1 };
5779+
tsk_bool_t keep[] = { 1, 1, 1, 1 };
57805780
tsk_id_t parents[] = { -1, 1, 2 };
57815781
tsk_id_t id_map[4];
57825782

@@ -6243,7 +6243,7 @@ test_population_table_keep_rows(void)
62436243
tsk_population_table_t source, t1, t2;
62446244
tsk_population_t row;
62456245
const char *metadata = "ABC";
6246-
bool keep[3] = { 1, 1, 1 };
6246+
tsk_bool_t keep[3] = { 1, 1, 1 };
62476247
tsk_id_t id_map[3];
62486248
tsk_id_t indexes[] = { 0, 1, 2 };
62496249

@@ -6779,7 +6779,7 @@ test_provenance_table_keep_rows(void)
67796779
tsk_provenance_t row;
67806780
const char *timestamp = "XYZ";
67816781
const char *record = "ABC";
6782-
bool keep[3] = { 1, 1, 1 };
6782+
tsk_bool_t keep[3] = { 1, 1, 1 };
67836783
tsk_id_t indexes[] = { 0, 1, 2 };
67846784
tsk_id_t id_map[3];
67856785

c/tskit/core.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ specify options to API functions.
123123
typedef uint32_t tsk_flags_t;
124124
#define TSK_FLAGS_STORAGE_TYPE KAS_UINT32
125125

126+
/**
127+
@brief Boolean type.
128+
129+
@rst
130+
Fixed-size (1 byte) boolean values.
131+
@endrst
132+
*/
133+
typedef uint8_t tsk_bool_t;
134+
126135
// clang-format off
127136
/**
128137
@defgroup API_VERSION_GROUP API version macros.

c/tskit/tables.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ write_metadata_schema_header(
735735
/* Utilities for in-place subsetting columns */
736736

737737
static tsk_size_t
738-
count_true(tsk_size_t num_rows, const bool *restrict keep)
738+
count_true(tsk_size_t num_rows, const tsk_bool_t *restrict keep)
739739
{
740740
tsk_size_t j;
741741
tsk_size_t count = 0;
@@ -750,7 +750,7 @@ count_true(tsk_size_t num_rows, const bool *restrict keep)
750750

751751
static void
752752
keep_mask_to_id_map(
753-
tsk_size_t num_rows, const bool *restrict keep, tsk_id_t *restrict id_map)
753+
tsk_size_t num_rows, const tsk_bool_t *restrict keep, tsk_id_t *restrict id_map)
754754
{
755755
tsk_size_t j;
756756
tsk_id_t next_id = 0;
@@ -766,7 +766,7 @@ keep_mask_to_id_map(
766766

767767
static tsk_size_t
768768
subset_remap_id_column(tsk_id_t *restrict column, tsk_size_t num_rows,
769-
const bool *restrict keep, const tsk_id_t *restrict id_map)
769+
const tsk_bool_t *restrict keep, const tsk_id_t *restrict id_map)
770770
{
771771
tsk_size_t j, k;
772772
tsk_id_t value;
@@ -792,7 +792,7 @@ subset_remap_id_column(tsk_id_t *restrict column, tsk_size_t num_rows,
792792

793793
static tsk_size_t
794794
subset_id_column(
795-
tsk_id_t *restrict column, tsk_size_t num_rows, const bool *restrict keep)
795+
tsk_id_t *restrict column, tsk_size_t num_rows, const tsk_bool_t *restrict keep)
796796
{
797797
tsk_size_t j, k;
798798

@@ -808,7 +808,7 @@ subset_id_column(
808808

809809
static tsk_size_t
810810
subset_flags_column(
811-
tsk_flags_t *restrict column, tsk_size_t num_rows, const bool *restrict keep)
811+
tsk_flags_t *restrict column, tsk_size_t num_rows, const tsk_bool_t *restrict keep)
812812
{
813813
tsk_size_t j, k;
814814

@@ -824,7 +824,7 @@ subset_flags_column(
824824

825825
static tsk_size_t
826826
subset_double_column(
827-
double *restrict column, tsk_size_t num_rows, const bool *restrict keep)
827+
double *restrict column, tsk_size_t num_rows, const tsk_bool_t *restrict keep)
828828
{
829829
tsk_size_t j, k;
830830

@@ -840,7 +840,7 @@ subset_double_column(
840840

841841
static tsk_size_t
842842
subset_ragged_char_column(char *restrict data, tsk_size_t *restrict offset_col,
843-
tsk_size_t num_rows, const bool *restrict keep)
843+
tsk_size_t num_rows, const tsk_bool_t *restrict keep)
844844
{
845845
tsk_size_t j, k, i, offset;
846846

@@ -864,7 +864,7 @@ subset_ragged_char_column(char *restrict data, tsk_size_t *restrict offset_col,
864864

865865
static tsk_size_t
866866
subset_ragged_double_column(double *restrict data, tsk_size_t *restrict offset_col,
867-
tsk_size_t num_rows, const bool *restrict keep)
867+
tsk_size_t num_rows, const tsk_bool_t *restrict keep)
868868
{
869869
tsk_size_t j, k, i, offset;
870870

@@ -888,7 +888,8 @@ subset_ragged_double_column(double *restrict data, tsk_size_t *restrict offset_c
888888

889889
static tsk_size_t
890890
subset_remap_ragged_id_column(tsk_id_t *restrict data, tsk_size_t *restrict offset_col,
891-
tsk_size_t num_rows, const bool *restrict keep, const tsk_id_t *restrict id_map)
891+
tsk_size_t num_rows, const tsk_bool_t *restrict keep,
892+
const tsk_id_t *restrict id_map)
892893
{
893894
tsk_size_t j, k, i, offset;
894895
tsk_id_t di;
@@ -1804,7 +1805,7 @@ tsk_individual_table_equals(const tsk_individual_table_t *self,
18041805
}
18051806

18061807
int
1807-
tsk_individual_table_keep_rows(tsk_individual_table_t *self, const bool *keep,
1808+
tsk_individual_table_keep_rows(tsk_individual_table_t *self, const tsk_bool_t *keep,
18081809
tsk_flags_t TSK_UNUSED(options), tsk_id_t *ret_id_map)
18091810
{
18101811
int ret = 0;
@@ -2518,7 +2519,7 @@ tsk_node_table_get_row(const tsk_node_table_t *self, tsk_id_t index, tsk_node_t
25182519
}
25192520

25202521
int
2521-
tsk_node_table_keep_rows(tsk_node_table_t *self, const bool *keep,
2522+
tsk_node_table_keep_rows(tsk_node_table_t *self, const tsk_bool_t *keep,
25222523
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
25232524
{
25242525
int ret = 0;
@@ -3210,7 +3211,7 @@ tsk_edge_table_equals(
32103211
}
32113212

32123213
int
3213-
tsk_edge_table_keep_rows(tsk_edge_table_t *self, const bool *keep,
3214+
tsk_edge_table_keep_rows(tsk_edge_table_t *self, const tsk_bool_t *keep,
32143215
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
32153216
{
32163217
int ret = 0;
@@ -3968,7 +3969,7 @@ tsk_site_table_dump_text(const tsk_site_table_t *self, FILE *out)
39683969
}
39693970

39703971
int
3971-
tsk_site_table_keep_rows(tsk_site_table_t *self, const bool *keep,
3972+
tsk_site_table_keep_rows(tsk_site_table_t *self, const tsk_bool_t *keep,
39723973
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
39733974
{
39743975
int ret = 0;
@@ -4733,7 +4734,7 @@ tsk_mutation_table_dump_text(const tsk_mutation_table_t *self, FILE *out)
47334734
}
47344735

47354736
int
4736-
tsk_mutation_table_keep_rows(tsk_mutation_table_t *self, const bool *keep,
4737+
tsk_mutation_table_keep_rows(tsk_mutation_table_t *self, const tsk_bool_t *keep,
47374738
tsk_flags_t TSK_UNUSED(options), tsk_id_t *ret_id_map)
47384739
{
47394740
int ret = 0;
@@ -5437,7 +5438,7 @@ tsk_migration_table_equals(const tsk_migration_table_t *self,
54375438
}
54385439

54395440
int
5440-
tsk_migration_table_keep_rows(tsk_migration_table_t *self, const bool *keep,
5441+
tsk_migration_table_keep_rows(tsk_migration_table_t *self, const tsk_bool_t *keep,
54415442
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
54425443
{
54435444
int ret = 0;
@@ -6031,7 +6032,7 @@ tsk_population_table_equals(const tsk_population_table_t *self,
60316032
}
60326033

60336034
int
6034-
tsk_population_table_keep_rows(tsk_population_table_t *self, const bool *keep,
6035+
tsk_population_table_keep_rows(tsk_population_table_t *self, const tsk_bool_t *keep,
60356036
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
60366037
{
60376038
int ret = 0;
@@ -6661,7 +6662,7 @@ tsk_provenance_table_equals(const tsk_provenance_table_t *self,
66616662
}
66626663

66636664
int
6664-
tsk_provenance_table_keep_rows(tsk_provenance_table_t *self, const bool *keep,
6665+
tsk_provenance_table_keep_rows(tsk_provenance_table_t *self, const tsk_bool_t *keep,
66656666
tsk_flags_t TSK_UNUSED(options), tsk_id_t *id_map)
66666667
{
66676668
int ret = 0;

0 commit comments

Comments
 (0)