MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: facebookresearch+detectron2
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def create_dummy_class(klass, dependency, message=""):
    """
    When a dependency of a class is not available, create a dummy class which throws ImportError
    when used.

    Args:
        klass (str): name of the class.
        dependency (str): name of the dependency.
        message: extra message to print
    Returns:
        class: a class object
    """
    err = "Cannot import '{}', therefore '{}' is not available.".format(dependency, klass)
    if message:
        err = err + " " + message

    class _DummyMetaClass(type):
        # throw error on class attribute access
        def __getattr__(_, __):  # noqa: B902
            raise ImportError(err)

    class _Dummy(object, metaclass=_DummyMetaClass):
        # throw error on constructor
        def __init__(self, *args, **kwargs):
            raise ImportError(err)

    return _Dummy

create_dummy_class(klass='DeformConv', dependency='detectron2._C', message='detectron2 is not compiled successfully, please build following the instructions!')

Selected Statement: err = err + " " + message

Function Input:
klass: 'DeformConv'
dependency: 'detectron2._C'
message: 'detectron2 is not compiled successfully, please build following the instructions!'

Variable Values Before Statement:
message: 'detectron2 is not compiled successfully, please build following the instructions!'

Value After Statement Execution: "Cannot import 'detectron2._C', therefore 'DeformConv' is not available. detectron2 is not compiled successfully, please build following the instructions!"

Variable States During Runtime (line, value):
klass: 1
'DeformConv'
dependency: 1
'detectron2._C'
message: 1
'detectron2 is not compiled successfully, please build following the instructions!'
err: 13
"Cannot import 'detectron2._C', therefore 'DeformConv' is not available."
15
"Cannot import 'detectron2._C', therefore 'DeformConv' is not available. detectron2 is not compiled successfully, please build following the instructions!"
_DummyMetaClass: 17
<class 'detectron2.utils.develop.create_dummy_class.<locals>._DummyMetaClass'>
_Dummy: 22
<class 'detectron2.utils.develop.create_dummy_class.<locals>._Dummy'>
Project Name: facebookresearch+detectron2
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def create_dummy_func(func, dependency, message=""):
    """
    When a dependency of a function is not available, create a dummy function which throws
    ImportError when used.

    Args:
        func (str): name of the function.
        dependency (str or list[str]): name(s) of the dependency.
        message: extra message to print
    Returns:
        function: a function object
    """
    err = "Cannot import '{}', therefore '{}' is not available.".format(dependency, func)
    if message:
        err = err + " " + message

    if isinstance(dependency, (list, tuple)):
        dependency = ",".join(dependency)

    def _dummy(*args, **kwargs):
        raise ImportError(err)

    return _dummy

create_dummy_func(func='deform_conv', dependency='detectron2._C', message='detectron2 is not compiled successfully, please build following the instructions!')

Selected Statement: err = err + " " + message

Function Input:
func: 'deform_conv'
dependency: 'detectron2._C'
message: 'detectron2 is not compiled successfully, please build following the instructions!'

Variable Values Before Statement:
message: 'detectron2 is not compiled successfully, please build following the instructions!'

Value After Statement Execution: "Cannot import 'detectron2._C', therefore 'deform_conv' is not available. detectron2 is not compiled successfully, please build following the instructions!"

Variable States During Runtime (line, value):
func: 1
'deform_conv'
dependency: 1
'detectron2._C'
message: 1
'detectron2 is not compiled successfully, please build following the instructions!'
err: 13
"Cannot import 'detectron2._C', therefore 'deform_conv' is not available."
15
"Cannot import 'detectron2._C', therefore 'deform_conv' is not available. detectron2 is not compiled successfully, please build following the instructions!"
_dummy: 20
<function create_dummy_func.<locals>._dummy at 0x7f3337cdfd30>
Project Name: gruns+icecream
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def format_pair(prefix, arg, value):
    if arg is _arg_source_missing:
        arg_lines = []
        value_prefix = prefix
    else:
        arg_lines = indented_lines(prefix, arg)
        value_prefix = arg_lines[-1] + ': '

    looksLikeAString = value[0] + value[-1] in ["''", '""']
    if looksLikeAString:  # Align the start of multiline strings.
        value = prefixLinesAfterFirst(' ', value)

    value_lines = indented_lines(value_prefix, value)
    lines = arg_lines[:-1] + value_lines
    return '\n'.join(lines)

format_pair(prefix='    ', arg='multilineStr', value="'line1\nline2'")

Selected Statement: value_prefix = arg_lines[-1] + ': '

Function Input:
prefix: '    '
arg: 'multilineStr'
value: "'line1\nline2'"

Variable Values Before Statement:

Value After Statement Execution: '    multilineStr: '

Variable States During Runtime (line, value):
prefix: 1
'    '
arg: 1
'multilineStr'
value: 1
"'line1\nline2'"
11
"'line1\n line2'"
arg_lines: 6
    multilineStr
value_prefix: 7
'    multilineStr: '
looksLikeAString: 9
True
value_lines: 13
    multilineStr: 'line1,                    line2'
lines: 14
    multilineStr: 'line1,                    line2'
Project Name: gruns+icecream
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def prefixLinesAfterFirst(prefix, s):
    lines = s.splitlines(True)

    for i in range(1, len(lines)):
        lines[i] = prefix + lines[i]

    return ''.join(lines)

prefixLinesAfterFirst(prefix=' ', s="'line1\nline2'")

Selected Statement: lines[i] = prefix + lines[i]

Function Input:
prefix: ' '
s: "'line1\nline2'"

Variable Values Before Statement:
prefix: ' '

Value After Statement Execution: 'line1

 line2'

Variable States During Runtime (line, value):
prefix: 1
' '
s: 1
"'line1\nline2'"
lines: 2
'line1

line2'
5
'line1

 line2'
i: 4
1
Project Name: chen0040+pyalgs
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _sort(a, aux, lo, hi):
        if lo >= hi:
            return

        if hi - lo + 1 < MergeSort.CUTOFF:
            InsertionSort.sort(a, lo, hi)
            return

        mid = lo + (hi - lo) // 2
        MergeSort._sort(a, aux, lo, mid)
        MergeSort._sort(a, aux, mid + 1, hi)
        MergeSort._merge(a, aux, lo, mid, hi)

_sort(a=[4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66], aux=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], lo=0, hi=7)

Selected Statement: mid = lo + (hi - lo) // 2

Function Input:
a: [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]
aux: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
lo: 0
hi: 7

Variable Values Before Statement:
lo: 0

Value After Statement Execution: 3

Variable States During Runtime (line, value):
a: 1
[4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]
10
[1, 2, 4, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]
11
[1, 2, 4, 4, 5, 6, 7, 23, 8, 9, 20, 11, 13, 34, 66]
aux: 1
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
12
[1, 2, 4, 4, 5, 6, 7, 23, 0, 0, 0, 0, 0, 0, 0]
lo: 1
0
hi: 1
7
mid: 9
3
Project Name: chen0040+pyalgs
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _merge(a, aux, lo, mid, hi):
        i = lo
        j = mid + 1

        for k in range(lo, hi + 1):
            aux[k] = a[k]

        for k in range(lo, hi + 1):
            if i > mid:
                a[k] = aux[j]
                j += 1
            elif j > hi:
                a[k] = aux[i]
                i += 1
            elif util.less(aux[i], aux[j]):
                a[k] = aux[i]
                i += 1
            else:
                a[k] = aux[j]
                j += 1

_merge(a=[1, 2, 4, 4, 5, 6, 7, 23, 8, 9, 20, 11, 13, 34, 66], aux=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], lo=0, mid=3, hi=7)

Selected Statement: j = mid + 1

Function Input:
a: [1, 2, 4, 4, 5, 6, 7, 23, 8, 9, 20, 11, 13, 34, 66]
aux: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
lo: 0
mid: 3
hi: 7

Variable Values Before Statement:
mid: 3

Value After Statement Execution: 4

Variable States During Runtime (line, value):
a: 1
[1, 2, 4, 4, 5, 6, 7, 23, 8, 9, 20, 11, 13, 34, 66]
aux: 1
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0]
6
[1, 2, 4, 4, 5, 6, 7, 23, 0, 0, 0, 0, 0, 0, 0]
lo: 1
0
mid: 1
3
hi: 1
7
i: 2
0
17
1
17
2
17
3
17
4
j: 3
4
11
5
11
6
11
7
11
8
k: 5
0
5
1
5
2
5
3
5
4
5
5
5
6
5
7
8
0
8
1
8
2
8
3
8
4
8
5
8
6
8
7
Project Name: cyril-s+aptly-ctl
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def version_compare(self, other):
        "Compares version of the form [epoch:]upstream-version[-debian-revision]" \
        + " according to Debian package version number format."

        # compare epoch
        diff = self.epoch - other.epoch
        if diff != 0:
            return diff

        # compare upstream version and debian revision
        for slf, othr in (self.upstream_version, other.upstream_version), (self.revision, other.revision):
            i = 0
            while len(slf) > 0 or len(othr) > 0:
                decimal = (i % 2 == 1) 
                slf_part, slf = self._get_part(slf, decimal=decimal)
                othr_part, othr = self._get_part(othr, decimal=decimal)
                diff = self._compare_parts(slf_part, othr_part, decimal=decimal)
                if diff != 0:
                    return diff
                i += 1

        # versions are equal
        return 0

version_compare(self=2.2.0~rc5, other=2.2.0~rc5, self.epoch=0, self.revision='0', self.revision_allowed_chars=('.', '+', '~'), self.upstream_version='2.2.0~rc5', self.upstream_version_allowed_chars=('.', '+', '~', '-', ':'), self.version='2.2.0~rc5')

Selected Statement: diff = self.epoch - other.epoch

Function Input:
self: 2.2.0~rc5
other: 2.2.0~rc5
self.epoch: 0
self.revision: '0'
self.revision_allowed_chars: ('.', '+', '~')
self.upstream_version: '2.2.0~rc5'
self.upstream_version_allowed_chars: ('.', '+', '~', '-', ':')
self.version: '2.2.0~rc5'

Variable Values Before Statement:

Value After Statement Execution: 0

Variable States During Runtime (line, value):
self: 1
2.2.0~rc5
other: 1
2.2.0~rc5
self.epoch: 1
0
self.revision: 1
'0'
self.revision_allowed_chars: 1
('.', '+', '~')
self.upstream_version: 1
'2.2.0~rc5'
self.upstream_version_allowed_chars: 1
('.', '+', '~', '-', ':')
self.version: 1
'2.2.0~rc5'
diff: 6
0
slf: 11
'2.2.0~rc5'
15
'.2.0~rc5'
15
'2.0~rc5'
15
'.0~rc5'
15
'0~rc5'
15
'~rc5'
15
'5'
15
''
11
'0'
15
''
othr: 11
'2.2.0~rc5'
16
'.2.0~rc5'
16
'2.0~rc5'
16
'.0~rc5'
16
'0~rc5'
16
'~rc5'
16
'5'
16
''
11
'0'
16
''
i: 12
0
20
1
20
2
20
3
20
4
20
5
20
6
20
7
20
8
12
0
20
1
20
2
decimal: 14
False
14
True
14
False
14
True
14
False
14
True
14
False
14
True
14
False
14
True
slf_part: 15
''
15
'2'
15
'.'
15
'2'
15
'.'
15
'0'
15
'~rc'
15
'5'
15
''
15
'0'
othr_part: 16
''
16
'2'
16
'.'
16
'2'
16
'.'
16
'0'
16
'~rc'
16
'5'
16
''
16
'0'
Project Name: GEMPACKsoftware+HARPY
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _setHeaderBaseData(array, coeff_name, hao, long_name) -> None:
        if not isinstance(array, (np.ndarray, np.float32, np.int32,np.float64)):
            print(type(array))
            raise HeaderArrayObj.UnsupportedArrayType("'array' must be of numpy.ndarray type.")

        # Defaults handling
        if coeff_name is None:
            coeff_name = " " * 12
        if long_name is None:
            long_name = coeff_name
        if len(coeff_name) < 12:
            coeff_name = coeff_name.ljust(12)
        if len(long_name) < 70:
            long_name = long_name.ljust(70)
        hao.array = array
        hao.coeff_name = coeff_name
        hao.long_name = long_name

_setHeaderBaseData(array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), coeff_name=None, hao={_coeff_name='', _array=None, _sets=None, _long_name=''}, long_name='Creation Date and Time                                                ')

Selected Statement: coeff_name = " " * 12

Function Input:
array: array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70')
coeff_name: None
hao: {_coeff_name='', _array=None, _sets=None, _long_name=''}
long_name: 'Creation Date and Time                                                '

Variable Values Before Statement:

Value After Statement Execution: '            '

Variable States During Runtime (line, value):
array: 1
array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70')
coeff_name: 1
None
8
'            '
hao: 1
{_coeff_name='', _array=None, _sets=None, _long_name=''}
15
{_coeff_name='', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name=''}
16
{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name=''}
17
{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name='Creation Date and Time                                                '}
long_name: 1
'Creation Date and Time                                                '
Project Name: GEMPACKsoftware+HARPY
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def SetHeaderFromData(setName: str, setElements:'Union[List[str], np.array]',  long_name: str=None):
        if not isinstance(setName,str):
            raise TypeError("setName must be of type str")
        if len(setName.strip()) > 12 :
            raise ValueError("setName is restricted to 12 Characters")
        if long_name is None: long_name=""
        if isinstance(long_name, str):
            long_name="Set "+setName.strip()+" "+long_name.strip()
        else:
            raise TypeError("LongName must be string")

        if isinstance(setElements,(list,np.ndarray)):
            if not all([isinstance(el,str) for el in setElements]):
                raise TypeError("All Set Elements must be of type str")
            if not all([len(el)<=12 for el in setElements]):
                raise ValueError("Set Elelement strings must be 12 characters at most")

        if isinstance(setElements,list):
            array=np.array(setElements)
            setElDict={setName:setElements}
        elif isinstance(setElements,np.ndarray):
            array=setElements
            setElDict = {setName: setElements.tolist()}
        else:
            raise TypeError("SetElemenets must be list of str or np array of strings")


        return HeaderArrayObj.HeaderArrayFromData(array=array, long_name=long_name, sets=[setName], setElDict=setElDict)

SetHeaderFromData(setName='sect', setElements=array(['s1          ', 's2          '], dtype='<U12'), long_name=' Sectors                                                                        ')

Selected Statement: long_name="Set "+setName.strip()+" "+long_name.strip()

Function Input:
setName: 'sect'
setElements: array(['s1          ', 's2          '], dtype='<U12')
long_name: ' Sectors                                                                        '

Variable Values Before Statement:

Value After Statement Execution: 'Set sect Sectors'

Variable States During Runtime (line, value):
setName: 1
'sect'
setElements: 1
array(['s1          ', 's2          '], dtype='<U12')
long_name: 1
' Sectors                                                                        '
8
'Set sect Sectors'
array: 22
array(['s1          ', 's2          '], dtype='<U12')
setElDict: 23
{'sect': ['s1          ', 's2          ']}
Project Name: pdfminer+pdfminer.six
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def set_bbox(self, bbox: Rect) -> None:
        (x0, y0, x1, y1) = bbox
        self.x0 = x0
        self.y0 = y0
        self.x1 = x1
        self.y1 = y1
        self.width = x1 - x0
        self.height = y1 - y0
        self.bbox = bbox

set_bbox(self=REPR FAILED, bbox=[0, 100, 0, 100])

Selected Statement: self.width = x1 - x0

Function Input:
self: REPR FAILED
bbox: [0, 100, 0, 100]

Variable Values Before Statement:
x1: 0
x0: 0

Value After Statement Execution: 0

Variable States During Runtime (line, value):
self: 1
REPR FAILED
9
<LTContainer 0.000,100.000,0.000,100.000>
bbox: 1
[0, 100, 0, 100]
x0: 2
0
y0: 2
100
x1: 2
0
y1: 2
100
self.x0: 3
0
self.y0: 4
100
self.x1: 5
0
self.y1: 6
100
self.width: 7
0
self.height: 8
0
self.bbox: 9
[0, 100, 0, 100]
Project Name: rsalmei+alive-progress
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def calibrated_fps(calibrate):
    """Calibration of the dynamic frames per second engine.

    I've started with the equation y = log10(x + m) * k + n, where:
      y is the desired fps, m and n are horizontal and vertical translation,
      k is a calibration factor, computed from some user input c (see readme for details).

    Considering minfps and maxfps as given constants, I came to:
      fps = log10(x + 1) * k + minfps, which must be equal to maxfps for x = c,
    so the factor k = (maxfps - minfps) / log10(c + 1), and
      fps = log10(x + 1) * (maxfps - minfps) / log10(c + 1) + minfps

    Neat! ;)

    Args:
        calibrate (float): user provided

    Returns:
        a callable to calculate the fps

    """
    min_fps, max_fps = 2., 60.
    calibrate = max(1e-6, calibrate)
    adjust_log_curve = 100. / min(calibrate, 100.)  # adjust the curve for small numbers
    factor = (max_fps - min_fps) / math.log10((calibrate * adjust_log_curve) + 1.)

    def fps(rate):
        if rate <= 0:
            return 10.  # bootstrap speed
        if rate < calibrate:
            return math.log10((rate * adjust_log_curve) + 1.) * factor + min_fps
        return max_fps

    return fps

calibrated_fps(calibrate=-5.0)

Selected Statement: adjust_log_curve = 100. / min(calibrate, 100.)  # adjust the curve for small numbers

Function Input:
calibrate: -5.0

Variable Values Before Statement:

Value After Statement Execution: 100000000.0

Variable States During Runtime (line, value):
calibrate: 1
-5.0
23
1e-06
max_fps: 22
60.0
min_fps: 22
2.0
adjust_log_curve: 24
100000000.0
factor: 25
28.93747517671773
fps: 27
<function calibrated_fps.<locals>.fps at 0x7f355669f1f0>
Project Name: combatopera+Concern
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def getblockimpl(lines, first, last, pilcrow):
    max = len(lines) - 1
    first -= 1
    last -= 1
    i = first
    while i < max and not hastext(lines[i]):
        if i >= last and istoplevel(lines[i + 1]):
            return None, None, '# Nothing to send.' + pilcrow + eol
        i += 1
    while last < max and not istoplevel(lines[last + 1]):
        last += 1
    while first < last and not hastext(lines[first]):
        first += 1
    while first and not istoplevel(lines[first]):
        first -= 1
    lines[last] # Check for out of range.
    return first, last, eol.join(l for l in lines[first:last + 1] if hastext(l)) + pilcrow + eol

getblockimpl(lines=['', 'hello', 'function with', ' indented block', 'class with', '', '  block after blank', '  \tand its own indented block', '\t', '  and back again after a wrong blank', '', 'something else', '\t', ' \t', 'last'], first=10, last=11, pilcrow='')

Selected Statement: max = len(lines) - 1

Function Input:
lines: hello, function with,  indented block, class with,   block after blank,   	and its own indented block, 	,   and back again after a wrong blank, something else, 	,  	, last
first: 10
last: 11
pilcrow: ''

Variable Values Before Statement:

Value After Statement Execution: 14

Variable States During Runtime (line, value):
lines: 1
hello, function with,  indented block, class with,   block after blank,   	and its own indented block, 	,   and back again after a wrong blank, something else, 	,  	, last
first: 1
10
3
9
15
8
15
7
15
6
15
5
15
4
last: 1
11
4
10
pilcrow: 1
''
max: 2
14
i: 5
9
Project Name: ArunTejCh+python-driver
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _from_timetuple(self, t):
        self.days_from_epoch = calendar.timegm(t) // Date.DAY

_from_timetuple(self=Date(0), t=time.struct_time(tm_year=2024, tm_mon=4, tm_mday=3, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=94, tm_isdst=-1))

Selected Statement: self.days_from_epoch = calendar.timegm(t) // Date.DAY

Function Input:
self: Date(0)
t: time.struct_time(tm_year=2024, tm_mon=4, tm_mday=3, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=94, tm_isdst=-1)

Variable Values Before Statement:

Value After Statement Execution: 19816

Variable States During Runtime (line, value):
self: 1
Date(0)
2
Date(19816)
t: 1
time.struct_time(tm_year=2024, tm_mon=4, tm_mday=3, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=94, tm_isdst=-1)
self.days_from_epoch: 2
19816
Project Name: ArunTejCh+python-driver
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def _insert(self, key, value):
        flat_key = self._serialize_key(key)
        i = self._index.get(flat_key, -1)
        if i >= 0:
            self._items[i] = (key, value)
        else:
            self._items.append((key, value))
            self._index[flat_key] = len(self._items) - 1

_insert(self=OrderedMapSerializedKey([]), key='みbob', value=199)

Selected Statement: self._index[flat_key] = len(self._items) - 1

Function Input:
self: OrderedMapSerializedKey([])
key: 'みbob'
value: 199

Variable Values Before Statement:

Value After Statement Execution: 199

Variable States During Runtime (line, value):
self: 1
OrderedMapSerializedKey([])
7
OrderedMapSerializedKey([('みbob', 199)])
key: 1
'みbob'
value: 1
199
flat_key: 2
b'\xe3\x81\xbfbob'
i: 3
-1
self['みbob']: 8
199
Project Name: mher+flower
Language: Python
Statement Type: Arithmetic Assignment

Source Code:
def stringified_dict_contains_value(key, value, str_dict):
    """Checks if dict in for of string like "{'test': 5}" contains
    key/value pair. This works faster, then creating actual dict
    from string since this operation is called for each task in case
    of kwargs search."""
    if not str_dict:
        return False
    value = str(value)
    try:
        # + 3 for key right quote, one for colon and one for space
        key_index = str_dict.index(key) + len(key) + 3
    except ValueError:
        return False
    try:
        comma_index = str_dict.index(',', key_index)
    except ValueError:
        # last value in dict
        comma_index = str_dict.index('}', key_index)
    return str(value) == str_dict[key_index:comma_index].strip('"\'')

stringified_dict_contains_value(key='test', value=5, str_dict="{'test': 5}")

Selected Statement: key_index = str_dict.index(key) + len(key) + 3

Function Input:
key: 'test'
value: 5
str_dict: "{'test': 5}"

Variable Values Before Statement:

Value After Statement Execution: 9

Variable States During Runtime (line, value):
key: 1
'test'
value: 1
5
8
'5'
str_dict: 1
"{'test': 5}"
key_index: 11
9
comma_index: 18
10