-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
As discussed elsewhere, add the issue here with the code location:
libmir/mir-algorithm#442 (comment)
You'd better allow user to plug in his own converters for his own data.
It is allowed now. Please check the conversionFinalizer.
conversionFinalizer : (
unquotedString,
scalar,
columnIndex,
columnName)
So you pass out the columnIndex and columnName to let the user branch in his function to dispatch to different columns? This looks ugly, and may incur code duplication, e.g. two different csv, with col-1, col-2 swapped:
in Python, pass in dict, 2 one-liner:
data1 = np.genfromtxt("data1.csv", ..., converters = {1: cvtr1, 2: cvtr2})
data2 = np.genfromtxt("data2.csv", ..., converters = {2: cvtr1, 1: cvtr2})
But with conversionFinalizer in D:
conversionFinalizer1 (...) {
switch (columnIndex) {
1: return cvtr1(unquotedString);
2: return cvtr2(unquotedString);
}
}
conversionFinalizer2 (...) {
switch (columnIndex) {
1: return cvtr2(unquotedString);
2: return cvtr1(unquotedString);
}
}
too verbose.
Why not use the Python dictionary format, and let the Mir do such branching in the library?
Example in D can just follow the Python api:
double cvtr1(string str) {return ...;}
double cvtr2(string str) {return ...;}
data1 = mir.genfromtxt("data1.csv", ..., [1: cvtr1, 2: cvtr2]); // D does not have named arg yet, let just use positional arg
data2 = mir.genfromtxt("data2.csv", ..., [2: cvtr1, 1: cvtr2]); // pass in D's AA.
Metadata
Metadata
Assignees
Labels
No labels