patch to improve matrix conformability error message

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

patch to improve matrix conformability error message

Joshua N Pritikin
With this patch,

> A <- matrix(1, 2, 2)
> B <- matrix(2, 3, 2)
> A %*% B
Error in A %*% B :
  non-conformable arguments of dimension (2, 2) and (3, 2)

From 205b591d4d14b5ff667325fb233a6deb08314726 Mon Sep 17 00:00:00 2001
From: Joshua Nathaniel Pritikin <[hidden email]>
Date: Fri, 5 Apr 2019 12:03:58 -0400
Subject: [PATCH] Improve non-conformable arguments error message

---
 src/main/array.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/main/array.c b/src/main/array.c
index 4b95e33..cedf627 100644
--- a/src/main/array.c
+++ b/src/main/array.c
@@ -1350,15 +1350,18 @@ SEXP attribute_hidden do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho)
     if (PRIMVAL(op) == 0) {
  /* primitive, so use call */
  if (ncx != nry)
-    errorcall(call, _("non-conformable arguments"));
+  errorcall(call, _("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
+    nrx, ncx, nry, ncy);
     }
     else if (PRIMVAL(op) == 1) {
  if (nrx != nry)
-    error(_("non-conformable arguments"));
+  error(_("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
+ nrx, ncx, nry, ncy);
     }
     else {
  if (ncx != ncy)
-    error(_("non-conformable arguments"));
+  error(_("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
+ nrx, ncx, nry, ncy);
     }
 
     if (isComplex(CAR(args)) || isComplex(CADR(args)))
--
2.19.1

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch to improve matrix conformability error message

frederik
I think this is a good idea. Is there a reason why it got no interest?
Slippery slope?

Or maybe others were also just occupied trying to figure out how
Joshua's second message had timestamp earlier than his first message?

On Fri, Apr 05, 2019 at 12:05:36PM -0400, Joshua N Pritikin wrote:

>With this patch,
>
>> A <- matrix(1, 2, 2)
>> B <- matrix(2, 3, 2)
>> A %*% B
>Error in A %*% B :
>  non-conformable arguments of dimension (2, 2) and (3, 2)
>
>From 205b591d4d14b5ff667325fb233a6deb08314726 Mon Sep 17 00:00:00 2001
>From: Joshua Nathaniel Pritikin <[hidden email]>
>Date: Fri, 5 Apr 2019 12:03:58 -0400
>Subject: [PATCH] Improve non-conformable arguments error message
>
>---
> src/main/array.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/src/main/array.c b/src/main/array.c
>index 4b95e33..cedf627 100644
>--- a/src/main/array.c
>+++ b/src/main/array.c
>@@ -1350,15 +1350,18 @@ SEXP attribute_hidden do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho)
>     if (PRIMVAL(op) == 0) {
> /* primitive, so use call */
> if (ncx != nry)
>-    errorcall(call, _("non-conformable arguments"));
>+  errorcall(call, _("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
>+    nrx, ncx, nry, ncy);
>     }
>     else if (PRIMVAL(op) == 1) {
> if (nrx != nry)
>-    error(_("non-conformable arguments"));
>+  error(_("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
>+ nrx, ncx, nry, ncy);
>     }
>     else {
> if (ncx != ncy)
>-    error(_("non-conformable arguments"));
>+  error(_("non-conformable arguments of dimension (%d, %d) and (%d, %d)"),
>+ nrx, ncx, nry, ncy);
>     }
>
>     if (isComplex(CAR(args)) || isComplex(CADR(args)))
>--
>2.19.1
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch to improve matrix conformability error message

Joshua N Pritikin
On Mon, Apr 29, 2019 at 06:28:46PM -0700, [hidden email] wrote:
> I think this is a good idea. Is there a reason why it got no interest?
> Slippery slope?

What's the next step? Can it get committed?

> Or maybe others were also just occupied trying to figure out how
> Joshua's second message had timestamp earlier than his first message?

As a new subscriber, I guess my messages got caught in moderation.

--
Joshua N. Pritikin, Ph.D.
Virginia Institute for Psychiatric and Behavioral Genetics
Virginia Commonwealth University
PO Box 980126
800 E Leigh St, Biotech One, Suite 1-133
Richmond, VA 23219
http://exuberant-island.surge.sh

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch to improve matrix conformability error message

frederik
I'm not really the one who makes these decisions; I'd just wait for
someone on the Core team to reply to this thread. Maybe they are all
just busy right now.

On Mon, Apr 29, 2019 at 10:08:43PM -0400, Joshua N Pritikin wrote:

>On Mon, Apr 29, 2019 at 06:28:46PM -0700, [hidden email] wrote:
>> I think this is a good idea. Is there a reason why it got no interest?
>> Slippery slope?
>
>What's the next step? Can it get committed?
>
>> Or maybe others were also just occupied trying to figure out how
>> Joshua's second message had timestamp earlier than his first message?
>
>As a new subscriber, I guess my messages got caught in moderation.
>
>--
>Joshua N. Pritikin, Ph.D.
>Virginia Institute for Psychiatric and Behavioral Genetics
>Virginia Commonwealth University
>PO Box 980126
>800 E Leigh St, Biotech One, Suite 1-133
>Richmond, VA 23219
>http://exuberant-island.surge.sh
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel