gstlal
1.13.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tests
drop_test_01.py
1
#!/usr/bin/env python3
2
# Copyright (C) 2014 Kipp Cannon
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License as published by the
6
# Free Software Foundation; either version 2 of the License, or (at your
7
# option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12
# Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18
#
19
# =============================================================================
20
#
21
# Preamble
22
#
23
# =============================================================================
24
#
25
26
27
import
numpy
28
import
sys
29
from
gstlal
import
pipeparts
30
import
test_common
31
import
cmp_nxydumps
32
33
34
#
35
# =============================================================================
36
#
37
# Pipelines
38
#
39
# =============================================================================
40
#
41
42
43
#
44
# is the element an identity transform when given 1 channel of 1s and n = 1 ?
45
#
46
47
48
#
49
# test the transformation of a specific buffer
50
#
51
52
53
def
drop_test_02(name, dtype, length, drop_samples, sample_fuzz = cmp_nxydumps.default_sample_fuzz):
54
channels_in = 1
55
numpy.random.seed(0)
56
# check that the first array is dropped
57
input_array = numpy.random.random((length, channels_in)).astype(dtype)
58
output_reference = input_array[drop_samples:]
59
output_array = numpy.array(
test_common.transform_arrays
([input_array], pipeparts.mkdrop, name, drop_samples = drop_samples))
60
residual = abs((output_array - output_reference))
61
if
residual[residual > sample_fuzz].any():
62
raise
ValueError(
"incorrect output: expected %s, got %s\ndifference = %s"
% (output_reference, output_array, residual))
63
64
65
#
66
# =============================================================================
67
#
68
# Main
69
#
70
# =============================================================================
71
#
72
73
74
drop_test_02(
"drop_test_02a"
,
"float64"
, length = 13147, drop_samples = 1337, sample_fuzz = cmp_nxydumps.default_sample_fuzz)
75
drop_test_02(
"drop_test_02a"
,
"float32"
, length = 13147, drop_samples = 1337, sample_fuzz = cmp_nxydumps.default_sample_fuzz)
test_common.transform_arrays
transform_arrays(input_arrays, elemfunc, name, rate=1, **elemfunc_kwargs)
Definition
test_common.py:141
Generated by
1.17.0