commit
stringlengths 40
40
| old_file
stringlengths 4
118
| new_file
stringlengths 4
118
| old_contents
stringlengths 10
2.94k
| new_contents
stringlengths 21
3.18k
| subject
stringlengths 16
444
| message
stringlengths 17
2.63k
| lang
stringclasses 1
value | license
stringclasses 13
values | repos
stringlengths 5
43k
| ndiff
stringlengths 51
3.32k
| instruction
stringlengths 16
444
| content
stringlengths 133
4.32k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
0177066012b3373753cba8baf86f00a365d7147b | findaconf/tests/config.py | findaconf/tests/config.py |
from decouple import config
from findaconf.tests.fake_data import fake_conference, seed
def set_app(app, db=False):
unset_app(db)
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
if db:
app.config['SQLALCHEMY_DATABASE_URI'] = config(
'DATABASE_URL_TEST',
default='sqlite:///' + app.config['BASEDIR'].child('findaconf',
'tests',
'tests.db')
)
test_app = app.test_client()
if db:
db.create_all()
seed(app, db)
[db.session.add(fake_conference(db)) for i in range(1, 43)]
db.session.commit()
return test_app
def unset_app(db=False):
if db:
db.session.remove()
db.drop_all()
|
from decouple import config
from findaconf.tests.fake_data import fake_conference, seed
def set_app(app, db=False):
# set test vars
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
# set test db
if db:
app.config['SQLALCHEMY_DATABASE_URI'] = config(
'DATABASE_URL_TEST',
default='sqlite:///' + app.config['BASEDIR'].child('findaconf',
'tests',
'tests.db')
)
# create test app
test_app = app.test_client()
# create and feed db tables
if db:
# start from a clean db
db.session.remove()
db.drop_all()
# create tables and feed them
db.create_all()
seed(app, db)
[db.session.add(fake_conference(db)) for i in range(1, 43)]
db.session.commit()
# return test app
return test_app
def unset_app(db=False):
if db:
db.session.remove()
db.drop_all()
| Fix bug that used dev db instead of test db | Fix bug that used dev db instead of test db
| Python | mit | cuducos/findaconf,koorukuroo/findaconf,cuducos/findaconf,koorukuroo/findaconf,koorukuroo/findaconf,cuducos/findaconf |
from decouple import config
from findaconf.tests.fake_data import fake_conference, seed
def set_app(app, db=False):
- unset_app(db)
+
+ # set test vars
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
+
+ # set test db
if db:
app.config['SQLALCHEMY_DATABASE_URI'] = config(
'DATABASE_URL_TEST',
default='sqlite:///' + app.config['BASEDIR'].child('findaconf',
'tests',
'tests.db')
)
+
+ # create test app
test_app = app.test_client()
+
+ # create and feed db tables
if db:
+
+ # start from a clean db
+ db.session.remove()
+ db.drop_all()
+
+ # create tables and feed them
db.create_all()
seed(app, db)
[db.session.add(fake_conference(db)) for i in range(1, 43)]
db.session.commit()
+
+ # return test app
return test_app
def unset_app(db=False):
if db:
db.session.remove()
db.drop_all()
| Fix bug that used dev db instead of test db | ## Code Before:
from decouple import config
from findaconf.tests.fake_data import fake_conference, seed
def set_app(app, db=False):
unset_app(db)
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
if db:
app.config['SQLALCHEMY_DATABASE_URI'] = config(
'DATABASE_URL_TEST',
default='sqlite:///' + app.config['BASEDIR'].child('findaconf',
'tests',
'tests.db')
)
test_app = app.test_client()
if db:
db.create_all()
seed(app, db)
[db.session.add(fake_conference(db)) for i in range(1, 43)]
db.session.commit()
return test_app
def unset_app(db=False):
if db:
db.session.remove()
db.drop_all()
## Instruction:
Fix bug that used dev db instead of test db
## Code After:
from decouple import config
from findaconf.tests.fake_data import fake_conference, seed
def set_app(app, db=False):
# set test vars
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
# set test db
if db:
app.config['SQLALCHEMY_DATABASE_URI'] = config(
'DATABASE_URL_TEST',
default='sqlite:///' + app.config['BASEDIR'].child('findaconf',
'tests',
'tests.db')
)
# create test app
test_app = app.test_client()
# create and feed db tables
if db:
# start from a clean db
db.session.remove()
db.drop_all()
# create tables and feed them
db.create_all()
seed(app, db)
[db.session.add(fake_conference(db)) for i in range(1, 43)]
db.session.commit()
# return test app
return test_app
def unset_app(db=False):
if db:
db.session.remove()
db.drop_all()
|
592df76f77c3450ba56b249ab0cd4404c8dd99e2 | bundle_graph.py | bundle_graph.py |
from random import randint
class Student:
def __init__(self, id):
self.id = id
self.papers = []
def assign_paper(self, paper):
self.papers.append(paper)
def __str__(self):
return str(self.id) + ": " + str(self.papers)
class Paper:
def __init__(self, id):
self.id = id
def create_bundle_graph(n, k):
students = [Student(x + 1) for x in range(n)]
papers = [Paper(x + 1) for x in range(n)]
while True:
for i in range(k):
inavai_pap = set()
for j in range(len(students)):
paper = None
while True:
paper = papers[randint(0, len(papers) - 1)]
if paper.id == students[j].id:
continue
if paper.id not in inavai_pap and paper.id not in students[j].papers:
inavai_pap.add(paper.id)
break
students[j].assign_paper(paper.id)
# make sure not more than one paper is assigned to every two people
success = True
for i in range(n):
for j in range(i + 1, n):
cnt = 0
for l in range(k):
if students[i].papers[l] == students[j].papers[l]:
cnt = cnt + 1
if cnt >= 2:
success = False
break
if not success:
break
if not success:
break
if success:
break
return students
|
from random import randint
class Student:
def __init__(self, id):
self.id = id
self.papers = []
def assign_paper(self, paper):
self.papers.append(paper)
def __str__(self):
return str(self.id) + ": " + str(self.papers)
class Paper:
def __init__(self, id):
self.id = id
def create_bundle_graph(n, k):
students = [Student(x + 1) for x in range(n)]
papers = [Paper(x + 1) for x in range(n)]
while True:
for i in range(k):
inavai_pap = set()
for j in range(len(students)):
paper = None
while True:
paper = papers[randint(0, len(papers) - 1)]
if paper.id == students[j].id:
continue
if paper.id not in inavai_pap and paper.id not in students[j].papers:
inavai_pap.add(paper.id)
break
students[j].assign_paper(paper.id)
# make sure not more than one paper is assigned to every two people
success = True
for i in range(n):
for j in range(i + 1, n):
cnt = len(set(students[i].papers).intersection(set(students[j].papers)))
if cnt >= 2:
success = False
break
if not success:
break
if success:
break
return students
| Update validation check for paper bundles. | Update validation check for paper bundles.
| Python | mit | haoyueping/peer-grading-for-MOOCs |
from random import randint
class Student:
def __init__(self, id):
self.id = id
self.papers = []
def assign_paper(self, paper):
self.papers.append(paper)
def __str__(self):
return str(self.id) + ": " + str(self.papers)
class Paper:
def __init__(self, id):
self.id = id
def create_bundle_graph(n, k):
students = [Student(x + 1) for x in range(n)]
papers = [Paper(x + 1) for x in range(n)]
while True:
for i in range(k):
inavai_pap = set()
for j in range(len(students)):
paper = None
while True:
paper = papers[randint(0, len(papers) - 1)]
if paper.id == students[j].id:
continue
if paper.id not in inavai_pap and paper.id not in students[j].papers:
inavai_pap.add(paper.id)
break
students[j].assign_paper(paper.id)
# make sure not more than one paper is assigned to every two people
success = True
for i in range(n):
for j in range(i + 1, n):
+ cnt = len(set(students[i].papers).intersection(set(students[j].papers)))
- cnt = 0
- for l in range(k):
- if students[i].papers[l] == students[j].papers[l]:
- cnt = cnt + 1
- if cnt >= 2:
+ if cnt >= 2:
- success = False
+ success = False
- break
- if not success:
break
if not success:
break
if success:
break
return students
| Update validation check for paper bundles. | ## Code Before:
from random import randint
class Student:
def __init__(self, id):
self.id = id
self.papers = []
def assign_paper(self, paper):
self.papers.append(paper)
def __str__(self):
return str(self.id) + ": " + str(self.papers)
class Paper:
def __init__(self, id):
self.id = id
def create_bundle_graph(n, k):
students = [Student(x + 1) for x in range(n)]
papers = [Paper(x + 1) for x in range(n)]
while True:
for i in range(k):
inavai_pap = set()
for j in range(len(students)):
paper = None
while True:
paper = papers[randint(0, len(papers) - 1)]
if paper.id == students[j].id:
continue
if paper.id not in inavai_pap and paper.id not in students[j].papers:
inavai_pap.add(paper.id)
break
students[j].assign_paper(paper.id)
# make sure not more than one paper is assigned to every two people
success = True
for i in range(n):
for j in range(i + 1, n):
cnt = 0
for l in range(k):
if students[i].papers[l] == students[j].papers[l]:
cnt = cnt + 1
if cnt >= 2:
success = False
break
if not success:
break
if not success:
break
if success:
break
return students
## Instruction:
Update validation check for paper bundles.
## Code After:
from random import randint
class Student:
def __init__(self, id):
self.id = id
self.papers = []
def assign_paper(self, paper):
self.papers.append(paper)
def __str__(self):
return str(self.id) + ": " + str(self.papers)
class Paper:
def __init__(self, id):
self.id = id
def create_bundle_graph(n, k):
students = [Student(x + 1) for x in range(n)]
papers = [Paper(x + 1) for x in range(n)]
while True:
for i in range(k):
inavai_pap = set()
for j in range(len(students)):
paper = None
while True:
paper = papers[randint(0, len(papers) - 1)]
if paper.id == students[j].id:
continue
if paper.id not in inavai_pap and paper.id not in students[j].papers:
inavai_pap.add(paper.id)
break
students[j].assign_paper(paper.id)
# make sure not more than one paper is assigned to every two people
success = True
for i in range(n):
for j in range(i + 1, n):
cnt = len(set(students[i].papers).intersection(set(students[j].papers)))
if cnt >= 2:
success = False
break
if not success:
break
if success:
break
return students
|