Skip to content

Commit 0a76818

Browse files
author
maechler
committed
numeric vs double in error msgs (and trust coerceVector() works)
git-svn-id: https://svn.r-project.org/R/trunk@87678 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent d5d4863 commit 0a76818

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/library/grDevices/src/chull.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ SEXP chull(SEXP x)
433433
for (int i = 0; i < n; i++) in[i] = i+1;
434434
int *ih = (int*)R_alloc(4*n, sizeof(int));
435435
x = PROTECT(coerceVector(x, REALSXP));
436-
if(TYPEOF(x) != REALSXP) error("'x' is not numeric");
437436
in_chull(&n, REAL(x), &n, in, ih+n, ih+2*n, ih, &nh, ih+3*n);
438437
SEXP ans = allocVector(INTSXP, nh);
439438
int *ians = INTEGER(ans);

src/library/graphics/src/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static SEXP baseCallback(GEevent task, pGEDevDesc dd, SEXP data)
351351
/* Modify the saved settings so this effects display list too */
352352
ddpSaved->scale *= rf;
353353
} else
354-
error("event 'GE_ScalePS' requires a single numeric value");
354+
error("event 'GE_ScalePS' requires a single numeric (double) value");
355355
break;
356356
}
357357
}

src/library/stats/src/port.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 2005-2024 The R Core Team.
3+
* Copyright (C) 2005-2025 The R Core Team.
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -382,16 +382,15 @@ SEXP port_nlminb(SEXP fn, SEXP gr, SEXP hs, SEXP rho,
382382
if (isNull(rho)) {
383383
error(_("use of NULL environment is defunct"));
384384
rho = R_BaseEnv;
385-
} else
386-
if (!isEnvironment(rho))
385+
} else if (!isEnvironment(rho))
387386
error(_("'rho' must be an environment"));
388387
if (!isReal(d) || n < 1)
389-
error(_("'d' must be a nonempty numeric vector"));
388+
error(_("'d' must be a nonempty numeric (double) vector"));
390389
if (hs != R_NilValue && gr == R_NilValue)
391390
error(_("When Hessian defined must also have gradient defined"));
392391
if (R_NilValue == (xpt = findVarInFrame(rho, dot_par_symbol)) ||
393392
!isReal(xpt) || LENGTH(xpt) != n)
394-
error(_("environment 'rho' must contain a numeric vector '.par' of length %d"),
393+
error(_("environment 'rho' must contain a numeric (double) vector '.par' of length %d"),
395394
n);
396395
/* We are going to alter .par, so must duplicate it */
397396
defineVar(dot_par_symbol, duplicate(xpt), rho);
@@ -405,7 +404,7 @@ SEXP port_nlminb(SEXP fn, SEXP gr, SEXP hs, SEXP rho,
405404
b[2*i] = rl[i];
406405
b[2*i + 1] = ru[i];
407406
}
408-
} else error(_("'lower' and 'upper' must be numeric vectors"));
407+
} else error(_("'lower' and 'upper' must be numeric (double) vectors"));
409408
}
410409
if (gr != R_NilValue) {
411410
g = (double *)R_alloc(n, sizeof(double));
@@ -552,7 +551,7 @@ SEXP port_nlsb(SEXP m, SEXP d, SEXP gg, SEXP iv, SEXP v,
552551
*rd = (double *)R_alloc(nd, sizeof(double));
553552

554553
if (!isReal(d) || n < 1)
555-
error(_("'d' must be a nonempty numeric vector"));
554+
error(_("'d' must be a nonempty numeric (double) vector"));
556555
if(!isNewList(m)) error(_("m must be a list"));
557556
/* Initialize parameter vector */
558557
getPars = PROTECT(lang1(getFunc(m, "getPars", "m")));

src/main/raw.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ attribute_hidden SEXP do_numToInts(SEXP call, SEXP op, SEXP args, SEXP env)
151151
{
152152
checkArity(op, args);
153153
SEXP x = PROTECT(coerceVector(CAR(args), REALSXP));
154-
if (!isReal(x))
155-
error(_("argument 'x' must be a numeric vector"));
156154
SEXP ans = PROTECT(allocVector(INTSXP, 2*XLENGTH(x)));
157155
R_xlen_t i, j = 0;
158156
double *x_ = REAL(x);
@@ -169,13 +167,11 @@ attribute_hidden SEXP do_numToInts(SEXP call, SEXP op, SEXP args, SEXP env)
169167
UNPROTECT(2);
170168
return ans;
171169
}
172-
// split "real", i.e. = double = 64-bitd, to bits (<==> do_intToBits( do_numToInts(..) .. ))
170+
// split "real", i.e. = double = 64-bit, to bits (<==> do_intToBits( do_numToInts(..) .. ))
173171
attribute_hidden SEXP do_numToBits(SEXP call, SEXP op, SEXP args, SEXP env)
174172
{
175173
checkArity(op, args);
176174
SEXP x = PROTECT(coerceVector(CAR(args), REALSXP));
177-
if (!isReal(x))
178-
error(_("argument 'x' must be a numeric vector"));
179175
SEXP ans = PROTECT(allocVector(RAWSXP, 64*XLENGTH(x)));
180176
R_xlen_t i, j = 0;
181177
double *x_ = REAL(x);

0 commit comments

Comments
 (0)