1#! /usr/bin/env python
2
3from __future__ import print_function
4from openturns import *
5
6TESTPREAMBLE()
7
8try:
9    size = 10
10    dimension = 2
11    sample = Sample(size, dimension)
12    # Fill-in the sample
13    for i in range(size):
14        p = Point(dimension)
15        for j in range(dimension):
16            p[j] = i + j * 1.0 / dimension
17        sample[i] = p
18    print("sample=", repr(sample))
19    # History using the Null strategy
20    nullStrategy = Null()
21    for i in range(size):
22        nullStrategy.store(sample[i])
23    print("Null strategy sample=", repr(nullStrategy.getSample()))
24    # History using the Full strategy
25    fullStrategy = Full()
26    fullStrategy.setDimension(dimension)
27    for i in range(size):
28        fullStrategy.store(sample[i])
29    print("Full strategy sample=", repr(fullStrategy.getSample()))
30    # History using the Last strategy, large storage
31    lastStrategy = Last(3 * size)
32    lastStrategy.setDimension(dimension)
33    for i in range(size):
34        lastStrategy.store(sample[i])
35    print("Last strategy sample (large storage)=",
36          repr(lastStrategy.getSample()))
37    lastStrategy = Last(size // 3)
38    lastStrategy.setDimension(dimension)
39    # History using the Last strategy, small storage
40    for i in range(size):
41        lastStrategy.store(sample[i])
42    print("Last strategy sample (small storage)=",
43          repr(lastStrategy.getSample()))
44    # History using the Compact strategy, large storage
45    compactStrategy = Compact(3 * size)
46    compactStrategy.setDimension(dimension)
47    for i in range(size):
48        compactStrategy.store(sample[i])
49    print("Compact strategy sample (large storage)=",
50          repr(compactStrategy.getSample()))
51    compactStrategy = Compact(size // 3)
52    compactStrategy.setDimension(dimension)
53    # History using the Compact strategy, small storage
54    for i in range(size):
55        compactStrategy.store(sample[i])
56    print("Compact strategy sample (small storage)=",
57          repr(compactStrategy.getSample()))
58
59except:
60    import sys
61    print("t_HistoryStrategy_std.py", sys.exc_info()[0], sys.exc_info()[1])
62