#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()

# We create an empty Sample
sample = ot.Sample(0, 2)
sample.setName("EmptySample")
print("sample=", repr(sample))

try:
    # We access the element of the sample
    p = sample[0]
    print("p=", repr(p))

    # We should NEVER go here
    raise
except Exception:
    pass

# We create an small Sample
sample = ot.Sample(1, 2)
sample.setName("SmallSample")
print("sample=", repr(sample))
print(sample)
print(sample._repr_html_())

# We access the element of the sample
p = ot.Point(sample[0])
print("p=", repr(p))
try:
    # We try to access past the last element of the point
    p0, p1, p2 = p[0], p[1], p[2]
    print("p[0]=", p0, " p[1]=", p1, " p[2]=", p2)
    # We should NEVER go here
    raise
except Exception:
    pass

# We create a big Sample
sample = ot.Sample(1000000, 2)
sample.setName("BigSample")

# We populate the sample
for i in range(sample.getSize()):
    sample[i, 0] = i
    sample[i, 1] = i

print("sample first point=", repr(sample[0]))
print("sample last  point=", repr(sample[sample.getSize() - 1]))

# Test pretty-print or a sample with relatively large dimension
size = 49
dimension = 50
sample = ot.Sample(size, dimension)
sample.setName("BigSample50x50")
for i in range(size):
    sample[i] = ot.Point(list(range(dimension))) / size

print(sample._repr_html_())
