MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: MrTango+click
Language: Python
Statement Type: API

Source Code:
def _unpack_args(args, nargs_spec):
    """Given an iterable of arguments and an iterable of nargs specifications,
    it returns a tuple with all the unpacked arguments at the first index
    and all remaining arguments as the second.

    The nargs specification is the number of arguments that should be consumed
    or `-1` to indicate that this position should eat up all the remainders.

    Missing items are filled with `None`.
    """
    args = deque(args)
    nargs_spec = deque(nargs_spec)
    rv = []
    spos = None

    def _fetch(c):
        try:
            if spos is None:
                return c.popleft()
            else:
                return c.pop()
        except IndexError:
            return None

    while nargs_spec:
        nargs = _fetch(nargs_spec)
        if nargs == 1:
            rv.append(_fetch(args))
        elif nargs > 1:
            x = [_fetch(args) for _ in range(nargs)]
            # If we're reversed, we're pulling in the arguments in reverse,
            # so we need to turn them around.
            if spos is not None:
                x.reverse()
            rv.append(tuple(x))
        elif nargs < 0:
            if spos is not None:
                raise TypeError('Cannot have two nargs < 0')
            spos = len(rv)
            rv.append(None)

    # spos is the position of the wildcard (star).  If it's not `None`,
    # we fill it with the remainder.
    if spos is not None:
        rv[spos] = tuple(args)
        args = []
        rv[spos + 1:] = reversed(rv[spos + 1:])

    return tuple(rv), list(args)

_unpack_args(args=['foo.txt', 'bar.txt', 'dir'], nargs_spec=[-1, 1])

Selected Statement: rv[spos] = tuple(args)

Function Input:
args: foo.txt, bar.txt, dir
nargs_spec: [-1, 1]

Variable Values Before Statement:
args: deque(['foo.txt', 'bar.txt'])

Value After Statement Execution: [('foo.txt', 'bar.txt'), 'dir']

Variable States During Runtime (line, value):
args: 1
foo.txt, bar.txt, dir
11
deque(['foo.txt', 'bar.txt', 'dir'])
28
deque(['foo.txt', 'bar.txt'])
46
nargs_spec: 1
[-1, 1]
12
deque([-1, 1])
26
deque([1])
26
deque([])
rv: 13
40
[None]
28
dir
45
[('foo.txt', 'bar.txt'), 'dir']
spos: 14
None
39
0
_fetch: 16
<function _unpack_args.<locals>._fetch at 0x7fe6e9431b80>
nargs: 26
-1
26
1
Project Name: MrTango+click
Language: Python
Statement Type: API

Source Code:
def join_options(options):
    """Given a list of option strings this joins them in the most appropriate
    way and returns them in the form ``(formatted_string,
    any_prefix_is_slash)`` where the second item in the tuple is a flag that
    indicates if any of the option prefixes was a slash.
    """
    rv = []
    any_prefix_is_slash = False
    for opt in options:
        prefix = split_opt(opt)[0]
        if prefix == '/':
            any_prefix_is_slash = True
        rv.append((len(prefix), opt))

    rv.sort(key=lambda x: x[0])

    rv = ', '.join(x[1] for x in rv)
    return rv, any_prefix_is_slash

join_options(options=['--help'])

Selected Statement: rv.append((len(prefix), opt))

Function Input:
options: --help

Variable Values Before Statement:
prefix: '--'

Value After Statement Execution: [(2, '--help')]

Variable States During Runtime (line, value):
options: 1
--help
rv: 7
13
[(2, '--help')]
17
'--help'
any_prefix_is_slash: 8
False
opt: 9
'--help'
prefix: 10
'--'
Project Name: MrTango+click
Language: Python
Statement Type: API

Source Code:
def format_filename(filename, shorten=False):
    """Formats a filename for user display.  The main purpose of this
    function is to ensure that the filename can be displayed at all.  This
    will decode the filename to unicode if necessary in a way that it will
    not fail.  Optionally, it can shorten the filename to not include the
    full path to the filename.

    :param filename: formats a filename for UI display.  This will also convert
                     the filename into unicode without failing.
    :param shorten: this optionally shortens the filename to strip of the
                    path that leads up to it.
    """
    if shorten:
        filename = os.path.basename(filename)
    return filename_to_ui(filename)

format_filename(filename='/x/foo.txt', shorten=True)

Selected Statement: filename = os.path.basename(filename)

Function Input:
filename: '/x/foo.txt'
shorten: True

Variable Values Before Statement:
filename: '/x/foo.txt'

Value After Statement Execution: 'foo.txt'

Variable States During Runtime (line, value):
filename: 1
'/x/foo.txt'
14
'foo.txt'
shorten: 1
True
Project Name: SpotlightKid+picoredis
Language: Python
Statement Type: API

Source Code:
def encode_request(*args):
    """Pack a series of arguments into a RESP array of bulk strings."""
    result = ["*" + str(len(args)) + CRLF]
    
    for arg in args:
        if arg is None:
            result.append('$-1' + CRLF)
        else:
            s = str(arg)
            result.append('$' + str(len(s)) + CRLF + s + CRLF)

    return "".join(result)

encode_request(args=('ping',))

Selected Statement: s = str(arg)

Function Input:
args: ('ping',)

Variable Values Before Statement:
arg: 'ping'

Value After Statement Execution: 'ping'

Variable States During Runtime (line, value):
args: 1
('ping',)
result: 3
*1

10
*1

$4
ping

arg: 5
'ping'
s: 9
'ping'
Project Name: rsalmei+alive-progress
Language: Python
Statement Type: API

Source Code:
def static_sliding_window(sep, gap, contents, length, right, initial):
    """Implement a sliding window over some content interspersed with a separator.
    It is very efficient, storing data in only one string.

    Note that the implementation is "static" in the sense that the content is pre-
    calculated and maintained static, but actually when the window slides both the
    separator and content seem to be moved.
    Also keep in mind that `right` is for the content, not the window.
    """

    def sliding_window():
        pos = initial
        while True:
            if pos < 0:
                pos += original
            elif pos >= original:
                pos -= original
            yield content[pos:pos + length]
            pos += step

    adjusted_sep = fix_cells((sep * math.ceil(gap / len(sep)))[:gap]) if gap else ''
    content = tuple(chain.from_iterable(chain.from_iterable(zip(repeat(adjusted_sep), contents))))
    original, step = len(content), -1 if right else 1
    assert length <= original, f'window slides inside content, {length} must be <= {original}'
    content += content[:length]
    return sliding_window()

static_sliding_window(sep=(' ',), gap=3, contents=(('a', 'b', 'c'),), length=3, right=True, initial=0)

Selected Statement: original, step = len(content), -1 if right else 1

Function Input:
sep: (' ',)
gap: 3
contents: (('a', 'b', 'c'),)
length: 3
right: True
initial: 0

Variable Values Before Statement:
content: (' ', ' ', ' ', 'a', 'b', 'c')

Value After Statement Execution: 6

Variable States During Runtime (line, value):
sep: 1
(' ',)
gap: 1
3
contents: 1
(('a', 'b', 'c'),)
length: 1
3
right: 1
True
initial: 1
0
sliding_window: 11
<function static_sliding_window.<locals>.sliding_window at 0x7f354c6a3dc0>
adjusted_sep: 21
(' ', ' ', ' ')
content: 22
(' ', ' ', ' ', 'a', 'b', 'c')
25
(' ', ' ', ' ', 'a', 'b', 'c', ' ', ' ', ' ')
original: 23
6
step: 23
-1
Project Name: rsalmei+alive-progress
Language: Python
Statement Type: API

Source Code:
def test_split_options(param, expected):
    if expected is SAME:
        expected = param
    assert split_options(param) == expected

test_split_options(param=None, expected=(None, None))

Selected Statement: assert split_options(param) == expected

Function Input:
param: None
expected: (None, None)

Variable Values Before Statement:
param: None

Value After Statement Execution: None

Variable States During Runtime (line, value):
param: 1
None
expected: 1
(None, None)
@py_assert2: 4
None
@py_assert4: 4
None
Project Name: rsalmei+alive-progress
Language: Python
Statement Type: API

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: calibrate = max(1e-6, calibrate)

Function Input:
calibrate: -5.0

Variable Values Before Statement:
calibrate: -5.0

Value After Statement Execution: 1e-06

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: rsalmei+alive-progress
Language: Python
Statement Type: API

Source Code:
def elapsed_text(seconds, precise, prefix=''):
    seconds = round(seconds, 1 if precise else 0)
    if seconds < 60.:
        return '{}{:{}f}s'.format(prefix, seconds, .1 if precise else .0)

    minutes, seconds = divmod(seconds, 60.)
    if minutes < 60.:
        return '{}{:.0f}:{:0{}f}'.format(prefix, minutes, seconds, 4.1 if precise else 2.0)

    hours, minutes = divmod(minutes, 60.)
    return '{}{:.0f}:{:02.0f}:{:0{}f}'.format(prefix, hours, minutes, seconds,
                                              4.1 if precise else 2.0)

elapsed_text(seconds=1.23, precise=True, prefix='')

Selected Statement: seconds = round(seconds, 1 if precise else 0)

Function Input:
seconds: 1.23
precise: True
prefix: ''

Variable Values Before Statement:
seconds: 1.23

Value After Statement Execution: 1.2

Variable States During Runtime (line, value):
seconds: 1
1.23
2
1.2
precise: 1
True
prefix: 1
''
Project Name: combatopera+Concern
Language: Python
Statement Type: API

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:
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

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: Delgan+loguru
Language: Python
Statement Type: API

Source Code:
def parse(text, *, strip=False, strict=True):
    parser = loguru._colorizer.AnsiParser()
    parser.feed(text)
    tokens = parser.done(strict=strict)

    if strip:
        return parser.strip(tokens)
    return parser.colorize(tokens, "")

parse(text='<red>Foo</red>\n', strip=False, strict=True)

Selected Statement: parser.feed(text)

Function Input:
text: '<red>Foo</red>\n'
strip: False
strict: True

Variable Values Before Statement:
text: '<red>Foo</red>\n'

Value After Statement Execution: {_tokens

Variable States During Runtime (line, value):
text: 1
'<red>Foo</red>\n'
strip: 1
False
strict: 1
True
parser: 2
{_tokens=[], _tags=[], _color_tokens=[]}
3
{_tokens=[(1, ''), (2, '\x1b[31m'), (1, 'Foo'), (4, '\x1b[0m'), (1, '\n')], _tags=[], _color_tokens=[]}
tokens: 4
[(1, ''), (2, '\x1b[31m'), (1, 'Foo'), (4, '\x1b[0m'), (1, '\n')]
Project Name: jina-ai+clip-as-service
Language: Python
Statement Type: API

Source Code:
def random_port():
        port = helper.random_port()
        while port in generated_ports:
            port = helper.random_port()
        generated_ports.add(port)
        return port

random_port(generated_ports=set())

Selected Statement: generated_ports.add(port)

Function Input:
generated_ports: set()

Variable Values Before Statement:
port: 56663

Value After Statement Execution: {56663}

Variable States During Runtime (line, value):
generated_ports: 1
set()
5
{56663}
port: 2
56663
Project Name: jina-ai+clip-as-service
Language: Python
Statement Type: API

Source Code:
def test_split_img_txt_da(inputs):
    txt_da = DocumentArray()
    img_da = DocumentArray()
    for doc in inputs[0]:
        split_img_txt_da(doc, img_da, txt_da)
    assert len(txt_da) == inputs[1][0]
    assert len(img_da) == inputs[1][1]

test_split_img_txt_da(inputs=(<DocumentArray (length=4) at 140538627068688>, (3, 1)))

Selected Statement: assert len(txt_da) == inputs[1][0]

Function Input:
inputs: (<DocumentArray (length=4) at 140538627068688>, (3, 1))

Variable Values Before Statement:
txt_da: <DocumentArray (length=3) at 140537876329136>

Value After Statement Execution: None

Variable States During Runtime (line, value):
inputs: 1
(<DocumentArray (length=4) at 140538627068688>, (3, 1))
txt_da: 2
<DocumentArray (length=0) at 140537876329136>
5
<DocumentArray (length=1) at 140537876329136>
5
<DocumentArray (length=2) at 140537876329136>
5
<DocumentArray (length=3) at 140537876329136>
img_da: 3
<DocumentArray (length=0) at 140537876330432>
5
<DocumentArray (length=1) at 140537876330432>
doc: 4
<Document ('id', 'text') at 4f6626f35426c735426ec7292e9a1f16>
4
<Document ('id', 'text') at d6d91a560e93b578961de0cda87d7354>
4
<Document ('id', 'mime_type', 'text', 'uri') at 0bc25489570139a4fb1df04f2c8f3441>
4
<Document ('id', 'mime_type', 'uri') at 661ab035d871096f43200d69a11270ad>
@py_assert2: 6
None
@py_assert5: 6
None
@py_assert4: 6
None
Project Name: ArunTejCh+python-driver
Language: Python
Statement Type: API

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:
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)

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: API

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: flat_key = self._serialize_key(key)

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

Variable Values Before Statement:
key: 'みbob'

Value After Statement Execution: b'\xe3\x81\xbfbob'

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: API

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: comma_index = str_dict.index('}', key_index)

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

Variable Values Before Statement:
key_index: 9

Value After Statement Execution: 10

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
Project Name: mher+flower
Language: Python
Statement Type: API

Source Code:
def abs_path(path):
    path = os.path.expanduser(path)
    if not os.path.isabs(path):
        cwd = os.environ.get('PWD') or os.getcwd()
        path = os.path.join(cwd, path)
    return path

abs_path(path='~/file.txt')

Selected Statement: path = os.path.expanduser(path)

Function Input:
path: '~/file.txt'

Variable Values Before Statement:
path: '~/file.txt'

Value After Statement Execution: '/home/jinjun/file.txt'

Variable States During Runtime (line, value):
path: 1
'~/file.txt'
2
'/home/jinjun/file.txt'
Project Name: mher+flower
Language: Python
Statement Type: API

Source Code:
def authenticate(pattern, email):
    if '|' in pattern:
        return email in pattern.split('|')
    if '*' in pattern:
        pattern = re.escape(pattern).replace(r'\.\*', r"[A-Za-z0-9!#$%&'*+/=?^_`{|}~.\-]*")
        return re.fullmatch(pattern, email)
    return pattern == email

authenticate(pattern='.*@example.com', email='one@example.com')

Selected Statement: pattern = re.escape(pattern).replace(r'\.\*', r"[A-Za-z0-9!#$%&'*+/=?^_`{|}~.\-]*")

Function Input:
pattern: '.*@example.com'
email: 'one@example.com'

Variable Values Before Statement:
pattern: '.*@example.com'

Value After Statement Execution: "[A-Za-z0-9!#$%&'*+/

Variable States During Runtime (line, value):
pattern: 1
'.*@example.com'
5
"[A-Za-z0-9!#$%&'*+/=?^_`{|}~.\\-]*@example\\.com"
email: 1
'one@example.com'
Project Name: chiptopher+guet
Language: Python
Statement Type: API

Source Code:
def _add_committer_to_committers(all_committers: List[str], initials: str, name: str, email: str):
    committer_formatted = f'{initials},{name},{email}\n'
    committer_position = _position_of_committer_with_initials(all_committers, initials)
    if committer_position is _COMMITTER_NOT_PRESENT:
        all_committers.append(committer_formatted)
    else:
        all_committers[committer_position] = committer_formatted

_add_committer_to_committers(all_committers=[], initials='initials3', name='name3', email='email3')

Selected Statement: committer_position = _position_of_committer_with_initials(all_committers, initials)

Function Input:
initials: 'initials3'
name: 'name3'
email: 'email3'

Variable Values Before Statement:
initials: 'initials3'

Value After Statement Execution: -1

Variable States During Runtime (line, value):
all_committers: 1
5
initials3,name3,email3

initials: 1
'initials3'
name: 1
'name3'
email: 1
'email3'
committer_formatted: 2
'initials3,name3,email3\n'
committer_position: 3
-1
Project Name: chiptopher+guet
Language: Python
Statement Type: API

Source Code:
def add_committer(initials: str, name: str, email: str, *, file_path: str = _GLOBAL) -> None:
    all_committers = _read_all_committers_from_file(file_path)
    _add_committer_to_committers(all_committers, initials, name, email)
    _write_committers_to_file(all_committers, file_path)

add_committer(initials='initials3', name='name3', email='email3', file_path='/home/jinjun/.guet/committers')

Selected Statement: _add_committer_to_committers(all_committers, initials, name, email)

Function Input:
initials: 'initials3'
name: 'name3'
email: 'email3'
file_path: '/home/jinjun/.guet/committers'

Variable Values Before Statement:
all_committers: initials1,name1,email1

initials2,name2,email2

initials: 'initials3'
name: 'name3'
email: 'email3'

Value After Statement Execution: initials1,name1,email1

initials2,name2,email2

initials3,name3,email3


Variable States During Runtime (line, value):
initials: 1
'initials3'
name: 1
'name3'
email: 1
'email3'
file_path: 1
'/home/jinjun/.guet/committers'
all_committers: 2
initials1,name1,email1

initials2,name2,email2

3
initials1,name1,email1

initials2,name2,email2

initials3,name3,email3
Project Name: chiptopher+guet
Language: Python
Statement Type: API

Source Code:
def _load_global_committers(path: str) -> List[Committer]:
    lines = read_lines(path)
    committers = []
    for line in lines:
        initials, name, email = line.rstrip().split(',')
        committers.append(GlobalCommitter(initials=initials, name=name, email=email))
    return committers

_load_global_committers(path='/home/jinjun/.guet/committers')

Selected Statement: lines = read_lines(path)

Function Input:
path: '/home/jinjun/.guet/committers'

Variable Values Before Statement:
path: '/home/jinjun/.guet/committers'

Value After Statement Execution: initials,name,email


Variable States During Runtime (line, value):
path: 1
'/home/jinjun/.guet/committers'
lines: 2
initials,name,email

committers: 3
6
[<guet.committers.global_committer.GlobalCommitter object at 0x7fc0ad6a46a0>]
line: 4
'initials,name,email\n'
initials: 5
'initials'
name: 5
'name'
email: 5
'email'