MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: OxfordHED+sunbear
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _test_grad2_nd(n, ndim):
    coords = [np.arange(n)] * ndim
    xc = np.meshgrid(*coords, indexing="ij")

    # u = sum_i(xc[i]**2)
    u = reduce(lambda x,y: x+y**2, xc, 0.0)
    ucopy = np.copy(u)

    # check the gradient values
    gu = np.zeros(tuple([n-2]*ndim))
    gu2 = gu + 2.0
    for i in range(ndim):
        for j in range(ndim):
            if i == j:
                assert grad2(u, axes=(i,j)) == pytest.approx(gu2)
            else:
                assert grad2(u, axes=(i,j)) == pytest.approx(gu)

    # check if u is unchanged
    assert np.all(u == ucopy)

_test_grad2_nd(n=32, ndim=1)

Selected Statement: coords = [np.arange(n)] * ndim

Function Input:
n: 32
ndim: 1

Variable Values Before Statement:
ndim: 1

Value After Statement Execution: [array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])]

Variable States During Runtime (line, value):
n: 1
32
ndim: 1
1
coords: 2
[array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])]
xc: 3
[array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])]
u: 6
array([  0.,   1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.,       121., 144., 169., 196., 225., 256., 289., 324., 361., 400., 441.,       484., 529., 576., 625., 676., 729., 784., 841., 900., 961.])
ucopy: 7
array([  0.,   1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.,       121., 144., 169., 196., 225., 256., 289., 324., 361., 400., 441.,       484., 529., 576., 625., 676., 729., 784., 841., 900., 961.])
gu: 10
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
gu2: 11
array([2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,       2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.])
i: 12
0
j: 13
0
@py_assert2: 15
None
@py_assert4: 15
None
@py_assert8: 15
None
@py_assert11: 15
None
@py_assert6: 15
None
@py_assert1: 20
None
Project Name: OxfordHED+sunbear
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def det_hess(u):
    """
    Get the determinant of the Hessian matrix of `u`.

    Parameters
    ----------
    * `u` : numpy.ndarray
        The ndarray input with shape (n0+2, n1+2, ..., nd1+2).

    Returns
    -------
    * numpy.ndarray
        The ndarray of the second grad of `u` with shape (n0, n1, ..., nd1).
    """
    ndim = np.ndim(u)
    inshape = np.asarray(u.shape)
    outshape = list(inshape - 2)

    # obtain the second gradient per each pairs of axes
    hess_unarranged = np.zeros([ndim, ndim] + outshape)
    for i in range(ndim):
        for j in range(i,ndim):
            grad2_val = grad2(u, (i,j))
            hess_unarranged[i,j] = grad2_val
            hess_unarranged[j,i] = grad2_val

    # rearrange hessian to have shape: outshape + [ndim, ndim]
    perm_idx = list(range(2,ndim+2)) + list(range(2))
    hess = np.transpose(hess_unarranged, perm_idx)

    # calculate and return the determinant
    return np.linalg.det(hess)

det_hess(u=array([  0.,   1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.,       121., 144., 169., 196., 225., 256., 289., 324., 361., 400., 441.,       484., 529., 576., 625., 676., 729., 784., 841., 900., 961.]))

Selected Statement: perm_idx = list(range(2,ndim+2)) + list(range(2))

Function Input:
u: array([  0.,   1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.,       121., 144., 169., 196., 225., 256., 289., 324., 361., 400., 441.,       484., 529., 576., 625., 676., 729., 784., 841., 900., 961.])

Variable Values Before Statement:

Value After Statement Execution: [2, 0, 1]

Variable States During Runtime (line, value):
u: 1
array([  0.,   1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.,       121., 144., 169., 196., 225., 256., 289., 324., 361., 400., 441.,       484., 529., 576., 625., 676., 729., 784., 841., 900., 961.])
ndim: 15
1
inshape: 16
array([32])
outshape: 17
[30]
hess_unarranged: 20
array([[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]])
24
array([[[2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,         2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.]]])
i: 21
0
j: 22
0
grad2_val: 23
array([2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,       2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.])
perm_idx: 28
[2, 0, 1]
hess: 29
array([[[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]],       [[2.]]])
Project Name: OxfordHED+sunbear
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _get_default_expanded_coordinate(shape, ndim):
    x_coords = []
    for i in range(ndim):
        idx = [None] * ndim
        idx[i] = slice(None, None, None)
        x_coords.append(np.arange(shape[i])[tuple(idx)])
    return x_coords

_get_default_expanded_coordinate(shape=array([102]), ndim=1)

Selected Statement: idx = [None] * ndim

Function Input:
shape: array([102])
ndim: 1

Variable Values Before Statement:
ndim: 1

Value After Statement Execution: [None]

Variable States During Runtime (line, value):
shape: 1
array([102])
ndim: 1
1
x_coords: 2
6
[array([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,        13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,        26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,        39,  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51,        52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,  64,        65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,        78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,        91,  92,  93,  94,  95,  96,  97,  98,  99, 100, 101])]
i: 3
0
idx: 4
[None]
5
[slice(None, None, None)]
Project Name: OxfordHED+sunbear
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _get_idx(ndim, dim, s, defidx=None):
    defidx = slice(None, None, None) if defidx is None else defidx
    idx = [defidx] * ndim
    idx[dim] = s
    return tuple(idx)

_get_idx(ndim=1, dim=0, s=slice(1, 2, None), defidx=None)

Selected Statement: idx = [defidx] * ndim

Function Input:
ndim: 1
dim: 0
s: slice(1, 2, None)
defidx: None

Variable Values Before Statement:
ndim: 1

Value After Statement Execution: [slice(None, None, None)]

Variable States During Runtime (line, value):
ndim: 1
1
dim: 1
0
s: 1
slice(1, 2, None)
defidx: 1
None
2
slice(None, None, None)
idx: 3
[slice(None, None, None)]
4
[slice(1, 2, None)]
Project Name: activeloopai+deeplake
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def parse_access_method(access_method: str):
    num_workers = 0
    scheduler = "threaded"
    download = access_method.startswith("download")
    local = access_method.startswith("local")
    if download or local:
        split = access_method.split(":")
        if len(split) == 1:
            split.extend(("threaded", "0"))
        elif len(split) == 2:
            split.append("threaded" if split[1].isnumeric() else "0")
        elif len(split) >= 3:
            num_integers = sum(1 for i in split if i.isnumeric())
            if num_integers != 1 or len(split) > 3:
                raise ValueError(
                    "Invalid access_method format. Expected format is one of the following: {download, download:scheduler, download:num_workers, download:scheduler:num_workers, download:num_workers:scheduler}"
                )

        access_method = "download" if download else "local"
        num_worker_index = 1 if split[1].isnumeric() else 2
        scheduler_index = 3 - num_worker_index
        num_workers = int(split[num_worker_index])
        scheduler = split[scheduler_index]
    return access_method, num_workers, scheduler

parse_access_method(access_method='download')

Selected Statement: scheduler_index = 3 - num_worker_index

Function Input:
access_method: 'download'

Variable Values Before Statement:
num_worker_index: 2

Value After Statement Execution: 1

Variable States During Runtime (line, value):
access_method: 1
'download'
num_workers: 2
0
scheduler: 3
'threaded'
download: 4
True
local: 5
False
split: 7
download
9
download, threaded, 0
num_worker_index: 20
2
scheduler_index: 21
1
Project Name: activeloopai+deeplake
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def serialize_chunkids(version: str, arr: np.ndarray) -> memoryview:
    """Serializes chunk ID encoders into a single byte stream. This is how the encoders will be written to the storage provider.

    Args:
        version: (str) Version of deeplake library.
        arr: (np.ndarray) Encoded chunk ids from a `ChunkIdEncoder` instance.

    Returns:
        Serialized chunk ids as memoryview.
    """
    len_version = len(version)
    write_dtype = version_compare(version, "2.7.6") >= 0
    flatbuff = bytearray(1 + int(write_dtype) + len_version + arr.nbytes)

    # Write version
    len_version = len(version)
    flatbuff[0] = len_version
    flatbuff[1 : 1 + len_version] = version.encode("ascii")
    offset = 1 + len_version

    # write encoder dtype
    if write_dtype:
        dtype = arr.dtype
        num_bytes = int(dtype.itemsize)
        flatbuff[offset] = num_bytes
        offset += 1

    # Write ids
    flatbuff[offset : offset + arr.nbytes] = arr.tobytes()
    offset += arr.nbytes
    return memoryview(flatbuff)

serialize_chunkids(version='3.8.18', arr=array([], shape=(0, 2), dtype=uint64))

Selected Statement: offset = 1 + len_version

Function Input:
version: '3.8.18'
arr: array([], shape=(0, 2), dtype=uint64)

Variable Values Before Statement:
len_version: 6

Value After Statement Execution: 7

Variable States During Runtime (line, value):
version: 1
'3.8.18'
arr: 1
array([], shape=(0, 2), dtype=uint64)
len_version: 11
6
write_dtype: 12
True
flatbuff: 13
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
17
bytearray(b'\x06\x00\x00\x00\x00\x00\x00\x00')
18
bytearray(b'\x063.8.18\x00')
25
bytearray(b'\x063.8.18\x08')
offset: 19
7
26
8
dtype: 23
dtype('uint64')
num_bytes: 24
8
Project Name: zauberzeug+nicegui
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def glob_absolute_paths(file: Union[str, Path]) -> List[Path]:
            path = Path(file)
            if not path.is_absolute():
                path = base / path
            return sorted(path.parent.glob(path.name), key=lambda p: p.stem)

glob_absolute_paths(file='aggrid.js', base=PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements'))

Selected Statement: path = base / path

Function Input:
file: 'aggrid.js'
base: PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements')

Variable Values Before Statement:
base: PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements')
path: PosixPath('aggrid.js')

Value After Statement Execution: PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements/aggrid.js')

Variable States During Runtime (line, value):
file: 1
'aggrid.js'
base: 1
PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements')
path: 2
PosixPath('aggrid.js')
4
PosixPath('/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/zauberzeug+nicegui/zauberzeug+nicegui/nicegui/elements/aggrid.js')
Project Name: sensepost+objection
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def ios_screenshot(args: list = None) -> None:
    """
        Take an iOS screenshot.

        :param args:
        :return:
    """

    if len(args) <= 0:
        click.secho('Usage: ios ui screenshot <local png destination>', bold=True)
        return

    destination = args[0]

    if not destination.endswith('.png'):
        destination = destination + '.png'

    api = state_connection.get_api()
    png = api.ios_ui_screenshot()

    with open(destination, 'wb') as f:
        f.write(png)

    click.secho('Screenshot saved to: {0}'.format(destination), fg='green')

ios_screenshot(args=['foo'])

Selected Statement: destination = destination + '.png'

Function Input:
args: foo

Variable Values Before Statement:
destination: 'foo'

Value After Statement Execution: 'foo.png'

Variable States During Runtime (line, value):
args: 1
foo
destination: 13
'foo'
16
'foo.png'
api: 18
<MagicMock name='get_api()' id='140041828273504'>
png: 19
b'\x00'
f: 21
<MagicMock name='open().__enter__()' id='140041828431664'>
Project Name: darknessomi+musicbox
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def aes(text, key):
    pad = 16 - len(text) % 16
    text = text + bytearray([pad] * pad)
    encryptor = AES.new(key, 2, b"0102030405060708")
    ciphertext = encryptor.encrypt(text)
    return base64.b64encode(ciphertext)

aes(text=b'{"ids": [347230, 496619464, 405998841, 28012031], "br": 320000, "csrf_token": ""}', key=b'0CoJUm6Qyw8W8jud')

Selected Statement: pad = 16 - len(text) % 16

Function Input:
text: b'{"ids": [347230, 496619464, 405998841, 28012031], "br": 320000, "csrf_token": ""}'
key: b'0CoJUm6Qyw8W8jud'

Variable Values Before Statement:

Value After Statement Execution: 15

Variable States During Runtime (line, value):
text: 1
b'{"ids": [347230, 496619464, 405998841, 28012031], "br": 320000, "csrf_token": ""}'
3
b'{"ids": [347230, 496619464, 405998841, 28012031], "br": 320000, "csrf_token": ""}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f'
key: 1
b'0CoJUm6Qyw8W8jud'
pad: 2
15
encryptor: 4
{_state=<Cryptodome.Util._raw_api.SmartPointer object at 0x7f925764db80>, block_size=16, iv=b'0102030405060708', IV=b'0102030405060708', _next=[<bound method CbcMode.encrypt of <Cryptodome.Cipher._mode_cbc.CbcMode object at 0x7f925764dd60>>, <bound method CbcMode.decrypt of <Cryptodome.Cipher._mode_cbc.CbcMode object at 0x7f925764dd60>>]}
5
{_state=<Cryptodome.Util._raw_api.SmartPointer object at 0x7f925764db80>, block_size=16, iv=b'0102030405060708', IV=b'0102030405060708', _next=[<bound method CbcMode.encrypt of <Cryptodome.Cipher._mode_cbc.CbcMode object at 0x7f925764dd60>>]}
ciphertext: 5
b'}8(\n\x91;\xe9\xca\x03\x0b+\xc3\xb6\xb5\xef\xc2\x06\x0e\xae?i\xd3\x1d\xd2b\x9d\x1c\xea\x80\xf9v\x1c\xac{\x06\xa2YS*\xfd\xbc\xf6*\x8fZS\x12\xec\xe8yZ\x06\x19d\x96\xb6E`\x11G\x01V\xcf\xa7\xcf\xbd\x90{VxT\xe3\x1c\xc4!\x96,p3\xffK\xc7g\x17\xfc\x0c\x11\xdf\\\xff\xa8\x84,\x85j\x12'
Project Name: Lightning-AI+lit-gpt
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def test_generate(monkeypatch, generated, stop_tokens, expected):
    import chat.base as chat
    import generate.base as generate

    input_idx = torch.tensor([5, 3])
    max_returned_tokens = len(input_idx) + 8
    model = MagicMock()
    model.config.block_size = 100
    model.max_seq_length = 100
    it = iter(generated)

    def multinomial(*_, **__):
        out = next(it)
        return torch.tensor([out])

    monkeypatch.setattr(generate, "multinomial_num_samples_1", multinomial)
    actual = chat.generate(model, input_idx, max_returned_tokens, stop_tokens=stop_tokens)
    actual = list(actual)

    assert len(actual) == len(expected)
    if not actual:
        assert actual == expected
    else:
        for t in actual:
            assert t.dtype == torch.long
        assert torch.cat(actual).tolist() == expected

test_generate(monkeypatch={_setattr=[], _setitem=[], _cwd=None, _savesyspath=None}, generated=repeat(1), stop_tokens=(), expected=[1, 1, 1, 1, 1, 1, 1, 1])

Selected Statement: max_returned_tokens = len(input_idx) + 8

Function Input:
monkeypatch: {_setattr=[], _setitem=[], _cwd=None, _savesyspath=None}
generated: repeat(1)
stop_tokens: ()
expected: [1, 1, 1, 1, 1, 1, 1, 1]

Variable Values Before Statement:

Value After Statement Execution: 10

Variable States During Runtime (line, value):
monkeypatch: 1
{_setattr=[], _setitem=[], _cwd=None, _savesyspath=None}
16
{_setattr=[(<module 'generate.base' from '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/Lightning-AI+lit-gpt/Lightning-AI+lit-gpt/generate/base.py'>, 'multinomial_num_samples_1', <function multinomial_num_samples_1 at 0x7f805238a160>)], _setitem=[], _cwd=None, _savesyspath=None}
generated: 1
repeat(1)
stop_tokens: 1
()
expected: 1
[1, 1, 1, 1, 1, 1, 1, 1]
chat: 2
<module 'chat.base' from '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/Lightning-AI+lit-gpt/Lightning-AI+lit-gpt/chat/base.py'>
generate: 3
<module 'generate.base' from '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/Lightning-AI+lit-gpt/Lightning-AI+lit-gpt/generate/base.py'>
input_idx: 5
tensor([5, 3])
max_returned_tokens: 6
10
model: 7
<MagicMock id='140188337253248'>
it: 10
repeat(1)
multinomial: 12
<function test_generate.<locals>.multinomial at 0x7f7fd0f7e430>
actual: 17
<generator object generate at 0x7f803c55ff90>
18
[tensor([1]), tensor([1]), tensor([1]), tensor([1]), tensor([1]), tensor([1]), tensor([1]), tensor([1])]
@py_assert2: 20
None
@py_assert7: 20
None
@py_assert4: 20
None
t: 24
tensor([1])
@py_assert1: 25
None
@py_assert5: 25
None
@py_assert3: 25
None
@py_assert6: 26
None
@py_assert8: 26
None
@py_assert10: 26
None
Project Name: burnash+gspread
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def rowcol_to_a1(row, col):
    """Translates a row and column cell address to A1 notation.

    :param row: The row of the cell to be converted.
        Rows start at index 1.
    :type row: int, str

    :param col: The column of the cell to be converted.
        Columns start at index 1.
    :type row: int, str

    :returns: a string containing the cell's coordinates in A1 notation.

    Example:

    >>> rowcol_to_a1(1, 1)
    A1

    """
    row = int(row)
    col = int(col)

    if row < 1 or col < 1:
        raise IncorrectCellLabel("({}, {})".format(row, col))

    div = col
    column_label = ""

    while div:
        (div, mod) = divmod(div, 26)
        if mod == 0:
            mod = 26
            div -= 1
        column_label = chr(mod + MAGIC_NUMBER) + column_label

    label = "{}{}".format(column_label, row)

    return label

rowcol_to_a1(row=4, col=4)

Selected Statement: column_label = chr(mod + MAGIC_NUMBER) + column_label

Function Input:
row: 4
col: 4

Variable Values Before Statement:
column_label: ''

Value After Statement Execution: 'D'

Variable States During Runtime (line, value):
row: 1
4
col: 1
4
div: 26
4
30
0
column_label: 27
''
34
'D'
mod: 30
4
label: 36
'D4'
Project Name: burnash+gspread
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def fill_gaps(L, rows=None, cols=None, padding_value=""):
    """Fill gaps in a list of lists.
    e.g.,::

        >>> L = [
        ... [1, 2, 3],
        ... ]
        >>> fill_gaps(L, 2, 4)
        [
            [1, 2, 3, ""],
            ["", "", "", ""]
        ]

    :param L: List of lists to fill gaps in.
    :param rows: Number of rows to fill.
    :param cols: Number of columns to fill.
    :param padding_value: Default value to fill gaps with.

    :type L: list[list[T]]
    :type rows: int
    :type cols: int
    :type padding_value: T

    :return: List of lists with gaps filled.
    :rtype: list[list[T]]:
    """
    try:
        max_cols = max(len(row) for row in L) if cols is None else cols
        max_rows = len(L) if rows is None else rows

        pad_rows = max_rows - len(L)

        if pad_rows:
            L = L + ([[]] * pad_rows)

        return [rightpad(row, max_cols, padding_value=padding_value) for row in L]
    except ValueError:
        return []

fill_gaps(L=[['', 'Dummy']], rows=None, cols=None, padding_value='')

Selected Statement: pad_rows = max_rows - len(L)

Function Input:
L: [['', 'Dummy']]
rows: None
cols: None
padding_value: ''

Variable Values Before Statement:
max_rows: 1

Value After Statement Execution: 0

Variable States During Runtime (line, value):
L: 1
[['', 'Dummy']]
rows: 1
None
cols: 1
None
padding_value: 1
''
max_cols: 28
2
max_rows: 29
1
pad_rows: 31
0
Project Name: berkeleylab+als.milo
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def render_pep440_feature(pieces):
    """Build up version string, used within "feature" branch of repository.

    Our goal: MERGE-POINT.post.devN+gHEX.BRANCH-NAME.M[.dirty]
        +) MERGE-POINT = Most recent common ancestor for `develop` and `master`
          *) Does not yet handle branch from `release-*`
        +) N = DISTANCE from the MERGE-POINT of `develop` and `master`
        +) M = DISTANCE from the MERGE-POINT of "feature" and `develop`

    Exceptions:
    1: no tags. 0.post.devDISTANCE+gHEX[.dirty]
    """
    if pieces["closest-tag"] and pieces["develop"]:
        rendered = pieces["closest-tag"]
        distance_to_develop = pieces["distance-to-develop"]
        distance_to_merge = pieces["distance-to-master"]
        distance_merge_to_tag = (pieces["distance"] - distance_to_merge)
        distance_dev_to_merge = (distance_to_merge - distance_to_develop)
        if (distance_merge_to_tag > 0):
            rendered += ".%d" % distance_merge_to_tag
        rendered += ".post.dev%d" % distance_dev_to_merge
        rendered += plus_or_dot(pieces)
        rendered += "g%s" % pieces["short"]
        rendered += ".%s" % pieces["branch"]
        rendered += ".%d" % distance_to_develop
    else:
        # exception #1
        rendered = "0.post.dev%d" % (pieces["distance"] - 1)
        rendered += plus_or_dot(pieces)
        rendered += "g%s" % pieces["short"]
    if pieces["dirty"]:
        rendered += ".dirty"
    return rendered

render_pep440_feature(pieces={'long': 'e60d005d389cb31b6e99f937e35adbe3fccb7aaf', 'short': 'e60d005', 'error': None, 'dirty': False, 'closest-tag': '0.8', 'distance': 3, 'branch': 'HEAD', 'distance-to-master': 0, 'develop': None, 'distance-to-develop': None, 'date': '2018-05-05T22:17:58-0700', 'authors': ['Padraic Shafer']})

Selected Statement: rendered = "0.post.dev%d" % (pieces["distance"] - 1)

Function Input:
pieces: {'long': 'e60d005d389cb31b6e99f937e35adbe3fccb7aaf', 'short': 'e60d005', 'error': None, 'dirty': False, 'closest-tag': '0.8', 'distance': 3, 'branch': 'HEAD', 'distance-to-master': 0, 'develop': None, 'distance-to-develop': None, 'date': '2018-05-05T22:17:58-0700', 'authors': ['Padraic Shafer']}

Variable Values Before Statement:

Value After Statement Execution: '0.post.dev2'

Variable States During Runtime (line, value):
pieces: 1
{'long': 'e60d005d389cb31b6e99f937e35adbe3fccb7aaf', 'short': 'e60d005', 'error': None, 'dirty': False, 'closest-tag': '0.8', 'distance': 3, 'branch': 'HEAD', 'distance-to-master': 0, 'develop': None, 'distance-to-develop': None, 'date': '2018-05-05T22:17:58-0700', 'authors': ['Padraic Shafer']}
rendered: 28
'0.post.dev2'
29
'0.post.dev2+'
30
'0.post.dev2+ge60d005'
Project Name: Cjkkkk+Pyflow
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def compute_loc(idx, shape):
    loc = [0] * len(shape)
    for i in range(len(shape)):
        prod = int(np.prod(shape[i + 1:]))
        loc[i] = idx // prod
        idx = idx % prod
    return tuple(loc)

compute_loc(idx=0, shape=(2, 4))

Selected Statement: loc = [0] * len(shape)

Function Input:
idx: 0
shape: (2, 4)

Variable Values Before Statement:

Value After Statement Execution: [0, 0]

Variable States During Runtime (line, value):
idx: 1
0
shape: 1
(2, 4)
loc: 2
[0, 0]
i: 3
0
3
1
prod: 4
4
4
1