本文整理汇总了Python中operator.gt方法的典型用法代码示例。如果您正苦于以下问题:Python operator.gt方法的具体用法?Python operator.gt怎么用?Python operator.gt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块operator的用法示例。
在下文中一共展示了operator.gt方法的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dedup_with_blocking_vs_sortedneighbourhood
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_dedup_with_blocking_vs_sortedneighbourhood(self, window):
indexers = [
NeighbourhoodBlock(
['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
NeighbourhoodBlock(
left_on=['var_arange', 'var_block10'],
right_on=['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
SortedNeighbourhood(
'var_arange', block_on='var_block10', window=window),
]
self.assert_index_comparisons(eq, indexers, self.a)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:18,
示例2: test_link_with_blocking_vs_sortedneighbourhood
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_link_with_blocking_vs_sortedneighbourhood(self, window):
indexers = [
NeighbourhoodBlock(
['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
NeighbourhoodBlock(
left_on=['var_arange', 'var_block10'],
right_on=['var_arange', 'var_block10'],
max_nulls=1,
windows=[window, 1]),
SortedNeighbourhood(
'var_arange', block_on='var_block10', window=window),
]
self.assert_index_comparisons(eq, indexers, self.a, self.b)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a,
self.incomplete_b)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:19,
示例3: test_richcompare_crash
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_richcompare_crash(self):
# gh-4613
import operator as op
# dummy class where __array__ throws exception
class Foo(object):
__array_priority__ = 1002
def __array__(self, *args, **kwargs):
raise Exception()
rhs = Foo()
lhs = np.array(1)
for f in [op.lt, op.le, op.gt, op.ge]:
if sys.version_info[0] >= 3:
assert_raises(TypeError, f, lhs, rhs)
elif not sys.py3kwarning:
# With -3 switch in python 2, DeprecationWarning is raised
# which we are not interested in
f(lhs, rhs)
assert_(not op.eq(lhs, rhs))
assert_(op.ne(lhs, rhs))
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,
示例4: test_compare_frame
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_compare_frame(self):
# GH#24282 check that Categorical.__cmp__(DataFrame) defers to frame
data = ["a", "b", 2, "a"]
cat = Categorical(data)
df = DataFrame(cat)
for op in [operator.eq, operator.ne, operator.ge,
operator.gt, operator.le, operator.lt]:
with pytest.raises(ValueError):
# alignment raises unless we transpose
op(cat, df)
result = cat == df.T
expected = DataFrame([[True, True, True, True]])
tm.assert_frame_equal(result, expected)
result = cat[::-1] != df.T
expected = DataFrame([[False, True, True, False]])
tm.assert_frame_equal(result, expected)
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,
示例5: test_comparison_flex_basic
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_comparison_flex_basic(self):
left = pd.Series(np.random.randn(10))
right = pd.Series(np.random.randn(10))
tm.assert_series_equal(left.eq(right), left == right)
tm.assert_series_equal(left.ne(right), left != right)
tm.assert_series_equal(left.le(right), left < right)
tm.assert_series_equal(left.lt(right), left <= right)
tm.assert_series_equal(left.gt(right), left > right)
tm.assert_series_equal(left.ge(right), left >= right)
# axis
for axis in [0, None, 'index']:
tm.assert_series_equal(left.eq(right, axis=axis), left == right)
tm.assert_series_equal(left.ne(right, axis=axis), left != right)
tm.assert_series_equal(left.le(right, axis=axis), left < right)
tm.assert_series_equal(left.lt(right, axis=axis), left <= right)
tm.assert_series_equal(left.gt(right, axis=axis), left > right)
tm.assert_series_equal(left.ge(right, axis=axis), left >= right)
#
msg = 'No axis named 1 for object type'
for op in ['eq', 'ne', 'le', 'le', 'gt', 'ge']:
with pytest.raises(ValueError, match=msg):
getattr(left, op)(right, axis=1)
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,
示例6: from_dict
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def from_dict(cls, cond_config, get_logs=None):
# provided to help keep track of arguments
constructor_config = {
"decay_factor": 0.98,
"thresh": 0,
"start_val": 1,
"end_val": 0,
"window_size": 1,
"min_wait": 1,
"max_wait": 10000,
"operator": operator.gt,
"metric": "sparse", # dense, length
}
if "operator" in cond_config:
cond_config["operator"] = getattr(operator, cond_config["operator"])
trimmed_config = {k: v for k, v in cond_config.items() if k in constructor_config}
constructor_config.update(trimmed_config)
return cls(**constructor_config, get_logs=get_logs)
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:21,
示例7: is_sorted
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def is_sorted(iterable, key=None, reverse=False, distinct=False):
if key is None:
key = identity
if reverse:
if distinct:
if isinstance(iterable, range) and iterable.step < 0:
return True
op = operator.gt
else:
op = operator.ge
else:
if distinct:
if isinstance(iterable, range) and iterable.step > 0:
return True
if isinstance(iterable, SortedFrozenSet):
return True
op = operator.lt
else:
op = operator.le
return all(op(a, b) for a, b in pairwise(map(key, iterable)))
开发者ID:sixty-north,项目名称:segpy,代码行数:22,
示例8: get_op
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
'
'>': operator.gt,
'<=': operator.le,
'>=': operator.ge,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
开发者ID:jpush,项目名称:jbox,代码行数:20,
示例9: _filter_range_index
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def _filter_range_index(pd_range_index, min_val, min_val_close, max_val, max_val_close):
if is_pd_range_empty(pd_range_index):
return pd_range_index
raw_min, raw_max, step = pd_range_index.min(), pd_range_index.max(), _get_range_index_step(pd_range_index)
# seek min range
greater_func = operator.gt if min_val_close else operator.ge
actual_min = raw_min
while greater_func(min_val, actual_min):
actual_min += abs(step)
if step < 0:
actual_min += step # on the right side
# seek max range
less_func = operator.lt if max_val_close else operator.le
actual_max = raw_max
while less_func(max_val, actual_max):
actual_max -= abs(step)
if step > 0:
actual_max += step # on the right side
if step > 0:
return pd.RangeIndex(actual_min, actual_max, step)
return pd.RangeIndex(actual_max, actual_min, step)
开发者ID:mars-project,项目名称:mars,代码行数:27,
示例10: testBigComplexComparisons
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def testBigComplexComparisons(self):
self.assertFalse(F(10**23) == complex(10**23))
self.assertRaises(TypeError, operator.gt, F(10**23), complex(10**23))
self.assertRaises(TypeError, operator.le, F(10**23), complex(10**23))
x = F(3, 8)
z = complex(0.375, 0.0)
w = complex(0.375, 0.2)
self.assertTrue(x == z)
self.assertFalse(x != z)
self.assertFalse(x == w)
self.assertTrue(x != w)
for op in operator.lt, operator.le, operator.gt, operator.ge:
self.assertRaises(TypeError, op, x, z)
self.assertRaises(TypeError, op, z, x)
self.assertRaises(TypeError, op, x, w)
self.assertRaises(TypeError, op, w, x)
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,
示例11: test_dicts
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_dicts(self):
# Verify that __eq__ and __ne__ work for dicts even if the keys and
# values don't support anything other than __eq__ and __ne__ (and
# __hash__). Complex numbers are a fine example of that.
import random
imag1a = {}
for i in range(50):
imag1a[random.randrange(100)*1j] = random.randrange(100)*1j
items = imag1a.items()
random.shuffle(items)
imag1b = {}
for k, v in items:
imag1b[k] = v
imag2 = imag1b.copy()
imag2[k] = v + 1.0
self.assertTrue(imag1a == imag1a)
self.assertTrue(imag1a == imag1b)
self.assertTrue(imag2 == imag2)
self.assertTrue(imag1a != imag2)
for opname in ("lt", "le", "gt", "ge"):
for op in opmap[opname]:
self.assertRaises(TypeError, op, imag1a, imag2)
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,
示例12: test_richcompare_crash
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_richcompare_crash(self):
# gh-4613
import operator as op
# dummy class where __array__ throws exception
class Foo(object):
__array_priority__ = 1002
def __array__(self,*args,**kwargs):
raise Exception()
rhs = Foo()
lhs = np.array(1)
for f in [op.lt, op.le, op.gt, op.ge]:
if sys.version_info[0] >= 3:
assert_raises(TypeError, f, lhs, rhs)
else:
f(lhs, rhs)
assert_(not op.eq(lhs, rhs))
assert_(op.ne(lhs, rhs))
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:22,
示例13: op
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def op(operation, column):
if operation == 'in':
def comparator(column, v):
return column.in_(v)
elif operation == 'like':
def comparator(column, v):
return column.like(v + '%')
elif operation == 'eq':
comparator = _operator.eq
elif operation == 'ne':
comparator = _operator.ne
elif operation == 'le':
comparator = _operator.le
elif operation == 'lt':
comparator = _operator.lt
elif operation == 'ge':
comparator = _operator.ge
elif operation == 'gt':
comparator = _operator.gt
else:
raise ValueError('Operation {} not supported'.format(operation))
return comparator
# TODO: fix comparators, keys should be something better
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:27,
示例14: add_globals
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def add_globals(self):
"Add some Scheme standard procedures."
import math, cmath, operator as op
from functools import reduce
self.update(vars(math))
self.update(vars(cmath))
self.update({
'+':op.add, '-':op.sub, '*':op.mul, '/':op.itruediv, 'níl':op.not_, 'agus':op.and_,
'>':op.gt, '=':op.ge, '<=':op.le, '=':op.eq, 'mod':op.mod,
'frmh':cmath.sqrt, 'dearbhluach':abs, 'uas':max, 'íos':min,
'cothrom_le?':op.eq, 'ionann?':op.is_, 'fad':len, 'cons':cons,
'ceann':lambda x:x[0], 'tóin':lambda x:x[1:], 'iarcheangail':op.add,
'liosta':lambda *x:list(x), 'liosta?': lambda x:isa(x,list),
'folamh?':lambda x: x == [], 'adamh?':lambda x: not((isa(x, list)) or (x == None)),
'boole?':lambda x: isa(x, bool), 'scag':lambda f, x: list(filter(f, x)),
'cuir_le':lambda proc,l: proc(*l), 'mapáil':lambda p, x: list(map(p, x)),
'lódáil':lambda fn: load(fn), 'léigh':lambda f: f.read(),
'oscail_comhad_ionchuir':open,'dún_comhad_ionchuir':lambda p: p.file.close(),
'oscail_comhad_aschur':lambda f:open(f,'w'), 'dún_comhad_aschur':lambda p: p.close(),
'dac?':lambda x:x is eof_object, 'luacháil':lambda x: evaluate(x),
'scríobh':lambda x,port=sys.stdout:port.write(to_string(x) + '\n')})
return self
开发者ID:neal-o-r,项目名称:aireamhan,代码行数:24,
示例15: operator_gt
点赞 6
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def operator_gt(self, app_data, test_data):
"""Compare app data is greater than tests data.
Args:
app_data (dict, list, str): The data created by the App.
test_data (dict, list, str): The data provided in the test case.
Returns:
bool, str: The results of the operator and any error message
"""
if app_data is None:
return False, 'Invalid app_data: {app_data}'
if test_data is None:
return False, 'Invalid test_data: {test_data}'
app_data = self._string_to_int_float(app_data)
test_data = self._string_to_int_float(test_data)
results = operator.gt(app_data, test_data)
details = ''
if not results:
details = f'{app_data} {type(app_data)} !(>) {test_data} {type(test_data)}'
return results, details
开发者ID:ThreatConnect-Inc,项目名称:tcex,代码行数:24,
示例16: follower_action
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def follower_action(agent):
return common_action(agent,
get_group(RED_TSETTERS),
get_group(BLUE_TSETTERS),
lt, gt)
开发者ID:gcallah,项目名称:indras_net,代码行数:7,
示例17: tsetter_action
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def tsetter_action(agent):
return common_action(agent,
get_group(RED_FOLLOWERS),
get_group(BLUE_FOLLOWERS),
gt,
lt)
开发者ID:gcallah,项目名称:indras_net,代码行数:8,
示例18: binary_search
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def binary_search(f, g, f_type, y_target, y_target_eps, x_min, x_max, x_eps, max_num_iter=1000, log=True):
""" does binary search on f :: X -> Z by calculating z = f(x) and using g :: Z -> Y to get y = g(z) = g(f(x)).
(g . f) is assumed to be monotonically increasing iff f_tpye == 'increasing' and monotonically decreasing iff
f_type == 'decreasing'.
Returns first (x, z) for which |y_target - g(f(x))| < y_target_eps. x_min, x_max specifiy initial search interval for x.
Stops if x_max - x_min < x_eps. Raises BinarySearchFailedException when x interval too small or if search takes
more than max_num_iter iterations. The expection has a field `discovered_values` which is a list of checked
(x, y) coordinates. """
def _print(s):
if log:
print(s)
assert f_type in ('increasing', 'decreasing')
cmp_op = operator.gt if f_type == 'increasing' else operator.lt
discovered_values = []
print_col_width = len(str(x_max)) + 3
for _ in range(max_num_iter):
x = x_min + (x_max - x_min) / 2
z = f(x)
y = g(z)
discovered_values.append((x, y))
_print('[{:{width}.2f}, {:{width}.2f}] -- g(f({:{width}.2f})) = {:.2f}'.format(
x_min, x_max, x, y, width=print_col_width))
if abs(y_target - y) < y_target_eps:
return z, x
if cmp_op(y, y_target):
x_max = x
else:
x_min = x
if x_max - x_min < x_eps:
_print('Stopping, interval too close!')
break
sorted_discovered_values = sorted(discovered_values)
first_y, last_y = sorted_discovered_values[0][1], sorted_discovered_values[-1][1]
if (f_type == 'increasing' and first_y > last_y) or (f_type == 'decreasing' and first_y < last_y):
raise ValueError('Got f_type == {}, but first_y, last_y = {}, {}'.format(
f_type, first_y, last_y))
raise BinarySearchFailedException(discovered_values)
# ------------------------------------------------------------------------------
开发者ID:fab-jul,项目名称:imgcomp-cvpr,代码行数:43,
示例19: testGt
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def testGt(self):
self.comparisonCheck(operator.gt)
开发者ID:myhdl,项目名称:myhdl,代码行数:4,
示例20: __gt__
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def __gt__(self, other: Union['Quantity', float, int]) -> bool:
return Quantity._bool_operation(self, other, operator.gt)
开发者ID:tensortrade-org,项目名称:tensortrade,代码行数:4,
示例21: __gt__
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def __gt__(a, b):
"""a > b"""
return a._richcmp(b, operator.gt)
开发者ID:war-and-code,项目名称:jawfish,代码行数:5,
示例22: test_dedup_single_blocking_key_vs_block
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_dedup_single_blocking_key_vs_block(self):
indexers = [
NeighbourhoodBlock('var_block10', max_nulls=1),
NeighbourhoodBlock(
left_on='var_block10', right_on='var_block10', max_nulls=1),
Block('var_block10'),
]
self.assert_index_comparisons(eq, indexers, self.a)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:11,
示例23: test_link_single_blocking_key_vs_block
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_link_single_blocking_key_vs_block(self):
indexers = [
NeighbourhoodBlock('var_arange', max_nulls=1),
NeighbourhoodBlock(
left_on='var_arange', right_on='var_arange', max_nulls=1),
Block('var_arange'),
]
self.assert_index_comparisons(eq, indexers, self.a, self.b)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a,
self.incomplete_b)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:12,
示例24: test_dedup_multiple_blocking_keys_vs_block
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_dedup_multiple_blocking_keys_vs_block(self):
indexers = [
NeighbourhoodBlock(['var_single', 'var_block10'], max_nulls=1),
NeighbourhoodBlock(
left_on=['var_single', 'var_block10'],
right_on=['var_single', 'var_block10'],
max_nulls=1),
Block(['var_single', 'var_block10']),
]
self.assert_index_comparisons(eq, indexers, self.a)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:13,
示例25: test_link_multiple_blocking_keys_vs_block
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_link_multiple_blocking_keys_vs_block(self):
indexers = [
NeighbourhoodBlock(['var_arange', 'var_block10'], max_nulls=1),
NeighbourhoodBlock(
left_on=['var_arange', 'var_block10'],
right_on=['var_arange', 'var_block10'],
max_nulls=1),
Block(['var_arange', 'var_block10']),
]
self.assert_index_comparisons(eq, indexers, self.a, self.b)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a,
self.incomplete_b)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:14,
示例26: test_dedup_single_sorting_key_vs_sortedneighbourhood
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_dedup_single_sorting_key_vs_sortedneighbourhood(self, window):
indexers = [
NeighbourhoodBlock('var_arange', max_nulls=1, windows=window),
NeighbourhoodBlock(
left_on='var_arange',
right_on='var_arange',
max_nulls=1,
windows=window),
SortedNeighbourhood('var_arange', window=window),
]
self.assert_index_comparisons(eq, indexers, self.a)
self.assert_index_comparisons(gt, indexers[-2:], self.incomplete_a)
开发者ID:J535D165,项目名称:recordlinkage,代码行数:14,
示例27: test_len_unpack_not
点赞 5
# 需要导入模块: import operator [as 别名]
# 或者: from operator import gt [as 别名]
def test_len_unpack_not():
"""Even though not(not(x)) -> x shouldn't exist, its length should be the inner length"""
lt, gt = conditions_for("")
outer = NotCondition(lt)
condition = NotCondition(outer)
assert len(condition) == len(outer) == 1
# Swap inner for an AND with length 2
and_ = AndCondition(lt, gt)
outer.values[0] = and_
assert len(condition) == len(outer) == len(and_) == 2
开发者ID:numberoverzero,项目名称:bloop,代码行数:13,
注:本文中的operator.gt方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。