MonoshiTonmoy/Code_Statement_Prediction_Dataset huggingface dataset:
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def do_replace(fname, content, before_text, after_text, fence=None):
    before_text = strip_quoted_wrapping(before_text, fname, fence)
    after_text = strip_quoted_wrapping(after_text, fname, fence)
    fname = Path(fname)

    # does it want to make a new file?
    if not fname.exists() and not before_text.strip():
        fname.touch()
        content = ""

    if content is None:
        return

    if not before_text.strip():
        # append to existing file, or start a new file
        new_content = content + after_text
    else:
        new_content = replace_most_similar_chunk(content, before_text, after_text)

    return new_content

do_replace(fname='/tmp/tmp7g7a2csg/file.txt', content='two\n', before_text='two\n', after_text='three\n', fence=('```', '```'))

Selected Statement: new_content = replace_most_similar_chunk(content, before_text, after_text)

Function Input:
fname: '/tmp/tmp7g7a2csg/file.txt'
content: 'two\n'
before_text: 'two\n'
after_text: 'three\n'
fence: ('```', '```')

Variable Values Before Statement:
content: 'two\n'
before_text: 'two\n'
after_text: 'three\n'

Value After Statement Execution: 'three\n'

Variable States During Runtime (line, value):
fname: 1
'/tmp/tmp7g7a2csg/file.txt'
4
PosixPath('/tmp/tmp7g7a2csg/file.txt')
content: 1
'two\n'
before_text: 1
'two\n'
after_text: 1
'three\n'
fence: 1
('```', '```')
new_content: 18
'three\n'
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def strip_quoted_wrapping(res, fname=None, fence=DEFAULT_FENCE):
    """
    Given an input string which may have extra "wrapping" around it, remove the wrapping.
    For example:

    filename.ext
    ```
    We just want this content
    Not the filename and triple quotes
    ```
    """
    if not res:
        return res

    res = res.splitlines()

    if fname and res[0].strip().endswith(Path(fname).name):
        res = res[1:]

    if res[0].startswith(fence[0]) and res[-1].startswith(fence[1]):
        res = res[1:-1]

    res = "\n".join(res)
    if res and res[-1] != "\n":
        res += "\n"

    return res

strip_quoted_wrapping(res='two\n', fname='/tmp/tmp7g7a2csg/file.txt', fence=('```', '```'))

Selected Statement: res = "\n".join(res)

Function Input:
res: 'two\n'
fname: '/tmp/tmp7g7a2csg/file.txt'
fence: ('```', '```')

Variable Values Before Statement:
res: two

Value After Statement Execution: 'two'

Variable States During Runtime (line, value):
res: 1
'two\n'
15
two
23
'two'
25
'two\n'
fname: 1
'/tmp/tmp7g7a2csg/file.txt'
fence: 1
('```', '```')
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def replace_most_similar_chunk(whole, part, replace):
    """Best efforts to find the `part` lines in `whole` and replace them with `replace`"""

    whole, whole_lines = prep(whole)
    part, part_lines = prep(part)
    replace, replace_lines = prep(replace)

    res = perfect_or_whitespace(whole_lines, part_lines, replace_lines)
    if res:
        return res

    # drop leading empty line, GPT sometimes adds them spuriously (issue #25)
    if len(part_lines) > 2 and not part_lines[0].strip():
        skip_blank_line_part_lines = part_lines[1:]
        res = perfect_or_whitespace(whole_lines, skip_blank_line_part_lines, replace_lines)
        if res:
            return res

    # Try to handle when it elides code with ...
    try:
        res = try_dotdotdots(whole, part, replace)
        if res:
            return res
    except ValueError:
        pass

    return
    # Try fuzzy matching
    res = replace_closest_edit_distance(whole_lines, part, part_lines, replace_lines)
    if res:
        return res

replace_most_similar_chunk(whole='two\n', part='two\n', replace='three\n')

Selected Statement: replace, replace_lines = prep(replace)

Function Input:
whole: 'two\n'
part: 'two\n'
replace: 'three\n'

Variable Values Before Statement:
replace: 'three\n'

Value After Statement Execution: three


Variable States During Runtime (line, value):
whole: 1
'two\n'
part: 1
'two\n'
replace: 1
'three\n'
whole_lines: 4
two

part_lines: 5
two

replace_lines: 6
three

res: 8
'three\n'
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def perfect_or_whitespace(whole_lines, part_lines, replace_lines):
    # Try for a perfect match
    res = perfect_replace(whole_lines, part_lines, replace_lines)
    if res:
        return res

    # Try being flexible about leading whitespace
    res = replace_part_with_missing_leading_whitespace(whole_lines, part_lines, replace_lines)
    if res:
        return res

perfect_or_whitespace(whole_lines=['two\n'], part_lines=['two\n'], replace_lines=['three\n'])

Selected Statement: res = perfect_replace(whole_lines, part_lines, replace_lines)

Function Input:
whole_lines: two

part_lines: two

replace_lines: three


Variable Values Before Statement:
whole_lines: two

part_lines: two

replace_lines: three


Value After Statement Execution: 'three\n'

Variable States During Runtime (line, value):
whole_lines: 1
two

part_lines: 1
two

replace_lines: 1
three

res: 3
'three\n'
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def perfect_replace(whole_lines, part_lines, replace_lines):
    part_tup = tuple(part_lines)
    part_len = len(part_lines)

    for i in range(len(whole_lines) - part_len + 1):
        whole_tup = tuple(whole_lines[i : i + part_len])
        if part_tup == whole_tup:
            res = whole_lines[:i] + replace_lines + whole_lines[i + part_len :]
            return "".join(res)

perfect_replace(whole_lines=['two\n'], part_lines=['two\n'], replace_lines=['three\n'])

Selected Statement: part_tup = tuple(part_lines)

Function Input:
whole_lines: two

part_lines: two

replace_lines: three


Variable Values Before Statement:
part_lines: two


Value After Statement Execution: ('two\n',)

Variable States During Runtime (line, value):
whole_lines: 1
two

part_lines: 1
two

replace_lines: 1
three

part_tup: 2
('two\n',)
part_len: 3
1
i: 5
0
whole_tup: 6
('two\n',)
res: 8
three
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def parse_quoted_filenames(args):
    filenames = re.findall(r"\"(.+?)\"|(\S+)", args)
    filenames = [name for sublist in filenames for name in sublist if name]
    return filenames

parse_quoted_filenames(args='foo.txt bar.txt')

Selected Statement: filenames = re.findall(r"\"(.+?)\"|(\S+)", args)

Function Input:
args: 'foo.txt bar.txt'

Variable Values Before Statement:
args: 'foo.txt bar.txt'

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

Variable States During Runtime (line, value):
args: 1
'foo.txt bar.txt'
filenames: 2
[('', 'foo.txt'), ('', 'bar.txt')]
3
foo.txt, bar.txt
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def match_but_for_leading_whitespace(whole_lines, part_lines):
    num = len(whole_lines)

    # does the non-whitespace all agree?
    if not all(whole_lines[i].lstrip() == part_lines[i].lstrip() for i in range(num)):
        return

    # are they all offset the same?
    add = set(
        whole_lines[i][: len(whole_lines[i]) - len(part_lines[i])]
        for i in range(num)
        if whole_lines[i].strip()
    )

    if len(add) != 1:
        return

    return add.pop()

match_but_for_leading_whitespace(whole_lines=['    line1\n', '    line2\n'], part_lines=['line1\n', 'line2\n'])

Selected Statement: num = len(whole_lines)

Function Input:
whole_lines:     line1

    line2

part_lines: line1

line2


Variable Values Before Statement:
whole_lines:     line1

    line2


Value After Statement Execution: 2

Variable States During Runtime (line, value):
whole_lines: 1
    line1

    line2

part_lines: 1
line1

line2

num: 2
2
add: 9
{'    '}
18
set()
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def check_gitignore(git_root, io, ask=True):
    if not git_root:
        return

    try:
        repo = git.Repo(git_root)
        if repo.ignored(".aider"):
            return
    except git.exc.InvalidGitRepositoryError:
        pass

    pat = ".aider*"

    gitignore_file = Path(git_root) / ".gitignore"
    if gitignore_file.exists():
        content = io.read_text(gitignore_file)
        if content is None:
            return
        if pat in content.splitlines():
            return
    else:
        content = ""

    if ask and not io.confirm_ask(f"Add {pat} to .gitignore (recommended)?"):
        return

    if content and not content.endswith("\n"):
        content += "\n"
    content += pat + "\n"
    io.write_text(gitignore_file, content)

    io.tool_output(f"Added {pat} to .gitignore")

check_gitignore(git_root=PosixPath('/tmp/tmpcr1f5en7'), io={user_input_color=None, tool_output_color=None, tool_error_color=None, input=None, output=None, pretty=False, yes=True, input_history_file=None, chat_history_file=None, encoding='utf-8', dry_run=False, console=<console width=105 None>}, ask=True)

Selected Statement: gitignore_file = Path(git_root) / ".gitignore"

Function Input:
git_root: PosixPath('/tmp/tmpcr1f5en7')
io: {user_input_color=None, tool_output_color=None, tool_error_color=None, input=None, output=None, pretty=False, yes=True, input_history_file=None, chat_history_file=None, encoding='utf-8', dry_run=False, console=<console width=105 None>}
ask: True

Variable Values Before Statement:
git_root: PosixPath('/tmp/tmpcr1f5en7')

Value After Statement Execution: PosixPath('/tmp/tmpcr1f5en7/.gitignore')

Variable States During Runtime (line, value):
git_root: 1
PosixPath('/tmp/tmpcr1f5en7')
io: 1
{user_input_color=None, tool_output_color=None, tool_error_color=None, input=None, output=None, pretty=False, yes=True, input_history_file=None, chat_history_file=None, encoding='utf-8', dry_run=False, console=<console width=105 None>}
24
{user_input_color=None, tool_output_color=None, tool_error_color=None, input=None, output=None, pretty=False, yes=True, input_history_file=None, chat_history_file=None, encoding='utf-8', dry_run=False, console=<console width=105 None>, num_user_asks=1}
ask: 1
True
repo: 6
<git.repo.base.Repo '/tmp/tmpcr1f5en7/.git'>
pat: 12
'.aider*'
gitignore_file: 14
PosixPath('/tmp/tmpcr1f5en7/.gitignore')
content: 22
''
29
'.aider*\n'
Project Name: paul-gauthier+aider
Language: Python
Statement Type: API

Source Code:
def find_diffs(content):
    # We can always fence with triple-quotes, because all the udiff content
    # is prefixed with +/-/space.

    if not content.endswith("\n"):
        content = content + "\n"

    lines = content.splitlines(keepends=True)
    line_num = 0
    edits = []
    while line_num < len(lines):
        while line_num < len(lines):
            line = lines[line_num]
            if line.startswith("```diff"):
                line_num, these_edits = process_fenced_block(lines, line_num + 1)
                edits += these_edits
                break
            line_num += 1

    # For now, just take 1!
    # edits = edits[:1]

    return edits

find_diffs(content='\nSome text...\n\n```diff\n--- /dev/null\n+++ file.txt\n@@ ... @@\n-Original\n+Modified\n```\n')

Selected Statement: line_num, these_edits = process_fenced_block(lines, line_num + 1)

Function Input:
content: '\nSome text...\n\n```diff\n--- /dev/null\n+++ file.txt\n@@ ... @@\n-Original\n+Modified\n```\n'

Variable Values Before Statement:
lines: 

Some text...



```diff

--- /dev/null

+++ file.txt

@@ ... @@

-Original

+Modified

```


Value After Statement Execution: [('file.txt', ['-Original\n', '+Modified\n'])]

Variable States During Runtime (line, value):
content: 1
'\nSome text...\n\n```diff\n--- /dev/null\n+++ file.txt\n@@ ... @@\n-Original\n+Modified\n```\n'
lines: 8


Some text...



```diff

--- /dev/null

+++ file.txt

@@ ... @@

-Original

+Modified

```

line_num: 9
0
18
1
18
2
18
3
15
10
edits: 10
16
[('file.txt', ['-Original\n', '+Modified\n'])]
line: 13
'\n'
13
'Some text...\n'
13
'\n'
13
'```diff\n'
these_edits: 15
[('file.txt', ['-Original\n', '+Modified\n'])]
Project Name: GeoStat-Framework+welltestpy
Language: Python
Statement Type: API

Source Code:
def _addpoint(sol, i, distances, prec):
    """
    Try to add point i to a given solution-approach.

    gives all possibilties and a status about the solution:
        state = 0: possibilities found
        state = 1: no possibilities but no contradiction
        state = 2: solution-approach has a contradiction with point i
    """
    res = []

    # if i is already part of the solution return it
    if np.ndim(sol[i]) != 0:
        return [sol], 0

    # collect the points already present in the solution
    solpnts = []
    for n, m in enumerate(sol):
        if np.ndim(m) != 0:
            solpnts.append(n)

    # number of present points
    pntscount = len(solpnts)

    # try to add the point in all possible constellations
    for n in range(pntscount - 1):
        for m in range(n + 1, pntscount):
            tmppnt, state = _pntcoord(
                sol, i, solpnts[n], solpnts[m], distances, prec
            )

            # if possiblities are found, add them (at most 2! (think about))
            if state == 0:
                for pnt in tmppnt:
                    res.append(dcopy(sol))
                    res[-1][i] = pnt

            # if one possiblity or a contradiction is found, return the result
            if state != 1:
                return res, state

    # if the state remaind 1, return empty result and no contradiction
    return res, state

_addpoint(sol=[array([0., 0.]), array([3., 0.]), 0, 0], i=2, distances=array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]]), prec=0.1)

Selected Statement: for m in range(n + 1, pntscount):

Function Input:
sol: [array([0., 0.]), array([3., 0.]), 0, 0]
i: 2
distances: array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]])
prec: 0.1

Variable Values Before Statement:
pntscount: 2

Value After Statement Execution: 1

Variable States During Runtime (line, value):
sol: 1
[array([0., 0.]), array([3., 0.]), 0, 0]
i: 1
2
distances: 1
array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]])
prec: 1
0.1
res: 10
35
[[array([0., 0.]), array([3., 0.]), 0, 0]]
36
[[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), 0]]
35
[[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), 0], [array([0., 0.]), array([3., 0.]), 0, 0]]
36
[[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), 0], [array([0., 0.]), array([3., 0.]), array([ 3.5       , -1.93649167]), 0]]
solpnts: 17
20
[0]
20
[0, 1]
n: 18
0
18
1
18
2
18
3
26
0
m: 18
array([0., 0.])
18
array([3., 0.])
18
0
27
1
pntscount: 23
2
tmppnt: 28
[array([3.5       , 1.93649167]), array([ 3.5       , -1.93649167])]
state: 28
0
pnt: 34
array([3.5       , 1.93649167])
34
array([ 3.5       , -1.93649167])
Project Name: GeoStat-Framework+welltestpy
Language: Python
Statement Type: API

Source Code:
def _pntcoord(sol, i, n, m, distances, prec):
    """
    Generate coordinates for point i in constellation to points m and n.

    Check if these coordinates are valid with all other points in the solution.
    """
    tmppnt = []

    state = 1

    pntscount = len(sol)

    # if no distances known, return empty result and the unknown-state
    if distances[i, n] < -0.5 or distances[i, m] < -0.5:
        return tmppnt, state

    # if the Triangle inequality is not fullfilled give a contradiction
    if distances[i, n] + distances[i, m] < _dist(sol[n], sol[m]):
        state = 2
        return tmppnt, state

    # generate the affine rotation to bring the points in the right place
    g = _affinef(*_invtranmat(*_tranmat(sol[n], sol[m])))

    # generate the coordinates
    x = _xvalue(distances[i, n], distances[i, m], _dist(sol[n], sol[m]))
    y1, y2 = _yvalue(distances[i, n], distances[i, m], _dist(sol[n], sol[m]))

    # generate the possible positons
    pos1 = g(np.array([x, y1]))
    pos2 = g(np.array([x, y2]))

    valid1 = True
    valid2 = True

    # check if the possible positions are valid
    for k in range(pntscount):
        if np.ndim(sol[k]) != 0 and distances[i, k] > -0.5:
            valid1 &= abs(_dist(sol[k], pos1) - distances[i, k]) < prec
            valid2 &= abs(_dist(sol[k], pos2) - distances[i, k]) < prec

    # if any position is valid, add it to the result
    if valid1 or valid2:
        state = 0
        same = abs(y1 - y2) < prec / 4.0
        if valid1:
            tmppnt.append(dcopy(pos1))
        if valid2 and not same:
            tmppnt.append(dcopy(pos2))
    # if the positions are not valid, give a contradiction
    else:
        state = 2

    return tmppnt, state

_pntcoord(sol=[array([0., 0.]), array([3., 0.]), 0, 0], i=2, n=0, m=1, distances=array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]]), prec=0.1)

Selected Statement: tmppnt.append(dcopy(pos2))

Function Input:
sol: [array([0., 0.]), array([3., 0.]), 0, 0]
i: 2
n: 0
m: 1
distances: array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]])
prec: 0.1

Variable Values Before Statement:
pos2: array([ 3.5       , -1.93649167])

Value After Statement Execution: [array([3.5       , 1.93649167]), array([ 3.5       , -1.93649167])]

Variable States During Runtime (line, value):
sol: 1
[array([0., 0.]), array([3., 0.]), 0, 0]
i: 1
2
n: 1
0
m: 1
1
distances: 1
array([[ 0.,  3.,  4.,  1.],       [ 3.,  0.,  2.,  3.],       [ 4.,  2.,  0., -1.],       [ 1.,  3., -1.,  0.]])
prec: 1
0.1
tmppnt: 7
47
[array([3.5       , 1.93649167])]
49
[array([3.5       , 1.93649167]), array([ 3.5       , -1.93649167])]
state: 9
1
44
0
pntscount: 11
4
g: 23
<function _affinef.<locals>.func at 0x7f9d2f5dc9d0>
x: 26
3.5
y1: 27
1.9364916731037083
y2: 27
-1.9364916731037083
pos1: 30
array([3.5       , 1.93649167])
pos2: 31
array([ 3.5       , -1.93649167])
valid1: 33
True
valid2: 34
True
k: 37
0
37
1
37
2
37
3
same: 45
False
Project Name: GeoStat-Framework+welltestpy
Language: Python
Statement Type: API

Source Code:
def _tranmat(a, b):
    """
    Get the coefficents for the affine-linear function f(x)=Ax+s.

    Which fullfills that A is a rotation-matrix,
    f(a) = [0,0] and f(b) = [|b-a|,0].
    """
    A = np.zeros((2, 2))
    A[0, 0] = b[0] - a[0]
    A[1, 1] = b[0] - a[0]
    A[1, 0] = -(b[1] - a[1])
    A[0, 1] = +(b[1] - a[1])
    A /= _dist(a, b)
    s = -np.dot(A, a)
    return A, s

_tranmat(a=array([0., 0.]), b=array([3., 0.]))

Selected Statement: s = -np.dot(A, a)

Function Input:
a: array([0., 0.])
b: array([3., 0.])

Variable Values Before Statement:
A: array([[ 1.,  0.],       [-0.,  1.]])
a: array([0., 0.])

Value After Statement Execution: array([-0., -0.])

Variable States During Runtime (line, value):
a: 1
array([0., 0.])
b: 1
array([3., 0.])
A: 8
array([[0., 0.],       [0., 0.]])
9
array([[3., 0.],       [0., 0.]])
10
array([[3., 0.],       [0., 3.]])
11
array([[ 3.,  0.],       [-0.,  3.]])
13
array([[ 1.,  0.],       [-0.,  1.]])
s: 14
array([-0., -0.])
Project Name: GeoStat-Framework+welltestpy
Language: Python
Statement Type: API

Source Code:
def _yvalue(b, a, c):
    """
    Get the two possible y-values for the upper point of a triangle.

    where c is the length of the down side starting in the origin and
    lying on the x-axes, a is the distance of the unknown point to the origen
    and b is the distance of the unknown point to the righter given point
    """
    # ckeck flatness to eliminate numerical errors when the triangle is flat
    if a + b <= c or a + c <= b or b + c <= a:
        return 0.0, -0.0

    res = 2 * ((a * b) ** 2 + (a * c) ** 2 + (b * c) ** 2)
    res -= a ** 4 + b ** 4 + c ** 4
    # in case of numerical errors set res to 0 (hope you check validty before)
    res = max(res, 0.0)
    res = np.sqrt(res)
    res /= 2 * c
    return res, -res

_yvalue(b=4.0, a=2.0, c=3.0)

Selected Statement: res = np.sqrt(res)

Function Input:
b: 4.0
a: 2.0
c: 3.0

Variable Values Before Statement:
res: 135.0

Value After Statement Execution: 11.61895003862225

Variable States During Runtime (line, value):
b: 1
4.0
a: 1
2.0
c: 1
3.0
res: 13
488.0
14
135.0
17
11.61895003862225
18
1.9364916731037083
Project Name: GeoStat-Framework+welltestpy
Language: Python
Statement Type: API

Source Code:
def _solequal(sol1, sol2, prec):
    """
    Compare two different solutions with a given precicion.

    Return True if they equal.
    """
    res = True

    for sol_1, sol_2 in zip(sol1, sol2):
        if np.ndim(sol_1) != 0 and np.ndim(sol_2) != 0:
            res &= _dist(sol_1, sol_2) < prec
        elif np.ndim(sol_1) != 0 and np.ndim(sol_2) == 0:
            return False
        elif np.ndim(sol_1) == 0 and np.ndim(sol_2) != 0:
            return False

    return res

_solequal(sol1=[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([ 0.16666667, -0.9860133 ])], sol2=[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([0.16666667, 0.9860133 ])], prec=0.1)

Selected Statement: res &= _dist(sol_1, sol_2) < prec

Function Input:
sol1: [array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([ 0.16666667, -0.9860133 ])]
sol2: [array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([0.16666667, 0.9860133 ])]
prec: 0.1

Variable Values Before Statement:
sol_1: array([ 0.16666667, -0.9860133 ])
sol_2: array([0.16666667, 0.9860133 ])

Value After Statement Execution: False

Variable States During Runtime (line, value):
sol1: 1
[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([ 0.16666667, -0.9860133 ])]
sol2: 1
[array([0., 0.]), array([3., 0.]), array([3.5       , 1.93649167]), array([0.16666667, 0.9860133 ])]
prec: 1
0.1
res: 7
True
11
False
sol_1: 9
array([0., 0.])
9
array([3., 0.])
9
array([3.5       , 1.93649167])
9
array([ 0.16666667, -0.9860133 ])
sol_2: 9
array([0., 0.])
9
array([3., 0.])
9
array([3.5       , 1.93649167])
9
array([0.16666667, 0.9860133 ])
Project Name: martinblech+xmltodict
Language: Python
Statement Type: API

Source Code:
def _process_namespace(name, namespaces, ns_sep=':', attr_prefix='@'):
    if not namespaces:
        return name
    try:
        ns, name = name.rsplit(ns_sep, 1)
    except ValueError:
        pass
    else:
        ns_res = namespaces.get(ns.strip(attr_prefix))
        name = '{}{}{}{}'.format(
            attr_prefix if ns.startswith(attr_prefix) else '',
            ns_res, ns_sep, name) if ns_res else name
    return name

_process_namespace(name='http://defaultns.com/:root', namespaces={'http://defaultns.com/': '', 'http://a.com/': 'a', 'http://b.com/': 'b'}, ns_sep=':', attr_prefix='@')

Selected Statement: ns, name = name.rsplit(ns_sep, 1)

Function Input:
name: 'http://defaultns.com/:root'
namespaces: http://a.com/: a
http://b.com/: b
ns_sep: ':'
attr_prefix: '@'

Variable Values Before Statement:
ns_sep: ':'

Value After Statement Execution: 'http://defaultns.com/'

Variable States During Runtime (line, value):
name: 1
'http://defaultns.com/:root'
5
'root'
namespaces: 1
http://a.com/: a
http://b.com/: b
ns_sep: 1
':'
attr_prefix: 1
'@'
ns: 5
'http://defaultns.com/'
ns_res: 9
''
Project Name: arc53+DocsGPT
Language: Python
Statement Type: API

Source Code:
def response_error(code_status, message=None):
    payload = {'error': HTTP_STATUS_CODES.get(code_status, "something went wrong")}
    if message:
        payload['message'] = message
    response = jsonify(payload)
    response.status_code = code_status
    return response

response_error(code_status=400, message='Invalid input')

Selected Statement: response = jsonify(payload)

Function Input:
code_status: 400
message: 'Invalid input'

Variable Values Before Statement:
payload: error: Bad Request
message: Invalid input

Value After Statement Execution: <Response 50 bytes [200 OK]>

Variable States During Runtime (line, value):
code_status: 1
400
message: 1
'Invalid input'
payload: 2
error: Bad Request
4
error: Bad Request
message: Invalid input
response: 5
<Response 50 bytes [200 OK]>
6
<Response 50 bytes [400 BAD REQUEST]>