input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _to_python(self, value):
if isinstance(value, Proxy):
return value.get()
else:
return value |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __len__(self):
return len(self._collection) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __delitem__(self, key):
del self._collection[key] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __setitem__(self, key, value):
self._collection[key] = self._from_python(key, value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def pop(self, key, default=None):
value = self._collection.pop(key, default)
if isinstance(value, Proxy):
value = value.get()
return value |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, config_l, path=None, resolver=None):
super().__init__(path=path, resolver=resolver)
self._collection = []
for key, value in enumerate(config_l):
self._collection.append(self._from_python(str(key), value)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __getitem__(self, key):
value = self._collection[key]
if isinstance(key, slice):
slice_repr = ":".join(str("" if i is None else i) for i in (key.start, key.stop, key.step))
logger.debug("Get /%s[%s] config key", "/".join(self._path), slice_repr)
return [self._to_p... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __iter__(self):
for element in self._collection:
yield self._to_python(element) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def serialize(self):
s = []
for v in self:
if isinstance(v, BaseConfig):
v = v.serialize()
s.append(v)
return s |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, config_d, path=None, resolver=None):
super().__init__(path=path, resolver=resolver)
self._collection = {}
for key, value in config_d.items():
self._collection[key] = self._from_python(key, value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __getitem__(self, key):
logger.debug("Get /%s config key", "/".join(self._path + (key,)))
value = self._collection[key]
return self._to_python(value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get(self, key, default=None):
try:
value = self[key]
except KeyError:
value = self._to_python(default)
return value |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __iter__(self):
yield from self._collection |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def keys(self):
return self._collection.keys() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def values(self):
for value in self._collection.values():
yield self._to_python(value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def items(self):
for key, value in self._collection.items():
yield key, self._to_python(value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def clear(self):
return self._collection.clear() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setdefault(self, key, default=None):
return self._collection.setdefault(key, self._from_python(key, default)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def pop(self, key, default=None):
value = self._collection.pop(key, default)
return self._to_python(value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def popitem(self):
key, value = self._collection.popitem()
return key, self._to_python(value) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def copy(self):
return ConfigDict(self._collection.copy(), path=self._path, resolver=self._resolver) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def update(self, *args, **kwargs):
chain = []
for arg in args:
if isinstance(arg, dict):
iterator = arg.items()
else:
iterator = arg
chain = itertools.chain(chain, iterator)
if kwargs:
chain = itertools.chain(chain, ... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, p_str):
TodoBase.__init__(self, p_str)
self.attributes = {} |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_organizations(self):
legis = Organization('Minnesota Legislature', classification='legislature')
upper = Organization('Minnesota Senate', classification='upper',
parent_id=legis._id)
lower = Organization('Minnesota House of Representatives',
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_date(self, p_tag):
""" Given a date tag, return a date object. """
string = self.tag_value(p_tag)
result = None
try:
result = date_string_to_date(string) if string else None
except ValueError:
pass
return result |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def start_date(self):
""" Returns a date object of the todo's start date. """
return self.get_date(config().tag_start()) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def due_date(self):
""" Returns a date object of the todo's due date. """
return self.get_date(config().tag_due()) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def is_active(self):
"""
Returns True when the start date is today or in the past and the
task has not yet been completed.
"""
start = self.start_date()
return not self.is_completed() and (not start or start <= date.today()) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def is_overdue(self):
"""
Returns True when the due date is in the past and the task has not
yet been completed.
"""
return not self.is_completed() and self.days_till_due() < 0 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def days_till_due(self):
"""
Returns the number of days till the due date. Returns a negative number
of days when the due date is in the past.
Returns 0 when the task has no due date.
"""
due = self.due_date()
if due:
diff = due - date.today()
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def main(self):
UI.OpenDialog(
VBox(
Heading("This Is a Heading."),
Label("This is a Label."),
PushButton("&OK")
)
)
UI.UserInput()
UI.CloseDialog() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
df2 = df[['A']]
df2['A'] += 10
return df2.A, df.A |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
S1 = pd.Series(np.ones(n))
S2 = pd.Series(np.random.ranf(n))
df = pd.DataFrame({'A': S1, 'B': S2})
return df.A.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df['A'][df['B']].values |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = np.array([1., 2., 3.])
A[0] = np.nan
df = pd.DataFrame({'A': A})
B = df.A.fillna(5.0)
return B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = np.array([1., 2., 3.])
A[0] = np.nan
df = pd.DataFrame({'A': A})
df.A.fillna(5.0, inplace=True)
return df.A.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = np.array([1., 2., 3.])
A[0] = np.nan
df = pd.DataFrame({'A': A})
return df.A.mean() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = np.array([1., 2., 3.])
A[0] = 4.0
df = pd.DataFrame({'A': A})
return df.A.var() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = np.array([1., 2., 3.])
A[0] = 4.0
df = pd.DataFrame({'A': A})
return df.A.std() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n)})
df['B'] = df.A.map(lambda a: 2 * a)
return df.B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
df['B'] = df.A.map(lambda a: 2 * a)
return |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})
Ac = df.A.cumsum()
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})
df.A.fillna(5.0, inplace=True)
DF = df.A.fillna(5.0)
s = DF.sum()
m = df.A.mean()
v = df.A.var()
t = df.A.std()
Ac = df.A.cumsum()
re... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(0, n, 1, np.float64)})
return df.A.quantile(.25) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(0, n, 1, np.float32)})
df.A[0:100] = np.nan
df.A[200:331] = np.nan
return df.A.quantile(.25) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(0, n, 1, np.int32)})
return df.A.quantile(.25) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(A):
df = pd.DataFrame({'A': A})
return df.A.quantile(.25) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n)})
df.A[2] = 0
return df.A.nunique() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df = pq.read_table('example.parquet').to_pandas()
return df.four.nunique() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': ['aa', 'bb', 'aa', 'cc', 'cc']})
return df.A.nunique() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df = pq.read_table('example.parquet').to_pandas()
return df.two.nunique() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df = pq.read_table('example.parquet').to_pandas()
return (df.four.unique() == 3.0).sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df = pq.read_table('example.parquet').to_pandas()
return (df.two.unique() == 'foo').sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(0, n, 1, np.float64)})
return df.A.describe() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = StringArray(['ABC', 'BB', 'ADEF'])
df = pd.DataFrame({'A': A})
B = df.A.str.contains('AB*', regex=True)
return B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
A = StringArray(['ABC', 'BB', 'ADEF'])
df = pd.DataFrame({'A': A})
B = df.A.str.contains('BB', regex=False)
return B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.A.str.replace('AB*', 'EE', regex=True) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.A.str.replace('AB', 'EE', regex=False) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
B = df.A.str.replace('AB*', 'EE', regex=True)
return B |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.A.str.split() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
B = df.A.str.split(',')
df2 = pd.DataFrame({'B': B})
return df2[df2.B.str.len() > 1] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.A.iloc[0] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
B = df.A.str.split(',')
C = pd.to_numeric(B.str.get(1), errors='coerce')
return C |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
A = df.A.str.split(',')
return pd.Series(list(itertools.chain(*A))) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
A = df.A.str.split(',')
B = pd.Series(list(itertools.chain(*A)))
return B |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
B = pd.to_numeric(df.A, errors='coerce')
return B |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n), 'B': np.arange(n) + 1.0})
df1 = df[df.A > 5]
return len(df1.B) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n), 'B': np.random.ranf(n)})
Ac = df.A.rolling(3).sum()
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl_2(n):
df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)})
Ac = df.A.rolling(7).sum()
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})
df['moving average'] = df.A.rolling(window=5, center=True).mean()
return df['moving average'].sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})
Ac = df.A.rolling(3, center=True).apply(lambda a: a[0] + 2 * a[1] + a[2])
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)})
Ac = df.A.shift(1)
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)})
Ac = df.A.pct_change(1)
return Ac.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
C = df.B == 'two'
return C.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(df):
return df.B.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df1 = pd.DataFrame({'key1': np.arange(n), 'A': np.arange(n) + 1.0})
df2 = pd.DataFrame({'key2': n - np.arange(n), 'A': n + np.arange(n) + 1.0})
df3 = pd.concat([df1, df2])
return df3.A.sum() + df3.key2.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df1 = pq.read_table('example.parquet').to_pandas()
df2 = pq.read_table('example.parquet').to_pandas()
A3 = pd.concat([df1, df2])
return (A3.two == 'foo').sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(n):
df1 = pd.DataFrame({'key1': np.arange(n), 'A': np.arange(n) + 1.0})
df2 = pd.DataFrame({'key2': n - np.arange(n), 'A': n + np.arange(n) + 1.0})
A3 = pd.concat([df1.A, df2.A])
return A3.sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl():
df1 = pq.read_table('example.parquet').to_pandas()
df2 = pq.read_table('example.parquet').to_pandas()
A3 = pd.concat([df1.two, df2.two])
return (A3 == 'foo').sum() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(nsyms):
max_num_days = 100
all_res = 0.0
for i in sdc.prange(nsyms):
s_open = 20 * np.ones(max_num_days)
s_low = 28 * np.ones(max_num_days)
s_close = 19 * np.ones(max_num_days)
df = pd.DataFrame({'Open': s_... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_impl(A, B):
df = pd.DataFrame({'A': A, 'B': B})
df2 = df.groupby('A', as_index=False)['B'].sum()
# TODO: fix handling of df setitem to force match of array dists
# probably with a new node that is appended to the end of basic block
# df2['C'] = np.ful... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_both():
"""Both f and g."""
p = are.above(2) & are.below(4)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, True, False, False] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def AddResultsOptions(parser):
group = optparse.OptionGroup(parser, 'Results options')
group.add_option('--chartjson', action='store_true',
help='Output Chart JSON. Ignores --output-format.')
group.add_option('--output-format', action='append', dest='output_formats',
choices... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_either():
"""Either f or g."""
p = are.above(3) | are.below(2)
ps = [p(x) for x in range(1, 6)]
assert ps == [True, False, False, True, True] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def ProcessCommandLineArgs(parser, args):
# TODO(ariblue): Delete this flag entirely at some future data, when the
# existence of such a flag has been long forgotten.
if args.output_file:
parser.error('This flag is deprecated. Please use --output-dir instead.')
try:
os.makedirs(args.output_dir)
excep... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_equal_to():
"""Equal to y."""
p = are.equal_to(1)
ps = [p(x) for x in range(1, 6)]
assert ps == [True, False, False, False, False] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _GetOutputStream(output_format, output_dir):
assert output_format in _OUTPUT_FORMAT_CHOICES, 'Must specify a valid format.'
assert output_format not in ('gtest', 'none'), (
'Cannot set stream for \'gtest\' or \'none\' output formats.')
if output_format == 'buildbot':
return sys.stdout
assert out... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_above():
"""Greater than y."""
p = are.above(3)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, False, True, True] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _GetProgressReporter(output_skipped_tests_summary, suppress_gtest_report):
if suppress_gtest_report:
return progress_reporter.ProgressReporter()
return gtest_progress_reporter.GTestProgressReporter(
sys.stdout, output_skipped_tests_summary=output_skipped_tests_summary) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_below():
"""Less than y."""
p = are.not_below(4)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, False, True, True] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_above_or_equal_to():
"""Greater than or equal to y."""
p = are.above_or_equal_to(4)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, False, True, True] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_below_or_equal_to():
"""Less than or equal to y."""
p = are.not_below_or_equal_to(3)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, False, True, True] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_strictly_between():
"""Greater than y and less than z."""
p = are.strictly_between(2, 4)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, True, False, False] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_between():
"""Greater than or equal to y and less than z."""
p = are.between(3, 4)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, True, False, False] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test_between_or_equal_to():
"""Greater than or equal to y and less than or equal to z."""
p = are.between_or_equal_to(3, 3)
ps = [p(x) for x in range(1, 6)]
assert ps == [False, False, True, False, False] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.