Passed
Push — mpeta ( bb54e1...a4027b )
by Konstantinos
01:39
created

so_magic.data.built_in_commands   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A encode_nominal_subsets_command() 0 5 1
1
"""This module is responsible to define functions that will serve as engine commands with an arbitrary object as receiver.
2
These commands should be "built" using a suitable function/decorator.
3
At runtime, their (command) arguments are the same as the function holding the business logic.
4
"""
5
6
# at runtime it will expect only the 'datapoints', 'attribute' and 'new_attribute' arguments
7
def encode_nominal_subsets_command(datapoints, attribute, new_attribute):
8
    from so_magic.data.features.phis import ListOfCategoricalPhi, DatapointsAttributePhi
9
    phi = ListOfCategoricalPhi(DatapointsAttributePhi(datapoints))
10
    new_values = phi(attribute)
11
    datapoints.mutator.add_column(datapoints, new_values, new_attribute)
12