Skip to content

Commit

Permalink
chore: Renamed src namespaces and path from iql to gensql
Browse files Browse the repository at this point in the history
Retained old inferenceql symbols in gpm/readers, for backwards-compatibility.
  • Loading branch information
KingMob committed Apr 29, 2024
1 parent 266cfbe commit 77694f6
Show file tree
Hide file tree
Showing 45 changed files with 205 additions and 194 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# inferenceql.inference
# GenSQL.inference

![tests](https://github.com/probcomp/inferenceql.inference/workflows/tests/badge.svg)
![linter](https://github.com/probcomp/inferenceql.inference/workflows/lint/badge.svg)
![tests](https://github.com/OpenGen/GenSQL.inference/workflows/tests/badge.svg)
![linter](https://github.com/OpenGen/GenSQL.inference/workflows/lint/badge.svg)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.approximate
(:require [inferenceql.inference.gpm.proto :as gpm.proto]
[inferenceql.inference.utils :as utils]))
(ns gensql.inference.approximate
(:require [gensql.inference.gpm.proto :as gpm.proto]
[gensql.inference.utils :as utils]))

(defn mutual-info
"Given a GPM, estimates the mutual-information of `target-a` and `target-b`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns inferenceql.inference.distributions
(ns gensql.inference.distributions
(:require [clojure.math :as math]
[clojure.spec.alpha :as s]
[inferenceql.inference.gpm.multimixture.specification :as spec]
[gensql.inference.gpm.multimixture.specification :as spec]
[metaprob.distributions]
[metaprob.prelude :as mp]))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns inferenceql.inference.dpm
(ns gensql.inference.dpm
"Functions operating on discriminative population models. All probabilistic
models for which you can simulate and compute the log-PDF only for a set of
dependent variables (most typically 1 column variable), and for which
Expand Down Expand Up @@ -40,8 +40,8 @@
:dpm dpm}))))

(defn assert-args-valid
"Asserts that `inferenceql.inference.gpm/logpdf` and
`inferenceql.inference.gpm/constraints` can be called with the provided
"Asserts that `gensql.inference.gpm/logpdf` and
`gensql.inference.gpm/constraints` can be called with the provided
targeted and constrained variables."
[dpm target-variables constrained-variables]
(assert-targets-dependent dpm target-variables)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns inferenceql.inference.event
(ns gensql.inference.event
"Functions to process SPPL-style events.")

(defn operator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
(ns inferenceql.inference.gpm
(ns gensql.inference.gpm
(:refer-clojure :exclude [merge read read-string])
(:require [clojure.core :as clojure]
[clojure.edn :as edn]
[inferenceql.inference.gpm.column :as column]
[inferenceql.inference.gpm.compositional :as compositional]
[inferenceql.inference.gpm.crosscat :as xcat]
#?(:clj [inferenceql.inference.gpm.ensemble :as ensemble])
#?(:clj [inferenceql.inference.gpm.http :as http])
[inferenceql.inference.gpm.multimixture :as mmix]
[inferenceql.inference.gpm.multimixture.specification :as mmix.spec]
[inferenceql.inference.gpm.primitive-gpms.bernoulli :as bernoulli]
[inferenceql.inference.gpm.primitive-gpms.categorical :as categorical]
[inferenceql.inference.gpm.primitive-gpms.gaussian :as gaussian]
[inferenceql.inference.gpm.proto :as gpm-proto]
[inferenceql.inference.gpm.view :as view]))
[gensql.inference.gpm.column :as column]
[gensql.inference.gpm.compositional :as compositional]
[gensql.inference.gpm.crosscat :as xcat]
#?(:clj [gensql.inference.gpm.ensemble :as ensemble])
#?(:clj [gensql.inference.gpm.http :as http])
[gensql.inference.gpm.multimixture :as mmix]
[gensql.inference.gpm.multimixture.specification :as mmix.spec]
[gensql.inference.gpm.primitive-gpms.bernoulli :as bernoulli]
[gensql.inference.gpm.primitive-gpms.categorical :as categorical]
[gensql.inference.gpm.primitive-gpms.gaussian :as gaussian]
[gensql.inference.gpm.proto :as gpm-proto]
[gensql.inference.gpm.view :as view]))

#?(:clj
(defn http
Expand Down Expand Up @@ -144,7 +144,18 @@
(gpm-proto/constrain gpm event opts))

(def readers
{'inferenceql.inference.gpm.column.Column column/map->Column
{'gensql.inference.gpm.column.Column column/map->Column
'gensql.inference.gpm.compositional.Compositional compositional/map->Compositional
'gensql.inference.gpm.crosscat.XCat xcat/map->XCat
#?@(:clj ['gensql.inference.gpm.ensemble.Ensemble ensemble/map->Ensemble])
'gensql.inference.gpm.multimixture.Multimixture mmix/map->Multimixture
'gensql.inference.gpm.primitive_gpms.bernoulli.Bernoulli bernoulli/map->Bernoulli
'gensql.inference.gpm.primitive_gpms.categorical.Categorical categorical/map->Categorical
'gensql.inference.gpm.primitive_gpms.gaussian.Gaussian gaussian/map->Gaussian
'gensql.inference.gpm.view.View view/map->View

;; for backwards-compatibility with older models
'inferenceql.inference.gpm.column.Column column/map->Column
'inferenceql.inference.gpm.compositional.Compositional compositional/map->Compositional
'inferenceql.inference.gpm.crosscat.XCat xcat/map->XCat
#?@(:clj ['inferenceql.inference.gpm.ensemble.Ensemble ensemble/map->Ensemble])
Expand All @@ -166,7 +177,7 @@

(defn read
"Like `clojure.edn/read` but includes readers for records in
`inferneceql.inference`."
`gensql.inference`."
([stream]
(read {} stream))
([opts stream]
Expand All @@ -176,7 +187,7 @@

(defn ^:export read-string
"Like `clojure.edn/read-string` but includes readers for records from
`inferenceql.inference`."
`gensql.inference`."
([s]
(read-string {} s))
([opts s]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(ns inferenceql.inference.gpm.column
(ns gensql.inference.gpm.column
"Implementation of a GPM that represents a population of data of the
same primitive type. For a tabular dataset, this GPM abstracts a Column
of that dataset. See `inferenceql.inference.gpm/column` for details."
of that dataset. See `gensql.inference.gpm/column` for details."
(:require [clojure.math :as math]
[inferenceql.inference.gpm.conditioned :as conditioned]
[inferenceql.inference.gpm.constrained :as constrained]
[inferenceql.inference.gpm.primitive-gpms :as pgpms]
[inferenceql.inference.gpm.proto :as gpm.proto]
[inferenceql.inference.primitives :as primitives]
[inferenceql.inference.utils :as utils]))
[gensql.inference.gpm.conditioned :as conditioned]
[gensql.inference.gpm.constrained :as constrained]
[gensql.inference.gpm.primitive-gpms :as pgpms]
[gensql.inference.gpm.proto :as gpm.proto]
[gensql.inference.primitives :as primitives]
[gensql.inference.utils :as utils]))

(defn crp-weights
"Given a column and alpha, returns the CRP prior over categories."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns inferenceql.inference.gpm.compositional
(ns gensql.inference.gpm.compositional
(:require [clojure.set :as set]
[inferenceql.inference.dpm :as dpm]
[inferenceql.inference.gpm.proto :as proto]
[gensql.inference.dpm :as dpm]
[gensql.inference.gpm.proto :as proto]
[metaprob.distributions :as dist]))

(defn ^:private monte-carlo-integration
Expand All @@ -26,7 +26,7 @@
independent-targets (set/intersection target-variables independent-variables)]
(cond (and (seq dependent-targets)
(seq independent-targets))
(throw (ex-info "`inferenceql.inference.gpm/logpdf` cannot be computed for a mixture of dependent and independent target variables."
(throw (ex-info "`gensql.inference.gpm/logpdf` cannot be computed for a mixture of dependent and independent target variables."
{:dependent-targets dependent-targets
:independent-targets independent-targets
:dpm dpm}))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns inferenceql.inference.gpm.conditioned
(:require [inferenceql.inference.gpm.proto :as gpm.proto]))
(ns gensql.inference.gpm.conditioned
(:require [gensql.inference.gpm.proto :as gpm.proto]))

(defrecord ConditionedGPM [gpm conditions]
gpm.proto/GPM
Expand All @@ -23,7 +23,7 @@

(defn condition
"Conditions gpm based on conditions via rejection sampling. Arguments are the
same as those for `inferenceql.inference.gom/condition`."
same as those for `gensql.inference.gom/condition`."
[gpm conditions]
(assert map? conditions)
(->ConditionedGPM gpm conditions))
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns inferenceql.inference.gpm.constrained
(ns gensql.inference.gpm.constrained
(:refer-clojure :exclude [eval])
(:require [clojure.math :as math]
[inferenceql.inference.gpm.proto :as gpm.proto]
[gensql.inference.gpm.proto :as gpm.proto]
[net.cgrand.xforms.rfs :as rfs]))

(defn ^:private and-f
Expand Down Expand Up @@ -78,7 +78,7 @@

(defn constrain
"Constrains gpm based on event via rejection sampling. Arguments are the same
as those for `inferenceql.inference.gpm/constrain`."
as those for `gensql.inference.gpm/constrain`."
[gpm event opts]
(let [pred? (event->pred event opts)
variables (event->variables event opts)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(ns inferenceql.inference.gpm.crosscat
(ns gensql.inference.gpm.crosscat
(:require [clojure.set :as set]
[clojure.edn :as edn]
[inferenceql.inference.gpm.conditioned :as conditioned]
[inferenceql.inference.gpm.constrained :as constrained]
[inferenceql.inference.gpm.view :as view]
[inferenceql.inference.gpm.column :as column]
[inferenceql.inference.gpm.primitive-gpms :as pgpms]
[inferenceql.inference.gpm.proto :as gpm.proto]
[inferenceql.inference.primitives :as primitives]))
[gensql.inference.gpm.conditioned :as conditioned]
[gensql.inference.gpm.constrained :as constrained]
[gensql.inference.gpm.view :as view]
[gensql.inference.gpm.column :as column]
[gensql.inference.gpm.primitive-gpms :as pgpms]
[gensql.inference.gpm.proto :as gpm.proto]
[gensql.inference.primitives :as primitives]))

(defn update-hyper-grids
"Given a collection of columns, updates the columns' respective hyper grids."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(ns inferenceql.inference.gpm.ensemble
(ns gensql.inference.gpm.ensemble
(:require [clojure.math :as math]
[inferenceql.inference.gpm.conditioned :as conditioned]
[inferenceql.inference.gpm.constrained :as constrained]
[inferenceql.inference.gpm.proto :as gpm.proto]
[inferenceql.inference.utils :as utils])
[gensql.inference.gpm.conditioned :as conditioned]
[gensql.inference.gpm.constrained :as constrained]
[gensql.inference.gpm.proto :as gpm.proto]
[gensql.inference.utils :as utils])
#?(:clj (:import [java.util ArrayList]
[org.apache.commons.math3.distribution EnumeratedDistribution]
[org.apache.commons.math3.util Pair])))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns inferenceql.inference.gpm.http
(ns gensql.inference.gpm.http
"Implementation of a GPM that forwards requests over HTTP. See
`inferenceql.inference.gpm/http` for details."
`gensql.inference.gpm/http` for details."
(:require [clj-http.client :as http]
[inferenceql.inference.gpm.conditioned :as conditioned]
[inferenceql.inference.gpm.constrained :as constrained]
[inferenceql.inference.gpm.proto :as proto]
[gensql.inference.gpm.conditioned :as conditioned]
[gensql.inference.gpm.constrained :as constrained]
[gensql.inference.gpm.proto :as proto]
[jsonista.core :as json]))

(defrecord HTTP [url]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(ns inferenceql.inference.gpm.multimixture
(ns gensql.inference.gpm.multimixture
(:require [metaprob.prelude :as mp]
[inferenceql.inference.gpm.conditioned :as conditioned]
[inferenceql.inference.gpm.constrained :as constrained]
[inferenceql.inference.gpm.multimixture.utils :as mmix.utils]
[inferenceql.inference.gpm.proto :as gpm-proto]))
[gensql.inference.gpm.conditioned :as conditioned]
[gensql.inference.gpm.constrained :as constrained]
[gensql.inference.gpm.multimixture.utils :as mmix.utils]
[gensql.inference.gpm.proto :as gpm-proto]))

;; XXX Currently, assumes that the row generator of the mmix map is passed in.
(defrecord Multimixture [vars views]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.gpm.multimixture.metrics
(ns gensql.inference.gpm.multimixture.metrics
(:require [clojure.math :as math]
[inferenceql.inference.gpm.multimixture.utils :as utils]))
[gensql.inference.gpm.multimixture.utils :as utils]))

(defn check-distribution-criteria
"Checks basic assumptions about two distributions being compared.
Expand Down Expand Up @@ -44,7 +44,7 @@
(defn jensen-shannon-divergence
"Calculates the Jenson-Shannon divergence between two distributions.
Since it depends on
`inferenceql.inference.multimixture.metrics/kl-divergence`, `p` must be zero
`gensql.inference.multimixture.metrics/kl-divergence`, `p` must be zero
when `q` is zero. `p` and `q` must have the same alphabet size (i.e. length)."
[p q]
(check-distribution-criteria p q)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.gpm.multimixture.metrics-viz
(ns gensql.inference.gpm.multimixture.metrics-viz
(:require [clojure.string :refer [split]]
[inferenceql.inference.gpm.multimixture.metrics :as metrics]))
[gensql.inference.gpm.multimixture.metrics :as metrics]))

(defmacro with-out-str-data-time-map
"Returns time and data of an expression of the form `(time expression)`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns inferenceql.inference.gpm.multimixture.search
(ns gensql.inference.gpm.multimixture.search
(:require [clojure.math :as math]
[clojure.spec.alpha :as s]
[inferenceql.inference.distributions :as idbdist]
[inferenceql.inference.gpm :as gpm]
[inferenceql.inference.gpm.multimixture.specification :as spec]
[inferenceql.inference.gpm.multimixture.utils :as mmix.utils]
[inferenceql.inference.utils :as utils]
[gensql.inference.distributions :as idbdist]
[gensql.inference.gpm :as gpm]
[gensql.inference.gpm.multimixture.specification :as spec]
[gensql.inference.gpm.multimixture.utils :as mmix.utils]
[gensql.inference.utils :as utils]
[metaprob.distributions :as dist]
[metaprob.generative-functions :as g :refer [at gen]]
[metaprob.prelude :as mp]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.gpm.multimixture.search.deterministic
(:require [inferenceql.inference.utils :as utils]
[inferenceql.inference.gpm.multimixture.search.utils :as search.utils]))
(ns gensql.inference.gpm.multimixture.search.deterministic
(:require [gensql.inference.utils :as utils]
[gensql.inference.gpm.multimixture.search.utils :as search.utils]))

#?(:cljs (enable-console-print!))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns inferenceql.inference.gpm.multimixture.search.enumerative
(ns gensql.inference.gpm.multimixture.search.enumerative
(:require [clojure.math.combinatorics :as combo]
[inferenceql.inference.utils :as utils]
[inferenceql.inference.gpm.multimixture.search.utils :as search.utils]))
[gensql.inference.utils :as utils]
[gensql.inference.gpm.multimixture.search.utils :as search.utils]))

(defn rows->all-cluster-configurations
"Returns a (lazy) sequence of all possible cluster configurations for rows."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.gpm.multimixture.search.gibbs
(ns gensql.inference.gpm.multimixture.search.gibbs
(:require [metaprob.distributions :as dist]
[inferenceql.inference.gpm.multimixture.search.utils :as search.utils]))
[gensql.inference.gpm.multimixture.search.utils :as search.utils]))

(defn sample-cluster-assignments
"Given a probability table for rows, samples cluster assignments. A valid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns inferenceql.inference.gpm.multimixture.search.utils
(:require [inferenceql.inference.gpm.multimixture.utils :as mmix.utils]
[inferenceql.inference.utils :as utils]
(ns gensql.inference.gpm.multimixture.search.utils
(:require [gensql.inference.gpm.multimixture.utils :as mmix.utils]
[gensql.inference.utils :as utils]
[metaprob.prelude :as mp]))

(defn normalize-row-probability
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns inferenceql.inference.gpm.multimixture.specification
(ns gensql.inference.gpm.multimixture.specification
(:require [clojure.spec.alpha :as s]))

(s/def ::alpha pos?)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(ns inferenceql.inference.gpm.multimixture.utils
(ns gensql.inference.gpm.multimixture.utils
#?(:cljs (:require-macros [metaprob.generative-functions :refer [gen]]))
(:require [clojure.math.combinatorics :as combo]
[clojure.spec.alpha :as s]
#?(:clj [metaprob.generative-functions :as g :refer [apply-at at gen]]
:cljs [metaprob.generative-functions :as g :refer [apply-at at]])
[metaprob.distributions :as dist]
[metaprob.prelude :as mp]
[inferenceql.inference.gpm.multimixture.specification :as spec]))
[gensql.inference.gpm.multimixture.specification :as spec]))

(defn row-generator
"Returns a generative function that samples a row from the provided view
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns inferenceql.inference.gpm.primitive-gpms
(:require [inferenceql.inference.gpm.primitive-gpms.bernoulli :as bernoulli]
[inferenceql.inference.gpm.primitive-gpms.categorical :as categorical]
[inferenceql.inference.gpm.primitive-gpms.gaussian :as gaussian]))
(ns gensql.inference.gpm.primitive-gpms
(:require [gensql.inference.gpm.primitive-gpms.bernoulli :as bernoulli]
[gensql.inference.gpm.primitive-gpms.categorical :as categorical]
[gensql.inference.gpm.primitive-gpms.gaussian :as gaussian]))

(defn primitive?
"Checks whether the given GPM is a primitive GPM."
Expand Down
Loading

0 comments on commit 77694f6

Please sign in to comment.