-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move literal-function => abstract, switch fn inheritance order #171
Conversation
Codecov Report
@@ Coverage Diff @@
## sritchie/abstract_updates #171 +/- ##
=============================================================
+ Coverage 84.41% 84.50% +0.08%
=============================================================
Files 73 73
Lines 6858 6859 +1
Branches 394 393 -1
=============================================================
+ Hits 5789 5796 +7
+ Misses 675 670 -5
+ Partials 394 393 -1
Continue to review full report at Codecov.
|
;; along with this code; if not, see <http://www.gnu.org/licenses/>. | ||
;; | ||
|
||
(ns sicmutils.abstract.function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a move, nothing new.
@@ -110,6 +110,13 @@ | |||
(x/expression-of expr) | |||
expr)) | |||
|
|||
(defn- defunary [generic-op op-sym] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this up to keep unary => binary order...
@@ -431,14 +432,11 @@ | |||
((d f) (first xs)) | |||
((d #(apply f %)) (matrix/seq-> xs))))))) | |||
|
|||
(derive ::x/numeric ::codiff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had introduced this and forgotten that ::scalar
was all we really need, no need now for a new ::codiff
.
@@ -493,11 +491,14 @@ | |||
(defmethod g/partial-derivative [::matrix/matrix v/seqtype] [f selectors] | |||
(multivariate-derivative f selectors)) | |||
|
|||
(def derivative-symbol 'D) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this in here so it lives in this one spot.
@@ -31,6 +32,8 @@ | |||
|
|||
(declare generate) | |||
|
|||
(derive ::matrix ::f/cofunction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@littleredcomputer , curious what you think here. I realized that if we were building this up from scratch, we wouldn't have matrices at the point where we added functions... so I moved this derivation over to matrix
, so that function.cljc
could stay cleaner.
What do you think?
If someone ever wants to use a matrix, they have to require this ns
anyway, which will trigger the derive
call. And if they don't, no sweat.
@@ -563,6 +563,7 @@ | |||
|
|||
(derive ::x/numeric ::coseries) | |||
(derive ::v/number ::coseries) | |||
(derive ::v/function ::coseries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thought here as in matrix; series should register themselves.
(derive ::up ::structure) | ||
(derive ::down ::structure) | ||
(derive PersistentVector ::up) | ||
|
||
;; Structures can interact with functions. | ||
(derive ::structure ::f/cofunction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thought here.
;; along with this code; if not, see <http://www.gnu.org/licenses/>. | ||
;; | ||
|
||
(ns sicmutils.abstract.function-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are all the tests that explicitly use literal-function
.
[sicmutils.generic :as g] | ||
[sicmutils.generators :as sg] | ||
[sicmutils.matrix :as m] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only tests left here are the ones that did NOT use literal-function. Now we can add more, only about Clojure functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR
::v/function
and::sicmutils.function
literal-function
machinery and tests into their own namespace,sicmutils.abstract.function
sicmutils.function
quite clean. This gets the library closer to a "built from Clojure up" style.::v/function
is now the main thing, and
::sicmutils.function/function` extends from this.