Skip to content

Instantly share code, notes, and snippets.

@davidvhill
Last active May 21, 2019 13:50
Show Gist options
  • Save davidvhill/83c793a02c1d85c61c4b0c829e0a99b9 to your computer and use it in GitHub Desktop.
Save davidvhill/83c793a02c1d85c61c4b0c829e0a99b9 to your computer and use it in GitHub Desktop.
Spec'd beginning of Clojure based change detection
(ns tmpclj.changedetection
(:require [clojure.spec.alpha :as s])
(:gen-class))
(s/def ::dates (s/coll-of int?))
(s/def ::reds (s/coll-of float?))
(s/def ::greens (s/coll-of float?))
(s/def ::blues (s/coll-of float?))
(s/def ::nirs (s/coll-of float?))
(s/def ::swir1s (s/coll-of float?))
(s/def ::swir2s (s/coll-of float?))
(s/def ::thermals (s/coll-of float?))
(s/def ::qas (s/coll-of float?))
(s/def ::input (s/keys :req [::dates
::reds
::blues
::greens
::nirs
::swir1s
::swir2s
::thermals
::qas]))
(s/def ::output (s/keys :req []))
(comment
(s/fdef detect
:args ::input
:ret ::output
:fn #(->> (:args %) vals (map count) (into #{}) count (= 1))))
(defn same-length?
[sequences]
(->> sequences
(map count)
(into #{})
count
(= 1)))
(defn procedure
[parameter]
(fn [x] x))
(defn detect
[inputs]
{:pre [(and (s/valid? ::input inputs) (same-length? (vals inputs)))]}
((procedure inputs) inputs) )
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Running Change Detection..."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment