Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Sample .travis.yml for R projects

language: r
warnings_are_errors: true
sudo: required
r_packages:
- covr

after_success:
- Rscript -e 'covr::codecov()'
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Package: memoise
Title: Memoise functions
Version: 0.2.99
Title: Memoisation of Functions
Version: 0.2.99.9000
Author: Hadley Wickham <h.wickham@gmail.com>
Maintainer: Hadley Wickham <h.wickham@gmail.com>
Description: Cache the results of a function so that when you call it
again with the same arguments it returns the pre-computed value.
URL: http://github.com/hadley/memoise
BugReports: http://github.com/hadley/memoise/issues
URL: https://github.com/hadley/memoise
BugReports: https://github.com/hadley/memoise/issues
Imports:
digest
Suggests: testthat
License: MIT + file LICENSE
Roxygen: list(wrap = FALSE)
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.0.0): do not edit by hand
# Generated by roxygen2 (4.1.1): do not edit by hand

export(forget)
export(is.memoised)
Expand Down
21 changes: 0 additions & 21 deletions NEWS

This file was deleted.

18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Version 0.2.99.9000

# Version 0.2.1

* Update to fix outstanding R CMD check issues.

# Version 0.2 (2010-11-11)

## New features

* Memoised functions now have an attribute memoised=TRUE, and
is.memoised() tests whether a function is memoised. (Contributed by
Sietse Brouwer.)

## Improvements

* Documentation is now more elaborate, and hopefully more accessible to
newcomers. Thanks to Sietse Brouwer for the verbosity.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# memoise
# memoise [![Travis-CI Build Status](https://travis-ci.org/hadley/memoise.svg?branch=master)](https://travis-ci.org/hadley/memoise) [![Coverage Status](https://img.shields.io/codecov/c/github/hadley/memoise/master.svg)](https://codecov.io/github/hadley/memoise?branch=master)


If a function is called multiple times with the same input, you can
often speed things up by keeping a cache of known answers that it can
Expand Down
3 changes: 2 additions & 1 deletion man/forget.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/memoise.r
\name{forget}
\alias{forget}
\title{Forget past results.
Expand Down
3 changes: 2 additions & 1 deletion man/is.memoised.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/memoise.r
\name{is.memoised}
\alias{is.memoised}
\alias{is.memoized}
Expand Down
3 changes: 2 additions & 1 deletion man/memoise.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/memoise.r
\name{memoise}
\alias{memoise}
\alias{memoize}
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(memoise)

test_check("memoise")
35 changes: 35 additions & 0 deletions tests/testthat/test-memoise.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
context("memoise")

test_that("memoisation works", {
fn <- function() { i <<- i + 1; i }
i <- 0
fnm <- memoise(fn)
expect_equal(fn(), 1)
expect_equal(fn(), 2)
expect_equal(fnm(), 3)
expect_equal(fnm(), 3)
expect_equal(fn(), 4)
expect_equal(fnm(), 3)

forget(fnm)
expect_equal(fnm(), 5)

expect_true(is.memoised(fnm))
expect_false(is.memoised(fn))
})

test_that("memoisation depends on argument", {
fn <- function(j) { i <<- i + 1; i }
i <- 0
fnm <- memoise(fn)
expect_equal(fn(1), 1)
expect_equal(fn(1), 2)
expect_equal(fnm(1), 3)
expect_equal(fnm(1), 3)
expect_equal(fn(1), 4)
expect_equal(fnm(1), 3)
expect_equal(fnm(2), 5)
expect_equal(fnm(2), 5)
expect_equal(fnm(1), 3)
expect_equal(fn(2), 6)
})