function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_concat_small(self, size):
return self.basic_concat_test(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_concat_large(self, size):
return self.basic_concat_test(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
self.assertEquals(len(t), size * 5)
self.failUnless(5 in t)
self.failIf((1, 2, 3, 4, 5) in t)
self.failIf(0 in t) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_hash(self, size):
t1 = (0,) * size
h1 = hash(t1)
del t1
t2 = (0,) * (size + 1)
self.failIf(h1 == hash(t2)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_index_and_slice(self, size):
t = (None,) * size
self.assertEquals(len(t), size)
self.assertEquals(t[-1], None)
self.assertEquals(t[5], None)
self.assertEquals(t[size - 1], None)
self.assertRaises(IndexError, operator.getitem, t, size)
self.assertEq... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_repeat(self, size):
t = ('',) * size
self.assertEquals(len(t), size)
t = t * 2
self.assertEquals(len(t), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat_small(self, size):
return self.basic_test_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat_large(self, size):
return self.basic_test_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat_large_2(self, size):
return self.basic_test_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_from_2G_generator(self, size):
try:
t = tuple(xrange(size))
except MemoryError:
pass # acceptable on 32-bit
else:
count = 0
for item in t:
self.assertEquals(item, count)
count += 1
self... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_from_almost_2G_generator(self, size):
try:
t = tuple(xrange(size))
count = 0
for item in t:
self.assertEquals(item, count)
count += 1
self.assertEquals(count, size)
except MemoryError:
pass # ac... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_repr(self, size):
t = (0,) * size
s = repr(t)
# The repr of a tuple of 0's is exactly three times the tuple length.
self.assertEquals(len(s), size * 3)
self.assertEquals(s[:5], '(0, 0')
self.assertEquals(s[-5:], '0, 0)')
self.assertEquals(s.c... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_small(self, size):
return self.basic_test_repr(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_large(self, size):
return self.basic_test_repr(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_compare(self, size):
l1 = [u''] * size
l2 = [u''] * size
self.failUnless(l1 == l2)
del l2
l2 = [u''] * (size + 1)
self.failIf(l1 == l2)
del l2
l2 = [2] * size
self.failIf(l1 == l2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_concat(self, size):
l = [[]] * size
self.assertEquals(len(l), size)
l = l + l
self.assertEquals(len(l), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_concat_small(self, size):
return self.basic_test_concat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_concat_large(self, size):
return self.basic_test_concat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_inplace_concat(self, size):
l = [sys.stdout] * size
l += l
self.assertEquals(len(l), size * 2)
self.failUnless(l[0] is l[-1])
self.failUnless(l[size - 1] is l[size + 1]) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_inplace_concat_small(self, size):
return self.basic_test_inplace_concat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_inplace_concat_large(self, size):
return self.basic_test_inplace_concat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEquals(len(l), size * 5)
self.failUnless(5 in l)
self.failIf([1, 2, 3, 4, 5] in l)
self.failIf(0 in l) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_hash(self, size):
l = [0] * size
self.failUnlessRaises(TypeError, hash, l) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_index_and_slice(self, size):
l = [None] * size
self.assertEquals(len(l), size)
self.assertEquals(l[-1], None)
self.assertEquals(l[5], None)
self.assertEquals(l[size - 1], None)
self.assertRaises(IndexError, operator.getitem, l, size)
self.assertEqu... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_repeat(self, size):
l = [] * size
self.failIf(l)
l = [''] * size
self.assertEquals(len(l), size)
l = l * 2
self.assertEquals(len(l), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat_small(self, size):
return self.basic_test_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat_large(self, size):
return self.basic_test_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_inplace_repeat(self, size):
l = ['']
l *= size
self.assertEquals(len(l), size)
self.failUnless(l[0] is l[-1])
del l | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_inplace_repeat_small(self, size):
return self.basic_test_inplace_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_inplace_repeat_large(self, size):
return self.basic_test_inplace_repeat(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_repr(self, size):
l = [0] * size
s = repr(l)
# The repr of a list of 0's is exactly three times the list length.
self.assertEquals(len(s), size * 3)
self.assertEquals(s[:5], '[0, 0')
self.assertEquals(s[-5:], '0, 0]')
self.assertEquals(s.coun... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_small(self, size):
return self.basic_test_repr(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_large(self, size):
return self.basic_test_repr(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_append(self, size):
l = [object()] * size
l.append(object())
self.assertEquals(len(l), size+1)
self.failUnless(l[-3] is l[-2])
self.failIf(l[-2] is l[-1]) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_count(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEquals(l.count(1), size)
self.assertEquals(l.count("1"), 0) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_test_extend(self, size):
l = [file] * size
l.extend(l)
self.assertEquals(len(l), size * 2)
self.failUnless(l[0] is l[-1])
self.failUnless(l[size - 1] is l[size + 1]) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_extend_small(self, size):
return self.basic_test_extend(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_extend_large(self, size):
return self.basic_test_extend(size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_index(self, size):
l = [1L, 2L, 3L, 4L, 5L] * size
size *= 5
self.assertEquals(l.index(1), 0)
self.assertEquals(l.index(5, size - 5), size - 1)
self.assertEquals(l.index(5, size - 5, size), size - 1)
self.assertRaises(ValueError, l.index, 1, size - 4, size)... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_insert(self, size):
l = [1.0] * size
l.insert(size - 1, "A")
size += 1
self.assertEquals(len(l), size)
self.assertEquals(l[-3:], [1.0, "A", 1.0]) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_pop(self, size):
l = [u"a", u"b", u"c", u"d", u"e"] * size
size *= 5
self.assertEquals(len(l), size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_remove(self, size):
l = [10] * size
self.assertEquals(len(l), size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_reverse(self, size):
l = [1, 2, 3, 4, 5] * size
l.reverse()
self.assertEquals(len(l), size * 5)
self.assertEquals(l[-5:], [5, 4, 3, 2, 1])
self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_sort(self, size):
l = [1, 2, 3, 4, 5] * size
l.sort()
self.assertEquals(len(l), size * 5)
self.assertEquals(l.count(1), size)
self.assertEquals(l[:10], [1] * 10)
self.assertEquals(l[-10:], [5] * 10) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat(self, size):
try:
with test_support._check_py3k_warnings():
b = buffer("AAAA")*size
except MemoryError:
pass # acceptable on 32-bit
else:
count = 0
for c in b:
self.assertEquals(c, 'A')
... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_main():
test_support.run_unittest(StrTest, TupleTest, ListTest, BufferTest) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(762, 302)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setMargin(0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.splitter = QtGui.Q... | robertsj/poropy | [
6,
12,
6,
3,
1324137820
] |
def __getitem__(cls, item):
return op_chain_root.__getitem__(item) | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def abs(cls):
""" Element-wize absolute value op.
"""
return op_chain_root.abs | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def identity(cls):
""" A no-op.
"""
return op_chain_root.identity | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def argsort(cls):
""" Numpy style argsort.
"""
return op_chain_root.argsort | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def sum(cls):
""" Numpy style sum.
"""
return op_chain_root.sum | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def max(cls):
""" Numpy style max.
"""
return op_chain_root.max | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def min(cls):
""" Numpy style min.
"""
return op_chain_root.min | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def mean(cls):
""" Numpy style mean.
"""
return op_chain_root.mean | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def sample(cls):
""" Numpy style sample.
"""
return op_chain_root.sample | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def hclust(cls):
""" Hierarchial clustering op.
"""
return op_chain_root.hclust | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __init__( # pylint: disable=too-many-arguments
self,
values,
base_values=None,
data=None,
display_data=None,
instance_names=None,
feature_names=None,
output_names=None,
output_indexes=None,
lower_bounds=None,
upper_bounds=None,
... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def shape(self):
""" Compute the shape over potentially complex data nesting.
"""
return _compute_shape(self._s.values) | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def values(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def values(self, new_values):
self._s.values = new_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def base_values(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.base_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def base_values(self, new_base_values):
self._s.base_values = new_base_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def data(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.data | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def data(self, new_data):
self._s.data = new_data | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def display_data(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.display_data | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def display_data(self, new_display_data):
if issubclass(type(new_display_data), pd.DataFrame):
new_display_data = new_display_data.values
self._s.display_data = new_display_data | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def instance_names(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.instance_names | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def output_names(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.output_names | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def output_names(self, new_output_names):
self._s.output_names = new_output_names | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def output_indexes(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.output_indexes | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def feature_names(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.feature_names | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def feature_names(self, new_feature_names):
self._s.feature_names = new_feature_names | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def lower_bounds(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.lower_bounds | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def upper_bounds(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.upper_bounds | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def error_std(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.error_std | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def main_effects(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.main_effects | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def main_effects(self, new_main_effects):
self._s.main_effects = new_main_effects | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def hierarchical_values(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.hierarchical_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def hierarchical_values(self, new_hierarchical_values):
self._s.hierarchical_values = new_hierarchical_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def clustering(self):
""" Pass-through from the underlying slicer object.
"""
return self._s.clustering | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def clustering(self, new_clustering):
self._s.clustering = new_clustering | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __repr__(self):
""" Display some basic printable info, but not everything.
"""
out = ".values =\n"+self.values.__repr__()
if self.base_values is not None:
out += "\n\n.base_values =\n"+self.base_values.__repr__()
if self.data is not None:
out += "\n\n.... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __len__(self):
return self.shape[0] | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def _apply_binary_operator(self, other, binary_op, op_name):
new_exp = self.__copy__()
new_exp.op_history = copy.copy(self.op_history)
new_exp.op_history.append({
"name": op_name,
"args": (other,),
"prev_shape": self.shape
})
if isinstance(othe... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __radd__(self, other):
return self._apply_binary_operator(other, operator.add, "__add__") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __rsub__(self, other):
return self._apply_binary_operator(other, operator.sub, "__sub__") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __rmul__(self, other):
return self._apply_binary_operator(other, operator.mul, "__mul__") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def _numpy_func(self, fname, **kwargs):
""" Apply a numpy-style function to this Explanation.
"""
new_self = copy.copy(self)
axis = kwargs.get("axis", None)
# collapse the slicer to right shape
if axis == 0:
new_self = new_self[0]
elif axis == 1:
... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def max(self, axis):
""" Numpy-style mean function.
"""
return self._numpy_func("max", axis=axis) | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def sum(self, axis=None, grouping=None):
""" Numpy-style mean function.
"""
if grouping is None:
return self._numpy_func("sum", axis=axis)
elif axis == 1 or len(self.shape) == 1:
return group_features(self, grouping)
else:
raise Exception("Only... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def abs(self):
return self._numpy_func("abs") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def identity(self):
return self | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def argsort(self):
return self._numpy_func("argsort") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def flip(self):
return self._numpy_func("flip") | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def sample(self, max_samples, replace=False, random_state=0):
""" Randomly samples the instances (rows) of the Explanation object.
Parameters
----------
max_samples : int
The number of rows to sample. Note that if replace=False then less than
fewer than max_sampl... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def _use_data_as_feature_names(self):
new_values = {}
for i in range(len(self.values)):
for s,v in zip(self.data[i], self.values[i]):
if s not in new_values:
new_values[s] = []
new_values[s].append(v)
return new_values | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def group_features(shap_values, feature_map):
# TODOsomeday: support and deal with clusterings
reverse_map = {}
for name in feature_map:
reverse_map[feature_map[name]] = reverse_map.get(feature_map[name], []) + [name]
curr_names = shap_values.feature_names
sv_new = copy.deepcopy(shap_values... | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def is_1d(val):
return not (isinstance(val[0], list) or isinstance(val[0], np.ndarray)) | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
def __init__(self, percentile):
self.percentile = percentile | slundberg/shap | [
18731,
2825,
18731,
1626,
1479842228
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.