Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fractalis
fractalis
Commits
6a4d09f2
Commit
6a4d09f2
authored
Aug 31, 2017
by
Sascha Herzinger
Browse files
Fixed bug in filtering
parent
8bd7667f
Pipeline
#2274
failed with stage
in 43 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
fractalis/analytics/task.py
View file @
6a4d09f2
...
...
@@ -109,7 +109,8 @@ class AnalyticTask(Task, metaclass=abc.ABCMeta):
:return: Filtered data frame.
"""
for
key
in
filters
:
df
=
df
[
df
[
key
].
isin
(
filters
[
key
])]
if
filters
[
key
]:
df
=
df
[
df
[
key
].
isin
(
filters
[
key
])]
return
df
@
staticmethod
...
...
fractalis/data/controller.py
View file @
6a4d09f2
...
...
@@ -145,4 +145,3 @@ def get_meta_information(task_id: str) -> Tuple[Response, int]:
data_state
=
get_data_state_for_task_id
(
task_id
,
wait
)
logger
.
debug
(
"Successfully gather meta information. Sending response."
)
return
jsonify
({
'meta'
:
data_state
[
'meta'
]}),
200
tests/unit/analytics/test_analytics_task.py
View file @
6a4d09f2
...
...
@@ -23,10 +23,13 @@ class TestAnalyticsTask:
def
test_apply_filter
(
self
):
df
=
pd
.
DataFrame
([[
1
,
2
,
3
],
[
4
,
5
,
6
],
[
7
,
8
,
9
]],
columns
=
[
'A'
,
'B'
,
'C'
])
filters
=
{
'A'
:
[
1
,
7
],
'B'
:
[
2
,
5
,
8
],
'C'
:
[
6
,
9
]}
df
=
self
.
task
.
apply_filters
(
df
=
df
,
filters
=
filters
)
assert
df
.
shape
==
(
1
,
3
)
assert
df
.
iloc
[
0
].
tolist
()
==
[
7
,
8
,
9
]
filters1
=
{
'A'
:
[
1
,
7
],
'B'
:
[
2
,
5
,
8
],
'C'
:
[
6
,
9
]}
filters2
=
{
'A'
:
[]}
df1
=
self
.
task
.
apply_filters
(
df
=
df
,
filters
=
filters1
)
df2
=
self
.
task
.
apply_filters
(
df
=
df
,
filters
=
filters2
)
assert
df1
.
shape
==
(
1
,
3
)
assert
df1
.
iloc
[
0
].
tolist
()
==
[
7
,
8
,
9
]
assert
df2
.
shape
==
(
3
,
3
)
def
test_parse_value
(
self
):
arg1
=
'${"id": 123, "filters": {"foo": [1,2]}}$'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment