Skip to content

Commit d3fcacd

Browse files
authored
Merge branch 'master' into add-more-info-sitrep-612
2 parents d5305fd + c41858c commit d3fcacd

File tree

271 files changed

+8423
-6605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+8423
-6605
lines changed

.github/workflows/R-CMD-check.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ jobs:
8181
run: remotes::install_local(dependencies = TRUE, force = TRUE)
8282

8383
- name: Install greta deps
84-
run: greta::install_greta_deps(timeout = 50)
84+
run: |
85+
library(greta)
86+
greta::install_greta_deps(timeout = 50)
8587
8688
- name: Situation Report on greta install
8789
run: greta::greta_sitrep()

.github/workflows/test-coverage.yaml

+62-49
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,89 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on:
24
push:
3-
branches:
4-
- main
5-
- master
5+
branches: [main, master]
66
pull_request:
7-
branches:
8-
- main
9-
- master
7+
branches: [main, master]
108

11-
name: test-coverage
9+
name: test-coverage.yaml
10+
11+
permissions: read-all
1212

1313
jobs:
1414
test-coverage:
15-
runs-on: macOS-latest
15+
runs-on: ubuntu-latest
1616
env:
1717
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18+
1819
steps:
19-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2021

2122
- uses: r-lib/actions/setup-r@v2
23+
with:
24+
use-public-rspm: true
2225

23-
- uses: r-lib/actions/setup-pandoc@v2
24-
25-
- name: Query dependencies
26-
run: |
27-
install.packages('remotes')
28-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
29-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
30-
shell: Rscript {0}
31-
32-
- name: Restore R package cache
33-
uses: actions/cache@v2
26+
- uses: r-lib/actions/setup-r-dependencies@v2
3427
with:
35-
path: ${{ env.R_LIBS_USER }}
36-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
37-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
28+
extra-packages: |
29+
any::covr
30+
any::xml2
31+
any::remotes
32+
needs: coverage
3833

39-
- name: Install dependencies
34+
- name: Install system dependencies
35+
if: runner.os == 'Linux'
36+
shell: bash
4037
run: |
41-
install.packages(c("remotes"))
42-
remotes::install_deps(dependencies = TRUE)
43-
remotes::install_cran("covr")
38+
. /etc/os-release
39+
while read -r cmd
40+
do
41+
echo "$cmd"
42+
sudo $cmd
43+
done < <(Rscript -e "writeLines(remotes::system_requirements('$ID-$VERSION_ID'))")
44+
45+
- name: Install package + deps
46+
run: remotes::install_local(dependencies = TRUE, force = TRUE)
4447
shell: Rscript {0}
4548

46-
###
47-
- name: Install Miniconda
49+
- name: Install greta deps
4850
run: |
49-
install.packages(c("remotes", "keras"))
50-
reticulate::install_miniconda()
51+
library(greta)
52+
greta::install_greta_deps(timeout = 50)
5153
shell: Rscript {0}
5254

53-
- name: Set options for conda binary for macOS
54-
if: runner.os == 'macOS'
55-
run: |
56-
echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
55+
- name: Situation Report on greta install
56+
run: greta::greta_sitrep()
57+
shell: Rscript {0}
5758

58-
# Perhaps here is where we can install / change the environment that we are
59-
# installing into? Can we call our own greta install functions here?
60-
- name: Install TensorFlow
59+
- name: Test coverage
6160
run: |
62-
reticulate::conda_create(envname = "greta-env",python_version = "3.7")
63-
reticulate::conda_install(envname = "greta-env", packages = c("numpy==1.16.4", "tensorflow-probability==0.7.0", "tensorflow==1.14.0"))
61+
cov <- covr::package_coverage(
62+
quiet = FALSE,
63+
clean = FALSE,
64+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
65+
)
66+
covr::to_cobertura(cov)
6467
shell: Rscript {0}
6568

66-
- name: Python + TF details
69+
- uses: codecov/codecov-action@v4
70+
with:
71+
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
72+
file: ./cobertura.xml
73+
plugin: noop
74+
disable_search: true
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
77+
- name: Show testthat output
78+
if: always()
6779
run: |
68-
Rscript -e 'tensorflow::tf_config()'
69-
Rscript -e 'tensorflow::tf_version()'
70-
Rscript -e 'reticulate::py_module_available("tensorflow_probability")'
71-
Rscript -e 'reticulate::py_config()'
72-
###
80+
## --------------------------------------------------------------------
81+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
82+
shell: bash
7383

74-
- name: Test coverage
75-
run: covr::codecov()
76-
shell: Rscript {0}
84+
- name: Upload test results
85+
if: failure()
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: coverage-test-failures
89+
path: ${{ runner.temp }}/package

DESCRIPTION

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: greta
33
Title: Simple and Scalable Statistical Modelling in R
4-
Version: 0.4.5.9000
4+
Version: 0.5.0.9000
55
Authors@R: c(
66
person("Nick", "Golding", , "[email protected]", role = "aut",
77
comment = c(ORCID = "0000-0001-8916-5570")),
@@ -28,7 +28,7 @@ Description: Write statistical models in R and fit them by MCMC and
2828
including tutorials, examples, package documentation, and the greta
2929
forum.
3030
License: Apache License 2.0
31-
URL: https://greta-stats.org
31+
URL: https://greta-stats.org, https://github.com/greta-dev/greta
3232
BugReports: https://github.com/greta-dev/greta/issues
3333
Depends:
3434
R (>= 4.1.0)
@@ -39,13 +39,17 @@ Imports:
3939
coda,
4040
future (>= 1.22.1),
4141
glue (>= 1.5.1),
42+
lifecycle,
4243
methods,
4344
parallelly (>= 1.29.0),
4445
progress (>= 1.2.0),
4546
R6,
4647
reticulate (>= 1.19.0),
4748
rlang,
48-
tensorflow (>= 2.8.0),
49+
tensorflow (== 2.16.0),
50+
tools,
51+
utils,
52+
whisker,
4953
yesno
5054
Suggests:
5155
bayesplot,
@@ -81,9 +85,9 @@ Encoding: UTF-8
8185
Language: en-US
8286
Roxygen: list(markdown = TRUE)
8387
RoxygenNote: 7.3.2
84-
SystemRequirements: Python (>= 2.7.0) with header files and shared
85-
library; TensorFlow (v1.14; https://www.tensorflow.org/); TensorFlow
86-
Probability (v0.7.0; https://www.tensorflow.org/probability/)
88+
SystemRequirements: Python (>= 3.7.0) with header files and shared
89+
library; TensorFlow (>= v2.0.0; https://www.tensorflow.org/); TensorFlow
90+
Probability (v0.8.0; https://www.tensorflow.org/probability/)
8791
Collate:
8892
'package.R'
8993
'utils.R'
@@ -130,6 +134,7 @@ Collate:
130134
'checkers.R'
131135
'test_if_forked_cluster.R'
132136
'testthat-helpers.R'
137+
'write-logfiles.R'
133138
'zzz.R'
134139
'internals.R'
135140
LazyData: true

NAMESPACE

+8-8
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ S3method(mean,greta_array)
106106
S3method(min,greta_array)
107107
S3method(plot,greta_model)
108108
S3method(print,greta_array)
109+
S3method(print,greta_deps_spec)
109110
S3method(print,greta_mcmc_list)
110111
S3method(print,greta_model)
111-
S3method(print,greta_python_deps)
112112
S3method(print,initials)
113113
S3method(print,optimiser)
114114
S3method(print,sampler)
@@ -181,6 +181,7 @@ export(colMeans)
181181
export(colSums)
182182
export(cov2cor)
183183
export(cpu_only)
184+
export(destroy_greta_deps)
184185
export(diag)
185186
export(dirichlet)
186187
export(dirichlet_multinomial)
@@ -195,15 +196,12 @@ export(gamma)
195196
export(gpu_only)
196197
export(gradient_descent)
197198
export(greta_array)
199+
export(greta_create_conda_env)
198200
export(greta_deps_receipt)
199-
export(greta_notes_conda_create_error)
200-
export(greta_notes_conda_create_output)
201-
export(greta_notes_conda_install_error)
202-
export(greta_notes_conda_install_output)
203-
export(greta_notes_install_miniconda_error)
204-
export(greta_notes_install_miniconda_output)
201+
export(greta_deps_spec)
202+
export(greta_install_miniconda)
205203
export(greta_notes_tf_num_error)
206-
export(greta_python_deps)
204+
export(greta_set_install_logfile)
207205
export(greta_sitrep)
208206
export(hmc)
209207
export(hypergeometric)
@@ -238,6 +236,7 @@ export(nelder_mead)
238236
export(newton_cg)
239237
export(normal)
240238
export(ones)
239+
export(open_greta_install_log)
241240
export(opt)
242241
export(ordered_variable)
243242
export(pareto)
@@ -268,6 +267,7 @@ export(uniform)
268267
export(variable)
269268
export(weibull)
270269
export(wishart)
270+
export(write_greta_install_log)
271271
export(zeros)
272272
import(methods)
273273
importFrom(R6,R6Class)

NEWS.md

+48-22
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
# greta 0.4.5.9000 (development version)
1+
# greta (development version)
22

3-
## Features
3+
## Changes
4+
5+
- `log.greta_array()` function warns if user uses the `base` arg, as it was unused, (#597).
6+
- Add warmup information to MCMC print method (#652, resolved by #755).
7+
8+
# greta 0.5.0
49

5-
* This version of greta uses Tensorflow 2.0.0, which comes with it a host of new very exciting features!
10+
This version of greta uses Tensorflow 2.0.0, which comes with it a host of new very exciting features!
611

7-
### Optimizers
12+
## Optimizers
813

914
The latest interface to optimizers in tensorflow are now used, these changes are described.
1015

@@ -30,44 +35,65 @@ The following optimisers are removed, as they are no longer supported by Tensorf
3035

3136
## Installation revamp
3237

33-
This release provides a few improvements to installation in greta. It should now provide more information about installation progress, and be more robust. The intention is, it should _just work_, and if it doesn't fail gracefully with some useful advice on problem solving.
38+
This release provides a few improvements to installation in greta. It should now provide more information about installation progress, and be more robust. The intention is, it should _just work_, and if it doesn't, it should fail gracefully with some useful advice on problem solving.
3439

35-
* Added option to restart R + run `library(greta)` after installation (#523)
36-
* Added installation deps object, `greta_python_deps()` to help simplify specifying package versions (#664)
37-
* removed `method` and `conda` arguments from `install_greta_deps()` as they
40+
* Added option to restart R + run `library(greta)` after installation (#523).
41+
* Added installation deps object, `greta_deps_sepc()` to help simplify specifying package versions (#664).
42+
* Removed `method` and `conda` arguments from `install_greta_deps()` as they
3843
were not used.
39-
* removed `manual` argument in `install_greta_deps()`.
40-
* added default 5 minute timer to installation processes
41-
* Added `greta_deps_receipt()` to list the current main python packages installed. (#668)
42-
* Added checking suite to ensure you are using valid versions of TF, TFP, and Python(#666)
44+
* Removed `manual` argument in `install_greta_deps()`.
45+
* Added default 5 minute timer to installation processes.
46+
* Added `greta_deps_receipt()` to list the current main python packages installed (#668).
47+
* Added checking suite to ensure you are using valid versions of TF, TFP, and Python(#666).
4348
* Added data `greta_deps_tf_tfp` (#666), which contains valid versions combinations of TF, TFP, and Python.
49+
* Remove `greta_nodes_install/conda_*()` options as #493 makes them defunct.
50+
* Added option to write to a single logfile with `greta_set_install_logfile()`, and `write_greta_install_log()`, and `open_greta_install_log()` (#493).
51+
* Added `destroy_greta_deps()` function to remove miniconda and python conda environment.
52+
* Improved `write_greta_install_log()` and `open_greta_install_log()` to use `tools::R_user_dir()` to always write to a file location. `open_greta_install_log()` will open one found from an environment variable or go to the default location (#703).
53+
54+
## New Print methods
55+
56+
* New print method for `greta_mcmc_list`. This means MCMC output will be shorter and more informative (#644).
57+
* greta arrays now have a print method that stops them from printing too many rows into the console. Similar to MCMC print method, you can control the print output with the `n` argument: `print(object, n = <elements to print>)` (#644).
4458

4559
## Minor
4660

47-
* `greta_sitrep()` now checks for minimum versions of software, instead of exact versions. It requires at least Python version 3.8, TensorFlow 2.8.0, and Tensorflow Probability 0.14.0.
48-
* slice sampler no longer needs precision = "single" to work.
61+
* `greta_sitrep()` now checks for installations of Python, TF, and TFP.
62+
* Slice sampler no longer needs precision = "single" to work.
4963
* greta now depends on R 4.1.0, which was released May 2021, over 3 years ago.
50-
* export `is.greta_array()` and `is.greta_mcmc_list()`
51-
* greta arrays now have a print method that stops them from printing too many rows into the console. Similar to MCMC print method, you can control the print output with the `n` argument: `print(object, n = <elements to print>)`. (#644)
52-
* New print method for `greta_mcmc_list`. This means MCMC output will be shorter and more informative. (#644)
53-
* `restart` argument for `install_greta_deps()` and `reinstall_greta_deps()` to automatically restart R (#523)
64+
* export `is.greta_array()` and `is.greta_mcmc_list()`.
65+
* `restart` argument for `install_greta_deps()` and `reinstall_greta_deps()` to automatically restart R (#523).
5466

5567
## Internals
5668

5769
* Internally we are replacing most of the error handling code as separate
5870
`check_*` functions.
5971
* Implemented `cli::cli_abort/warn/inform()` in place of `cli::format_error/warning/message()` + `stop/warning/message(msg, call. = FALSE)` pattern.
6072
* Uses legacy optimizer internally (Use `tf$keras$optimizers$legacy$METHOD` over `tf$keras$optimizers$METHOD`). No user impact expected.
61-
* Update photo of Grete Hermann (#598)
62-
* Use `%||%` internally to replace the pattern: `if (is.null(x)) x <- thing` with `x <- x %||% thing`. (#630)
73+
* Update photo of Grete Hermann (#598).
74+
* Use `%||%` internally to replace the pattern: `if (is.null(x)) x <- thing` with `x <- x %||% thing` (#630).
6375
* Add more explaining variables - replace `if (thing & thing & what == this)` with `if (explanation_of_thing)`.
64-
* Refactored repeated uses of `vapply` into functions (#377, #658)
76+
* Refactored repeated uses of `vapply` into functions (#377, #658).
6577
* Add internal data files `.deps_tf` and `.deps_tfp` to track dependencies of TF and TFP. Related to #666.
6678

79+
- Posterior density checks (#720):
80+
- Don't run Geweke on CI as it takes 30 minutes to run.
81+
- Add thinning to Geweke tests.
82+
- Fix broken geweke tests from TF1-->TF2 change.
83+
- Increase the number of effective samples for check_samples for lkj distribution
84+
- Add more checks to posterior to run on CI/on each test of greta
85+
6786
## Bug fixes
6887

6988
* Fix bug where matrix multiply had dimension error before coercing to greta array. (#464)
70-
*
89+
- Fixes for Wishart and LKJ Correlation distributions (#729 #733 #734):
90+
- Add bijection density to choleskied distributions.
91+
- Note about some issues with LKJ and our normalisation constant for the density.
92+
- Removed our custom `forward_log_det_jacobian()` function from `tf_correlation_cholesky_bijector()` (used in `lkj_correlation()`). Previously, it did not work with unknown dimensions, but it now works with them.
93+
- Ensure wishart uses sigma_chol in scale_tril
94+
- Wishart uses `tf$matmul(chol_draws, chol_draws, adjoint_b = TRUE)` instead of `tf_chol2symm(chol_draws)`.
95+
- Test log prob function returns valid numeric numbers.
96+
- Addresses issue with log prob returning NaNs--replace `FillTriangular` with `FillScaleTriL` and apply Chaining to first transpose input.
7197

7298
# greta 0.4.5
7399

R/as_data.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ as_data.greta_array <- function(x) {
4848
non_data_greta_array <- !is.data_node(get_node(x))
4949
if (non_data_greta_array) {
5050
cli::cli_abort(
51-
"cannot coerce a non-data greta_array to data"
51+
"cannot coerce a non-data {.cls greta_array} to data"
5252
)
5353
}
5454
x

0 commit comments

Comments
 (0)