pyvista.core._validation.check.check_ndim#
- check_ndim( ) None[ソース]#
配列が指定された次元数を持つかどうかをチェックします.
注釈
Scalar values have a dimension of
0.- パラメータ:
- array
float|ArrayLike[float] Number or array to check.
- ndim
int|Sequence[int],optional A single dimension or a sequence of allowable dimensions. If an integer, the array must have this number of dimension(s). If a sequence, the array must have at least one of the specified number of dimensions.
- name
str, default: "Array" エラーメッセージが発生した場合に使用する変数名.
- array
- エラー処理:
ValueErrorIf the array does not have the required number of dimensions.
例
Check if an array is one-dimensional
>>> import numpy as np >>> from pyvista import _validation >>> _validation.check_ndim([1, 2, 3], ndim=1)
Check if an array is two-dimensional or a scalar.
>>> _validation.check_ndim(1, ndim=(0, 2))