summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorMatthew Brett <matthew.brett@gmail.com>2016-02-14 15:38:32 -0800
committerMatthew Brett <matthew.brett@gmail.com>2016-02-14 16:27:12 -0800
commit3048fa421659bff375290d24c23aa439f1d98a8d (patch)
tree3d27413cb271078ee575e4652d397b7c46df0762 /benchmarks
parentf570f278dbdb2825d9f19a33ea6e3a721f31e62f (diff)
downloadnumpy-3048fa421659bff375290d24c23aa439f1d98a8d.tar.gz
ENH: make memmap file in temporary directory
Memmap test can fail if run from a directory for which we don't have write permission. Avoid NamedTemporaryFile because of problems reopening files on Windows.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarks/bench_indexing.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/benchmarks/benchmarks/bench_indexing.py b/benchmarks/benchmarks/bench_indexing.py
index 3e5a2ee60..a62a2050e 100644
--- a/benchmarks/benchmarks/bench_indexing.py
+++ b/benchmarks/benchmarks/bench_indexing.py
@@ -2,10 +2,13 @@ from __future__ import absolute_import, division, print_function
from .common import Benchmark, get_squares_, get_indexes_, get_indexes_rand_
+from os.path import join as pjoin
+import shutil
import sys
import six
from numpy import memmap, float32, array
import numpy as np
+from tempfile import mkdtemp
class Indexing(Benchmark):
@@ -37,9 +40,15 @@ class Indexing(Benchmark):
class IndexingSeparate(Benchmark):
def setup(self):
- self.fp = memmap('tmp.dat', dtype=float32, mode='w+', shape=(50, 60))
+ self.tmp_dir = mkdtemp()
+ self.fp = memmap(pjoin(self.tmp_dir, 'tmp.dat'),
+ dtype=float32, mode='w+', shape=(50, 60))
self.indexes = array([3, 4, 6, 10, 20])
+ def teardown(self):
+ del self.fp
+ shutil.rmtree(self.tmp_dir)
+
def time_mmap_slicing(self):
for i in range(1000):
self.fp[5:10]