Skip to content

Commit

Permalink
Merge pull request #37 from nubank/nodely/fix-get-contenxt-to-accept-nil
Browse files Browse the repository at this point in the history
[FIX] Adapting inference context operation to accept nil cases
  • Loading branch information
phbomfim authored Aug 29, 2024
2 parents 128c04f + ace4cf6 commit 4ddce66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.19.1 / 2024-08-28
- Fix Contextual protocol to accept nil context cases

## 1.19.0 / 2024-08-15
- Remove applicative engine dependency from funcool/cats

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject dev.nu/nodely "1.19.0"
(defproject dev.nu/nodely "1.19.1"
:description "Decoupling data fetching from data dependency declaration"
:url "https://github.com/nubank/nodely"
:license {:name "MIT"}
Expand Down
4 changes: 4 additions & 0 deletions src/nodely/engine/applicative/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
java.lang.Object
(-get-context [_] nil))

(extend-protocol p/Contextual
nil
(-get-context [_] nil))

(defn infer
"Given an optional value infer its context. If context is already set, it
is returned as is without any inference operation."
Expand Down
6 changes: 4 additions & 2 deletions test/nodely/fixtures.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

(defn leaf-gen
[env]
(gen/let [inputs (subset (keys env))]
(data/leaf inputs identity)))
(gen/let [inputs (subset (keys env))
f (gen/frequency [[1 (gen/return (constantly nil))]
[9 (gen/return identity)]])]
(data/leaf inputs f)))

(defn scalar-gen
[env]
Expand Down

0 comments on commit 4ddce66

Please sign in to comment.