Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87846859
test_memory.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 15, 07:40
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Oct 17, 07:40 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21615837
Attached To
rTAMAAS tamaas
test_memory.py
View Options
# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-2020 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
Log In to Comment