uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fcd2b9e96637c4325e407ab3 | train | function | @_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glPushDebugGroup(source,id,length,message):pass
| @_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glPushDebugGroup(source,id,length,message): | pass
| glPopDebugGroup():pass
@_f
@_p.types(None,)
def glPopDebugGroupKHR():pass
@_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glPushDebugGroup(source,id,length,message): | 64 | 64 | 40 | 38 | 25 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glPushDebugGroup | glPushDebugGroup | 155 | 157 | 155 | 157 | 0bed5510323265b0de44b71d88985fbe3cdb759a | bigcode/the-stack | train |
70843ec8729f7071ff27b961 | train | function | @_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointerv(pname,params):pass
| @_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointerv(pname,params): | pass
| _void_p,_cs.GLsizei,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetObjectPtrLabelKHR(ptr,bufSize,length,label):pass
@_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointerv(pname,params): | 64 | 64 | 33 | 31 | 32 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glGetPointerv | glGetPointerv | 131 | 133 | 131 | 133 | 863fd4307aae8cfb7d783a304908b133265db04d | bigcode/the-stack | train |
62813a6a4c58dd7386e7b923 | train | function | def _f( function ):
return _p.createFunction( function,_p.PLATFORM.GLES2,'GLES2_KHR_debug',error_checker=_errors._error_checker)
| def _f( function ):
| return _p.createFunction( function,_p.PLATFORM.GLES2,'GLES2_KHR_debug',error_checker=_errors._error_checker)
| _types as _cs
# End users want this...
from OpenGL.raw.GLES2._types import *
from OpenGL.raw.GLES2 import _errors
from OpenGL.constant import Constant as _C
import ctypes
_EXTENSION_NAME = 'GLES2_KHR_debug'
def _f( function ):
| 64 | 64 | 37 | 6 | 58 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | _f | _f | 12 | 13 | 12 | 12 | 486a279f6ee374004679ea7c503fb94e976e06fc | bigcode/the-stack | train |
3313c7bd8908b77bb2aa7ff0 | train | function | @_f
@_p.types(None,ctypes.c_void_p,_cs.GLsizei,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetObjectPtrLabelKHR(ptr,bufSize,length,label):pass
| @_f
@_p.types(None,ctypes.c_void_p,_cs.GLsizei,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetObjectPtrLabelKHR(ptr,bufSize,length,label): | pass
| arrays.GLcharArray)
def glGetObjectPtrLabel(ptr,bufSize,length,label):pass
@_f
@_p.types(None,ctypes.c_void_p,_cs.GLsizei,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetObjectPtrLabelKHR(ptr,bufSize,length,label): | 64 | 64 | 46 | 44 | 19 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glGetObjectPtrLabelKHR | glGetObjectPtrLabelKHR | 128 | 130 | 128 | 130 | 228832e885ea7bb982438e9c4329ceafde7b7234 | bigcode/the-stack | train |
1c85b107e6aa6e764e2a7098 | train | function | @_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControl(source,type,severity,count,ids,enabled):pass
| @_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControl(source,type,severity,count,ids,enabled): | pass
| glDebugMessageCallbackKHR(callback,userParam):pass
@_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControl(source,type,severity,count,ids,enabled): | 64 | 64 | 55 | 53 | 10 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glDebugMessageControl | glDebugMessageControl | 101 | 103 | 101 | 103 | e47a8db142173920e112b052575423c289240d8d | bigcode/the-stack | train |
503b2d2818af899641f135c8 | train | function | @_f
@_p.types(_cs.GLuint,_cs.GLuint,_cs.GLsizei,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetDebugMessageLogKHR(count,bufSize,sources,types,ids,severities,lengths,messageLog):pass
| @_f
@_p.types(_cs.GLuint,_cs.GLuint,_cs.GLsizei,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetDebugMessageLogKHR(count,bufSize,sources,types,ids,severities,lengths,messageLog): | pass
| @_f
@_p.types(_cs.GLuint,_cs.GLuint,_cs.GLsizei,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLuintArray,arrays.GLsizeiArray,arrays.GLcharArray)
def glGetDebugMessageLogKHR(count,bufSize,sources,types,ids,severities,lengths,messageLog): | 76 | 64 | 78 | 76 | 0 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glGetDebugMessageLogKHR | glGetDebugMessageLogKHR | 116 | 118 | 116 | 118 | df15a4fa3b8461fb8e94eb3bdb3acfc7eaa649f1 | bigcode/the-stack | train |
a37e32081bcf7780bfd8e077 | train | function | @_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointervKHR(pname,params):pass
| @_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointervKHR(pname,params): | pass
| _f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointerv(pname,params):pass
@_f
@_p.types(None,_cs.GLenum,arrays.GLvoidpArray)
def glGetPointervKHR(pname,params): | 63 | 64 | 34 | 32 | 30 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glGetPointervKHR | glGetPointervKHR | 134 | 136 | 134 | 136 | d1b4dd1310e5891022491c013ad46d5dc6fb30f4 | bigcode/the-stack | train |
2ef32f7985ec2edb4a2037c8 | train | function | @_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControlKHR(source,type,severity,count,ids,enabled):pass
| @_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControlKHR(source,type,severity,count,ids,enabled): | pass
| ,severity,count,ids,enabled):pass
@_f
@_p.types(None,_cs.GLenum,_cs.GLenum,_cs.GLenum,_cs.GLsizei,arrays.GLuintArray,_cs.GLboolean)
def glDebugMessageControlKHR(source,type,severity,count,ids,enabled): | 64 | 64 | 56 | 54 | 9 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glDebugMessageControlKHR | glDebugMessageControlKHR | 104 | 106 | 104 | 106 | f1ea376144232ae9802e26dd9497cd0d6b3429f1 | bigcode/the-stack | train |
567383f760ebe9ccf1e1924a | train | function | @_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glObjectLabelKHR(identifier,name,length,label):pass
| @_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glObjectLabelKHR(identifier,name,length,label): | pass
| um,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glObjectLabel(identifier,name,length,label):pass
@_f
@_p.types(None,_cs.GLenum,_cs.GLuint,_cs.GLsizei,arrays.GLcharArray)
def glObjectLabelKHR(identifier,name,length,label): | 64 | 64 | 40 | 38 | 25 | 5gconnectedbike/Navio2 | env/Lib/site-packages/OpenGL/raw/GLES2/KHR/debug.py | Python | glObjectLabelKHR | glObjectLabelKHR | 140 | 142 | 140 | 142 | 9b5ce9b908cba73940a4145fa63d569d04cac0be | bigcode/the-stack | train |
cf0ed4618e0f8f6419d2ed72 | train | function | def _data_from_cuda_array_interface_desc(obj) -> Buffer:
desc = obj.__cuda_array_interface__
ptr = desc["data"][0]
nelem = desc["shape"][0] if len(desc["shape"]) > 0 else 1
dtype = cudf.dtype(desc["typestr"])
data = Buffer(data=ptr, size=nelem * dtype.itemsize, owner=obj)
return data
| def _data_from_cuda_array_interface_desc(obj) -> Buffer:
| desc = obj.__cuda_array_interface__
ptr = desc["data"][0]
nelem = desc["shape"][0] if len(desc["shape"]) > 0 else 1
dtype = cudf.dtype(desc["typestr"])
data = Buffer(data=ptr, size=nelem * dtype.itemsize, owner=obj)
return data
| ", "mixed-integer",)
):
native_dtype = "object"
arbitrary = np.asarray(
arbitrary,
dtype=native_dtype
if native_dtype is None
else np.dtype(native_dtype),
)
return arbitrary
def _data_from_cuda_array_interface_desc(obj) -> Buffer:
| 64 | 64 | 89 | 13 | 50 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | _data_from_cuda_array_interface_desc | _data_from_cuda_array_interface_desc | 2,160 | 2,167 | 2,160 | 2,160 | 523a5be4935700c9c5b653b5f45830130484ecdf | bigcode/the-stack | train |
1e6560a38f885343f8fc9f2d | train | function | def concat_columns(objs: "MutableSequence[ColumnBase]") -> ColumnBase:
"""Concatenate a sequence of columns."""
if len(objs) == 0:
dtype = cudf.dtype(None)
return column_empty(0, dtype=dtype, masked=True)
# If all columns are `NumericalColumn` with different dtypes,
# we cast them to a ... | def concat_columns(objs: "MutableSequence[ColumnBase]") -> ColumnBase:
| """Concatenate a sequence of columns."""
if len(objs) == 0:
dtype = cudf.dtype(None)
return column_empty(0, dtype=dtype, masked=True)
# If all columns are `NumericalColumn` with different dtypes,
# we cast them to a common dtype.
# Notice, we can always cast pure null columns
no... | to fill a new array.
dtype : default None
Data type specifier. It is inferred from other arguments by default.
Returns
-------
Column
Examples
--------
>>> import cudf
>>> col = cudf.core.column.full(size=5, fill_value=7, dtype='int8')
>>> col
<cudf.core.column.numeric... | 188 | 188 | 627 | 18 | 170 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | concat_columns | concat_columns | 2,330 | 2,397 | 2,330 | 2,330 | 29efdb3f823793620ec996908279b91c8d303d73 | bigcode/the-stack | train |
5e5108bdb0abe69d75186c79 | train | class | class ColumnBase(Column, Serializable):
def as_frame(self) -> "cudf.core.frame.Frame":
"""
Converts a Column to Frame
"""
return cudf.core.frame.SingleColumnFrame({None: self.copy(deep=False)})
@property
def data_array_view(self) -> "cuda.devicearray.DeviceNDArray":
... | class ColumnBase(Column, Serializable):
| def as_frame(self) -> "cudf.core.frame.Frame":
"""
Converts a Column to Frame
"""
return cudf.core.frame.SingleColumnFrame({None: self.copy(deep=False)})
@property
def data_array_view(self) -> "cuda.devicearray.DeviceNDArray":
"""
View the data as a device ar... | lib.transform import bools_to_mask
from cudf._typing import BinaryOperand, ColumnLike, Dtype, ScalarLike
from cudf.api.types import (
_is_non_decimal_numeric_dtype,
_is_scalar_or_zero_d_array,
infer_dtype,
is_bool_dtype,
is_categorical_dtype,
is_decimal32_dtype,
is_decimal64_dtype,
is_de... | 256 | 256 | 8,725 | 7 | 249 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | ColumnBase | ColumnBase | 79 | 1,265 | 79 | 79 | 7c76bebab79c2748f263bd8e53d20b8499b80f1c | bigcode/the-stack | train |
bc848c899ccb3de32b273932 | train | function | def _construct_array(
arbitrary: Any, dtype: Optional[Dtype]
) -> Union[np.ndarray, cupy.ndarray]:
"""
Construct a CuPy or NumPy array from `arbitrary`
"""
try:
dtype = dtype if dtype is None else cudf.dtype(dtype)
arbitrary = cupy.asarray(arbitrary, dtype=dtype)
except (TypeErro... | def _construct_array(
arbitrary: Any, dtype: Optional[Dtype]
) -> Union[np.ndarray, cupy.ndarray]:
| """
Construct a CuPy or NumPy array from `arbitrary`
"""
try:
dtype = dtype if dtype is None else cudf.dtype(dtype)
arbitrary = cupy.asarray(arbitrary, dtype=dtype)
except (TypeError, ValueError):
native_dtype = dtype
if (
dtype is None
and not... | else:
data = as_column(
_construct_array(arbitrary, dtype),
dtype=dtype,
nan_as_null=nan_as_null,
)
return data
def _construct_array(
arbitrary: Any, dtype: Optional[Dtype]
) -> Union[... | 64 | 64 | 174 | 26 | 37 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | _construct_array | _construct_array | 2,134 | 2,157 | 2,134 | 2,136 | 1611ff2533a96735281e7876d16bbf25fab480c0 | bigcode/the-stack | train |
51698995f95b8a40b130ec3d | train | function | def deserialize_columns(headers: List[dict], frames: List) -> List[ColumnBase]:
"""
Construct a list of Columns from a list of headers
and frames.
"""
columns = []
for meta in headers:
col_frame_count = meta["frame_count"]
col_typ = pickle.loads(meta["type-serialized"])
... | def deserialize_columns(headers: List[dict], frames: List) -> List[ColumnBase]:
| """
Construct a list of Columns from a list of headers
and frames.
"""
columns = []
for meta in headers:
col_frame_count = meta["frame_count"]
col_typ = pickle.loads(meta["type-serialized"])
colobj = col_typ.deserialize(meta, frames[:col_frame_count])
columns.app... | 0:
header_columns = [c.serialize() for c in columns]
headers, column_frames = zip(*header_columns)
for f in column_frames:
frames.extend(f)
return headers, frames
def deserialize_columns(headers: List[dict], frames: List) -> List[ColumnBase]:
| 64 | 64 | 109 | 19 | 44 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | deserialize_columns | deserialize_columns | 2,220 | 2,235 | 2,220 | 2,220 | 0dbb363b7fae063a487f7a2db3ec414cf232c934 | bigcode/the-stack | train |
80ddcb16f6c117811ec11cea | train | function | def build_list_column(
indices: ColumnBase,
elements: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.ListColumn":
"""
Build a ListColumn
Parameters
----------
indices : ColumnBase
Column of list indi... | def build_list_column(
indices: ColumnBase,
elements: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.ListColumn":
| """
Build a ListColumn
Parameters
----------
indices : ColumnBase
Column of list indices
elements : ColumnBase
Column of list elements
mask: Buffer
Null mask
size: int, optional
offset: int, optional
"""
dtype = ListDtype(element_type=elements.dtype)
... | left, right),
)
def build_list_column(
indices: ColumnBase,
elements: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.ListColumn":
| 64 | 64 | 190 | 58 | 6 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | build_list_column | build_list_column | 1,599 | 1,633 | 1,599 | 1,606 | c0d45e676c2644958aa3baeb9659c790c199f4f6 | bigcode/the-stack | train |
9dea174cbd54299b95f7dc90 | train | function | def arange(
start: Union[int, float],
stop: Union[int, float] = None,
step: Union[int, float] = 1,
dtype=None,
) -> ColumnBase:
"""
Returns a column with evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop).
The first three argum... | def arange(
start: Union[int, float],
stop: Union[int, float] = None,
step: Union[int, float] = 1,
dtype=None,
) -> ColumnBase:
| """
Returns a column with evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop).
The first three arguments are mapped like the range built-in function,
i.e. start and step are optional.
Parameters
----------
start : int/float
... | columns = []
for meta in headers:
col_frame_count = meta["frame_count"]
col_typ = pickle.loads(meta["type-serialized"])
colobj = col_typ.deserialize(meta, frames[:col_frame_count])
columns.append(colobj)
# Advance frames
frames = frames[col_frame_count:]
ret... | 114 | 114 | 383 | 44 | 69 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | arange | arange | 2,238 | 2,293 | 2,238 | 2,243 | 70ae4065b1c18d9a9a7278039156684af69ca797 | bigcode/the-stack | train |
ee6db0108a4e8e0a84e9e393 | train | function | def _mask_from_cuda_array_interface_desc(obj) -> Union[Buffer, None]:
desc = obj.__cuda_array_interface__
mask = desc.get("mask", None)
if mask is not None:
desc = mask.__cuda_array_interface__
ptr = desc["data"][0]
nelem = desc["shape"][0]
typestr = desc["typestr"]
... | def _mask_from_cuda_array_interface_desc(obj) -> Union[Buffer, None]:
| desc = obj.__cuda_array_interface__
mask = desc.get("mask", None)
if mask is not None:
desc = mask.__cuda_array_interface__
ptr = desc["data"][0]
nelem = desc["shape"][0]
typestr = desc["typestr"]
typecode = typestr[1]
if typecode == "t":
mask_siz... | len(desc["shape"]) > 0 else 1
dtype = cudf.dtype(desc["typestr"])
data = Buffer(data=ptr, size=nelem * dtype.itemsize, owner=obj)
return data
def _mask_from_cuda_array_interface_desc(obj) -> Union[Buffer, None]:
| 64 | 64 | 178 | 17 | 46 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | _mask_from_cuda_array_interface_desc | _mask_from_cuda_array_interface_desc | 2,170 | 2,190 | 2,170 | 2,170 | 3a0e69c681bc8e2ff8328f4099a0938278bc717c | bigcode/the-stack | train |
d5ba5437266da2c50fe66e88 | train | function | def column_empty(
row_count: int, dtype: Dtype = "object", masked: bool = False
) -> ColumnBase:
"""Allocate a new column like the given row_count and dtype.
"""
dtype = cudf.dtype(dtype)
children = () # type: Tuple[ColumnBase, ...]
if is_struct_dtype(dtype):
data = None
childr... | def column_empty(
row_count: int, dtype: Dtype = "object", masked: bool = False
) -> ColumnBase:
| """Allocate a new column like the given row_count and dtype.
"""
dtype = cudf.dtype(dtype)
children = () # type: Tuple[ColumnBase, ...]
if is_struct_dtype(dtype):
data = None
children = tuple(
column_empty(row_count, field_dtype)
for field_dtype in dtype.fie... | same length and the same mask.
Parameters
----------
dtype : np.dtype like
The dtype of the data buffer.
"""
result = column_empty_like(column, dtype)
if column.nullable:
result = result.set_mask(column.mask)
return result
def column_empty(
row_count: int, dtype: Dtype ... | 87 | 87 | 292 | 29 | 57 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | column_empty | column_empty | 1,314 | 1,355 | 1,314 | 1,316 | c02e7ce5c22906a4f66e228b8cc4e0fc99b53c40 | bigcode/the-stack | train |
9d81f56ed7a4bd9c7760e01a | train | function | def full(size: int, fill_value: ScalarLike, dtype: Dtype = None) -> ColumnBase:
"""
Returns a column of given size and dtype, filled with a given value.
Parameters
----------
size : int
size of the expected column.
fill_value : scalar
A scalar value to fill a new array.
dty... | def full(size: int, fill_value: ScalarLike, dtype: Dtype = None) -> ColumnBase:
| """
Returns a column of given size and dtype, filled with a given value.
Parameters
----------
size : int
size of the expected column.
fill_value : scalar
A scalar value to fill a new array.
dtype : default None
Data type specifier. It is inferred from other argumen... | size = int(np.ceil((stop - start) / step))
return libcudf.filling.sequence(
size,
as_device_scalar(start, dtype=dtype),
as_device_scalar(step, dtype=dtype),
)
def full(size: int, fill_value: ScalarLike, dtype: Dtype = None) -> ColumnBase:
| 71 | 71 | 238 | 23 | 48 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | full | full | 2,296 | 2,327 | 2,296 | 2,296 | 872b2da47ac70f6af7074e6c320ef62447667ebd | bigcode/the-stack | train |
e84216e19b9bc13dbe110006 | train | function | def build_interval_column(
left_col,
right_col,
mask=None,
size=None,
offset=0,
null_count=None,
closed="right",
):
"""
Build an IntervalColumn
Parameters
----------
left_col : Column
Column of values representing the left of the interval
right_col : Column
... | def build_interval_column(
left_col,
right_col,
mask=None,
size=None,
offset=0,
null_count=None,
closed="right",
):
| """
Build an IntervalColumn
Parameters
----------
left_col : Column
Column of values representing the left of the interval
right_col : Column
Column of representing the right of the interval
mask : Buffer
Null mask
size : int, optional
offset : int, optional
... | =dtype,
mask=mask,
size=size,
offset=offset,
null_count=null_count,
children=(codes,),
)
return cast("cudf.core.column.CategoricalColumn", result)
def build_interval_column(
left_col,
right_col,
mask=None,
size=None,
offset=0,
null_count=None,
... | 82 | 82 | 274 | 37 | 45 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | build_interval_column | build_interval_column | 1,553 | 1,596 | 1,553 | 1,561 | 3d21f88da4905072f7310426fba0dc1607714865 | bigcode/the-stack | train |
75b742a8b0227ff67a95ea9c | train | function | def as_column(
arbitrary: Any,
nan_as_null: bool = None,
dtype: Dtype = None,
length: int = None,
):
"""Create a Column from an arbitrary object
Parameters
----------
arbitrary : object
Object to construct the Column from. See *Notes*.
nan_as_null : bool, optional, default N... | def as_column(
arbitrary: Any,
nan_as_null: bool = None,
dtype: Dtype = None,
length: int = None,
):
| """Create a Column from an arbitrary object
Parameters
----------
arbitrary : object
Object to construct the Column from. See *Notes*.
nan_as_null : bool, optional, default None
If None (default), treats NaN values in arbitrary as null if there is
no mask passed along with i... | ", result)
def build_struct_column(
names: Sequence[str],
children: Tuple[ColumnBase, ...],
dtype: Optional[Dtype] = None,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.StructColumn":
"""
Build a StructColumn
Parameters
... | 256 | 256 | 3,627 | 34 | 222 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | as_column | as_column | 1,677 | 2,131 | 1,677 | 1,682 | 7e6f153a6f92ed8c9dca73b971b7a3fe6d9387d9 | bigcode/the-stack | train |
d0a3f368be486cdc3a2038dc | train | function | def column_empty_like(
column: ColumnBase,
dtype: Dtype = None,
masked: bool = False,
newsize: int = None,
) -> ColumnBase:
"""Allocate a new column like the given *column*
"""
if dtype is None:
dtype = column.dtype
row_count = len(column) if newsize is None else newsize
if ... | def column_empty_like(
column: ColumnBase,
dtype: Dtype = None,
masked: bool = False,
newsize: int = None,
) -> ColumnBase:
| """Allocate a new column like the given *column*
"""
if dtype is None:
dtype = column.dtype
row_count = len(column) if newsize is None else newsize
if (
hasattr(column, "dtype")
and is_categorical_dtype(column.dtype)
and dtype == column.dtype
):
column = ... | is a nested column, recursively apply this function on
the children of ``self``.
"""
return self
def column_empty_like(
column: ColumnBase,
dtype: Dtype = None,
masked: bool = False,
newsize: int = None,
) -> ColumnBase:
| 64 | 64 | 199 | 39 | 24 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | column_empty_like | column_empty_like | 1,268 | 1,295 | 1,268 | 1,273 | 46f210e17e271fe10280ccab027bc07567e65f73 | bigcode/the-stack | train |
5aa05a5af976ae048f3a2d25 | train | function | def serialize_columns(columns) -> Tuple[List[dict], List]:
"""
Return the headers and frames resulting
from serializing a list of Column
Parameters
----------
columns : list
list of Columns to serialize
Returns
-------
headers : list
list of header metadata for each C... | def serialize_columns(columns) -> Tuple[List[dict], List]:
| """
Return the headers and frames resulting
from serializing a list of Column
Parameters
----------
columns : list
list of Columns to serialize
Returns
-------
headers : list
list of header metadata for each Column
frames : list
list of frames
"""
... | elif typecode == "b":
col = as_column(mask)
mask = bools_to_mask(col)
else:
raise NotImplementedError(
f"Cannot infer mask from typestr {typestr}"
)
return mask
def serialize_columns(columns) -> Tuple[List[dict], List]:
| 64 | 64 | 147 | 13 | 50 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | serialize_columns | serialize_columns | 2,193 | 2,217 | 2,193 | 2,193 | a82fbe74173eb0859344f6c81e26acaa368a23a5 | bigcode/the-stack | train |
6a82afcc368f5acc806cb3b3 | train | function | def build_categorical_column(
categories: ColumnBase,
codes: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
ordered: bool = None,
) -> "cudf.core.column.CategoricalColumn":
"""
Build a CategoricalColumn
Parameters
----------
c... | def build_categorical_column(
categories: ColumnBase,
codes: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
ordered: bool = None,
) -> "cudf.core.column.CategoricalColumn":
| """
Build a CategoricalColumn
Parameters
----------
categories : Column
Column of categories
codes : Column
Column of codes, the size of the resulting Column will be
the size of `codes`
mask : Buffer
Null mask
size : int, optional
offset : int, option... | Error(f"Unrecognized dtype: {dtype}")
def build_categorical_column(
categories: ColumnBase,
codes: ColumnBase,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
ordered: bool = None,
) -> "cudf.core.column.CategoricalColumn":
| 77 | 78 | 262 | 67 | 10 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | build_categorical_column | build_categorical_column | 1,508 | 1,550 | 1,508 | 1,516 | a0ff83732959677401ac3c0cb85c9e76204d228e | bigcode/the-stack | train |
daae8d28b081e914412c8b06 | train | function | def column_empty_like_same_mask(
column: ColumnBase, dtype: Dtype
) -> ColumnBase:
"""Create a new empty Column with the same length and the same mask.
Parameters
----------
dtype : np.dtype like
The dtype of the data buffer.
"""
result = column_empty_like(column, dtype)
if colu... | def column_empty_like_same_mask(
column: ColumnBase, dtype: Dtype
) -> ColumnBase:
| """Create a new empty Column with the same length and the same mask.
Parameters
----------
dtype : np.dtype like
The dtype of the data buffer.
"""
result = column_empty_like(column, dtype)
if column.nullable:
result = result.set_mask(column.mask)
return result
| mask=codes.base_mask,
children=(as_column(codes.base_data, dtype=codes.dtype),),
size=codes.size,
)
return column_empty(row_count, dtype, masked)
def column_empty_like_same_mask(
column: ColumnBase, dtype: Dtype
) -> ColumnBase:
| 64 | 64 | 90 | 23 | 41 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | column_empty_like_same_mask | column_empty_like_same_mask | 1,298 | 1,311 | 1,298 | 1,300 | 172abeae097b3f0e774f753471b3df56246d0e6e | bigcode/the-stack | train |
5b236436d7e5ac9bd422fe9b | train | function | def build_column(
data: Union[Buffer, None],
dtype: Dtype,
*,
size: int = None,
mask: Buffer = None,
offset: int = 0,
null_count: int = None,
children: Tuple[ColumnBase, ...] = (),
) -> ColumnBase:
"""
Build a Column of the appropriate type from the given parameters
Paramete... | def build_column(
data: Union[Buffer, None],
dtype: Dtype,
*,
size: int = None,
mask: Buffer = None,
offset: int = 0,
null_count: int = None,
children: Tuple[ColumnBase, ...] = (),
) -> ColumnBase:
| """
Build a Column of the appropriate type from the given parameters
Parameters
----------
data : Buffer
The data buffer (can be None if constructing certain Column
types like StringColumn, ListColumn, or CategoricalColumn)
dtype
The dtype associated with the Column to c... | elif is_categorical_dtype(dtype):
data = None
children = (
build_column(
data=Buffer.empty(row_count * cudf.dtype("int32").itemsize),
dtype="int32",
),
)
elif dtype.kind in "OU" and not is_decimal_dtype(dtype):
data = None
... | 256 | 256 | 885 | 68 | 188 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | build_column | build_column | 1,358 | 1,505 | 1,358 | 1,367 | 6cdf130c64d11f3547cf9203dd6611b86ae6a962 | bigcode/the-stack | train |
565266469dc110acde8a5f2d | train | function | def build_struct_column(
names: Sequence[str],
children: Tuple[ColumnBase, ...],
dtype: Optional[Dtype] = None,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.StructColumn":
"""
Build a StructColumn
Parameters
---------... | def build_struct_column(
names: Sequence[str],
children: Tuple[ColumnBase, ...],
dtype: Optional[Dtype] = None,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.StructColumn":
| """
Build a StructColumn
Parameters
----------
names : list-like
Field names to map to children dtypes
children : tuple
mask: Buffer
Null mask
size: int, optional
offset: int, optional
"""
if dtype is None:
dtype = StructDtype(
fields={na... | def build_struct_column(
names: Sequence[str],
children: Tuple[ColumnBase, ...],
dtype: Optional[Dtype] = None,
mask: Buffer = None,
size: int = None,
offset: int = 0,
null_count: int = None,
) -> "cudf.core.column.StructColumn":
| 72 | 65 | 219 | 72 | 0 | mayankanand007/cudf | python/cudf/cudf/core/column/column.py | Python | build_struct_column | build_struct_column | 1,636 | 1,674 | 1,636 | 1,644 | 19597279eafe09641f288f134bcf1aadd2083e4f | bigcode/the-stack | train |
1499fec26cc44040d34e9ec4 | train | class | @mgr_utils.mock_record_keepalive
class UpdateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_update_node(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
extra={'test': 'one'})
# check that ManagerServic... | @mgr_utils.mock_record_keepalive
class UpdateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_update_node(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
extra={'test': 'one'})
# check that ManagerService.update_node actually updates the node
node.extra = {'test': 'two'}
res = self.service.upda... | , driver='fake-hardware',
extra={'test': 'one'})
res = self.service.create_node(self.context, node)
self.assertEqual({'test': 'one'}, res['extra'])
res = objects.Node.get_by_uuid(self.context, node['uuid'])
self.assertEqual({'test': 'one'}, res['e... | 255 | 256 | 3,560 | 27 | 228 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | UpdateNodeTestCase | UpdateNodeTestCase | 471 | 882 | 471 | 472 | 92c1da62f4f0672c3610bc28c299cdd6f2cd9f10 | bigcode/the-stack | train |
340549e99418201f2bcac511 | train | class | @mgr_utils.mock_record_keepalive
class DoNodeInspectAbortTestCase(mgr_utils.CommonMixIn,
mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(manager, 'LOG')
@mock.patch('ironic.drivers.modules.fake.FakeInspect.abort')
@mock.p... | @mgr_utils.mock_record_keepalive
class DoNodeInspectAbortTestCase(mgr_utils.CommonMixIn,
mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(manager, 'LOG')
@mock.patch('ironic.drivers.modules.fake.FakeInspect.abort')
@mock.p... | def test_do_inspect_abort_interface_not_support(self, mock_acquire,
mock_abort, mock_log):
node = obj_utils.create_test_node(self.context,
driver='fake-hardware',
provision... | raitList.get_by_node_id(self.context, self.node.id)
self.assertEqual(self.traits, [trait.trait for trait in traits])
def test_remove_node_traits_node_locked(self):
self._test_remove_node_traits_exception(exception.NodeLocked)
def test_remove_node_traits_node_not_found(self):
self._test... | 182 | 182 | 608 | 80 | 102 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeInspectAbortTestCase | DoNodeInspectAbortTestCase | 8,996 | 9,054 | 8,996 | 9,002 | f559f8c354cdb03b67f384f87d605a538434d470 | bigcode/the-stack | train |
a7d9b9bdc45fd084fe3bc0fd | train | class | @mgr_utils.mock_record_keepalive
class VendorPassthruTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(task_manager.TaskManager, 'upgrade_lock')
@mock.patch.object(task_manager.TaskManager, 'spawn_after')
def test_vendor_passthru_async(self, mock_spawn,
... | @mgr_utils.mock_record_keepalive
class VendorPassthruTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(task_manager.TaskManager, 'upgrade_lock')
@mock.patch.object(task_manager.TaskManager, 'spawn_after')
| def test_vendor_passthru_async(self, mock_spawn,
mock_upgrade):
node = obj_utils.create_test_node(self.context,
vendor_interface='fake')
info = {'bar': 'baz'}
self._start_service()
response = self.service.v... | self.assertEqual(alloc.uuid, node.instance_uuid)
def test_update_node_deleting_allocation_in_maintenance(self):
node = obj_utils.create_test_node(self.context,
provision_state='active',
maintenance=True)
alloc = ob... | 256 | 256 | 3,189 | 57 | 199 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | VendorPassthruTestCase | VendorPassthruTestCase | 885 | 1,249 | 885 | 889 | dbe237425ecce60cbe3c21c01a3baa2817843825 | bigcode/the-stack | train |
292ed8bc7b2fb022df98d7a6 | train | class | @mgr_utils.mock_record_keepalive
class ConsoleTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_set_console_mode_worker_pool_full(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
self._start_service()
with mock.patch.object(self.service,
... | @mgr_utils.mock_record_keepalive
class ConsoleTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_set_console_mode_worker_pool_full(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
self._start_service()
with mock.patch.object(self.service,
'_spawn_worker') as spawn_mock:
spawn_mock.side_effect = exception.N... | expected_calls = [mock.call(mock.ANY, mock.ANY,
{'provision_state': 'deploying',
'reserved': False},
'deploying',
'provision_updated_at',
... | 256 | 256 | 1,450 | 26 | 230 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ConsoleTestCase | ConsoleTestCase | 4,914 | 5,060 | 4,914 | 4,915 | 7d77c09d572ca809cd9702e3c1163df2f2c7a698 | bigcode/the-stack | train |
a9de7d4980fff0833e34f613 | train | class | @mock.patch.object(waiters, 'wait_for_all')
@mock.patch.object(manager.ConductorManager, '_spawn_worker')
@mock.patch.object(manager.ConductorManager, '_sync_power_state_nodes_task')
class ParallelPowerSyncTestCase(mgr_utils.CommonMixIn, db_base.DbTestCase):
def setUp(self):
super(ParallelPowerSyncTestCase... | @mock.patch.object(waiters, 'wait_for_all')
@mock.patch.object(manager.ConductorManager, '_spawn_worker')
@mock.patch.object(manager.ConductorManager, '_sync_power_state_nodes_task')
class ParallelPowerSyncTestCase(mgr_utils.CommonMixIn, db_base.DbTestCase):
| def setUp(self):
super(ParallelPowerSyncTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
def test__sync_power_states_9_nodes_8_workers(
self, sync_mock, spawn_mock, waiter_mock):
CONF.set_override('sync_power_state_workers', 8, group... | _utils.mock_record_keepalive
class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def _check_hardware_type_properties(self, hardware_type, expected):
self.config(enabled_hardware_types=[hardware_type])
self.hardware_type =... | 225 | 225 | 750 | 60 | 165 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ParallelPowerSyncTestCase | ParallelPowerSyncTestCase | 7,250 | 7,333 | 7,250 | 7,254 | 1ccb4cfcae2b5eddac90ebc8f44c9681d5f3dd83 | bigcode/the-stack | train |
6cc60f3bbd4fac7b3165d9f9 | train | class | class DoNodeRescueTestCase(mgr_utils.CommonMixIn, mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch('ironic.conductor.task_manager.acquire', autospec=True)
def test_do_node_rescue(self, mock_acquire):
self._start_service()
task = self._create_task(
... | class DoNodeRescueTestCase(mgr_utils.CommonMixIn, mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch('ironic.conductor.task_manager.acquire', autospec=True)
| def test_do_node_rescue(self, mock_acquire):
self._start_service()
task = self._create_task(
node_attrs=dict(driver='fake-hardware',
provision_state=states.ACTIVE,
instance_info={}))
mock_acquire.side_effect = self._get_acqu... | _next_clean_steps(
task, skip_current_step=skip)
expected_index = 1 if skip else 0
self.assertEqual(expected_index, step_index)
def test__get_node_next_clean_steps(self):
self.__get_node_next_clean_steps()
def test__get_node_next_clean_steps_no_skip(self):
... | 256 | 256 | 3,250 | 45 | 211 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeRescueTestCase | DoNodeRescueTestCase | 4,356 | 4,661 | 4,356 | 4,358 | 14d9ffe8dddde3a2449ce60694972840816cacc3 | bigcode/the-stack | train |
4903b301ac27e6813df79425 | train | class | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckInspectWaitTimeoutsTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
def setUp(... | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckInspectWaitTimeoutsTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
| def setUp(self):
super(ManagerCheckInspectWaitTimeoutsTestCase, self).setUp()
self.config(inspect_wait_timeout=300, group='conductor')
self.service = manager.ConductorManager('hostname', 'test-topic')
self.service.dbapi = self.dbapi
self.node = self._create_node(provision_st... | .inspect_hardware')
def test_inspect_hardware_unexpected_error(self, mock_inspect):
self._start_service()
mock_inspect.side_effect = RuntimeError('x')
state = states.MANAGEABLE
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | 256 | 256 | 2,013 | 65 | 191 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerCheckInspectWaitTimeoutsTestCase | ManagerCheckInspectWaitTimeoutsTestCase | 7,726 | 7,944 | 7,726 | 7,730 | 4cfb1e65defcf70912e2d1f7a3dcf5eb8e75726a | bigcode/the-stack | train |
3982cab66e084ad27faa1878 | train | class | @mgr_utils.mock_record_keepalive
class DoNodeCleanAbortTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(fake.FakeDeploy, 'tear_down_cleaning', autospec=True)
def _test__do_node_clean_abort(self, step_name, tear_mock):
node = obj_utils.create_te... | @mgr_utils.mock_record_keepalive
class DoNodeCleanAbortTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(fake.FakeDeploy, 'tear_down_cleaning', autospec=True)
| def _test__do_node_clean_abort(self, step_name, tear_mock):
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_state=states.CLEANFAIL,
target_provision_state=states.AVAILABLE,
clean_step={'step': 'foo', 'abortable': True})
... | ')
node.refresh()
# Assert the current clean step was marked to be aborted later
self.assertIn('abort_after', node.clean_step)
self.assertTrue(node.clean_step['abort_after'])
# Make sure things stays as it was before
self.assertEqual(states.CLEANWAIT, node.provision_state... | 132 | 132 | 443 | 50 | 82 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeCleanAbortTestCase | DoNodeCleanAbortTestCase | 3,114 | 3,156 | 3,114 | 3,117 | 940019f1b69d05747115ce705c691892165f9dee | bigcode/the-stack | train |
ed8c5d3f8065ed5e340c5372 | train | class | @mgr_utils.mock_record_keepalive
class UpdateVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_update_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | @mgr_utils.mock_record_keepalive
class UpdateVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_update_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_state=states.POWER_OFF)
volume_connector = obj_utils.create_test_volume_connector(
self.context, node_id=node.id, extra={'foo':... | driver='fake-hardware',
reservation='fake-reserv')
volume_connector = obj_utils.create_test_volume_connector(
self.context, node_id=node.id)
exc = self.assertRaises(messaging.rpc.ExpectedException,
self.service.destr... | 228 | 228 | 762 | 29 | 199 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | UpdateVolumeConnectorTestCase | UpdateVolumeConnectorTestCase | 8,653 | 8,731 | 8,653 | 8,655 | 715269fd614494061c68460f28a93bee3e5b2f60 | bigcode/the-stack | train |
364f4d19893de2d48708956d | train | class | @mgr_utils.mock_record_keepalive
class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_destroy_portgroup(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
portgroup = obj_utils.create_test_portgroup(self.... | @mgr_utils.mock_record_keepalive
class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_destroy_portgroup(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
portgroup = obj_utils.create_test_portgroup(self.context,
node_id=node.id)
self.service.destroy_portgroup(self.context, portgroup)
... | self.assertRaises(messaging.rpc.ExpectedException,
self.service.destroy_port,
self.context, port)
self.assertEqual(exception.InvalidState, exc.exc_info[0])
@mgr_utils.mock_record_keepalive
class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin... | 64 | 64 | 206 | 29 | 35 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DestroyPortgroupTestCase | DestroyPortgroupTestCase | 8,008 | 8,027 | 8,008 | 8,010 | a2a20c101157b5ae2d1b7d1b2270365651c56bc3 | bigcode/the-stack | train |
79ece2967f6005a13e7f5c71 | train | class | @mgr_utils.mock_record_keepalive
@mock.patch.object(images, 'is_whole_disk_image')
class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_do_node_deploy_invalid_state(self, mock_iwdi):
mock_iwdi.return_value = False
self._start_... | @mgr_utils.mock_record_keepalive
@mock.patch.object(images, 'is_whole_disk_image')
class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_do_node_deploy_invalid_state(self, mock_iwdi):
mock_iwdi.return_value = False
self._start_service()
# test that node deploy fails if the node is already provisioned
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_sta... | .assert_called_once_with(mock.ANY, 'vendor',
driver_name='fake-hardware')
# Compare true exception hidden by @messaging.expected_exceptions
self.assertEqual(exception.NoValidDefaultForInterface,
exc.exc_info[0])
@mock.patch.obj... | 256 | 256 | 5,277 | 43 | 213 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ServiceDoNodeDeployTestCase | ServiceDoNodeDeployTestCase | 1,252 | 1,739 | 1,252 | 1,255 | be184c48f2f997623345836c838714fe42e4c028 | bigcode/the-stack | train |
60243d4e5e627afc481804fb | train | class | @mgr_utils.mock_record_keepalive
class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare')
... | @mgr_utils.mock_record_keepalive
class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare')
| def test__do_takeover(self, mock_prepare, mock_take_over,
mock_start_console):
self._start_service()
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
task = task_manager.TaskManager(self.context, node.uuid)
self.service._do_takeover(t... | ported_obj = 'fake-backported-obj'
obj_name = 'fake-obj'
test_obj = mock.Mock()
test_obj.obj_name.return_value = obj_name
test_obj.obj_to_primitive.return_value = fake_backported_obj
fake_version_manifest = {obj_name: '1.0'}
result = self.conductor.object_backport_versio... | 205 | 205 | 684 | 79 | 126 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeTakeOverTestCase | DoNodeTakeOverTestCase | 8,287 | 8,358 | 8,287 | 8,292 | ec3fa774f19592811341e0db1ba1c3874591b90e | bigcode/the-stack | train |
176b820e2721fe5581aa2e0b | train | class | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckDeployTimeoutsTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
def setUp(self):
... | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckDeployTimeoutsTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
| def setUp(self):
super(ManagerCheckDeployTimeoutsTestCase, self).setUp()
self.config(deploy_callback_timeout=300, group='conductor')
self.service = manager.ConductorManager('hostname', 'test-topic')
self.service.dbapi = self.dbapi
self.node = self._create_node(provision_stat... | _nodeinfo_list_response()
mapped_mock.return_value = True
acquire_mock.side_effect = self._get_acquire_side_effect(self.task)
self.power.get_power_state.return_value = states.ERROR
self.service._power_failure_recovery(self.context)
get_nodeinfo_mock.assert_called_once_with(
... | 256 | 256 | 2,129 | 64 | 192 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerCheckDeployTimeoutsTestCase | ManagerCheckDeployTimeoutsTestCase | 6,923 | 7,154 | 6,923 | 6,927 | 22810b58f2961f90fddba35dab9795a99697c96a | bigcode/the-stack | train |
4ad45aafdd4b1e85760ee02e | train | class | @mgr_utils.mock_record_keepalive
class BootDeviceTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(fake.FakeManagement, 'set_boot_device', autospec=True)
@mock.patch.object(fake.FakeManagement, 'validate', autospec=True)
def test_set_boot_device(self, mock_val, mock_sbd):
... | @mgr_utils.mock_record_keepalive
class BootDeviceTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(fake.FakeManagement, 'set_boot_device', autospec=True)
@mock.patch.object(fake.FakeManagement, 'validate', autospec=True)
| def test_set_boot_device(self, mock_val, mock_sbd):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
self.service.set_boot_device(self.context, node.uuid,
boot_devices.PXE)
mock_val.assert_called_once_with(mock.ANY, mock.ANY)
... | number_of_workers = 8
CONF.set_override('send_sensor_data', True, group='conductor')
CONF.set_override('send_sensor_data_workers', number_of_workers,
group='conductor')
# NOTE(galyna): do not wait for threads to be finished in unittests
CONF.set_override... | 207 | 207 | 693 | 63 | 144 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | BootDeviceTestCase | BootDeviceTestCase | 5,724 | 5,785 | 5,724 | 5,728 | 9c7777dadf94d391ba642cbb7918b4f7db3bb092 | bigcode/the-stack | train |
52279daa8930afe9fcb10621 | train | class | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerSyncLocalStateTestCase(mgr_utils.CommonMixIn, db_base.DbTestCase):
def setUp(self):
super(ManagerSyncLocalStateTestCase, sel... | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerSyncLocalStateTestCase(mgr_utils.CommonMixIn, db_base.DbTestCase):
| def setUp(self):
super(ManagerSyncLocalStateTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.service.conductor = mock.Mock()
self.service.dbapi = self.dbapi
self.service.ring_manager = mock.Mock()
self.node = self._crea... | self.assertEqual(1, waiter_mock.call_count)
@mock.patch.object(queue, 'Queue', autospec=True)
def test__sync_power_states_node_prioritization(
self, queue_mock, sync_mock, spawn_mock, waiter_mock):
CONF.set_override('sync_power_state_workers', 1, group='conductor')
wit... | 256 | 256 | 1,515 | 62 | 194 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerSyncLocalStateTestCase | ManagerSyncLocalStateTestCase | 7,336 | 7,501 | 7,336 | 7,340 | e8a39700d0e9e1b2a524253d18262a6a74675c7d | bigcode/the-stack | train |
80e37138ba98656f4f2ca595 | train | class | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerPowerRecoveryTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
def setUp(self):
super(M... | @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerPowerRecoveryTestCase(mgr_utils.CommonMixIn,
db_base.DbTestCase):
| def setUp(self):
super(ManagerPowerRecoveryTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.service.dbapi = self.dbapi
self.driver = mock.Mock(spec_set=drivers_base.BareDriver)
self.power = self.driver.power
self.task = mo... | , except for node
# not mapped to this conductor
self.assertEqual(len(nodes) - 1, sleep_mock.call_count)
get_nodeinfo_mock.assert_called_once_with(
columns=self.columns, filters=self.filters)
mapped_calls = [mock.call(x.uuid, x.driver,
... | 256 | 256 | 1,437 | 62 | 194 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerPowerRecoveryTestCase | ManagerPowerRecoveryTestCase | 6,766 | 6,920 | 6,766 | 6,770 | 6a7763a81255c13ec0227a5ba85acbc61d80f71d | bigcode/the-stack | train |
0085d3442b60fcd7b8b5a157 | train | class | @mgr_utils.mock_record_keepalive
class CreateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_create_node(self):
node = obj_utils.get_test_node(self.context, driver='fake-hardware',
extra={'test': 'one'})
res = self.service.create_node(s... | @mgr_utils.mock_record_keepalive
class CreateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_create_node(self):
node = obj_utils.get_test_node(self.context, driver='fake-hardware',
extra={'test': 'one'})
res = self.service.create_node(self.context, node)
self.assertEqual({'test': 'one'}, res['extra'])
res = objects.Node.get_b... | [0])
node.refresh()
supported_mock.assert_called_once_with(mock.ANY, mock.ANY)
self.assertEqual(states.POWER_ON, node.power_state)
self.assertIsNone(node.target_power_state)
self.assertIsNone(node.last_error)
@mgr_utils.mock_record_keepalive
class CreateNodeTestCase(mgr_utils.Se... | 81 | 81 | 272 | 27 | 54 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | CreateNodeTestCase | CreateNodeTestCase | 440 | 468 | 440 | 441 | 0ee8563fee09f28c338edc7b5521f2861e03b4e4 | bigcode/the-stack | train |
34e0ef651b39c6cf2dcaa9da | train | class | @mgr_utils.mock_record_keepalive
class DestroyPortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_destroy_port(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
port = obj_utils.create_test_port(self.context,
... | @mgr_utils.mock_record_keepalive
class DestroyPortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_destroy_port(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
port = obj_utils.create_test_port(self.context,
node_id=node.id)
self.service.destroy_port(self.context, port)
self.assertRaises(exception.P... | _effect([self.task] * 3))
self.service._check_inspect_wait_timeouts(self.context)
# Should only have ran 2.
self.assertEqual([mock.call(self.node.uuid, self.node.driver,
self.node.conductor_group)] * 2,
mapped_mock.call_args_list)
... | 159 | 159 | 530 | 27 | 132 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DestroyPortTestCase | DestroyPortTestCase | 7,947 | 8,005 | 7,947 | 7,948 | 635fb6c8b34dbe9906dfb051bf6903b9fdce31f7 | bigcode/the-stack | train |
4350b490f2f41a93247a8207 | train | class | @mgr_utils.mock_record_keepalive
class MiscTestCase(mgr_utils.ServiceSetUpMixin, mgr_utils.CommonMixIn,
db_base.DbTestCase):
def test__mapped_to_this_conductor(self):
self._start_service()
n = db_utils.get_test_node()
self.assertTrue(self.service._mapped_to_this_conductor(... | @mgr_utils.mock_record_keepalive
class MiscTestCase(mgr_utils.ServiceSetUpMixin, mgr_utils.CommonMixIn,
db_base.DbTestCase):
| def test__mapped_to_this_conductor(self):
self._start_service()
n = db_utils.get_test_node()
self.assertTrue(self.service._mapped_to_this_conductor(
n['uuid'], 'fake-hardware', ''))
self.assertFalse(self.service._mapped_to_this_conductor(
n['uuid'], 'fake-hard... | )
self.assertFalse(mock_get_power_state.called)
@mock.patch('ironic.drivers.modules.fake.FakePower.get_power_state')
@mock.patch('ironic.drivers.modules.fake.FakePower.validate')
def test__do_node_verify_get_state_fails(self, mock_validate,
mock_get_powe... | 256 | 256 | 1,474 | 33 | 223 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | MiscTestCase | MiscTestCase | 4,762 | 4,911 | 4,762 | 4,764 | 8811d26352172ca1d1d28c5a6865d76481e82997 | bigcode/the-stack | train |
d183c8edc4c53bc5a90c0936 | train | class | @mock.patch.object(swift, 'SwiftAPI')
class StoreConfigDriveTestCase(db_base.DbTestCase):
def setUp(self):
super(StoreConfigDriveTestCase, self).setUp()
self.node = obj_utils.create_test_node(self.context,
driver='fake-hardware',
... | @mock.patch.object(swift, 'SwiftAPI')
class StoreConfigDriveTestCase(db_base.DbTestCase):
| def setUp(self):
super(StoreConfigDriveTestCase, self).setUp()
self.node = obj_utils.create_test_node(self.context,
driver='fake-hardware',
instance_info=None)
def test_store_configdrive(self, mock_swi... | mapped_mock.assert_called_once_with(self.node.uuid, self.node.driver,
self.node.conductor_group)
# assert acquire() gets called only once because of the worker limit
acquire_mock.assert_called_once_with(self.context, self.node.uuid,
... | 117 | 117 | 390 | 23 | 94 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | StoreConfigDriveTestCase | StoreConfigDriveTestCase | 7,504 | 7,545 | 7,504 | 7,506 | 2b9cf8499d3c46bc02ad3616afb3537044ee66e7 | bigcode/the-stack | train |
ef3a493301e972f34c1ef844 | train | class | @mgr_utils.mock_record_keepalive
class DestroyVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_destroy_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | @mgr_utils.mock_record_keepalive
class DestroyVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_destroy_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_state=states.POWER_OFF)
volume_connector = obj_utils.create_test_volume_connector(
self.context, node_id=node.id)
self... | heartbeat(
self.context, node.uuid, 'http://callback', '1.4.1')
calls = [
mock.call(mock.ANY, 'http://callback', '1.4.1'),
mock.call(mock.ANY, 'http://callback')
]
mock_heartbeat.assert_has_calls(calls)
self.assertFalse(log_mock.warning.called)
@mgr_ut... | 106 | 106 | 355 | 29 | 77 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DestroyVolumeConnectorTestCase | DestroyVolumeConnectorTestCase | 8,612 | 8,650 | 8,612 | 8,614 | f3dbdb8a04ba5b534fd05dda8522e84779c7d943 | bigcode/the-stack | train |
411f2808f4e9a89899bed82b | train | class | @mgr_utils.mock_record_keepalive
class NodeInspectHardware(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeInspect.inspect_hardware')
def test_inspect_hardware_ok(self, mock_inspect):
self._start_service()
node = obj_utils.create_test_node(self.con... | @mgr_utils.mock_record_keepalive
class NodeInspectHardware(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeInspect.inspect_hardware')
| def test_inspect_hardware_ok(self, mock_inspect):
self._start_service()
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
provision_state=states.INSPECTING)
task = task_manager.TaskManager(self.context, node.uuid)
mock_i... | {'X-Delete-After': str(timeout)}
expected_instance_info = {'configdrive': 'http://1.2.3.4'}
# set configs and mocks
CONF.set_override('configdrive_use_object_store', True,
group='deploy')
CONF.set_override('configdrive_swift_container', container_name,
... | 256 | 256 | 1,829 | 44 | 212 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | NodeInspectHardware | NodeInspectHardware | 7,548 | 7,723 | 7,548 | 7,551 | 5fe90865b7fa9e964ea471f4f6ebc0f4eb6ef3cc | bigcode/the-stack | train |
62a1cff3a682e7df7c305bd6 | train | class | @mgr_utils.mock_record_keepalive
class NmiTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(fake.FakeManagement, 'inject_nmi', autospec=True)
@mock.patch.object(fake.FakeManagement, 'validate', autospec=True)
def test_inject_nmi(self, mock_val, mock_nmi):
node = obj_util... | @mgr_utils.mock_record_keepalive
class NmiTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(fake.FakeManagement, 'inject_nmi', autospec=True)
@mock.patch.object(fake.FakeManagement, 'validate', autospec=True)
| def test_inject_nmi(self, mock_val, mock_nmi):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
self.service.inject_nmi(self.context, node.uuid)
mock_val.assert_called_once_with(mock.ANY, mock.ANY)
mock_nmi.assert_called_once_with(mock.ANY, mock.ANY)
def t... | self.service.get_boot_device,
self.context, node.uuid)
# Compare true exception hidden by @messaging.expected_exceptions
self.assertEqual(exception.InvalidParameterValue, exc.exc_info[0])
def test_get_supported_boot_devices(self):
... | 164 | 164 | 549 | 63 | 101 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | NmiTestCase | NmiTestCase | 5,788 | 5,835 | 5,788 | 5,792 | 80cda960473c4a755a10cf621452879b6f297854 | bigcode/the-stack | train |
c5ae690c68914e272a0d28a5 | train | class | @mock.patch.object(waiters, 'wait_for_all',
new=mock.MagicMock(return_value=(0, 0)))
@mock.patch.object(manager.ConductorManager, '_spawn_worker',
new=lambda self, fun, *args: fun(*args))
@mock.patch.object(manager, 'do_sync_power_state')
@mock.patch.object(task_manager, 'acquire')... | @mock.patch.object(waiters, 'wait_for_all',
new=mock.MagicMock(return_value=(0, 0)))
@mock.patch.object(manager.ConductorManager, '_spawn_worker',
new=lambda self, fun, *args: fun(*args))
@mock.patch.object(manager, 'do_sync_power_state')
@mock.patch.object(task_manager, 'acquire')... | def setUp(self):
super(ManagerSyncPowerStatesTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.service.dbapi = self.dbapi
self.node = self._create_node()
self.filters = {'maintenance': False}
self.columns = ['uuid', 'driver... | .power_state)
self.assertFalse(node_power_action.called)
self.task.upgrade_lock.assert_called_once_with()
def test_correct_power_state_on_upgrade_lock(self, node_power_action):
def _fake_upgrade():
self.node.power_state = states.POWER_OFF
self.task.upgrade_lock.side_eff... | 256 | 256 | 2,216 | 129 | 127 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerSyncPowerStatesTestCase | ManagerSyncPowerStatesTestCase | 6,522 | 6,763 | 6,522 | 6,531 | 935318091d2015b5aa4a70df3772c4408a826189 | bigcode/the-stack | train |
9f93e0baf2c32b8eb2550084 | train | class | @mgr_utils.mock_record_keepalive
class ContinueNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def setUp(self):
super(ContinueNodeDeployTestCase, self).setUp()
self.deploy_start = {
'step': 'deploy_start', 'priority': 50, 'interface':... | @mgr_utils.mock_record_keepalive
class ContinueNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def setUp(self):
super(ContinueNodeDeployTestCase, self).setUp()
self.deploy_start = {
'step': 'deploy_start', 'priority': 50, 'interface': 'deploy'}
self.deploy_end = {
'step': 'deploy_end', 'priority': 20, 'interface': 'deploy'}
self.deploy_steps = [self.dep... | target_provision_state=tgt_prv_state,
last_error=None,
driver='fake-hardware')
self._start_service()
with mock.patch.object(self.service, '_spawn_worker',
autospec=True) as mock_spawn:
... | 255 | 256 | 1,019 | 29 | 226 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ContinueNodeDeployTestCase | ContinueNodeDeployTestCase | 1,742 | 1,846 | 1,742 | 1,744 | 2b4835c068f1da7f5ab6efc3a9f03ebeb5c78965 | bigcode/the-stack | train |
70ee65a98709e4611eeeeffb | train | class | @mgr_utils.mock_record_keepalive
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet')
def test_create_port(self, mock_validate):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
port = obj_... | @mgr_utils.mock_record_keepalive
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet')
| def test_create_port(self, mock_validate):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
port = obj_utils.get_test_port(self.context, node_id=node.id,
extra={'foo': 'bar'})
res = self.service.create_port(self.context, port)
... | mock_sc.side_effect = Exception()
self.service.destroy_node(self.context, node.uuid)
mock_sc.assert_called_once_with(mock.ANY, mock.ANY)
self.assertRaises(exception.NodeNotFound,
self.dbapi.get_node_by_uuid,
node.uuid)
mock_noti... | 229 | 229 | 765 | 42 | 187 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | CreatePortTestCase | CreatePortTestCase | 5,234 | 5,302 | 5,234 | 5,237 | 285b8013ae2586c03c7da733b47aefdfe1d2f5bb | bigcode/the-stack | train |
d757a150fa0c7f26abc3acb2 | train | class | @mgr_utils.mock_record_keepalive
class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def _check_hardware_type_properties(self, hardware_type, expected):
self.config(enabled_hardware_types=[hardware_type])
self.hardware_ty... | @mgr_utils.mock_record_keepalive
class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def _check_hardware_type_properties(self, hardware_type, expected):
self.config(enabled_hardware_types=[hardware_type])
self.hardware_type = driver_factory.get_hardware_type(hardware_type)
self._start_service()
properties = self.service.get_driver_properties(self.context,
... | .context, "bad-driver")
# Compare true exception hidden by @messaging.expected_exceptions
self.assertEqual(exception.DriverNotFound, exc.exc_info[0])
@mgr_utils.mock_record_keepalive
class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
db_base.DbTe... | 64 | 64 | 167 | 29 | 35 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerTestHardwareTypeProperties | ManagerTestHardwareTypeProperties | 7,231 | 7,247 | 7,231 | 7,234 | 0aa6bbb8f3766341dfc1b889128c21b10fc85034 | bigcode/the-stack | train |
4fac7879d22991e706505994 | train | class | @mgr_utils.mock_record_keepalive
class UpdateVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_update_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_st... | @mgr_utils.mock_record_keepalive
class UpdateVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_update_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_state=states.POWER_OFF)
volume_target = obj_utils.create_test_volume_target(
self.context, node_id=node.id, extra={'foo': 'bar'})
... | ed(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_state=states.POWER_OFF)
volume_target = obj_utils.create_test_volume_target(self.context,
node_id=node.id)
... | 256 | 256 | 993 | 29 | 227 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | UpdateVolumeTargetTestCase | UpdateVolumeTargetTestCase | 8,799 | 8,896 | 8,799 | 8,801 | 488e086e61d4eb6d63a588b8f8c10d2a7ee56a09 | bigcode/the-stack | train |
67441ad52da8367632c5f2c7 | train | class | class TestIndirectionApiConductor(db_base.DbTestCase):
def setUp(self):
super(TestIndirectionApiConductor, self).setUp()
self.conductor = manager.ConductorManager('test-host', 'test-topic')
def _test_object_action(self, is_classmethod, raise_exception,
return_object... | class TestIndirectionApiConductor(db_base.DbTestCase):
| def setUp(self):
super(TestIndirectionApiConductor, self).setUp()
self.conductor = manager.ConductorManager('test-host', 'test-topic')
def _test_object_action(self, is_classmethod, raise_exception,
return_object=False):
@obj_base.IronicObjectRegistry.register... | _once_with(self.node.uuid, 'fake-hardware',
'')
mock_fail_if.assert_called_once_with(
mock.ANY, {'uuid': self.node.uuid},
{states.DEPLOYING, states.CLEANING},
'provision_updated_at',
callback_method=conductor_utils.abort... | 234 | 234 | 781 | 13 | 221 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | TestIndirectionApiConductor | TestIndirectionApiConductor | 8,185 | 8,284 | 8,185 | 8,186 | 47f753291106a3a9229160fa8a539d924d404ffc | bigcode/the-stack | train |
0e23dde919b6c88ce9540f00 | train | class | @mgr_utils.mock_record_keepalive
class SensorsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test__filter_out_unsupported_types_all(self):
self._start_service()
CONF.set_override('send_sensor_data_types', ['All'], group='conductor')
fake_sensors_data = {"t1": {'f1': 'v1'}, "... | @mgr_utils.mock_record_keepalive
class SensorsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test__filter_out_unsupported_types_all(self):
self._start_service()
CONF.set_override('send_sensor_data_types', ['All'], group='conductor')
fake_sensors_data = {"t1": {'f1': 'v1'}, "t2": {'f1': 'v1'}}
actual_result = (
self.service._filter_out_unsupported_types(fake_s... | port)
# Compare true exception hidden by @messaging.expected_exceptions
self.assertEqual(exception.Conflict, exc.exc_info[0])
mock_validate.assert_called_once_with(mock.ANY, port)
@mock.patch.object(conductor_utils, 'validate_port_physnet')
def test_update_port_physnet_validation_failu... | 256 | 256 | 1,631 | 26 | 230 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | SensorsTestCase | SensorsTestCase | 5,566 | 5,721 | 5,566 | 5,568 | 6a1fc0bb986cee4593e80ccb1c9c047e3af0f37c | bigcode/the-stack | train |
27a13c217e31550c3f4c51ed | train | class | @mgr_utils.mock_record_keepalive
class DoNodeVerifyTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.objects.node.NodeCorrectedPowerStateNotification')
@mock.patch('ironic.drivers.modules.fake.FakePower.get_power_state')
@mock.patch('ironic.drivers.modules.fake.FakePower.validat... | @mgr_utils.mock_record_keepalive
class DoNodeVerifyTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.objects.node.NodeCorrectedPowerStateNotification')
@mock.patch('ironic.drivers.modules.fake.FakePower.get_power_state')
@mock.patch('ironic.drivers.modules.fake.FakePower.validat... | def test__do_node_verify(self, mock_validate, mock_get_power_state,
mock_notif):
self._start_service()
mock_get_power_state.return_value = states.POWER_OFF
# Required for exception handling
mock_notif.__name__ = 'NodeCorrectedPowerStateNotification'
... | .patch.object(fake.FakeRescue, 'clean_up', autospec=True)
def test__do_node_rescue_abort_clean_up_fail(self, clean_up_mock):
clean_up_mock.side_effect = Exception('Surprise')
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_state=states.RESCU... | 241 | 241 | 805 | 78 | 163 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeVerifyTestCase | DoNodeVerifyTestCase | 4,664 | 4,759 | 4,664 | 4,668 | b6a922043841c8869c6cd924f546021c47650588 | bigcode/the-stack | train |
5f2eaf1a8739caa16d4b2f2f | train | class | @mock.patch.object(conductor_utils, 'node_power_action')
class ManagerDoSyncPowerStateTestCase(db_base.DbTestCase):
def setUp(self):
super(ManagerDoSyncPowerStateTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.driver = mock.Mock(spec_set=drivers... | @mock.patch.object(conductor_utils, 'node_power_action')
class ManagerDoSyncPowerStateTestCase(db_base.DbTestCase):
| def setUp(self):
super(ManagerDoSyncPowerStateTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.driver = mock.Mock(spec_set=drivers_base.BareDriver)
self.power = self.driver.power
self.node = obj_utils.create_test_node(
... |
def test_set_target_raid_config_iface_not_supported(self):
# NOTE(jroll): it's impossible for a dynamic driver to have a null
# interface (e.g. node.driver.raid), so this instead tests that
# if validation fails, we blow up properly.
# need a different raid interface and a hardware... | 255 | 256 | 2,707 | 27 | 228 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerDoSyncPowerStateTestCase | ManagerDoSyncPowerStateTestCase | 6,240 | 6,519 | 6,240 | 6,241 | 5248c839e373f0e8d49413cb13ee55710a913e6f | bigcode/the-stack | train |
c4088bb31bc6f0edb41062a3 | train | class | @mgr_utils.mock_record_keepalive
class NodeTraitsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def setUp(self):
super(NodeTraitsTestCase, self).setUp()
self.traits = ['trait1', 'trait2']
self.node = obj_utils.create_test_node(self.context,
... | @mgr_utils.mock_record_keepalive
class NodeTraitsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def setUp(self):
super(NodeTraitsTestCase, self).setUp()
self.traits = ['trait1', 'trait2']
self.node = obj_utils.create_test_node(self.context,
driver='fake-hardware')
def test_add_node_traits(self):
self.service.add_node_traits(se... | ('Boo')
exc = self.assertRaises(messaging.rpc.ExpectedException,
self.service.update_volume_target,
self.context, volume_target)
# Compare true exception hidden by @messaging.expected_exceptions
self.assertEqual(... | 256 | 256 | 1,014 | 27 | 229 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | NodeTraitsTestCase | NodeTraitsTestCase | 8,899 | 8,993 | 8,899 | 8,901 | 04f0930efe59675a5486e30d6439b780bada62d8 | bigcode/the-stack | train |
5d8f05a3738103b873d401f4 | train | class | @mgr_utils.mock_record_keepalive
class DoProvisioningActionTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch('ironic.conductor.manager.ConductorManager._spawn_worker',
autospec=True)
def test_do_provisioning_action_worker_pool_full(self, mo... | @mgr_utils.mock_record_keepalive
class DoProvisioningActionTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch('ironic.conductor.manager.ConductorManager._spawn_worker',
autospec=True)
| def test_do_provisioning_action_worker_pool_full(self, mock_spawn):
prv_state = states.MANAGEABLE
tgt_prv_state = states.NOSTATE
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
provision_state=prv_state,
... | driver_internal_info=driver_internal_info, last_error=None)
self._start_service()
mock_spawn.side_effect = exception.NoFreeConductorWorker()
exc = self.assertRaises(messaging.rpc.ExpectedException,
self.service.do_node_tear_down,
... | 256 | 256 | 1,093 | 52 | 204 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoProvisioningActionTestCase | DoProvisioningActionTestCase | 3,003 | 3,111 | 3,003 | 3,007 | 1d085efa6d248abc67411aec7aa06825f753bfdf | bigcode/the-stack | train |
8a0fbf1031c5e918c1103f94 | train | class | @mgr_utils.mock_record_keepalive
class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(n_flat.FlatNetwork, 'portgroup_changed', autospec=True)
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
def test_update_portgroup(self, mock_val, mock_pc):
... | @mgr_utils.mock_record_keepalive
class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(n_flat.FlatNetwork, 'portgroup_changed', autospec=True)
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
| def test_update_portgroup(self, mock_val, mock_pc):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
portgroup = obj_utils.create_test_portgroup(self.context,
node_id=node.id,
... | exc.exc_info[0])
mock_valid.assert_called_once_with(mock.ANY, mock.ANY)
mock_detach.assert_called_once_with(mock.ANY, "interface")
@mock.patch.object(n_flat.FlatNetwork, 'vif_detach', autpspec=True)
def test_vif_detach_validate_error(self, mock_detach,
mo... | 256 | 256 | 1,802 | 64 | 192 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | UpdatePortgroupTestCase | UpdatePortgroupTestCase | 5,976 | 6,151 | 5,976 | 5,979 | 3c6c3e693ce50e2e63e281c6ca0d196120e311d9 | bigcode/the-stack | train |
33c749ba7761ebe24fddb16c | train | class | @mgr_utils.mock_record_keepalive
class DoNodeTearDownTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_do_node_tear_down_invalid_state(self):
self._start_service()
# test node.provision_state is incorrect for tear_down
node = obj_utils.create_test_node(self.context, driver=... | @mgr_utils.mock_record_keepalive
class DoNodeTearDownTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_do_node_tear_down_invalid_state(self):
self._start_service()
# test node.provision_state is incorrect for tear_down
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
provision_state=states.AVAILABLE)
exc = self.... | mock_clean_up):
self._start_service()
CONF.set_override('rescue_callback_timeout', 1, group='conductor')
tgt_prov_state = states.RESCUE
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
rescue_interface... | 256 | 256 | 2,444 | 30 | 226 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeTearDownTestCase | DoNodeTearDownTestCase | 2,763 | 3,000 | 2,763 | 2,764 | 6806d1dae28d5d2b3332bab2a93c029babb04156 | bigcode/the-stack | train |
7ae2304e6459d1f4f8b59294 | train | class | @mgr_utils.mock_record_keepalive
class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def setUp(self):
super(ManagerTestProperties, self).setUp()
self.service = manager.ConductorManager('test-host', 'test-topic')
def _check_driver_properties(self, hw_type, expected):
... | @mgr_utils.mock_record_keepalive
class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def setUp(self):
super(ManagerTestProperties, self).setUp()
self.service = manager.ConductorManager('test-host', 'test-topic')
def _check_driver_properties(self, hw_type, expected):
self._start_service()
properties = self.service.get_driver_properties(self.context, hw_type)
... | _response([self.node] * 3))
mapped_mock.return_value = True
acquire_mock.side_effect = (
self._get_acquire_side_effect([self.task] * 3))
self.service._check_deploy_timeouts(self.context)
# Should only have ran 2.
self.assertEqual([mock.call(self.node.uuid, self.node... | 226 | 226 | 755 | 26 | 200 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerTestProperties | ManagerTestProperties | 7,157 | 7,228 | 7,157 | 7,159 | aa2d98dc29b26d155a87e40f42cecfbeeb78fca0 | bigcode/the-stack | train |
f4ff5e3ce42e66c32332aacd | train | class | @mgr_utils.mock_record_keepalive
class DestroyVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def test_destroy_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power... | @mgr_utils.mock_record_keepalive
class DestroyVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def test_destroy_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
power_state=states.POWER_OFF)
volume_target = obj_utils.create_test_volume_target(self.context,
... | aging.expected_exceptions
self.assertEqual(exception.VolumeConnectorTypeAndIdAlreadyExists,
exc.exc_info[0])
def test_update_volume_connector_node_power_on(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | 177 | 177 | 590 | 29 | 148 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DestroyVolumeTargetTestCase | DestroyVolumeTargetTestCase | 8,734 | 8,796 | 8,734 | 8,736 | 606af1e30259ccb99fbc13aec88c2289b2cd45fa | bigcode/the-stack | train |
26af3530582a1b41f7e52067 | train | class | @mgr_utils.mock_record_keepalive
class UpdatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet')
@mock.patch.object(n_flat.FlatNetwork, 'port_changed', autospec=True)
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
... | @mgr_utils.mock_record_keepalive
class UpdatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet')
@mock.patch.object(n_flat.FlatNetwork, 'port_changed', autospec=True)
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
| def test_update_port(self, mock_val, mock_pc, mock_vpp):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
port = obj_utils.create_test_port(self.context,
node_id=node.id,
extra={'foo': 'bar'})... | .uuid)
@mock.patch.object(conductor_utils, 'validate_port_physnet')
def test_create_port_physnet_validation_failure_inconsistent(
self, mock_validate):
mock_validate.side_effect = exception.PortgroupPhysnetInconsistent(
portgroup='pg1', physical_networks='physnet1, physnet2')
... | 256 | 256 | 2,800 | 77 | 179 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | UpdatePortTestCase | UpdatePortTestCase | 5,305 | 5,563 | 5,305 | 5,310 | bf4353f439555e74fee410a8a114a60359a80170 | bigcode/the-stack | train |
cef470bd74d21790a52f37ad | train | class | @mgr_utils.mock_record_keepalive
class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def setUp(self):
super(DoNodeCleanTestCase, self).setUp()
self.config(automated_clean=True, group='conductor')
self.power_update = {
'step': 'update_firmware', 'priority':... | @mgr_utils.mock_record_keepalive
class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def setUp(self):
super(DoNodeCleanTestCase, self).setUp()
self.config(automated_clean=True, group='conductor')
self.power_update = {
'step': 'update_firmware', 'priority': 10, 'interface': 'power'}
self.deploy_update = {
'step': 'update_firmware', 'priority': ... | test__do_node_clean_abort(self):
self._test__do_node_clean_abort(None)
def test__do_node_clean_abort_with_step_name(self):
self._test__do_node_clean_abort('foo')
@mock.patch.object(fake.FakeDeploy, 'tear_down_cleaning', autospec=True)
def test__do_node_clean_abort_tear_down_fail(self, tea... | 256 | 256 | 11,249 | 28 | 228 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeCleanTestCase | DoNodeCleanTestCase | 3,159 | 4,353 | 3,159 | 3,160 | 61618aa99d5484780439daaee8a94fe19eded83c | bigcode/the-stack | train |
9848b90096eb9bb3509bc24a | train | class | @mgr_utils.mock_record_keepalive
class DoNextDeployStepTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
def setUp(self):
super(DoNextDeployStepTestCase, self).setUp()
self.deploy_start = {
'step': 'deploy_start', 'priority': 50, 'interface': 'depl... | @mgr_utils.mock_record_keepalive
class DoNextDeployStepTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
| def setUp(self):
super(DoNextDeployStepTestCase, self).setUp()
self.deploy_start = {
'step': 'deploy_start', 'priority': 50, 'interface': 'deploy'}
self.deploy_end = {
'step': 'deploy_end', 'priority': 20, 'interface': 'deploy'}
self.deploy_steps = [self.deplo... | False)
mock_deploy.assert_called_once_with(mock.ANY, task)
self.assertFalse(mock_log.warning.called)
self.assertEqual(self.service.conductor.id,
task.node.conductor_affinity)
@mock.patch('ironic.conductor.manager._start_co... | 256 | 256 | 2,717 | 30 | 226 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNextDeployStepTestCase | DoNextDeployStepTestCase | 2,392 | 2,679 | 2,392 | 2,394 | b3388a7896332b1b73ecbd0ae348008f127d9c8b | bigcode/the-stack | train |
6784747130c00f76700c8d7d | train | class | @mgr_utils.mock_record_keepalive
class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_destroy_node(self):
self._start_service()
for state in states.DELETE_ALLOWED_STATES:
node = obj_utils.create_test_node(self.context,
... | @mgr_utils.mock_record_keepalive
class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def test_destroy_node(self):
self._start_service()
for state in states.DELETE_ALLOWED_STATES:
node = obj_utils.create_test_node(self.context,
provision_state=state)
self.service.destroy_node(self.context, node.uuid)
se... | data = self.service.get_console_information(self.context,
node.uuid)
self.assertEqual(console_info, data)
def test_get_console_disabled(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | 256 | 256 | 1,396 | 27 | 229 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DestroyNodeTestCase | DestroyNodeTestCase | 5,063 | 5,231 | 5,063 | 5,065 | 3f96e365b960bb10add811845efe57cbec99736c | bigcode/the-stack | train |
18c2cd08dd6b3a9f2e0a63d3 | train | class | @mgr_utils.mock_record_keepalive
class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakePower.validate')
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate')
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console')
... | @mgr_utils.mock_record_keepalive
class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakePower.validate')
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate')
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console')
... | def test__do_adoption_with_takeover(self,
mock_prepare,
mock_take_over,
mock_start_console,
mock_boot_validate,
mock... | = Exception()
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
console_enabled=True)
task = task_manager.TaskManager(self.context, node.uuid)
self.service._do_takeover(task)
node.refresh()
self.assertIsNotNone(nod... | 255 | 256 | 2,273 | 111 | 144 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeAdoptionTestCase | DoNodeAdoptionTestCase | 8,361 | 8,609 | 8,361 | 8,368 | f4aaec0dbdaabca8a624ef13d29913b0ffbf6127 | bigcode/the-stack | train |
5c5da9dafa4470ea86ae6547 | train | class | @mgr_utils.mock_record_keepalive
class DoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.deploy')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare')
def test__do_node_deploy_driver_raises_prepare_error(self, mock_prepare,
... | @mgr_utils.mock_record_keepalive
class DoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.deploy')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare')
| def test__do_node_deploy_driver_raises_prepare_error(self, mock_prepare,
mock_deploy):
self._start_service()
# test when driver.deploy.prepare raises an ironic error
mock_prepare.side_effect = exception.InstanceDeployFailure('test')
... | _state = states.DEPLOYING
tgt_prv_state = states.ACTIVE
driver_info = {'deploy_steps': self.deploy_steps,
'deploy_step_index': 0}
self._start_service()
node = obj_utils.create_test_node(self.context, driver='fake-hardware',
... | 256 | 256 | 5,500 | 60 | 196 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | DoNodeDeployTestCase | DoNodeDeployTestCase | 1,849 | 2,389 | 1,849 | 1,852 | 7d1724b1f01143fad5582c7fc1fd9ce38dc36b01 | bigcode/the-stack | train |
292e5c5e6990dc6e52108733 | train | class | @mgr_utils.mock_record_keepalive
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
class VifTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def setUp(self):
super(VifTestCase, self).setUp()
self.vif = {'id': 'fake'}
@mock.patch.object(n_flat.FlatNetwork, 'vif_list', ... | @mgr_utils.mock_record_keepalive
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
class VifTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| def setUp(self):
super(VifTestCase, self).setUp()
self.vif = {'id': 'fake'}
@mock.patch.object(n_flat.FlatNetwork, 'vif_list', autospec=True)
def test_vif_list(self, mock_list, mock_valid):
mock_list.return_value = ['VIF_ID']
node = obj_utils.create_test_node(self.context, d... | ParameterValue, exc.exc_info[0])
@mock.patch.object(fake.FakeManagement, 'validate', autospec=True)
def test_inject_nmi_validate_missing_param(self, mock_val):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
mock_val.side_effect = exception.MissingParameterValue('error')... | 256 | 256 | 1,642 | 43 | 213 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | VifTestCase | VifTestCase | 5,838 | 5,973 | 5,838 | 5,841 | c932214cd6240d6258da9f6f95db75933c3c5807 | bigcode/the-stack | train |
7a2e5158a052af1e4e5e20a4 | train | class | @mgr_utils.mock_record_keepalive
class RaidHardwareTypeTestCases(RaidTestCases):
driver_name = 'fake-hardware'
raid_interface = 'fake'
def test_get_raid_logical_disk_properties_iface_not_supported(self):
# NOTE(jroll) we don't run this test as get_logical_disk_properties
# is supported on ... | @mgr_utils.mock_record_keepalive
class RaidHardwareTypeTestCases(RaidTestCases):
| driver_name = 'fake-hardware'
raid_interface = 'fake'
def test_get_raid_logical_disk_properties_iface_not_supported(self):
# NOTE(jroll) we don't run this test as get_logical_disk_properties
# is supported on all RAID implementations, and we cannot have a
# null interface for a hard... | bar'}
self.node.save()
exc = self.assertRaises(
messaging.rpc.ExpectedException,
self.service.set_target_raid_config,
self.context, self.node.uuid, raid_config)
self.node.refresh()
self.assertEqual({'foo': 'bar'}, self.node.target_raid_config)
... | 96 | 96 | 322 | 19 | 77 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | RaidHardwareTypeTestCases | RaidHardwareTypeTestCases | 6,206 | 6,237 | 6,206 | 6,208 | b56befa5c1e11c8203792e447ed2bb6dc6900b14 | bigcode/the-stack | train |
217c2a0bc258344182673143 | train | class | @mgr_utils.mock_record_keepalive
class ChangeNodePowerStateTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
def test_change_node_power_state_power_on(self, get_power_mock):
# Test change_no... | @mgr_utils.mock_record_keepalive
class ChangeNodePowerStateTestCase(mgr_utils.ServiceSetUpMixin,
db_base.DbTestCase):
@mock.patch.object(fake.FakePower, 'get_power_state', autospec=True)
| def test_change_node_power_state_power_on(self, get_power_mock):
# Test change_node_power_state including integration with
# conductor.utils.node_power_action and lower.
get_power_mock.return_value = states.POWER_OFF
node = obj_utils.create_test_node(self.context,
... | _versionedobjects import fields
import six
from six.moves import queue
from ironic.common import boot_devices
from ironic.common import driver_factory
from ironic.common import exception
from ironic.common import images
from ironic.common import states
from ironic.common import swift
from ironic.conductor import manag... | 256 | 256 | 3,283 | 49 | 206 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ChangeNodePowerStateTestCase | ChangeNodePowerStateTestCase | 62 | 437 | 62 | 66 | f741b2b23be486326eb0e52c11b1451479e6118c | bigcode/the-stack | train |
0f8d290243fe98119715dcde | train | class | @mgr_utils.mock_record_keepalive
class RaidTestCases(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
driver_name = 'fake-hardware'
raid_interface = None
def setUp(self):
super(RaidTestCases, self).setUp()
self.node = obj_utils.create_test_node(
self.context, driver=self.drive... | @mgr_utils.mock_record_keepalive
class RaidTestCases(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
| driver_name = 'fake-hardware'
raid_interface = None
def setUp(self):
super(RaidTestCases, self).setUp()
self.node = obj_utils.create_test_node(
self.context, driver=self.driver_name,
raid_interface=self.raid_interface,
provision_state=states.MANAGEABLE)
... | portgroup.node_id
portgroup.node_id = update_node.id
exc = self.assertRaises(messaging.rpc.ExpectedException,
self.service.update_portgroup,
self.context, portgroup)
self.assertEqual(exception.PortgroupNotEmpty, exc.exc_info[0])
... | 130 | 130 | 434 | 26 | 104 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | RaidTestCases | RaidTestCases | 6,154 | 6,203 | 6,154 | 6,156 | 8d211b3683d7e1bda3cc48a631470cfa6689fb9c | bigcode/the-stack | train |
6eb53e42c710de129228d9bb | train | class | @mgr_utils.mock_record_keepalive
@mock.patch.object(manager.ConductorManager, '_fail_if_in_state')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_offline_conductors')
class ManagerCheckOrphanNodesTestCase(mgr_utils.ServiceSetUpMixin,
... | @mgr_utils.mock_record_keepalive
@mock.patch.object(manager.ConductorManager, '_fail_if_in_state')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_offline_conductors')
class ManagerCheckOrphanNodesTestCase(mgr_utils.ServiceSetUpMixin,
... | def setUp(self):
super(ManagerCheckOrphanNodesTestCase, self).setUp()
self._start_service()
self.node = obj_utils.create_test_node(
self.context, id=1, uuid=uuidutils.generate_uuid(),
driver='fake-hardware', provision_state=states.DEPLOYING,
target_provis... | def test_destroy_portgroup(self):
node = obj_utils.create_test_node(self.context, driver='fake-hardware')
portgroup = obj_utils.create_test_portgroup(self.context,
node_id=node.id)
self.service.destroy_portgroup(self.context, portgroup)
... | 256 | 256 | 1,398 | 79 | 177 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | ManagerCheckOrphanNodesTestCase | ManagerCheckOrphanNodesTestCase | 8,030 | 8,182 | 8,030 | 8,035 | 89629a8e3926de3ffd6cf751ba800ce509a84136 | bigcode/the-stack | train |
f844781d0aa5fd487f6e2a02 | train | class | @mgr_utils.mock_record_keepalive
class CheckTimeoutsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.clean_up')
def test__check_deploy_timeouts(self, mock_cleanup):
self._start_service()
CONF.set_override('deploy_callback_timeout', 1,... | @mgr_utils.mock_record_keepalive
class CheckTimeoutsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.clean_up')
| def test__check_deploy_timeouts(self, mock_cleanup):
self._start_service()
CONF.set_override('deploy_callback_timeout', 1, group='conductor')
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_state=states.DEPLOYWAIT,
target... | self.assertEqual(1, step_index)
def test__get_node_next_deploy_steps_unset_deploy_step(self):
driver_internal_info = {'deploy_steps': self.deploy_steps,
'deploy_step_index': None}
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
... | 246 | 246 | 820 | 45 | 201 | urosorozel/ironic | ironic/tests/unit/conductor/test_manager.py | Python | CheckTimeoutsTestCase | CheckTimeoutsTestCase | 2,682 | 2,760 | 2,682 | 2,684 | b14d584f8c6322b538bd78ed7e1efb3bf6e18f0d | bigcode/the-stack | train |
8a855ec21f03ade990607d6d | train | function | def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('comments')
op.drop_table('users')
| def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
| op.drop_table('comments')
op.drop_table('users')
| sa.Column('author_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
| 63 | 64 | 32 | 18 | 45 | samwel-chege/Pitches | migrations/versions/4a167476d5f7_initial_migration.py | Python | downgrade | downgrade | 40 | 43 | 40 | 41 | 04598b08549e859a97b37807f7721c7e2a3b1529 | bigcode/the-stack | train |
e2bf4c8925d9b487d33c5feb | train | function | def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=255), nullable=True),
sa.Column('email', sa.String(length=255), nullable=True),
sa.Column('bio', sa.String(l... | def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
| op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=255), nullable=True),
sa.Column('email', sa.String(length=255), nullable=True),
sa.Column('bio', sa.String(length=255), nullable=True),
sa.Column('profile_pic_path', sa.String(), nullab... | as sa
# revision identifiers, used by Alembic.
revision = '4a167476d5f7'
down_revision = 'ff406f02b299'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
| 64 | 64 | 193 | 18 | 45 | samwel-chege/Pitches | migrations/versions/4a167476d5f7_initial_migration.py | Python | upgrade | upgrade | 19 | 36 | 19 | 20 | 34df93c20d0e8e70759751cd8b7441daa1ea5701 | bigcode/the-stack | train |
d9771ad9f1559d3835720527 | train | function | def conv3d_transpose(x, kernel, output_shape, strides=(1, 1, 1),
padding='valid', data_format=None):
"""3D deconvolution (i.e. transposed convolution).
# Arguments
x: Tensor or variable.
kernel: kernel tensor.
output_shape: 1D int tensor for the output shape.
... | def conv3d_transpose(x, kernel, output_shape, strides=(1, 1, 1),
padding='valid', data_format=None):
| """3D deconvolution (i.e. transposed convolution).
# Arguments
x: Tensor or variable.
kernel: kernel tensor.
output_shape: 1D int tensor for the output shape.
strides: strides tuple.
padding: string, `"same"` or `"valid"`.
data_format: `"channels_last"` or `"chan... | tuple(shape[1:])
shape = tf.stack(list(shape))
return shape
def _preprocess_padding(padding):
if padding == 'same':
padding = 'SAME'
elif padding == 'valid':
padding = 'VALID'
else:
raise ValueError('Invalid border mode:', padding)
return padding
def conv3d_transpos... | 102 | 102 | 340 | 32 | 69 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | conv3d_transpose | conv3d_transpose | 25 | 60 | 25 | 26 | 29d3d8875234a7f725e70ece96e91d418926a63b | bigcode/the-stack | train |
b906aa8b02550812880ef4df | train | function | def _preprocess_padding(padding):
if padding == 'same':
padding = 'SAME'
elif padding == 'valid':
padding = 'VALID'
else:
raise ValueError('Invalid border mode:', padding)
return padding
| def _preprocess_padding(padding):
| if padding == 'same':
padding = 'SAME'
elif padding == 'valid':
padding = 'VALID'
else:
raise ValueError('Invalid border mode:', padding)
return padding
| 0], shape[2], shape[3], shape[4], shape[1])
if shape[0] is None:
shape = (tf.shape(x)[0], ) + tuple(shape[1:])
shape = tf.stack(list(shape))
return shape
def _preprocess_padding(padding):
| 64 | 64 | 53 | 8 | 55 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | _preprocess_padding | _preprocess_padding | 16 | 23 | 16 | 16 | 100e84eb09691efdddcc680ac893bff2074da89a | bigcode/the-stack | train |
00a1b266043c7cd853079faf | train | function | def _preprocess_deconv3d_output_shape(x, shape, data_format):
if data_format == 'channels_first':
shape = (shape[0], shape[2], shape[3], shape[4], shape[1])
if shape[0] is None:
shape = (tf.shape(x)[0], ) + tuple(shape[1:])
shape = tf.stack(list(shape))
return shape
| def _preprocess_deconv3d_output_shape(x, shape, data_format):
| if data_format == 'channels_first':
shape = (shape[0], shape[2], shape[3], shape[4], shape[1])
if shape[0] is None:
shape = (tf.shape(x)[0], ) + tuple(shape[1:])
shape = tf.stack(list(shape))
return shape
| from keras.layers import Conv3D
from keras.engine import InputSpec
from keras import backend as K
from keras.utils import conv_utils
import tensorflow as tf
def _preprocess_deconv3d_output_shape(x, shape, data_format):
| 51 | 64 | 88 | 17 | 33 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | _preprocess_deconv3d_output_shape | _preprocess_deconv3d_output_shape | 8 | 14 | 8 | 8 | a3876274c65fec30da340f4b6659bbc569bba8e8 | bigcode/the-stack | train |
eb8f05fdbffff99d0aa2ee05 | train | class | class Conv3DTranspose(Conv3D):
"""Transposed convolution layer (sometimes called Deconvolution).
The need for transposed convolutions generally arises
from the desire to use a transformation going in the opposite direction
of a normal convolution, i.e., from something that has the shape of the
outpu... | class Conv3DTranspose(Conv3D):
| """Transposed convolution layer (sometimes called Deconvolution).
The need for transposed convolutions generally arises
from the desire to use a transformation going in the opposite direction
of a normal convolution, i.e., from something that has the shape of the
output of some convolution to someth... | .stack(output_shape)
x = _preprocess_conv3d_input(x, data_format)
output_shape = _preprocess_deconv3d_output_shape(x, output_shape, data_format)
padding = _preprocess_padding(padding)
strides = (1,) + strides + (1,)
x = tf.nn.conv3d_transpose(x, kernel, output_shape, strides,
... | 256 | 256 | 2,013 | 10 | 245 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | Conv3DTranspose | Conv3DTranspose | 77 | 290 | 77 | 77 | 0a7d6874ed490cff0647a1f3fbaac3b640379a2a | bigcode/the-stack | train |
a262aa5ec663d77c58faef4a | train | function | def _preprocess_conv3d_input(x, data_format):
if K.dtype(x) == 'float64':
x = tf.cast(x, 'float32')
if data_format == 'channels_first':
x = tf.transpose(x, (0, 2, 3, 4, 1))
return x
| def _preprocess_conv3d_input(x, data_format):
| if K.dtype(x) == 'float64':
x = tf.cast(x, 'float32')
if data_format == 'channels_first':
x = tf.transpose(x, (0, 2, 3, 4, 1))
return x
| ,) + strides + (1,)
x = tf.nn.conv3d_transpose(x, kernel, output_shape, strides,
padding=padding)
x = _postprocess_conv3d_output(x, data_format)
return x
def _preprocess_conv3d_input(x, data_format):
| 64 | 64 | 70 | 13 | 50 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | _preprocess_conv3d_input | _preprocess_conv3d_input | 62 | 67 | 62 | 62 | 98956485b6748172ec740b0f43c839af0f21eb49 | bigcode/the-stack | train |
46220200436441212894b9cd | train | function | def _postprocess_conv3d_output(x, data_format):
if data_format == 'channels_first':
x = tf.transpose(x, (0, 4, 1, 2, 3))
if K.floatx() == 'float64':
x = tf.cast(x, 'float64')
return x
| def _postprocess_conv3d_output(x, data_format):
| if data_format == 'channels_first':
x = tf.transpose(x, (0, 4, 1, 2, 3))
if K.floatx() == 'float64':
x = tf.cast(x, 'float64')
return x
| == 'float64':
x = tf.cast(x, 'float32')
if data_format == 'channels_first':
x = tf.transpose(x, (0, 2, 3, 4, 1))
return x
def _postprocess_conv3d_output(x, data_format):
| 64 | 64 | 70 | 13 | 50 | bupt-wx/AAAI2019-Image-Colorization_of_dx | RoughColorization/src/conv3dTranspose.py | Python | _postprocess_conv3d_output | _postprocess_conv3d_output | 69 | 75 | 69 | 69 | 866e408cc945a01fd9ac1a8d5c3f96668958104b | bigcode/the-stack | train |
5b4540fa4381db4f68644b74 | train | class | class Equation:
def __init__(self, equationStr):
self.equationStr = equationStr
self.term = parseEquationStr(self.equationStr)
def __repr__(self):
return repr(self.term)
def __str__(self):
return str(self.term)
@property
def lhs(self):
if self.term.args[0].__class__ == Sum:
return self.term.args[0]... | class Equation:
| def __init__(self, equationStr):
self.equationStr = equationStr
self.term = parseEquationStr(self.equationStr)
def __repr__(self):
return repr(self.term)
def __str__(self):
return str(self.term)
@property
def lhs(self):
if self.term.args[0].__class__ == Sum:
return self.term.args[0].args
else:
... | from bellbird.operators import *
from bellbird.variables import *
class Equation:
| 16 | 225 | 750 | 3 | 13 | GustavoExel/bellbird | bellbird/equation.py | Python | Equation | Equation | 4 | 103 | 4 | 4 | 1e3422401893d153ae60b769c82cc5843e64559e | bigcode/the-stack | train |
e6ed7f2838eaa72244714d35 | train | function | def updateDefinitions(term, definedVars):
definedNames = [ var.name for var in definedVars ]
for idx, arg in enumerate(term.args):
if hasSubclass(arg, Variable):
if arg.name in definedNames:
term.args[idx] = definedVars[ definedNames.index(arg.name) ]
if hasSubclass(arg, Operator):
updateDefinitions(ar... | def updateDefinitions(term, definedVars):
| definedNames = [ var.name for var in definedVars ]
for idx, arg in enumerate(term.args):
if hasSubclass(arg, Variable):
if arg.name in definedNames:
term.args[idx] = definedVars[ definedNames.index(arg.name) ]
if hasSubclass(arg, Operator):
updateDefinitions(arg, definedVars)
| .args[idx] = VectorField(arg.name)
# elif arg.__class__ == Variable and arg.name.isnumeric():
# term.args[idx] = Constant(arg.name)
if hasSubclass(arg, Operator):
updateVariables(arg, variableNames)
def updateDefinitions(term, definedVars):
| 63 | 64 | 80 | 8 | 55 | GustavoExel/bellbird | bellbird/equation.py | Python | updateDefinitions | updateDefinitions | 202 | 210 | 202 | 202 | 7287554b2386829565f959c317b2422f486f10d6 | bigcode/the-stack | train |
d134121b89999238a4e83a4b | train | function | def clusterOperations(term, flag=1):
for idx, arg in enumerate(term.args):
# Multiplication(A, Multiplication(B, C)) -> Multiplication(A, B, C)
if hasSubclass(arg, Multiplication):
args = []
for mArg in arg.args:
if hasSubclass(mArg, Multiplication):
args += mArg.args
else:
args.append(mArg... | def clusterOperations(term, flag=1):
| for idx, arg in enumerate(term.args):
# Multiplication(A, Multiplication(B, C)) -> Multiplication(A, B, C)
if hasSubclass(arg, Multiplication):
args = []
for mArg in arg.args:
if hasSubclass(mArg, Multiplication):
args += mArg.args
else:
args.append(mArg)
arg.args = args
# Sum(A, Sum(... | , arg in enumerate(term.args):
if hasSubclass(arg, TimeDerivative) and hasSubclass(arg.arg, Variable):
var = arg.arg
varOld = var.__class__(f"{var.name}_old")
term.args[idx] = Multiplication( Subtraction(var, varOld), overTimeDifferential )
elif hasSubclass(arg, Operator):
integrateInTime(arg)
def app... | 256 | 256 | 1,208 | 9 | 247 | GustavoExel/bellbird | bellbird/equation.py | Python | clusterOperations | clusterOperations | 298 | 409 | 298 | 298 | 20ce4747f402ac687695dbaf397fbd8d6b374a2b | bigcode/the-stack | train |
f6cd615d20f4990be2b78ef5 | train | function | def parseEquationStr(eqString):
# Separate symbols
for symbol in symbols:
eqString = eqString.replace(symbol, f" {symbol} ")
while " " in eqString:
eqString = eqString.replace(" ", " ")
eqString = eqString.replace("d / dt", "d/dt")
eqString = eqString.replace("grad _s", "grad_s")
eqComponentsStr = eqString.... | def parseEquationStr(eqString):
# Separate symbols
| for symbol in symbols:
eqString = eqString.replace(symbol, f" {symbol} ")
while " " in eqString:
eqString = eqString.replace(" ", " ")
eqString = eqString.replace("d / dt", "d/dt")
eqString = eqString.replace("grad _s", "grad_s")
eqComponentsStr = eqString.split()
# Separate parenthesis
while "(" in eqCom... | [ term for term in self.rhs if not containsVariables(term, variables) ]
self.term = Equals(
Sum( *lhsVars, Multiplication(minusOne, Sum(*rhsVars)) ) if rhsVars else Sum(*lhsVars),
Sum( *rhsInds, Multiplication(minusOne, Sum(*lhsInds)) ) if lhsInds else Sum(*rhsInds)
)
self.rearrange()
_order = None
@... | 182 | 182 | 609 | 12 | 170 | GustavoExel/bellbird | bellbird/equation.py | Python | parseEquationStr | parseEquationStr | 108 | 178 | 108 | 109 | 6bbaf1dcfe15467e45935bcba59e558372000916 | bigcode/the-stack | train |
09423a1c78a1c259eec6fa98 | train | function | def getOrder(term):
if hasSubclass(term, Scalar):
return 0
elif hasSubclass(term, Vector):
return 1
elif hasSubclass(term, Matrix):
return 2
elif hasSubclass(term, Tensor):
return 3
elif hasSubclass(term, Function):
if term.__class__ in [TimeDerivative, TimeIntegral, VolumetricIntegral, SurfaceIntegral, ... | def getOrder(term):
| if hasSubclass(term, Scalar):
return 0
elif hasSubclass(term, Vector):
return 1
elif hasSubclass(term, Matrix):
return 2
elif hasSubclass(term, Tensor):
return 3
elif hasSubclass(term, Function):
if term.__class__ in [TimeDerivative, TimeIntegral, VolumetricIntegral, SurfaceIntegral, VolumetricSummation,... | return [term]
fields = []
if hasSubclass(term, Operator):
for arg in term.args:
fields += getTermFields(arg)
return fields
def getTermVars(term):
if hasSubclass(term, Variable):
return [term]
variables = []
if hasSubclass(term, Operator):
for arg in term.args:
variables += getTermVars(arg)
r... | 141 | 141 | 471 | 5 | 135 | GustavoExel/bellbird | bellbird/equation.py | Python | getOrder | getOrder | 453 | 508 | 453 | 453 | c9d0dd8dfbc6396fa54499e05696545e1d45399a | bigcode/the-stack | train |
3be4b0ccc1aac29370a66d98 | train | function | def applyDistributiveProperty(term, flag=0):
for idx, arg in enumerate(term.args):
if hasSubclass(arg, Multiplication):
for sArg in arg.args:
if hasSubclass(sArg, Sum) or hasSubclass(sArg, Subtraction):
plus_func = sArg.__class__
args = [ mArg for mArg in arg.args if not mArg == sArg ]
term.ar... | def applyDistributiveProperty(term, flag=0):
| for idx, arg in enumerate(term.args):
if hasSubclass(arg, Multiplication):
for sArg in arg.args:
if hasSubclass(sArg, Sum) or hasSubclass(sArg, Subtraction):
plus_func = sArg.__class__
args = [ mArg for mArg in arg.args if not mArg == sArg ]
term.args[idx] = plus_func(*[Multiplication(*args, s... | varOld = var.__class__(f"{var.name}_old")
term.args[idx] = Multiplication( Subtraction(var, varOld), overTimeDifferential )
elif hasSubclass(arg, Operator):
integrateInTime(arg)
def applyDistributiveProperty(term, flag=0):
| 64 | 64 | 164 | 12 | 52 | GustavoExel/bellbird | bellbird/equation.py | Python | applyDistributiveProperty | applyDistributiveProperty | 279 | 296 | 279 | 279 | c944e80e10b4259e59f1dea87030eabb516e1ce6 | bigcode/the-stack | train |
9f15ee86bc5d1de2a7070960 | train | function | def containsVariables(term, variables):
if hasSubclass(term, Variable):
return term.name in variables + [varName.replace("_x", "") for varName in variables if "_x" in varName]
elif hasSubclass(term, Operator):
for arg in term.args:
if containsVariables(arg, variables):
return True
return False
| def containsVariables(term, variables):
| if hasSubclass(term, Variable):
return term.name in variables + [varName.replace("_x", "") for varName in variables if "_x" in varName]
elif hasSubclass(term, Operator):
for arg in term.args:
if containsVariables(arg, variables):
return True
return False
| .args.remove(sTerm)
# arg.args.append( Multiplication(Sum(*sharingTerms), var) )
if hasSubclass(arg, Operator):
clusterOperations(arg, flag+1)
if flag > 0:
clusterOperations(term, flag-1)
def containsVariables(term, variables):
| 63 | 64 | 72 | 7 | 56 | GustavoExel/bellbird | bellbird/equation.py | Python | containsVariables | containsVariables | 411 | 420 | 411 | 411 | 9d0723e7f86d4fa44cf05d2488e731311de86760 | bigcode/the-stack | train |
a0c1f50ad0c3a5a9f95fdba3 | train | function | def applyDivergenceTheorem(term):
for idx, arg in enumerate(term.args):
if arg.__class__ == VolumetricIntegral and arg.arg.__class__ == Divergence:
divArg = arg.arg.arg
term.args[idx] = SurfaceIntegral(divArg)
elif hasSubclass(arg, BinaryOperator):
applyDivergenceTheorem(arg)
| def applyDivergenceTheorem(term):
| for idx, arg in enumerate(term.args):
if arg.__class__ == VolumetricIntegral and arg.arg.__class__ == Divergence:
divArg = arg.arg.arg
term.args[idx] = SurfaceIntegral(divArg)
elif hasSubclass(arg, BinaryOperator):
applyDivergenceTheorem(arg)
| (Multiplication(*constants, *mArg.args)))
elif constants and not variables:
term.args[idx] = function(Multiplication(*constants, *mArg.args))
break
if hasSubclass(arg, Operator):
unapplyLinearProperty(arg)
def applyDivergenceTheorem(term):
| 64 | 64 | 78 | 9 | 55 | GustavoExel/bellbird | bellbird/equation.py | Python | applyDivergenceTheorem | applyDivergenceTheorem | 260 | 267 | 260 | 260 | a474b07b578b63f0f7a2c8ab457348906ec41b46 | bigcode/the-stack | train |
82b4d7def3a639f02c385263 | train | function | def getTermFields(term):
if hasSubclass(term, Field):
return [term]
fields = []
if hasSubclass(term, Operator):
for arg in term.args:
fields += getTermFields(arg)
return fields
| def getTermFields(term):
| if hasSubclass(term, Field):
return [term]
fields = []
if hasSubclass(term, Operator):
for arg in term.args:
fields += getTermFields(arg)
return fields
| return term.name in variables + [varName.replace("_x", "") for varName in variables if "_x" in varName]
elif hasSubclass(term, Operator):
for arg in term.args:
if containsVariables(arg, variables):
return True
return False
def getTermFields(term):
| 64 | 64 | 47 | 6 | 57 | GustavoExel/bellbird | bellbird/equation.py | Python | getTermFields | getTermFields | 422 | 431 | 422 | 422 | 07afcccf3d7d02411d05cac8c5afe3f1153875e7 | bigcode/the-stack | train |
cf50c5f191a2b5ac45d5d961 | train | function | def updatePropertyVars(term, propertyVars):
for idx, arg in enumerate(term.args):
if hasSubclass(arg, Variable):
if arg.name in propertyVars:
term.args[idx] = Constant(arg.name)
if hasSubclass(arg, Operator):
updatePropertyVars(arg, propertyVars)
| def updatePropertyVars(term, propertyVars):
| for idx, arg in enumerate(term.args):
if hasSubclass(arg, Variable):
if arg.name in propertyVars:
term.args[idx] = Constant(arg.name)
if hasSubclass(arg, Operator):
updatePropertyVars(arg, propertyVars)
| = eqComponents.index(operator)
args = [ eqComponents[idx-1], eqComponents[idx+1] ]
operator.setArgs(args)
eqComponents.pop( idx+1 )
eqComponents.pop( idx-1 )
return eqComponents[0]
def updatePropertyVars(term, propertyVars):
| 64 | 64 | 62 | 9 | 55 | GustavoExel/bellbird | bellbird/equation.py | Python | updatePropertyVars | updatePropertyVars | 180 | 187 | 180 | 180 | 96a0fcdbcd74f3e4cc71a515df00e107228a56fa | bigcode/the-stack | train |
db416d426d8152da16b5f7a0 | train | function | def hasTermWithSubclass(term, subclass):
if hasSubclass(term, subclass):
return True
elif hasSubclass(term, Operator):
for arg in term.args:
if hasTermWithSubclass(arg, subclass):
return True
return False
| def hasTermWithSubclass(term, subclass):
| if hasSubclass(term, subclass):
return True
elif hasSubclass(term, Operator):
for arg in term.args:
if hasTermWithSubclass(arg, subclass):
return True
return False
| )
return fields
def getTermVars(term):
if hasSubclass(term, Variable):
return [term]
variables = []
if hasSubclass(term, Operator):
for arg in term.args:
variables += getTermVars(arg)
return variables
def hasTermWithSubclass(term, subclass):
| 64 | 64 | 51 | 9 | 54 | GustavoExel/bellbird | bellbird/equation.py | Python | hasTermWithSubclass | hasTermWithSubclass | 444 | 451 | 444 | 444 | 884e064d7014229ac9e05b8814c02c2bc7a0d62b | bigcode/the-stack | train |
c8c4a36a364ac0ffbe8eb9c9 | train | function | def integrateInTime(term):
for idx, arg in enumerate(term.args):
if hasSubclass(arg, TimeDerivative) and hasSubclass(arg.arg, Variable):
var = arg.arg
varOld = var.__class__(f"{var.name}_old")
term.args[idx] = Multiplication( Subtraction(var, varOld), overTimeDifferential )
elif hasSubclass(arg, Operator... | def integrateInTime(term):
| for idx, arg in enumerate(term.args):
if hasSubclass(arg, TimeDerivative) and hasSubclass(arg.arg, Variable):
var = arg.arg
varOld = var.__class__(f"{var.name}_old")
term.args[idx] = Multiplication( Subtraction(var, varOld), overTimeDifferential )
elif hasSubclass(arg, Operator):
integrateInTime(arg)
| arg.__class__ == VolumetricIntegral and arg.arg.__class__ == Divergence:
divArg = arg.arg.arg
term.args[idx] = SurfaceIntegral(divArg)
elif hasSubclass(arg, BinaryOperator):
applyDivergenceTheorem(arg)
def integrateInTime(term):
| 64 | 64 | 91 | 6 | 58 | GustavoExel/bellbird | bellbird/equation.py | Python | integrateInTime | integrateInTime | 269 | 277 | 269 | 269 | 8d44e730cff59785e3d53b944c971bc0633f275d | bigcode/the-stack | train |
e15cbca544b6cdbbb571fdc7 | train | function | def applyLinearProperty(term, flag=1):
# f(a * X) = a * f(X)
for idx, arg in enumerate(term.args):
function = arg.__class__
if hasSubclass(arg, Function) and arg.linear:
if hasSubclass(arg.arg, Multiplication):
constants = [ mArg for mArg in arg.arg.args if hasSubclass(mArg, Constant) ]
variables = [ m... | def applyLinearProperty(term, flag=1):
# f(a * X) = a * f(X)
| for idx, arg in enumerate(term.args):
function = arg.__class__
if hasSubclass(arg, Function) and arg.linear:
if hasSubclass(arg.arg, Multiplication):
constants = [ mArg for mArg in arg.arg.args if hasSubclass(mArg, Constant) ]
variables = [ mArg for mArg in arg.arg.args if not hasSubclass(mArg, Constant... | ):
definedNames = [ var.name for var in definedVars ]
for idx, arg in enumerate(term.args):
if hasSubclass(arg, Variable):
if arg.name in definedNames:
term.args[idx] = definedVars[ definedNames.index(arg.name) ]
if hasSubclass(arg, Operator):
updateDefinitions(arg, definedVars)
def applyLinearProperty... | 95 | 96 | 320 | 23 | 72 | GustavoExel/bellbird | bellbird/equation.py | Python | applyLinearProperty | applyLinearProperty | 212 | 239 | 212 | 213 | e8d4d5c11085fbf38aa1747bad235ef1c2ce7935 | bigcode/the-stack | train |
97ba818fe6497645a660ff4b | train | function | def isTransient(term):
if hasSubclass(term, TimeDerivative):
return True
elif hasSubclass(term, Operator):
for arg in term.args:
if isTransient(arg):
return True
return False | def isTransient(term):
| if hasSubclass(term, TimeDerivative):
return True
elif hasSubclass(term, Operator):
for arg in term.args:
if isTransient(arg):
return True
return False | Product:
# May need revision
return getOrder(term.args[0])
if term.__class__ == Variable:
raise Exception(f"Variable {term} was not declared as a property")
else:
raise Exception(f"Could not find order of the term {term}")
def isTransient(term):
| 64 | 64 | 43 | 5 | 59 | GustavoExel/bellbird | bellbird/equation.py | Python | isTransient | isTransient | 510 | 519 | 510 | 510 | 938bd194c1063587fec8f115ff6446e9915c0f42 | bigcode/the-stack | train |
365fadb1b67e9278411bf4c1 | train | function | def getTermVars(term):
if hasSubclass(term, Variable):
return [term]
variables = []
if hasSubclass(term, Operator):
for arg in term.args:
variables += getTermVars(arg)
return variables
| def getTermVars(term):
| if hasSubclass(term, Variable):
return [term]
variables = []
if hasSubclass(term, Operator):
for arg in term.args:
variables += getTermVars(arg)
return variables
| , variables):
return True
return False
def getTermFields(term):
if hasSubclass(term, Field):
return [term]
fields = []
if hasSubclass(term, Operator):
for arg in term.args:
fields += getTermFields(arg)
return fields
def getTermVars(term):
| 64 | 64 | 51 | 6 | 57 | GustavoExel/bellbird | bellbird/equation.py | Python | getTermVars | getTermVars | 433 | 442 | 433 | 433 | 8130cc11f1dd8cc4670abc2b46d3fbbae1e5703b | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.