GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Orange.tests.sql.FilterStringTest   F
last analyzed

Complexity

Total Complexity 129

Size/Duplication

Total Lines 405
Duplicated Lines 0 %
Metric Value
dl 0
loc 405
rs 1.5789
wmc 129

36 Methods

Rating   Name   Duplication   Size   Complexity  
A test_filter_string_equal() 0 9 3
A test_filter_string_list_case_insensitive_value() 0 9 3
A test_filter_string_starts_with_case_insensitive() 0 12 4
A test_filter_string_not_equal_case_insensitive_data() 0 10 3
A test_filter_string_contains_case_insensitive_data() 0 11 4
A test_filter_string_greater() 0 10 4
A test_filter_string_greater_equal_case_insensitive_data() 0 11 4
A test_filter_string_starts_with() 0 10 4
A test_filter_string_less_case_insensitive_data() 0 11 4
A test_filter_string_equal_case_insensitive_data() 0 10 3
A test_filter_string_ends_with_case_insensitive() 0 12 4
A test_filter_string_is_defined() 0 9 3
A test_filter_string_not_equal() 0 9 3
A test_filter_string_less_equal_case_insensitive_value() 0 11 4
A setUp() 0 15 2
A test_filter_string_between_case_insensitive_data() 0 11 4
A test_filter_string_contains_case_insensitive_value() 0 11 4
A test_filter_string_greater_equal_case_insensitive_value() 0 11 4
A test_filter_string_contains() 0 10 4
A test_filter_string_less() 0 10 4
A test_filter_string_greater_case_insensitive_value() 0 11 4
A test_filter_string_not_equal_case_insensitive_value() 0 10 3
A test_filter_string_greater_equal() 0 10 4
A test_filter_string_ends_with() 0 10 4
A test_filter_string_list_case_insensitive_data() 0 9 3
A test_filter_string_equal_case_insensitive_value() 0 10 3
A test_filter_string_between_case_insensitive_value() 0 11 4
A test_filter_string_outside() 0 10 4
A test_filter_string_between() 0 10 4
A test_filter_string_less_case_insensitive_value() 0 11 4
A test_filter_string_greater_case_insensitive_data() 0 11 4
A tearDown() 0 2 1
A test_filter_string_outside_case_insensitive() 0 11 4
A test_filter_string_list() 0 9 3
A test_filter_string_less_equal_case_insensitive_data() 0 11 4
A test_filter_string_less_equal() 0 10 4

How to fix   Complexity   

Complex Class

Complex classes like Orange.tests.sql.FilterStringTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
import unittest
0 ignored issues
show
Unused Code introduced by
The import unittest seems to be unused.
Loading history...
2
from Orange.data.sql.table import SqlTable, SqlRowInstance
3
from Orange.data import filter, domain
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in filter.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
4
5
from Orange.tests.sql.base import PostgresTest, sql_version, sql_test
0 ignored issues
show
Unused Code introduced by
Unused sql_version imported from Orange.tests.sql.base
Loading history...
6
7
8
@sql_test
9
class IsDefinedFilterTests(PostgresTest):
10
    def setUp(self):
11
        self.data = [
12
            [1, 2, 3, None, 'm'],
13
            [2, 3, 1, 4, 'f'],
14
            [None, None, None, None, None],
15
            [7, None, 3, None, 'f'],
16
        ]
17
        conn, self.table_name = self.create_sql_table(self.data)
18
        self.table = SqlTable(conn, self.table_name, inspect_values=True)
19
20
    def tearDown(self):
21
        self.drop_sql_table(self.table_name)
22
23
    def test_on_all_columns(self):
24
        filtered_data = filter.IsDefined()(self.table)
25
        correct_data = [row for row in self.data if all(row)]
26
27
        self.assertEqual(len(filtered_data), len(correct_data))
28
        self.assertSequenceEqual(filtered_data, correct_data)
29
30
    def test_selected_columns(self):
31
        filtered_data = filter.IsDefined(columns=[0])(self.table)
32
        correct_data = [row for row in self.data if row[0]]
33
34
        self.assertEqual(len(filtered_data), len(correct_data))
35
        self.assertSequenceEqual(filtered_data, correct_data)
36
37
    def test_all_columns_negated(self):
38
        filtered_data = filter.IsDefined(negate=True)(self.table)
39
        correct_data = [row for row in self.data if not all(row)]
40
41
        self.assertEqual(len(filtered_data), len(correct_data))
42
        self.assertSequenceEqual(filtered_data, correct_data)
43
44
    def test_selected_columns_negated(self):
45
        filtered_data = \
46
            filter.IsDefined(negate=True, columns=[4])(self.table)
47
        correct_data = [row for row in self.data if not row[4]]
48
49
        self.assertEqual(len(filtered_data), len(correct_data))
50
        self.assertSequenceEqual(filtered_data, correct_data)
51
52
    def test_can_inherit_is_defined_filter(self):
53
        filtered_data = filter.IsDefined(columns=[1])(self.table)
54
        filtered_data = filtered_data[:, 4]
55
        correct_data = [[row[4]]for row in self.data if row[1]]
56
57
        self.assertEqual(len(filtered_data), len(correct_data))
58
        self.assertSequenceEqual(filtered_data, correct_data)
59
60
61
@sql_test
62
class HasClassFilterTests(PostgresTest):
63
    def setUp(self):
64
        self.data = [
65
            [1, 2, 3, None, 'm'],
66
            [2, 3, 1, 4, 'f'],
67
            [None, None, None, None, None],
68
            [7, None, 3, None, 'f'],
69
        ]
70
        self.conn, self.table_name = self.create_sql_table(self.data)
71
        table = SqlTable(self.conn, self.table_name, inspect_values=True)
72
        variables = table.domain.variables
73
        new_table = table.copy()
74
        new_table.domain = domain.Domain(variables[:-1], variables[-1:])
75
        self.table = new_table
76
77
    def tearDown(self):
78
        self.drop_sql_table(self.table_name)
79
80
    def test_has_class(self):
81
        filtered_data = filter.HasClass()(self.table)
82
        correct_data = [row for row in self.data if row[-1]]
83
84
        self.assertEqual(len(filtered_data), len(correct_data))
85
        self.assertSequenceEqual(filtered_data, correct_data)
86
87
    def test_negated(self):
88
        filtered_data = filter.HasClass(negate=True)(self.table)
89
        correct_data = [row for row in self.data if not row[-1]]
90
91
        self.assertEqual(len(filtered_data), len(correct_data))
92
        self.assertSequenceEqual(filtered_data, correct_data)
93
94
95
@sql_test
96
class SameValueFilterTests(PostgresTest):
97
    def setUp(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
        self.data = [
99
            [1, 2, 3, 'a', 'm'],
100
            [2, None, 1, 'a', 'f'],
101
            [None, 3, 1, 'b', None],
102
            [2, 2, 3, 'b', 'f'],
103
        ]
104
        self.conn, self.table_name = self.create_sql_table(self.data)
105
        self.table = SqlTable(self.conn, self.table_name, inspect_values=True)
106
107
    def tearDown(self):
108
        self.drop_sql_table(self.table_name)
109
110
    def test_on_continuous_attribute(self):
111
        filtered_data = filter.SameValue(0, 1)(self.table)
112
        correct_data = [row for row in self.data if row[0] == 1]
113
114
        self.assertEqual(len(filtered_data), len(correct_data))
115
        self.assertSequenceEqual(filtered_data, correct_data)
116
117
    def test_on_continuous_attribute_with_unknowns(self):
118
        filtered_data = filter.SameValue(1, 2)(self.table)
119
        correct_data = [row for row in self.data if row[1] == 2]
120
121
        self.assertEqual(len(filtered_data), len(correct_data))
122
        self.assertSequenceEqual(filtered_data, correct_data)
123
124
    def test_on_continuous_attribute_with_unknown_value(self):
125
        filtered_data = filter.SameValue(1, None)(self.table)
126
        correct_data = [row for row in self.data if row[1] is None]
127
128
        self.assertEqual(len(filtered_data), len(correct_data))
129
        self.assertSequenceEqual(filtered_data, correct_data)
130
131
    def test_on_continuous_attribute_negated(self):
132
        filtered_data = filter.SameValue(0, 1, negate=True)(self.table)
133
        correct_data = [row for row in self.data if not row[0] == 1]
134
135
        self.assertEqual(len(filtered_data), len(correct_data))
136
        self.assertSequenceEqual(filtered_data, correct_data)
137
138
    def test_on_discrete_attribute(self):
139
        filtered_data = filter.SameValue(3, 'a')(self.table)
140
        correct_data = [row for row in self.data if row[3] == 'a']
141
142
        self.assertEqual(len(filtered_data), len(correct_data))
143
        self.assertSequenceEqual(filtered_data, correct_data)
144
145
    def test_on_discrete_attribute_with_unknown_value(self):
146
        filtered_data = filter.SameValue(4, None)(self.table)
147
        correct_data = [row for row in self.data if row[4] is None]
148
149
        self.assertEqual(len(filtered_data), len(correct_data))
150
        self.assertSequenceEqual(filtered_data, correct_data)
151
152
    def test_on_discrete_attribute_with_unknowns(self):
153
        filtered_data = filter.SameValue(4, 'm')(self.table)
154
        correct_data = [row for row in self.data if row[4] == 'm']
155
156
        self.assertEqual(len(filtered_data), len(correct_data))
157
        self.assertSequenceEqual(filtered_data, correct_data)
158
159
    def test_on_discrete_attribute_negated(self):
160
        filtered_data = filter.SameValue(3, 'a', negate=True)(self.table)
161
        correct_data = [row for row in self.data if not row[3] == 'a']
162
163
        self.assertEqual(len(filtered_data), len(correct_data))
164
        self.assertSequenceEqual(filtered_data, correct_data)
165
166
    def test_on_discrete_attribute_value_passed_as_int(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
        values = self.table.domain[3].values
168
        filtered_data = filter.SameValue(3, 0, negate=True)(self.table)
169
        correct_data = [row for row in self.data if not row[3] == values[0]]
170
171
        self.assertEqual(len(filtered_data), len(correct_data))
172
        self.assertSequenceEqual(filtered_data, correct_data)
173
174
    def test_on_discrete_attribute_value_passed_as_float(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
175
        values = self.table.domain[3].values
176
        filtered_data = filter.SameValue(3, 0., negate=True)(self.table)
177
        correct_data = [row for row in self.data if not row[3] == values[0]]
178
179
        self.assertEqual(len(filtered_data), len(correct_data))
180
        self.assertSequenceEqual(filtered_data, correct_data)
181
182
183
@sql_test
184
class ValuesFilterTests(PostgresTest):
185
    def setUp(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
186
        self.data = [
187
            [1, 2, 3, 'a', 'm'],
188
            [2, None, 1, 'a', 'f'],
189
            [None, 3, 1, 'b', None],
190
            [2, 2, 3, 'b', 'f'],
191
        ]
192
        conn, self.table_name = self.create_sql_table(self.data)
193
        self.table = SqlTable(conn, self.table_name, inspect_values=True)
194
195
    def tearDown(self):
196
        self.drop_sql_table(self.table_name)
197
198
    def test_values_filter_with_no_conditions(self):
199
        with self.assertRaises(ValueError):
200
            filtered_data = filter.Values([])(self.table)
0 ignored issues
show
Unused Code introduced by
The variable filtered_data seems to be unused.
Loading history...
201
202
    def test_discrete_value_filter(self):
203
        filtered_data = filter.Values(conditions=[
204
            filter.FilterDiscrete(3, ['a'])
205
        ])(self.table)
206
        correct_data = [row for row in self.data if row[3] in ['a']]
207
208
        self.assertEqual(len(filtered_data), len(correct_data))
209
        self.assertSequenceEqual(filtered_data, correct_data)
210
211
    def test_discrete_value_filter_with_multiple_values(self):
212
        filtered_data = filter.Values(conditions=[
213
            filter.FilterDiscrete(3, ['a', 'b'])
214
        ])(self.table)
215
        correct_data = [row for row in self.data if row[3] in ['a', 'b']]
216
217
        self.assertEqual(len(filtered_data), len(correct_data))
218
        self.assertSequenceEqual(filtered_data, correct_data)
219
220
    def test_discrete_value_filter_with_None(self):
221
        filtered_data = filter.Values(conditions=[
222
            filter.FilterDiscrete(3, None)
223
        ])(self.table)
224
        correct_data = [row for row in self.data if row[3] is not None]
225
226
        self.assertEqual(len(filtered_data), len(correct_data))
227
        self.assertSequenceEqual(filtered_data, correct_data)
228
229
    def test_continuous_value_filter_equal(self):
230
        filtered_data = filter.Values(conditions=[
231
            filter.FilterContinuous(0, filter.FilterContinuous.Equal, 1)
232
        ])(self.table)
233
        correct_data = [row for row in self.data if row[0] == 1]
234
235
        self.assertEqual(len(filtered_data), len(correct_data))
236
        self.assertSequenceEqual(filtered_data, correct_data)
237
238
    def test_continuous_value_filter_not_equal(self):
239
        filtered_data = filter.Values(conditions=[
240
            filter.FilterContinuous(0, filter.FilterContinuous.NotEqual, 1)
241
        ])(self.table)
242
        correct_data = [row for row in self.data if row[0] != 1]
243
244
        self.assertEqual(len(filtered_data), len(correct_data))
245
        self.assertSequenceEqual(filtered_data, correct_data)
246
247
    def test_continuous_value_filter_less(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
248
        filtered_data = filter.Values(conditions=[
249
            filter.FilterContinuous(0, filter.FilterContinuous.Less, 2)
250
        ])(self.table)
251
        correct_data = [row for row in self.data
252
                        if row[0] is not None and row[0] < 2]
253
254
        self.assertEqual(len(filtered_data), len(correct_data))
255
        self.assertSequenceEqual(filtered_data, correct_data)
256
257
    def test_continuous_value_filter_less_equal(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
258
        filtered_data = filter.Values(conditions=[
259
            filter.FilterContinuous(0, filter.FilterContinuous.LessEqual, 2)
260
        ])(self.table)
261
        correct_data = [row for row in self.data
262
                        if row[0] is not None and row[0] <= 2]
263
264
        self.assertEqual(len(filtered_data), len(correct_data))
265
        self.assertSequenceEqual(filtered_data, correct_data)
266
267
    def test_continuous_value_filter_greater(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
268
        filtered_data = filter.Values(conditions=[
269
            filter.FilterContinuous(0, filter.FilterContinuous.Greater, 1)
270
        ])(self.table)
271
        correct_data = [row for row in self.data
272
                        if row[0] is not None and row[0] > 1]
273
274
        self.assertEqual(len(filtered_data), len(correct_data))
275
        self.assertSequenceEqual(filtered_data, correct_data)
276
277
    def test_continuous_value_filter_greater_equal(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
278
        filtered_data = filter.Values(conditions=[
279
            filter.FilterContinuous(0, filter.FilterContinuous.GreaterEqual, 1)
280
        ])(self.table)
281
        correct_data = [row for row in self.data
282
                        if row[0] is not None and row[0] >= 1]
283
284
        self.assertEqual(len(filtered_data), len(correct_data))
285
        self.assertSequenceEqual(filtered_data, correct_data)
286
287
    def test_continuous_value_filter_between(self):
288
        filtered_data = filter.Values(conditions=[
289
            filter.FilterContinuous(0, filter.FilterContinuous.Between, 1, 2)
290
        ])(self.table)
291
        correct_data = [row for row in self.data
292
                        if row[0] is not None and 1 <= row[0] <= 2]
293
294
        self.assertEqual(len(filtered_data), len(correct_data))
295
        self.assertSequenceEqual(filtered_data, correct_data)
296
297
    def test_continuous_value_filter_outside(self):
298
        filtered_data = filter.Values(conditions=[
299
            filter.FilterContinuous(0, filter.FilterContinuous.Outside, 2, 3)
300
        ])(self.table)
301
        correct_data = [row for row in self.data
302
                        if row[0] is not None and not 2 <= row[0] <= 3]
303
304
        self.assertEqual(len(filtered_data), len(correct_data))
305
        self.assertSequenceEqual(filtered_data, correct_data)
306
307
    def test_continuous_value_filter_isdefined(self):
308
        filtered_data = filter.Values(conditions=[
309
            filter.FilterContinuous(1, filter.FilterContinuous.IsDefined)
310
        ])(self.table)
311
        correct_data = [row for row in self.data if row[1] is not None]
312
313
        self.assertEqual(len(filtered_data), len(correct_data))
314
        self.assertSequenceEqual(filtered_data, correct_data)
315
316
317
@sql_test
318
class FilterStringTest(PostgresTest):
319
    def setUp(self):
320
        self.data = [
321
            [w] for w in "Lorem ipsum dolor sit amet, consectetur adipiscing"
322
            "elit. Vestibulum vel dolor nulla. Etiam elit lectus, mollis nec"
323
            "mattis sed, pellentesque in turpis. Vivamus non nisi dolor. Etiam"
324
            "lacinia dictum purus, in ullamcorper ante vulputate sed. Nullam"
325
            "congue blandit elementum. Donec blandit laoreet posuere. Proin"
326
            "quis augue eget tortor posuere mollis. Fusce vestibulum bibendum"
327
            "neque at convallis. Donec iaculis risus volutpat malesuada"
328
            "vehicula. Ut cursus tempor massa vulputate lacinia. Pellentesque"
329
            "eu tortor sed diam placerat porttitor et volutpat risus. In"
330
            "vulputate rutrum lacus ac sagittis. Suspendisse interdum luctus"
331
            "sem auctor commodo.".split(' ')] + [[None], [None]]
332
        self.conn, self.table_name = self.create_sql_table(self.data)
333
        self.table = SqlTable(self.conn, self.table_name)
334
335
    def tearDown(self):
336
        self.drop_sql_table(self.table_name)
337
338
    def test_filter_string_is_defined(self):
339
        filtered_data = filter.Values(conditions=[
340
            filter.FilterString(-1, filter.FilterString.IsDefined)
341
        ])(self.table)
342
        correct_data = [SqlRowInstance(filtered_data.domain, row)
343
                        for row in self.data if row[0] is not None]
344
345
        self.assertEqual(len(filtered_data), len(correct_data))
346
        self.assertSequenceEqual(filtered_data, correct_data)
347
348
    def test_filter_string_equal(self):
349
        filtered_data = filter.Values(conditions=[
350
            filter.FilterString(-1, filter.FilterString.Equal, 'in')
351
        ])(self.table)
352
        correct_data = [SqlRowInstance(filtered_data.domain, row)
353
                        for row in self.data if row[0] == 'in']
354
355
        self.assertEqual(len(filtered_data), len(correct_data))
356
        self.assertSequenceEqual(filtered_data, correct_data)
357
358
    def test_filter_string_equal_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
359
        filtered_data = filter.Values(conditions=[
360
            filter.FilterString(-1, filter.FilterString.Equal, 'In',
361
                                case_sensitive=False)
362
        ])(self.table)
363
        correct_data = [SqlRowInstance(filtered_data.domain, row)
364
                        for row in self.data if row[0] == 'in']
365
366
        self.assertEqual(len(filtered_data), len(correct_data))
367
        self.assertSequenceEqual(filtered_data, correct_data)
368
369
    def test_filter_string_equal_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
370
        filtered_data = filter.Values(conditions=[
371
            filter.FilterString(-1, filter.FilterString.Equal, 'donec',
372
                                case_sensitive=False)
373
        ])(self.table)
374
        correct_data = [SqlRowInstance(filtered_data.domain, row)
375
                        for row in self.data if row[0] == 'Donec']
376
377
        self.assertEqual(len(filtered_data), len(correct_data))
378
        self.assertSequenceEqual(filtered_data, correct_data)
379
380
    def test_filter_string_not_equal(self):
381
        filtered_data = filter.Values(conditions=[
382
            filter.FilterString(-1, filter.FilterString.NotEqual, 'in')
383
        ])(self.table)
384
        correct_data = [SqlRowInstance(filtered_data.domain, row)
385
                        for row in self.data if row[0] != 'in']
386
387
        self.assertEqual(len(filtered_data), len(correct_data))
388
        self.assertSequenceEqual(filtered_data, correct_data)
389
390
    def test_filter_string_not_equal_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
391
        filtered_data = filter.Values(conditions=[
392
            filter.FilterString(-1, filter.FilterString.NotEqual, 'In',
393
                                case_sensitive=False)
394
        ])(self.table)
395
        correct_data = [SqlRowInstance(filtered_data.domain, row)
396
                        for row in self.data if row[0] != 'in']
397
398
        self.assertEqual(len(filtered_data), len(correct_data))
399
        self.assertSequenceEqual(filtered_data, correct_data)
400
401
    def test_filter_string_not_equal_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
402
        filtered_data = filter.Values(conditions=[
403
            filter.FilterString(-1, filter.FilterString.NotEqual, 'donec',
404
                                case_sensitive=False)
405
        ])(self.table)
406
        correct_data = [SqlRowInstance(filtered_data.domain, row)
407
                        for row in self.data if row[0] != 'Donec']
408
409
        self.assertEqual(len(filtered_data), len(correct_data))
410
        self.assertSequenceEqual(filtered_data, correct_data)
411
412
    def test_filter_string_less(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
413
        filtered_data = filter.Values(conditions=[
414
            filter.FilterString(-1, filter.FilterString.Less, 'A')
415
        ])(self.table)
416
        correct_data = [SqlRowInstance(filtered_data.domain, row)
417
                        for row in self.data
418
                        if row[0] is not None and row[0] < 'A']
419
420
        self.assertEqual(len(filtered_data), len(correct_data))
421
        self.assertSequenceEqual(filtered_data, correct_data)
422
423
    def test_filter_string_less_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
424
        filtered_data = filter.Values(conditions=[
425
            filter.FilterString(-1, filter.FilterString.Less, 'In',
426
                                case_sensitive=False)
427
        ])(self.table)
428
        correct_data = [SqlRowInstance(filtered_data.domain, row)
429
                        for row in self.data
430
                        if row[0] is not None and row[0].lower() < 'in']
431
432
        self.assertEqual(len(filtered_data), len(correct_data))
433
        self.assertSequenceEqual(filtered_data, correct_data)
434
435
    def test_filter_string_less_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
436
        filtered_data = filter.Values(conditions=[
437
            filter.FilterString(-1, filter.FilterString.Less, 'donec',
438
                                case_sensitive=False)
439
        ])(self.table)
440
        correct_data = [SqlRowInstance(filtered_data.domain, row)
441
                        for row in self.data
442
                        if row[0] is not None and row[0].lower() < 'donec']
443
444
        self.assertEqual(len(filtered_data), len(correct_data))
445
        self.assertSequenceEqual(filtered_data, correct_data)
446
447
    def test_filter_string_less_equal(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
        filtered_data = filter.Values(conditions=[
449
            filter.FilterString(-1, filter.FilterString.LessEqual, 'A')
450
        ])(self.table)
451
        correct_data = [SqlRowInstance(filtered_data.domain, row)
452
                        for row in self.data
453
                        if row[0] is not None and row[0] <= 'A']
454
455
        self.assertEqual(len(filtered_data), len(correct_data))
456
        self.assertSequenceEqual(filtered_data, correct_data)
457
458
    def test_filter_string_less_equal_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
459
        filtered_data = filter.Values(conditions=[
460
            filter.FilterString(-1, filter.FilterString.LessEqual, 'In',
461
                                case_sensitive=False)
462
        ])(self.table)
463
        correct_data = [SqlRowInstance(filtered_data.domain, row)
464
                        for row in self.data
465
                        if row[0] is not None and row[0].lower() <= 'in']
466
467
        self.assertEqual(len(filtered_data), len(correct_data))
468
        self.assertSequenceEqual(filtered_data, correct_data)
469
470
    def test_filter_string_less_equal_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
471
        filtered_data = filter.Values(conditions=[
472
            filter.FilterString(-1, filter.FilterString.LessEqual, 'donec',
473
                                case_sensitive=False)
474
        ])(self.table)
475
        correct_data = [SqlRowInstance(filtered_data.domain, row)
476
                        for row in self.data
477
                        if row[0] is not None and row[0].lower() <= 'donec']
478
479
        self.assertEqual(len(filtered_data), len(correct_data))
480
        self.assertSequenceEqual(filtered_data, correct_data)
481
482
    def test_filter_string_greater(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
483
        filtered_data = filter.Values(conditions=[
484
            filter.FilterString(-1, filter.FilterString.Greater, 'volutpat')
485
        ])(self.table)
486
        correct_data = [SqlRowInstance(filtered_data.domain, row)
487
                        for row in self.data
488
                        if row[0] is not None and row[0] > 'volutpat']
489
490
        self.assertEqual(len(filtered_data), len(correct_data))
491
        self.assertSequenceEqual(filtered_data, correct_data)
492
493
    def test_filter_string_greater_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
494
        filtered_data = filter.Values(conditions=[
495
            filter.FilterString(-1, filter.FilterString.Greater, 'In',
496
                                case_sensitive=False)
497
        ])(self.table)
498
        correct_data = [SqlRowInstance(filtered_data.domain, row)
499
                        for row in self.data
500
                        if row[0] is not None and row[0].lower() > 'in']
501
502
        self.assertEqual(len(filtered_data), len(correct_data))
503
        self.assertSequenceEqual(filtered_data, correct_data)
504
505
    def test_filter_string_greater_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
506
        filtered_data = filter.Values(conditions=[
507
            filter.FilterString(-1, filter.FilterString.Greater, 'donec',
508
                                case_sensitive=False)
509
        ])(self.table)
510
        correct_data = [SqlRowInstance(filtered_data.domain, row)
511
                        for row in self.data
512
                        if row[0] is not None and row[0].lower() > 'donec']
513
514
        self.assertEqual(len(filtered_data), len(correct_data))
515
        self.assertSequenceEqual(filtered_data, correct_data)
516
517
    def test_filter_string_greater_equal(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
518
        filtered_data = filter.Values(conditions=[
519
            filter.FilterString(-1, filter.FilterString.GreaterEqual, 'volutpat')
520
        ])(self.table)
521
        correct_data = [SqlRowInstance(filtered_data.domain, row)
522
                        for row in self.data
523
                        if row[0] is not None and row[0] >= 'volutpat']
524
525
        self.assertEqual(len(filtered_data), len(correct_data))
526
        self.assertSequenceEqual(filtered_data, correct_data)
527
528
    def test_filter_string_greater_equal_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
529
        filtered_data = filter.Values(conditions=[
530
            filter.FilterString(-1, filter.FilterString.GreaterEqual, 'In',
531
                                case_sensitive=False)
532
        ])(self.table)
533
        correct_data = [SqlRowInstance(filtered_data.domain, row)
534
                        for row in self.data
535
                        if row[0] is not None and row[0].lower() >= 'in']
536
537
        self.assertEqual(len(filtered_data), len(correct_data))
538
        self.assertSequenceEqual(filtered_data, correct_data)
539
540
    def test_filter_string_greater_equal_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
541
        filtered_data = filter.Values(conditions=[
542
            filter.FilterString(-1, filter.FilterString.GreaterEqual, 'donec',
543
                                case_sensitive=False)
544
        ])(self.table)
545
        correct_data = [SqlRowInstance(filtered_data.domain, row)
546
                        for row in self.data
547
                        if row[0] is not None and row[0].lower() >= 'donec']
548
549
        self.assertEqual(len(filtered_data), len(correct_data))
550
        self.assertSequenceEqual(filtered_data, correct_data)
551
552
    def test_filter_string_between(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
553
        filtered_data = filter.Values(conditions=[
554
            filter.FilterString(-1, filter.FilterString.Between, 'a', 'c')
555
        ])(self.table)
556
        correct_data = [SqlRowInstance(filtered_data.domain, row)
557
                        for row in self.data
558
                        if row[0] is not None and 'a' <= row[0] <= 'c']
559
560
        self.assertEqual(len(filtered_data), len(correct_data))
561
        self.assertSequenceEqual(filtered_data, correct_data)
562
563
    def test_filter_string_between_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
564
        filtered_data = filter.Values(conditions=[
565
            filter.FilterString(-1, filter.FilterString.Between, 'I', 'O',
566
                                case_sensitive=False)
567
        ])(self.table)
568
        correct_data = [SqlRowInstance(filtered_data.domain, row)
569
                        for row in self.data
570
                        if row[0] is not None and 'i' < row[0].lower() <= 'o']
571
572
        self.assertEqual(len(filtered_data), len(correct_data))
573
        self.assertSequenceEqual(filtered_data, correct_data)
574
575
    def test_filter_string_between_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
576
        filtered_data = filter.Values(conditions=[
577
            filter.FilterString(-1, filter.FilterString.Between, 'i', 'O',
578
                                case_sensitive=False)
579
        ])(self.table)
580
        correct_data = [SqlRowInstance(filtered_data.domain, row)
581
                        for row in self.data
582
                        if row[0] is not None and 'i' <= row[0].lower() <= 'o']
583
584
        self.assertEqual(len(filtered_data), len(correct_data))
585
        self.assertSequenceEqual(filtered_data, correct_data)
586
587
    def test_filter_string_contains(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
588
        filtered_data = filter.Values(conditions=[
589
            filter.FilterString(-1, filter.FilterString.Contains, 'et')
590
        ])(self.table)
591
        correct_data = [SqlRowInstance(filtered_data.domain, row)
592
                        for row in self.data
593
                        if row[0] is not None and 'et' in row[0]]
594
595
        self.assertEqual(len(filtered_data), len(correct_data))
596
        self.assertSequenceEqual(filtered_data, correct_data)
597
598
    def test_filter_string_contains_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
599
        filtered_data = filter.Values(conditions=[
600
            filter.FilterString(-1, filter.FilterString.Contains, 'eT',
601
                                case_sensitive=False)
602
        ])(self.table)
603
        correct_data = [SqlRowInstance(filtered_data.domain, row)
604
                        for row in self.data
605
                        if row[0] is not None and 'et' in row[0].lower()]
606
607
        self.assertEqual(len(filtered_data), len(correct_data))
608
        self.assertSequenceEqual(filtered_data, correct_data)
609
610
    def test_filter_string_contains_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
611
        filtered_data = filter.Values(conditions=[
612
            filter.FilterString(-1, filter.FilterString.Contains, 'do',
613
                                case_sensitive=False)
614
        ])(self.table)
615
        correct_data = [SqlRowInstance(filtered_data.domain, row)
616
                        for row in self.data
617
                        if row[0] is not None and 'do' in row[0].lower()]
618
619
        self.assertEqual(len(filtered_data), len(correct_data))
620
        self.assertSequenceEqual(filtered_data, correct_data)
621
622
    def test_filter_string_outside(self):
623
        filtered_data = filter.Values(conditions=[
624
            filter.FilterString(-1, filter.FilterString.Outside, 'am', 'di')
625
        ])(self.table)
626
        correct_data = [SqlRowInstance(filtered_data.domain, row)
627
                        for row in self.data
628
                        if row[0] is not None and not 'am' < row[0] < 'di']
629
630
        self.assertEqual(len(filtered_data), len(correct_data))
631
        self.assertSequenceEqual(filtered_data, correct_data)
632
633
    def test_filter_string_outside_case_insensitive(self):
634
        filtered_data = filter.Values(conditions=[
635
            filter.FilterString(-1, filter.FilterString.Outside, 'd', 'k',
636
                                case_sensitive=False)
637
        ])(self.table)
638
        correct_data = [SqlRowInstance(filtered_data.domain, row)
639
                        for row in self.data
640
                        if row[0] is not None and not 'd' < row[0].lower() < 'k']
641
642
        self.assertEqual(len(filtered_data), len(correct_data))
643
        self.assertSequenceEqual(filtered_data, correct_data)
644
645
    def test_filter_string_starts_with(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
646
        filtered_data = filter.Values(conditions=[
647
            filter.FilterString(-1, filter.FilterString.StartsWith, 'D')
648
        ])(self.table)
649
        correct_data = [SqlRowInstance(filtered_data.domain, row)
650
                        for row in self.data
651
                        if row[0] is not None and row[0].startswith('D')]
652
653
        self.assertEqual(len(filtered_data), len(correct_data))
654
        self.assertSequenceEqual(filtered_data, correct_data)
655
656
    def test_filter_string_starts_with_case_insensitive(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
657
        filtered_data = filter.Values(conditions=[
658
            filter.FilterString(-1, filter.FilterString.StartsWith, 'D',
659
                                case_sensitive=False)
660
        ])(self.table)
661
        correct_data = [SqlRowInstance(filtered_data.domain, row)
662
                        for row in self.data
663
                        if row[0] is not None
664
                        and row[0].lower().startswith('d')]
665
666
        self.assertEqual(len(filtered_data), len(correct_data))
667
        self.assertSequenceEqual(filtered_data, correct_data)
668
669
    def test_filter_string_ends_with(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
670
        filtered_data = filter.Values(conditions=[
671
            filter.FilterString(-1, filter.FilterString.EndsWith, 's')
672
        ])(self.table)
673
        correct_data = [SqlRowInstance(filtered_data.domain, row)
674
                        for row in self.data
675
                        if row[0] is not None and row[0].endswith('s')]
676
677
        self.assertEqual(len(filtered_data), len(correct_data))
678
        self.assertSequenceEqual(filtered_data, correct_data)
679
680
    def test_filter_string_ends_with_case_insensitive(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
681
        filtered_data = filter.Values(conditions=[
682
            filter.FilterString(-1, filter.FilterString.EndsWith, 'S',
683
                                case_sensitive=False)
684
        ])(self.table)
685
        correct_data = [SqlRowInstance(filtered_data.domain, row)
686
                        for row in self.data
687
                        if row[0] is not None
688
                        and row[0].lower().endswith('s')]
689
690
        self.assertEqual(len(filtered_data), len(correct_data))
691
        self.assertSequenceEqual(filtered_data, correct_data)
692
693
    def test_filter_string_list(self):
694
        filtered_data = filter.Values(conditions=[
695
            filter.FilterStringList(-1, ['et', 'in'])
696
        ])(self.table)
697
        correct_data = [SqlRowInstance(filtered_data.domain, row)
698
                        for row in self.data if row[0] in ['et', 'in']]
699
700
        self.assertEqual(len(filtered_data), len(correct_data))
701
        self.assertSequenceEqual(filtered_data, correct_data)
702
703
    def test_filter_string_list_case_insensitive_value(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
704
        filtered_data = filter.Values(conditions=[
705
            filter.FilterStringList(-1, ['Et', 'In'], case_sensitive=False)
706
        ])(self.table)
707
        correct_data = [SqlRowInstance(filtered_data.domain, row)
708
                        for row in self.data if row[0] in ['et', 'in']]
709
710
        self.assertEqual(len(filtered_data), len(correct_data))
711
        self.assertSequenceEqual(filtered_data, correct_data)
712
713
    def test_filter_string_list_case_insensitive_data(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
714
        filtered_data = filter.Values(conditions=[
715
            filter.FilterStringList(-1, ['donec'], case_sensitive=False)
716
        ])(self.table)
717
        correct_data = [SqlRowInstance(filtered_data.domain, row)
718
                        for row in self.data if row[0] in ['Donec']]
719
720
        self.assertEqual(len(filtered_data), len(correct_data))
721
        self.assertSequenceEqual(filtered_data, correct_data)
722