r-lib / vctrs

Compare 37f8b58 ... +1 ... 1320e7b

Coverage Reach
src/rlang/walk.c src/rlang/dict.c src/rlang/vec.h src/rlang/dyn-list-of.c src/rlang/env.c src/rlang/cnd.c src/rlang/vec.c src/rlang/attrib.c src/rlang/eval.c src/rlang/dyn-array.c src/rlang/formula.c src/rlang/obj.c src/rlang/env-binding.c src/rlang/vec-chr.c src/rlang/stack.c src/rlang/globals.c src/rlang/rlang.c src/rlang/vec-lgl.c src/rlang/df.c src/rlang/node.c src/rlang/c-utils.h src/rlang/obj.h src/rlang/sym.c src/rlang/dyn-array.h src/rlang/parse.c src/rlang/attrib.h src/rlang/debug.c src/rlang/c-utils.c src/rlang/session.c src/rlang/call.c src/rlang/fn.c src/rlang/node.h src/rlang/env.h src/rlang/fn.h src/rlang/vec-chr.h src/rlang/export.c src/rlang/rlang.hpp src/rlang/cnd.h src/rlang/sym.h src/rlang/cpp/vec.cpp src/rlang/export.h src/rlang/state.h src/rlang/vendor.c src/rlang/eval.h src/order-radix.c src/utils.c src/type-data-frame.c src/names.c src/typeof2-s3.c src/bind.c src/subscript-loc.c src/dictionary.c src/typeof2.c src/type-date-time.c src/order-sortedness.c src/equal.c src/slice.c src/slice-chop.c src/runs.c src/subscript.c src/type-factor.c src/c.c src/hash.c src/rep.c src/cast.c src/type.c src/group.c src/slice-assign.c src/fill.c src/type2.c src/proxy.c src/equal.h src/cast-bare.c src/rank.c src/c-unchop.c src/poly-op.c src/size.c src/ptype2-dispatch.c src/type-info.c src/proxy-restore.c src/order-truelength.c src/translate.c src/altrep-rle.c src/arg.c src/conditions.c src/fields.c src/compare.c src/shape.c src/strides.h src/utils.h src/utils-dispatch.c src/order-groups.c src/size-common.c src/type-integer64.c src/arg-counter.c src/complete.c src/compare.h src/unspecified.c src/order-transform.c src/cast-dispatch.c src/init.c src/vctrs.h src/slice-assign-array.c src/slice-array.c src/type-tibble.c src/order-radix.h src/callables.c src/ptype2.h src/order-truelength.h src/dim.h src/lazy.h src/subscript.h src/split.c src/cast.h src/growable.c src/owned.h src/translate.h src/order-groups.h src/dim.c src/altrep.h src/ptype-common.h src/type-data-frame.h src/version.c R/conditions.R R/subscript-loc.R R/type-vctr.R R/subscript.R R/type-date-time.R R/names.R R/type-data-frame.R R/utils.R R/type2.R R/type-sf.R R/type-bare.R R/assert.R R/slice.R R/type-factor.R R/type-list-of.R R/print-str.R R/type.R R/shape.R R/cast.R R/type-sclr.R R/ptype-abbr-full.R R/type-dplyr.R R/type-integer64.R R/type-rcrd.R R/type-misc.R R/vctrs-deprecated.R R/partial-frame.R R/partial-factor.R R/dictionary.R R/type-asis.R R/order.R R/utils-cli.R R/compare.R R/proxy.R R/type-tibble.R R/cast-list.R R/type-table.R R/type-explore.R R/c.R R/arith.R R/group.R R/equal.R R/aaa.R R/partial.R R/rank.R R/numeric.R R/order-radix.R R/size.R R/type-unspecified.R R/bind.R R/complete.R R/slice-chop.R R/dim.R R/recycle.R R/fields.R R/runs.R R/rep.R R/hash.R R/split.R R/fill.R R/translate.R

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -299,10 +299,11 @@
Loading
299 299
// -----------------------------------------------------------------------------
300 300
301 301
/*
302 -
 * Returns a list of size two.
302 +
 * Returns a list of size three.
303 303
 * - The first element of the list contains the ordering as an integer vector.
304 304
 * - The second element of the list contains the group sizes as an integer
305 305
 *   vector.
306 +
 * - The third element of the list contains the max group size as an integer.
306 307
 */
307 308
// [[ include("order-radix.h") ]]
308 309
SEXP vec_order_info(SEXP x,
@@ -456,14 +457,15 @@
Loading
456 457
    p_truelength_info
457 458
  );
458 459
459 -
  SEXP out = PROTECT_N(r_alloc_list(2), &n_prot);
460 +
  SEXP out = PROTECT_N(r_alloc_list(3), &n_prot);
460 461
  r_list_poke(out, 0, p_order->data);
461 462
462 463
  if (group_sizes) {
463 464
    struct group_info* p_group_info = groups_current(p_group_infos);
464 465
    SEXP sizes = p_group_info->data;
465 466
    sizes = r_int_resize(sizes, p_group_info->n_groups);
466 467
    r_list_poke(out, 1, sizes);
468 +
    r_list_poke(out, 2, r_int((int) p_group_info->max_group_size));
467 469
  }
468 470
469 471
  UNPROTECT(n_prot);

@@ -10,6 +10,9 @@
Loading
10 10
#' `nan_distinct = FALSE`, `NaN` values are given the same rank as `NA`,
11 11
#' otherwise they are given a rank that differentiates them from `NA`.
12 12
#'
13 +
#' For data frames, `na_propagate = TRUE` will propagate a missing value if
14 +
#' any row is incomplete, as determined by [vec_detect_complete()].
15 +
#'
13 16
#' Like [vec_order_radix()], ordering is done in the C-locale. This can affect
14 17
#' the ranks of character vectors, especially regarding how uppercase and
15 18
#' lowercase letters are ranked. See the Details section of [vec_order_radix()]

@@ -1,6 +1,6 @@
Loading
1 1
#include <rlang.h>
2 2
#include "vctrs.h"
3 -
#include "equal.h"
3 +
#include "complete.h"
4 4
#include "order-radix.h"
5 5
6 6
enum ties {
@@ -48,44 +48,29 @@
Loading
48 48
  r_keep_t pi_x;
49 49
  KEEP_HERE(x, &pi_x);
50 50
51 -
  r_obj* missing = r_null;
52 -
  r_keep_t pi_missing;
53 -
  KEEP_HERE(missing, &pi_missing);
54 -
  int* v_missing = NULL;
55 -
56 -
  r_obj* not_missing = r_null;
57 -
  r_keep_t pi_not_missing;
58 -
  KEEP_HERE(not_missing, &pi_not_missing);
59 -
  int* v_not_missing = NULL;
51 +
  r_obj* complete = r_null;
52 +
  r_keep_t pi_complete;
53 +
  KEEP_HERE(complete, &pi_complete);
54 +
  int* v_complete = NULL;
60 55
61 56
  r_ssize rank_size = size;
62 57
63 58
  if (na_propagate) {
64 -
    // Slice out non-missing values of `x` to rank.
65 -
    // Retain `non_missing` logical vector for constructing `out`.
66 -
    missing = vec_equal_na(x);
67 -
    KEEP_AT(missing, pi_missing);
68 -
    v_missing = r_lgl_begin(missing);
69 -
70 -
    bool any_missing = r_lgl_any(missing);
71 -
72 -
    if (any_missing) {
73 -
      for (r_ssize i = 0; i < size; ++i) {
74 -
        v_missing[i] = !v_missing[i];
75 -
      }
76 -
77 -
      not_missing = missing;
78 -
      KEEP_AT(not_missing, pi_not_missing);
79 -
      v_not_missing = v_missing;
80 -
      missing = NULL;
81 -
      v_missing = NULL;
82 -
83 -
      x = vec_slice(x, not_missing);
59 +
    // Slice out complete values of `x` to rank.
60 +
    // Retain the logical vector for constructing `out`.
61 +
    complete = vec_detect_complete(x);
62 +
    KEEP_AT(complete, pi_complete);
63 +
    v_complete = r_lgl_begin(complete);
64 +
65 +
    bool all_complete = r_lgl_all(complete);
66 +
67 +
    if (all_complete) {
68 +
      na_propagate = false;
69 +
    } else {
70 +
      x = vec_slice(x, complete);
84 71
      KEEP_AT(x, pi_x);
85 72
86 73
      rank_size = vec_size(x);
87 -
    } else {
88 -
      na_propagate = false;
89 74
    }
90 75
  }
91 76
@@ -118,15 +103,15 @@
Loading
118 103
    r_ssize j = 0;
119 104
120 105
    for (r_ssize i = 0; i < size; ++i) {
121 -
      v_out[i] = v_not_missing[i] ? v_rank[j++] : r_globals.na_int;
106 +
      v_out[i] = v_complete[i] ? v_rank[j++] : r_globals.na_int;
122 107
    }
123 108
124 109
    FREE(1);
125 110
  } else {
126 111
    out = rank;
127 112
  }
128 113
129 -
  FREE(5);
114 +
  FREE(4);
130 115
  return out;
131 116
}
132 117
@@ -239,19 +224,19 @@
Loading
239 224
240 225
// Treats missing values as `true`
241 226
static inline
242 -
bool r_lgl_any(r_obj* x) {
227 +
bool r_lgl_all(r_obj* x) {
243 228
  if (r_typeof(x) != R_TYPE_logical) {
244 -
    r_stop_internal("r_lgl_any", "`x` must be a logical vector.");
229 +
    r_stop_internal("r_lgl_all", "`x` must be a logical vector.");
245 230
  }
246 231
247 232
  const int* v_x = r_lgl_cbegin(x);
248 233
  r_ssize size = r_length(x);
249 234
250 235
  for (r_ssize i = 0; i < size; ++i) {
251 -
    if (v_x[i]) {
252 -
      return true;
236 +
    if (!v_x[i]) {
237 +
      return false;
253 238
    }
254 239
  }
255 240
256 -
  return false;
241 +
  return true;
257 242
}

@@ -1,5 +1,4 @@
Loading
1 -
#include <rlang.h>
2 -
#include "vctrs.h"
1 +
#include "complete.h"
3 2
#include "equal.h"
4 3
#include "type-data-frame.h"
5 4
@@ -32,8 +31,6 @@
Loading
32 31
  return vec_locate_complete(x);
33 32
}
34 33
35 -
static SEXP vec_detect_complete(SEXP x);
36 -
37 34
static
38 35
SEXP vec_locate_complete(SEXP x) {
39 36
  SEXP where = PROTECT(vec_detect_complete(x));
@@ -51,7 +48,7 @@
Loading
51 48
52 49
static inline void vec_detect_complete_switch(SEXP x, R_len_t size, int* p_out);
53 50
54 -
static
51 +
// [[ include("complete.h") ]]
55 52
SEXP vec_detect_complete(SEXP x) {
56 53
  SEXP proxy = PROTECT(vec_proxy_complete(x));
57 54

Learn more Showing 1 files with coverage changes found.

Changes in src/order-sortedness.c
-2
+2
Loading file...
Files Coverage
rlang 29.61%
altrep-rle.c 52.87%
altrep.h 100.00%
arg-counter.c 100.00%
arg.c 100.00%
bind.c 98.46%
c-unchop.c 96.30%
c.c 97.02%
callables.c 0.00%
cast-bare.c 69.64%
cast-dispatch.c 97.62%
cast.c 100.00%
cast.h 100.00%
compare.c 76.32%
compare.h 96.43%
complete.c 96.49%
conditions.c 100.00%
dictionary.c 96.39%
dim.c 100.00%
dim.h 100.00%
equal.c 82.78%
equal.h 90.18%
fields.c 97.44%
fill.c 100.00%
group.c 100.00%
growable.c 100.00%
hash.c 97.59%
init.c 100.00%
lazy.h 100.00%
names.c 94.77%
order-groups.c 96.92%
order-groups.h 100.00%
order-radix.c +<.01% 94.66%
order-radix.h 94.74%
order-sortedness.c 0.88% 96.92%
order-transform.c 93.62%
order-truelength.c 94.57%
order-truelength.h 100.00%
owned.h 100.00%
poly-op.c 95.24%
proxy-restore.c 100.00%
proxy.c 98.23%
ptype-common.h 100.00%
ptype2-dispatch.c 84.85%
ptype2.h 100.00%
rank.c -0.22% 97.32%
rep.c 92.64%
runs.c 97.13%
shape.c 95.95%
size-common.c 96.77%
size.c 92.08%
slice-array.c 96.77%
slice-assign-array.c 93.75%
slice-assign.c 93.80%
slice-chop.c 98.90%
slice.c 96.81%
split.c 100.00%
strides.h 100.00%
subscript-loc.c 94.46%
subscript.c 95.98%
subscript.h 60.00%
translate.c 100.00%
translate.h 100.00%
type-data-frame.c 93.08%
type-data-frame.h 100.00%
type-date-time.c 97.93%
type-factor.c 88.24%
type-info.c 95.92%
type-integer64.c 94.83%
type-tibble.c 70.83%
type.c 97.20%
type2.c 93.97%
typeof2-s3.c 81.32%
typeof2.c 58.78%
unspecified.c 97.87%
utils-dispatch.c 98.46%
utils.c 86.22%
utils.h 92.86%
vctrs.h 81.25%
version.c 100.00%
Folder Totals (80 files) 83.22%
Project Totals (184 files) 83.93%
Loading