[SAMPLES] Fix flake issues in Python speech sample (#12514)
* Fix flake issues * Add whitespace * Add whitespaces in tests asserts
This commit is contained in:
parent
b9457b3a31
commit
4dc713c7eb
@ -102,7 +102,7 @@ def main():
|
||||
if args.batch_size:
|
||||
batch_size = args.batch_size if args.context_window_left == args.context_window_right == 0 else 1
|
||||
|
||||
if any([not _input.node.layout.empty for _input in model.inputs]):
|
||||
if any((not _input.node.layout.empty for _input in model.inputs)):
|
||||
set_batch(model, batch_size)
|
||||
else:
|
||||
log.warning('Layout is not set for any input, so custom batch size is not set')
|
||||
|
@ -55,7 +55,8 @@ def get_input_layouts(layout_string: str, inputs: List[Output]) -> Dict[str, str
|
||||
return {_input.get_any_name(): layout_string[1:-1] for _input in inputs}
|
||||
else:
|
||||
sep = '],' if ',' in layout_string else ']'
|
||||
return dict([_input.split('[') for _input in layout_string[:-1].split(sep)])
|
||||
tmp = [_input.split('[') for _input in layout_string[:-1].split(sep)]
|
||||
return {_input[0]: _input[1] for _input in tmp}
|
||||
|
||||
|
||||
def get_sorted_scale_factors(scale_factor_arg: Tuple[List[str], List[str]], inputs: List[Output]) -> List[str]:
|
||||
|
@ -360,15 +360,15 @@ def test_result():
|
||||
def test_node_friendly_name():
|
||||
dummy_node = ops.parameter(shape=[1], name="dummy_name")
|
||||
|
||||
assert(dummy_node.friendly_name == "dummy_name")
|
||||
assert (dummy_node.friendly_name == "dummy_name")
|
||||
|
||||
dummy_node.set_friendly_name("changed_name")
|
||||
|
||||
assert(dummy_node.get_friendly_name() == "changed_name")
|
||||
assert (dummy_node.get_friendly_name() == "changed_name")
|
||||
|
||||
dummy_node.friendly_name = "new_name"
|
||||
|
||||
assert(dummy_node.get_friendly_name() == "new_name")
|
||||
assert (dummy_node.get_friendly_name() == "new_name")
|
||||
|
||||
|
||||
def test_node_output():
|
||||
@ -448,8 +448,8 @@ def test_node_input_tensor():
|
||||
input_tensor1 = node.get_input_tensor(0)
|
||||
input_tensor2 = node.get_input_tensor(1)
|
||||
|
||||
assert(isinstance(input_tensor1, DescriptorTensor))
|
||||
assert(isinstance(input_tensor2, DescriptorTensor))
|
||||
assert (isinstance(input_tensor1, DescriptorTensor))
|
||||
assert (isinstance(input_tensor2, DescriptorTensor))
|
||||
assert np.equal(input_tensor1.get_shape(), data1.shape).all()
|
||||
assert np.equal(input_tensor2.get_shape(), data2.shape).all()
|
||||
|
||||
@ -692,18 +692,18 @@ def test_layout():
|
||||
assert scalar2 != layout2
|
||||
|
||||
assert str(scalar) == str(scalar2)
|
||||
assert not(scalar.has_name("N"))
|
||||
assert not(scalar.has_name("C"))
|
||||
assert not(scalar.has_name("W"))
|
||||
assert not(scalar.has_name("H"))
|
||||
assert not(scalar.has_name("D"))
|
||||
assert not (scalar.has_name("N"))
|
||||
assert not (scalar.has_name("C"))
|
||||
assert not (scalar.has_name("W"))
|
||||
assert not (scalar.has_name("H"))
|
||||
assert not (scalar.has_name("D"))
|
||||
|
||||
assert layout.to_string() == layout2.to_string()
|
||||
assert layout.has_name("N")
|
||||
assert layout.has_name("C")
|
||||
assert layout.has_name("W")
|
||||
assert layout.has_name("H")
|
||||
assert not(layout.has_name("D"))
|
||||
assert not (layout.has_name("D"))
|
||||
assert layout.get_index_by_name("N") == 0
|
||||
assert layout.get_index_by_name("C") == 1
|
||||
assert layout.get_index_by_name("W") == 2
|
||||
@ -715,25 +715,25 @@ def test_layout():
|
||||
assert str(layout) != str(layout2)
|
||||
assert layout.has_name("N")
|
||||
assert layout.has_name("C")
|
||||
assert not(layout.has_name("W"))
|
||||
assert not(layout.has_name("H"))
|
||||
assert not(layout.has_name("D"))
|
||||
assert not (layout.has_name("W"))
|
||||
assert not (layout.has_name("H"))
|
||||
assert not (layout.has_name("D"))
|
||||
assert layout.get_index_by_name("N") == 0
|
||||
assert layout.get_index_by_name("C") == 1
|
||||
|
||||
layout = ov.Layout("N...C")
|
||||
assert layout.has_name("N")
|
||||
assert not(layout.has_name("W"))
|
||||
assert not(layout.has_name("H"))
|
||||
assert not(layout.has_name("D"))
|
||||
assert not (layout.has_name("W"))
|
||||
assert not (layout.has_name("H"))
|
||||
assert not (layout.has_name("D"))
|
||||
assert layout.has_name("C")
|
||||
assert layout.get_index_by_name("C") == -1
|
||||
|
||||
layout = ov.Layout()
|
||||
assert not(layout.has_name("W"))
|
||||
assert not(layout.has_name("H"))
|
||||
assert not(layout.has_name("D"))
|
||||
assert not(layout.has_name("C"))
|
||||
assert not (layout.has_name("W"))
|
||||
assert not (layout.has_name("H"))
|
||||
assert not (layout.has_name("D"))
|
||||
assert not (layout.has_name("C"))
|
||||
|
||||
layout = ov.Layout("N...C")
|
||||
assert layout == "N...C"
|
||||
@ -742,11 +742,11 @@ def test_layout():
|
||||
|
||||
def test_layout_helpers():
|
||||
layout = ov.Layout("NCHWD")
|
||||
assert(layout_helpers.has_batch(layout))
|
||||
assert(layout_helpers.has_channels(layout))
|
||||
assert(layout_helpers.has_depth(layout))
|
||||
assert(layout_helpers.has_height(layout))
|
||||
assert(layout_helpers.has_width(layout))
|
||||
assert (layout_helpers.has_batch(layout))
|
||||
assert (layout_helpers.has_channels(layout))
|
||||
assert (layout_helpers.has_depth(layout))
|
||||
assert (layout_helpers.has_height(layout))
|
||||
assert (layout_helpers.has_width(layout))
|
||||
|
||||
assert layout_helpers.batch_idx(layout) == 0
|
||||
assert layout_helpers.channels_idx(layout) == 1
|
||||
@ -755,10 +755,10 @@ def test_layout_helpers():
|
||||
assert layout_helpers.depth_idx(layout) == 4
|
||||
|
||||
layout = ov.Layout("N...C")
|
||||
assert(layout_helpers.has_batch(layout))
|
||||
assert(layout_helpers.has_channels(layout))
|
||||
assert not(layout_helpers.has_depth(layout))
|
||||
assert not(layout_helpers.has_height(layout))
|
||||
assert (layout_helpers.has_batch(layout))
|
||||
assert (layout_helpers.has_channels(layout))
|
||||
assert not (layout_helpers.has_depth(layout))
|
||||
assert not (layout_helpers.has_height(layout))
|
||||
assert not (layout_helpers.has_width(layout))
|
||||
|
||||
assert layout_helpers.batch_idx(layout) == 0
|
||||
@ -774,10 +774,10 @@ def test_layout_helpers():
|
||||
layout_helpers.depth_idx(layout)
|
||||
|
||||
layout = ov.Layout("NC?")
|
||||
assert(layout_helpers.has_batch(layout))
|
||||
assert(layout_helpers.has_channels(layout))
|
||||
assert not(layout_helpers.has_depth(layout))
|
||||
assert not(layout_helpers.has_height(layout))
|
||||
assert (layout_helpers.has_batch(layout))
|
||||
assert (layout_helpers.has_channels(layout))
|
||||
assert not (layout_helpers.has_depth(layout))
|
||||
assert not (layout_helpers.has_height(layout))
|
||||
assert not (layout_helpers.has_width(layout))
|
||||
|
||||
assert layout_helpers.batch_idx(layout) == 0
|
||||
|
@ -142,7 +142,7 @@ def test_init_with_numpy_copy_memory(ov_type, numpy_dtype):
|
||||
assert isinstance(ov_tensor.data, np.ndarray)
|
||||
assert ov_tensor.data.dtype == numpy_dtype
|
||||
assert ov_tensor.data.shape == shape
|
||||
assert not(np.shares_memory(arr, ov_tensor.data))
|
||||
assert not (np.shares_memory(arr, ov_tensor.data))
|
||||
assert np.array_equal(ov_tensor.data, arr)
|
||||
assert ov_tensor.size == arr.size
|
||||
assert ov_tensor.byte_size == arr.nbytes
|
||||
|
@ -448,7 +448,7 @@ description_md = SCRIPT_DIR.parents[3] / "docs" / "install_guides" / "pypi-openv
|
||||
md_files = [description_md, SCRIPT_DIR.parents[3] / "docs" / "install_guides" / "pre-release-note.md"]
|
||||
docs_url = "https://docs.openvino.ai/latest/index.html"
|
||||
|
||||
if(os.getenv("CI_BUILD_DEV_TAG")):
|
||||
if (os.getenv("CI_BUILD_DEV_TAG")):
|
||||
output = Path.cwd() / "build" / "pypi-openvino-rt.md"
|
||||
output.parent.mkdir(exist_ok=True)
|
||||
description_md = concat_files(output, md_files)
|
||||
|
Loading…
Reference in New Issue
Block a user