本文整理汇总了Python中vis.analyzers.indexers.offset.FilterByOffsetIndexer.run方法的典型用法代码示例。如果您正苦于以下问题:Python FilterByOffsetIndexer.run方法的具体用法?Python FilterByOffsetIndexer.run怎么用?Python FilterByOffsetIndexer.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vis.analyzers.indexers.offset.FilterByOffsetIndexer
的用法示例。
在下文中一共展示了FilterByOffsetIndexer.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_2
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_run_2(self):
# ensure that run() properly gets "method" from self._settings (default value)
in_val = [mock.MagicMock(spec_set=pandas.Series)]
in_val[0].index = [0.0]
settings = {'quarterLength': 0.5}
ind = FilterByOffsetIndexer(in_val, settings)
ind.run()
in_val[0].reindex.assert_called_once_with(index=[0.0], method='ffill')
示例2: test_offset_xparts_2
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_xparts_2(self):
# input is expected output; 10 parts
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
expected = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5]),
pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例3: test_offset_1part_0
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_0(self):
# 0 parts
in_val = []
expected = []
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
示例4: test_offset_1part_9
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_9(self):
# targeted test for end-of-piece: when last thing lands on an observed offset
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.4, 1.1, 2.0])]
expected = pandas.Series(['a', 'b', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5, 2.0])
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(1, len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertSequenceEqual(list(expected.values), list(actual.values)) # same rows?
self.assertSequenceEqual(list(expected.index), list(actual.index)) # same index?
示例5: test_offset_1part_7
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_7(self):
# irregular offset interval to a large one
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.4, 1.1, 2.1])]
expected = pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 1.0, 2.0, 3.0])
offset_interval = 1.0
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(1, len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertSequenceEqual(list(expected.values), list(actual.values)) # same rows?
self.assertSequenceEqual(list(expected.index), list(actual.index)) # same index?
示例6: test_offset_1part_5
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_5(self):
# already regular offset interval (but some missing) to larger one
in_val = [pandas.Series(['a', 'b', 'c'], index=[0.0, 0.5, 1.5])]
expected = pandas.Series(['a', 'b', 'c'], index=[0.0, 1.0, 2.0])
offset_interval = 1.0
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(1, len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertSequenceEqual(list(expected.values), list(actual.values)) # same rows?
self.assertSequenceEqual(list(expected.index), list(actual.index)) # same index?
示例7: test_offset_1part_4b
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_4b(self):
# already regular offset interval to a very small one
in_val = [pandas.Series(['a', 'b'], index=[0.0, 0.5])]
expected = pandas.Series(['a', 'a', 'a', 'a', 'b'], index=[0.0, 0.125, 0.25, 0.375, 0.5])
offset_interval = 0.125
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(1, len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertSequenceEqual(list(expected.values), list(actual.values)) # same rows?
self.assertSequenceEqual(list(expected.index), list(actual.index)) # same index?
示例8: test_offset_1part_4b
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_4b(self):
# already regular offset interval to a very small one
in_val = [pandas.Series(['a', 'b'], index=[0.0, 0.5])]
expected = [pandas.Series(['a', 'a', 'a', 'a', 'b'], index=[0.0, 0.125, 0.25, 0.375, 0.5])]
offset_interval = 0.125
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例9: test_offset_1part_1
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_1(self):
# 0 length
in_val = [pandas.Series()]
expected = [pandas.Series()]
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例10: test_offset_1part_7
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_7(self):
# irregular offset interval to a large one
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.4, 1.1, 2.1])]
expected = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 1.0, 2.0, 3.0])]
offset_interval = 1.0
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例11: test_offset_1part_9
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_9(self):
# targeted test for end-of-piece: when last thing lands on an observed offset
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.4, 1.1, 2.0])]
expected = [pandas.Series(['a', 'b', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5, 2.0])]
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例12: test_offset_1part_5
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_5(self):
# already regular offset interval (but some missing) to larger one
in_val = [pandas.Series(['a', 'b', 'c'], index=[0.0, 0.5, 1.5])]
expected = [pandas.Series(['a', 'b', 'c'], index=[0.0, 1.0, 2.0])]
offset_interval = 1.0
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()
self.assertEqual(len(expected), len(actual)) # same number of columns?
for i in xrange(len(expected)):
self.assertEqual(len(expected[i]), len(actual[i])) # same number of rows?
self.assertEqual(list(expected[i].index), list(actual[i].index)) # same row names?
示例13: test_offset_1part_1
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_1(self):
# 0 length
in_val = [pandas.Series()]
expected = pandas.Series()
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(len(in_val), len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertEqual(len(expected), len(actual)) # same number of rows?
self.assertEqual(list(expected.index), list(actual.index)) # same row names?
示例14: test_offset_1part_2
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_1part_2(self):
# input is expected output
in_val = [pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])]
expected = pandas.Series(['a', 'b', 'c', 'd'], index=[0.0, 0.5, 1.0, 1.5])
offset_interval = 0.5
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(1, len(actual.columns)) # same number of columns?
actual = actual['0']
self.assertSequenceEqual(list(expected.values), list(actual.values)) # same rows?
self.assertSequenceEqual(list(expected.index), list(actual.index)) # same index?
示例15: test_offset_xparts_0a
# 需要导入模块: from vis.analyzers.indexers.offset import FilterByOffsetIndexer [as 别名]
# 或者: from vis.analyzers.indexers.offset.FilterByOffsetIndexer import run [as 别名]
def test_offset_xparts_0a(self):
# 0 length, many parts
in_val = [pandas.Series(), pandas.Series(), pandas.Series(), pandas.Series()]
expected = pandas.DataFrame({str(i): pandas.Series() for i in xrange(4)})
offset_interval = 12.0
ind = FilterByOffsetIndexer(in_val, {u'quarterLength': offset_interval})
actual = ind.run()['offset.FilterByOffsetIndexer']
self.assertEqual(len(expected.columns), len(actual.columns))
expected = expected.fillna(value='None') # avoid having to use isnan()
actual = actual.fillna(value='None')
for partname in expected.columns:
self.assertSequenceEqual(list(expected[partname].values), list(actual[partname].values))
self.assertSequenceEqual(list(expected[partname].index), list(actual[partname].index))