From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id UEMxLFhs9WWBswAAe85BDQ:P1 (envelope-from ) for ; Sat, 16 Mar 2024 10:54:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id UEMxLFhs9WWBswAAe85BDQ (envelope-from ) for ; Sat, 16 Mar 2024 10:54:32 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=GdO0+rhg; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1710582872; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/8HOB/Poc+G46ADGdAGEm5SF7dQn2/8+ZYl+6rHojQQ=; b=TGKhBOwSL7BmqI2loJ//gSapkds4i+10YMEj1EaLch2u6B4r9yrlUUM0Kwglq8b0eyxC/I fNO+4CFzg3VH9mQ1l93/tmRXctFwVi6SOlFFTbn2Yx/uD1JrRfo0r/7TDNhjy8mw9oDhnF eYGbhcOP7Yz0krEerd4SrHvdBYnXg/Hes8ERVC7MiJSM1+5X9ttMORficmy6skcuR+mq5B ZPcvFzTzUIIOMmt96D2Nv/craJlodzxyZ9TTB6w85h1VJ2Cf5AjGO4QmYY14PUVDysns7M P9yQmqogpZi0441Xea1BiMzr9zU2Q7kodBT7XWAXVZ7TYAb5otHY5We9qkp7Tg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1710582872; a=rsa-sha256; cv=none; b=AYbw+p0juVMK7fGYGFZAvhR/ssnI/svMVu5Prw/9cqExdLEHS8EllNfjd2MgzQhiw6Rnz+ q1aNejzgfbMpeEQeJ0eHPAgAEmMBTqWYg6/w+dc/DPeOlF7yaSTEnICRNlq19IJWVxwawu gwYud46IWA3jH4YDsnkEojHldmW1uPAYqM/ZQR+axHcYMZL85Zy4Zs2nZyGRGLkgRrNVan jMZ4Pm5QkyLjmpJeL8Te9N6COmV1uUqDrHovFeACLTmQnvCrKdhElUb4cP9z77ecrRoxaU kGFvIiz9OTnM+JXqLBQViQ+yC9qWu/0O1wfTaWMYQ33RfpyNmhaUu7m2RfJepw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=GdO0+rhg; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4CA0F6D4E7 for ; Sat, 16 Mar 2024 10:54:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlQj0-0000bo-KP; Sat, 16 Mar 2024 05:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlQiw-0000ZR-1I for emacs-orgmode@gnu.org; Sat, 16 Mar 2024 05:53:06 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlQim-0003ZS-9m for emacs-orgmode@gnu.org; Sat, 16 Mar 2024 05:52:58 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E28B0240103 for ; Sat, 16 Mar 2024 10:52:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1710582772; bh=qRxG5SUh9Keu/Q38BeIdyHelnVo3M24joplNtslkaHc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=GdO0+rhgN28+1LpEUXn49FlzxtOOwrSRyEzqKkmK3ocqxPM9YyoA3JlErhE/Q+vBU 9/c4tXMuzaAexW4uwyxS49mSAtdmCcg4y/Fl5pGSBqPiYcm5yqtXu1XsWiQVxiGV1c 0CGgxm9PjiAvBE3stUiWsRVuLVjHow8BECLshmgsKFMeYEipSOhsNxLs22lD6p+2z6 GdT7Y0wqWvyrJyxy7c0G3qigJvlFblTEaUqYwAHBiDpQZb2xELrUVW6h8xPyDJOd5e O7xs8s5X2X+lzxut/NifndBC46jruUFmZWsAjVBysPpg4GK+G9uVSpYbDz1ZJnSNUW 5Mg0gNce0hkNg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TxbyX20x6z9rxF; Sat, 16 Mar 2024 10:52:52 +0100 (CET) From: Ihor Radchenko To: Visuwesh Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Add support for tables in Calc src block :var In-Reply-To: <877ci2261h.fsf@gmail.com> References: <877ci2261h.fsf@gmail.com> Date: Sat, 16 Mar 2024 09:52:48 +0000 Message-ID: <87y1aiijv3.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.49 X-Spam-Score: -9.49 X-Migadu-Queue-Id: 4CA0F6D4E7 X-Migadu-Scanner: mx11.migadu.com X-TUID: qPNPhlxytqel Visuwesh writes: > Attached patch adds support for passing tables as matrices (or vector) > to a Calc source block through the :var parameter. There might be a > better way to do it than manually construct the data structure expected > by Calc for a matrix but given that it rarely sees changes in this area, > it shouldn't be a bother. > I also added tests for this feature, and other simple tests to ensure > everything works. I checked that all the tests passed on my side. Thanks! Since you are adding a new feature, may you also add an entry to etc/ORG-NEWS? > - (calc-push-list (list (cdr pair))) > + (let ((val (cdr pair))) > + (calc-push-list > + (list (if (listp val) > + (cons 'vec > + (if (null (cdr val)) > + (car val) > + (mapcar (lambda (x) (if (listp x) (cons 'vec x) x)) > + val))) > + val)))) It would be nice to add code comments explaining the Calc's internal format. Ideally, with references to Calc's manual or source code. Otherwise, this code looks like black magic :) > +++ b/testing/examples/ob-calc-test.org > @@ -0,0 +1,57 @@ > +#+TITLE: Tests for ob-calc > +#+OPTIONS: ^:nil Thanks a lot for adding many tests! Would you mind using `org-test-with-temp-text' instead of `org-test-at-id' as much as possible? Otherwise, looking at tests like > +(ert-deftest ob-calc/simple-program-mult () > + "Test of simple multiplication." > + (org-test-at-id "40e4cd26-fe15-45c0-938b-111e021a5a99" > + (org-babel-next-src-block) > + (should (equal "2" (org-babel-execute-src-block))))) it is very difficult to understand what exactly the tests is checking. `org-test-with-temp-text' would make things a lot more readable as we would see the calc code being tested right inside the test code. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at