Page MenuHomec4science

test_memory.py
No OneTemporary

File Metadata

Created
Fri, May 17, 00:47

test_memory.py

# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-2021 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import print_function, division
import tamaas as tm
import numpy as np
def createRandomSurface():
"""Return a surface from an object which loses a ref"""
sg = tm.SurfaceGeneratorFilter2D()
sg.setSizes([12, 12])
filter = tm.Isopowerlaw2D()
filter.q0 = 1
filter.q1 = 2
filter.q2 = 4
filter.hurst = 0.6
sg.setFilter(filter)
return sg.buildSurface()
def registerField(model):
"""Register a field which loses a ref"""
f = np.zeros([12, 12], dtype=tm.dtype)
model.registerField('f', f)
def test_surface_survival(tamaas_fixture):
surface = createRandomSurface()
surface += 1
assert surface.shape == (12, 12)
def test_register_field_survival(tamaas_fixture):
model = tm.ModelFactory.createModel(tm.model_type.basic_2d,
[1., 1.],
[12, 12])
registerField(model)
f = model['f']
f += 1
assert model['f'].shape == (12, 12)

Event Timeline