Skip to content

Commit

Permalink
Merge branch 'master' into feature/marginalise
Browse files Browse the repository at this point in the history
  • Loading branch information
goldingn committed Aug 24, 2019
2 parents 0744608 + 91db596 commit f6c89e8
Show file tree
Hide file tree
Showing 169 changed files with 18,988 additions and 1,631 deletions.
40 changes: 0 additions & 40 deletions .README.Rmd

This file was deleted.

23 changes: 13 additions & 10 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
^CRAN-RELEASE$
^_pkgdown\.yml$
^.*\.Rproj$
^\.Rproj\.user$

^codemeta\.json$
^.github$
^.netlify$
^.lintr$
^.travis.yml$
^docs$
^.*\.Rproj$
^\.Rproj\.user$

^README\.md$
^CRAN-RELEASE$
^CODE_OF_CONDUCT\.md$
^\.EDIT_WEBSITE\.md$
^LICENSE$
^cran-comments\.md$

^logos$
^paper$

^_pkgdown\.yml$
^docs$
^inst/pkgdown$
^index\.Rmd$
^index_files$
^index_cache$
^index\.md$
^README\.Rmd$
^\.README\.Rmd$
^README\.md$
^README_files$
^README_cache$

^vignettes/get_started_cache$
^vignettes/example_models_cache$
^vignettes/webpages$
^vignettes/analyses$

^man/figures/vis-1\.png$
^man/figures/plot_greta_legend\.R$
^man/figures/name_icon_on_purple\.png$
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
.RData
.Ruserdata

*_cache
*_files

vignette/figures
vignettes/**/*_files/
*_cache/

*.pdf
docs/*.Rmd
docs/examples
cran-comments.md
paper/paper.html
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
linters: with_defaults(commas_linter = NULL, object_usage_linter = NULL)
linters: with_defaults(commas_linter = NULL, object_usage_linter = NULL, object_length_linter = NULL)
exclude: "# Exclude Linting"
exclude_start: "# Begin Exclude Linting"
exclude_end: "# End Exclude Linting"
120 changes: 54 additions & 66 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,73 @@ sudo: required
language: r
warnings_are_errors: false
dist: trusty

# enable RELEASE_CANDIDATE to run (slow & fragile) tests of sampler validity before releases
env:
global:
- RELEASE_CANDIDATE=false
- LINTR_COMMENT_BOT=false
- secure: cZMk6ONjL+YQ/NjJRujeCsZqnq8+avQ3LunQWp699cMvtWRqF1E6m3kxh9uTHExMduifTreNl7Fn7mPDRSJot5fBi1AMK15yRX4I/W0HSXm5hmdoZAxQCBXEy2Tcd5a6URE9epv0UBFPeWqnI7KHoXwR6BI9R6/kiRbnJJQbS+HItVUXIXfoX57ur5ujlh44JLT6It/p/J5R1nAJDMbjKPifVSxbXF+PMEWrVdJKqaN3IJVXBOYHICf0vQ+sXncF6xsYoYw7B76ZGUHgxF6u+pPCBjMDtmtIiJ9ucE7AnJcQNn4d8ehEimlU5OtEP7uVyJLR2TdDQb/4PIkXKAAT/KrXoDapZYayuBh4ROrPiswlWUp5E+CP5MzOBz4s8V8jlj9qLhJC5Asy8egyQ7BMK0a9Ei4C5vwvumfO+91NhNmsWJPR6T4NW+ea1btWsMwFDFlLewekKYL4qdM+H17pFs0lbkfqk3lqWd3Bhr/0uCTcJLQd8pVdT8IMouBoZBYGl6NztYecpEsl9YeF5wB/seG8HMZQ1wvGXiGyI7RXdDNb32+qMBWErbvQkqSqy7rXgLl0zvxERkjIuyCbIviEHdZPPKbX3P06+Cqd+iIGmuGSNEVTcjYe97rKFNC8eCud1VcEkk+h/nkB3bJLwMD1zjfHRJpCKR3Eh6Oh5ulDgyE=
- RELEASE_CANDIDATE=false
- LINTR_COMMENT_BOT=true
- secure: Q34zwlFiE+zShcPgTM99NILILBG2ViTaVo1ufRB/GFniGbEBIOwliqnozzWhhbuHEHG64qCNGbM4pMhyekC5YC9Rwp0QEt7sUk/tpV/17tkDiwjfEICAWsXK9rLrP3d3Pe8R/PYd4vyh8DiwgRl8woHCmmMJlIU9D/4XSOF6a325LX7U1ubJP5p5FrAdHt1ki4vEdUti4b7CdHZJHPjger+C+TNvvb75cIXR4RBbAKBHmpg/rTBASMRthJcKOGfym7QDsSrynQqMKR/BJsqzWvGzGYlUtGq04tHBbE9AVmcgRMqA5UuBcwmrKwQarx/yEX5YG8pVG2IgWKxowuxf+DGSwQ84m3D58fmiDcvdfNV5Spr9/lzXXMu3ae0WBbLOSIAc3FPJaEW4NK/HkeXrqbFnDy1dm0trLvG5AE0XisTcwFpoyx8+PnbAAa9fkJSOP+1n8472ym6OGRfngs1GoMrFaCpUaLug9eux2Ckc1sq2cLOo9wWzTsIoFDKCS5uBEvj1Vw1I845iO0fymj0IGTpLtjoNHGNMVyb+YQ+yTIIjW/8sgYhj+NaDqvjCwSgaHEJbWouCgoxsFhKaXsivosWZDebMM1PLsUaDyShv3DwOuFv5xD+0pX4AiuSDhhrVO7yThgiqD9KCa/30d1/CXU/GSTV5OlShJLz2XsLr7+E=

r_binary_packages:
- abind
- coda
- codetools
- colorspace
- DBI
- digest
- foreign
- ggplot2
- inline
- lattice
- MASS
- MCMCpack
- mgcv
- mvtnorm
- nlme
- plyr
- Rcpp
- rpart
- rstan
- stringr
- survival
- XML

- abind
- coda
- codetools
- DBI
- foreign
- ggplot2
- inline
- lattice
- MASS
- MCMCpack
- mgcv
- mvtnorm
- nlme
- Rcpp
- rpart
- stringr
- survival
r_packages:
- reticulate
- tensorflow
- R6
- testthat
- covr
- DiagrammeR
- knitr
- rmarkdown
- rsvg
- bayesplot
- extraDistr
- devtools
- tidyverse
- lintr

r_github_packages:
- rich-iannone/DiagrammeRsvg

- reticulate
- tensorflow
- R6
- testthat
- covr
- DiagrammeR
- knitr
- rmarkdown
- rsvg
- bayesplot
- extraDistr
- devtools
- tidyverse
- lintr
- colorspace
- digest
- XML
- plyr
- DiagrammeRsvg
cache:
packages: true
directories:
- $HOME/.cache/pip

- "$HOME/.cache/pip"
addons:
apt:
sources:
ubuntu-toolchain-r-test
sources: ubuntu-toolchain-r-test
packages:
- libmagick++-dev
- wget
- libatlas3gf-base
- libatlas-dev
- python-joblib
- python-dev
- libv8-dev

- libmagick++-dev
- wget
- libatlas3gf-base
- libatlas-dev
- python-joblib
- python-dev
- libv8-dev
before_install:
- pip install --user numpy
- pip install --user scipy
- pip install --user 'tensorflow==1.10'
- pip install --user 'tensorflow-probability'

- pip install --user numpy
- pip install --user scipy
- pip install --user 'tensorflow==1.14'
- pip install --user 'tensorflow-probability==0.7.0'
after_success:
- Rscript -e "covr::codecov()"
- Rscript -e "lintr::lint_package()"

- Rscript -e "covr::codecov()"
- Rscript -e "lintr::lint_package()"
email:
on_success: change
on_failure: change
20 changes: 12 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: greta
Type: Package
Title: Simple and Scalable Statistical Modelling in R
Version: 0.3.0.9001
Date: 2018-11-12
Version: 0.3.1.9003
Date: 2019-08-21
Authors@R: c(
person("Nick", "Golding", role = c("aut", "cre"),
email = "[email protected]",
Expand All @@ -19,13 +19,15 @@ Authors@R: c(
person("Paul", "Teetor", role = "ctb"),
person("Jian", "Yen", role = "ctb")
)
Description: Write statistical models in R and fit them by MCMC on CPUs and GPUs, using Google TensorFlow (see <https://greta-dev.github.io/greta> for more information).
Description: Write statistical models in R and fit them by MCMC and optimisation on CPUs and GPUs, using Google 'TensorFlow'.
greta lets you write your own model like in BUGS, JAGS and Stan, except that you write models right in R, it scales well to massive datasets, and it’s easy to extend and build on.
See the website for more information, including tutorials, examples, package documentation, and the greta forum.
License: Apache License 2.0
URL: https://github.com/greta-dev/greta
URL: https://greta-stats.org
BugReports: https://github.com/greta-dev/greta/issues
SystemRequirements: Python (>= 2.7.0) with header files and shared library;
TensorFlow (>= 1.10; https://www.tensorflow.org/);
Tensorflow Probability (>=0.5.0; https://www.tensorflow.org/probability/)
TensorFlow (v1.14; https://www.tensorflow.org/);
TensorFlow Probability (v0.7.0; https://www.tensorflow.org/probability/)
Encoding: UTF-8
LazyData: true
Depends:
Expand Down Expand Up @@ -65,7 +67,7 @@ Collate:
'marginalisers.R'
Imports:
R6,
tensorflow,
tensorflow (>= 1.13.0),
reticulate,
progress (>= 1.2.0),
future,
Expand All @@ -86,6 +88,8 @@ Suggests:
tidyverse,
fields,
MASS,
abind
abind,
spelling
VignetteBuilder: knitr
RoxygenNote: 6.1.1
Language: en-GB
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ S3method(print,initials)
S3method(print,marginaliser)
S3method(print,optimiser)
S3method(print,sampler)
S3method(print,summary.greta_array)
S3method(print,unknowns)
S3method(prod,greta_array)
S3method(rbind,greta_array)
Expand Down Expand Up @@ -221,6 +222,7 @@ importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(progress,progress_bar)
importFrom(reticulate,conda_binary)
importFrom(reticulate,import)
importFrom(reticulate,py_available)
importFrom(reticulate,py_module_available)
importFrom(reticulate,py_set_attr)
Expand Down
11 changes: 9 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# greta 0.3.0.9001
# greta (development version)

* mcmc now works with TensorFlow Probability version 0.5.0 (#248)
# greta 0.3.1

This release is predominantly a patch to make greta work with recent versions of TensorFlow and TensorFlow Probability, which were not backward compatible with the versions on which greta previously depended. From this release forward, greta will depend on specific (rather than minimum) versions of these two pieces of software to avoid it breaking if more changes are made to the APIS of these packages.

* greta now (only) works with TensorFlow 1.14.0 and TensorFlow Probability 0.7.0 (#289, #290)

* behaviour of the `pb_update` argument to `mcmc()` has been changed slightly to avoid a bad interaction with thinning (#284)

* various edits to the documentation to fix spelling mistakes and typos

# greta 0.3.0

Expand Down
5 changes: 5 additions & 0 deletions R/as_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ as_data <- function(x) {
UseMethod("as_data", x)
}


# if it's already a *data* greta_array fine, else error
# Begin Exclude Linting
#' @export
as_data.greta_array <- function(x) {
# End Exclude Linting
if (!inherits(get_node(x), "data_node")) {
stop("cannot coerce a non-data greta_array to data",
call. = FALSE)
Expand All @@ -47,7 +50,9 @@ as_data.greta_array <- function(x) {
}

# otherwise try to coerce to a greta array
# Begin Exclude Linting
#' @export
as_data.default <- function(x) {
# End Exclude Linting
as.greta_array(x)
}
6 changes: 4 additions & 2 deletions R/calculate.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ calculate <- function(target, values = list(),

}

# Begin Exclude Linting
calculate_mcmc.list <- function(target, target_name, values, tf_float) {
# End Exclude Linting

model_info <- get_model_info(values)

Expand Down Expand Up @@ -173,13 +175,13 @@ calculate_list <- function(target, values, tf_float) {
# check that there are no unspecified variables on which the target depends

# find all the nodes depended on by this one
dependencies <- get_node(target)$child_names(recursive = TRUE)
dependencies <- get_node(target)$parent_names(recursive = TRUE)

# find all the nodes depended on by the new values, and remove them from the
# list
complete_dependencies <- lapply(fixed_greta_arrays,
function(x)
get_node(x)$child_names(recursive = TRUE))
get_node(x)$parent_names(recursive = TRUE))
complete_dependencies <- unique(unlist(complete_dependencies))

unmet_dependencies <- dependencies[!dependencies %in% complete_dependencies]
Expand Down
Loading

1 comment on commit f6c89e8

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/marginalise.R:28:8: style: Commented code should be removed.

#' #   n <- poisson(lambda)
       ^~~~~~~~~~~~~~~~~~~~

R/marginalise.R:29:8: style: Commented code should be removed.

#' #   mu <- theta ^ n
       ^~~~~~~~~~~~~~~

R/marginalise.R:30:8: style: Commented code should be removed.

#' #   distribution(y) <- normal(mu, sd)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/marginalisers.R:146:1: style: lines should not be more than 80 characters.

# simpler interface to conditional density. If reduce = TRUE, it does reduce_sum on component densities
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/marginalisers.R:154:1: style: lines should not be more than 80 characters.

# get the vectors of first and second derivatives of the conditional density function,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/marginalisers.R:230:7: style: Variable and function names should be all lowercase.

rW <- sqrt(W)
      ^~

R/marginalisers.R:236:25: style: Variable and function names should be all lowercase.

mat1 <- tf$matmul(rW, tf_transpose(rW)) * Sigma + eye
                        ^~

R/marginalisers.R:236:42: style: Variable and function names should be all lowercase.

mat1 <- tf$matmul(rW, tf_transpose(rW)) * Sigma + eye
                                         ^~

R/marginalisers.R:242:15: style: Variable and function names should be all lowercase.

mat2 <- rW * tf$matmul(Sigma, b)
              ^~

R/marginalisers.R:244:20: style: Variable and function names should be all lowercase.

adiff <- b - rW * tf$matrix_triangular_solve(L, mat3, lower = FALSE) - a
                   ^~

R/marginalisers.R:301:5: style: Variable and function names should be all lowercase.

rW <- sqrt(W)
    ^~

R/marginalisers.R:307:23: style: Variable and function names should be all lowercase.

mat1 <- tf$matmul(rW, tf_transpose(rW)) * Sigma + eye
                      ^~

R/marginalisers.R:307:40: style: Variable and function names should be all lowercase.

mat1 <- tf$matmul(rW, tf_transpose(rW)) * Sigma + eye
                                       ^~

R/marginalisers.R:344:1: style: lines should not be more than 80 characters.

as_marginaliser <- function (name, tf_marginaliser, parameters, distribution_check) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_marginalisation.R:35:23: style: Opening curly braces should never go on their own line and should always be followed by a new line.

fun <- function (x) {x + normal(0, 1)}
                      ^

tests/testthat/test_marginalisation.R:35:40: style: Closing curly-braces should always be on their own line, unless it's followed by an else.

fun <- function (x) {x + normal(0, 1)}
                                       ^

tests/testthat/test_marginalisation.R:44:23: style: Opening curly braces should never go on their own line and should always be followed by a new line.

fun <- function (x) {x * 2}
                      ^

tests/testthat/test_marginalisation.R:44:29: style: Closing curly-braces should always be on their own line, unless it's followed by an else.

fun <- function (x) {x * 2}
                            ^

tests/testthat/test_marginalisation.R:207:1: style: Trailing blank lines are superfluous.

^

tests/testthat/test_marginalisation.R:208:1: style: Trailing blank lines are superfluous.

^

Please sign in to comment.