diff --git a/test/test_decode.py b/test/test_decode.py index 4c2e192a7..e701584f9 100644 --- a/test/test_decode.py +++ b/test/test_decode.py @@ -1,32 +1,12 @@ #!/usr/bin/env python3 -# Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang) -# +# Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang) # See ../../LICENSE for clarification regarding multiple authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -You can run this file in one of the two ways: - - (1) cd icefall; pytest test/test_decode.py - (2) cd icefall; ./test/test_decode.py -""" +# Licensed under the Apache License, Version 2.0. +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 import k2 - from icefall.decode import Nbest - def test_nbest_from_lattice(): s = """ 0 1 1 10 0.1 @@ -44,15 +24,9 @@ def test_nbest_from_lattice(): lattice=lattice, num_paths=10, use_double_scores=True, - nbest_scale=0.5, + nbest_scale=0.5 ) - # each lattice has only 4 distinct paths that have different word sequences: - # 10->30 - # 10->40 - # 20->30 - # 20->40 - # - # So there should be only 4 paths for each lattice in the Nbest object + assert nbest.fsa.shape[0] == 4 * 2 assert nbest.shape.row_splits(1).tolist() == [0, 4, 8]