Skip to content

Commit 01beb01

Browse files
borkdudezampino
andauthored
Upgrade emmy (#673)
Co-authored-by: Andrea Amantini <[email protected]>
1 parent 843b69c commit 01beb01

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

.dir-locals.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(apply orig-fun args)))
1010

1111
(advice-add 'cider-jack-in :around #'cider-jack-in-wrapper-function)
12-
12+
1313
(when (not (featurep 'clerk))
1414
(let ((init-file-path (expand-file-name "clerk.el" default-directory)))
1515
(when (file-exists-p init-file-path)

book.clj

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
[nextjournal.clerk.eval :as eval]
1515
[nextjournal.clerk.analyzer :as ana]
1616
[nextjournal.clerk.viewer :as v]
17-
[sicmutils.env :as sicm]
17+
[emmy.env :as emmy]
18+
[emmy.expression]
1819
[weavejester.dependency :as dep])
1920
(:import (javax.imageio ImageIO)
2021
(java.net URL)))
@@ -626,7 +627,7 @@ v/table-viewer
626627
;; using `clerk/html` on the JVM. When you want to run code in the
627628
;; browser where Clerk's viewers are rendered, reach for
628629
;; `:render-fn`. As an example, we'll write a multiviewer for a
629-
;; sicmutils literal expression that will compute two alternative
630+
;; emmy literal expression that will compute two alternative
630631
;; representations and let the user switch between them in the
631632
;; browser.
632633

@@ -635,8 +636,8 @@ v/table-viewer
635636
;; original form.
636637

637638
(defn transform-literal [expr]
638-
{:TeX (-> expr sicm/->TeX clerk/tex)
639-
:original (clerk/code (with-out-str (sicm/print-expression (sicm/freeze expr))))})
639+
{:TeX (-> expr emmy/->TeX clerk/tex)
640+
:original (clerk/code (with-out-str (emmy/print-expression (emmy/freeze expr))))})
640641

641642
;; Our `literal-viewer` calls this `transform-literal` function and
642643
;; also calls `clerk/mark-preserve-keys`. This tells Clerk to leave
@@ -650,7 +651,7 @@ v/table-viewer
650651
;; `wrapped-value` that ran through `v/present` and show it.
651652

652653
(def literal-viewer
653-
{:pred sicmutils.expression/literal?
654+
{:pred emmy.expression/literal?
654655
:transform-fn (comp clerk/mark-preserve-keys
655656
(clerk/update-val transform-literal))
656657
:render-fn '(fn [label->val]
@@ -670,8 +671,8 @@ v/table-viewer
670671
;; representation!
671672

672673
^{::clerk/viewer literal-viewer}
673-
(sicm/+ (sicm/square (sicm/sin 'x))
674-
(sicm/square (sicm/cos 'x)))
674+
(emmy/+ (emmy/square (emmy/sin 'x))
675+
(emmy/square (emmy/cos 'x)))
675676

676677
;; #### 🥇 Selection
677678

@@ -696,8 +697,8 @@ v/table-viewer
696697

697698
;; As you can see we now get this viewer automatically, without
698699
;; needing to explicitly select it.
699-
(sicm/+ (sicm/square (sicm/sin 'x))
700-
(sicm/square (sicm/cos 'x)))
700+
(emmy/+ (emmy/square (emmy/sin 'x))
701+
(emmy/square (emmy/cos 'x)))
701702

702703
;; #### 🔓 Elisions
703704

deps.edn

+5-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@
7575
com.github.seancorfield/honeysql {:mvn/version "2.6.1126"}
7676
org.clojure/data.csv {:mvn/version "1.0.0"}
7777
hickory/hickory {:mvn/version "0.7.1"}
78-
sicmutils/sicmutils {:mvn/version "0.20.0"}
79-
io.github.mentat-collective/emmy {:git/sha "b98fef51d80d3edcff3100562b929f9980ff34d7"
80-
:exclusions [org.babashka/sci]}
78+
org.mentat/emmy {:mvn/version "0.32.0"
79+
:exclusions [org.babashka/sci]}
80+
;; emmy needs SCI, here we use the same version as in render:
81+
org.babashka/sci {:git/url "https://github.com/babashka/sci"
82+
:git/sha "c556f4474303c61da72e7a07eef496dcbf66a56e"}
8183
io.github.nextjournal/clerk-slideshow {:git/sha "11a83fea564da04b9d17734f2031a4921d917893"}}}
8284

8385
:nextjournal/garden {:exec-fn nextjournal.clerk/serve!

notebooks/double_pendulum.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[aerial.hanami.templates :as hanami-templates]
1515
[notespace-sicmutils.hanami-extras :as hanami-extras]
1616
[nextjournal.clerk :as clerk]
17-
[sicmutils.env :as e :refer :all]))
17+
[emmy.env :as e :refer :all]))
1818

1919
;; ## Lagrangian
2020
;;

notebooks/multiviewer.clj

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
(ns multiviewer
2-
(:require [clojure.walk :as w]
3-
[nextjournal.clerk :as clerk]
4-
[nextjournal.clerk.viewer :as viewer]
5-
[sicmutils.env :refer :all]
6-
[sicmutils.expression :as e]
7-
[sicmutils.value :as v]))
2+
(:require [nextjournal.clerk :as clerk]
3+
[emmy.env :refer :all]
4+
[emmy.expression :as e]
5+
[emmy.generic :as g]))
86

97
(defn ->formatted-str [expr]
10-
(let [form (v/freeze expr)]
8+
(let [form (g/freeze expr)]
119
(with-out-str (e/print-expression form))))
1210

1311
(defn transform-literal [literal]

notebooks/sicmutils.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
(:refer-clojure
1212
:exclude [+ - * / partial ref zero? numerator denominator compare = run!])
1313
(:require [nextjournal.clerk :as clerk]
14-
[sicmutils.env :as e :refer :all]))
14+
[emmy.env :as e :refer :all]))
1515

1616
;; ## Lagrangian
1717
;;

0 commit comments

Comments
 (0)