Exemplo n.º 1
0
def pfunc(score, statement, identifier, pfield, formula):
    '''Returns a modified score with selected pfields processed with
    the provided formula.
    
    A global variable is used because a pfunction requires that its
    arguments be of csd type numeric.  Thus, passing a forumula string
    does not work.

    '''

    global __formula
    __formula = formula
    return sco.map_(score, {0: statement, 1: identifier}, pfield, __func)
Exemplo n.º 2
0
def pfunc(score, statement, identifier, pfield, formula):
    '''Returns a modified score with selected pfields processed with
    the provided formula.
    
    A global variable is used because a pfunction requires that its
    arguments be of csd type numeric.  Thus, passing a forumula string
    does not work.

    '''
    
    global __formula
    __formula = formula
    return sco.map_(score, {0: statement, 1: identifier}, pfield, __func)
Exemplo n.º 3
0
def test(n, expect, score, pattern, pfield_index, pf_function, *args):
    result = sco.map_(score, pattern, pfield_index, pf_function, *args)
    did_pass = result == expect

    return did_pass, n, 'map_()', str(expect), str(result)
Exemplo n.º 4
0
# 
# csd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with csd.  If not, see <http://www.gnu.org/licenses/>.

'''Tests that csd has been installed.

Use::
    
    ./test.py

Output::

    i 1 0 0.25 0.001
    i 1 + 0.25 0.778

'''

import sys

from csd.sco import map_

if __name__ == '__main__':
    score = 'i 1 0 0.25 0.999\ni 1 + 0.25 0.222'
    print map_(score, {0: 'i'}, 4, lambda x: 1.0 - x)

Exemplo n.º 5
0
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# csd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with csd.  If not, see <http://www.gnu.org/licenses/>.
'''Tests that csd has been installed.

Use::
    
    ./test.py

Output::

    i 1 0 0.25 0.001
    i 1 + 0.25 0.778

'''

import sys

from csd.sco import map_

if __name__ == '__main__':
    score = 'i 1 0 0.25 0.999\ni 1 + 0.25 0.222'
    print map_(score, {0: 'i'}, 4, lambda x: 1.0 - x)
Exemplo n.º 6
0
def test(n, expect, score, pattern, pfield_index, pf_function, *args):
    result = sco.map_(score, pattern, pfield_index, pf_function, *args)
    did_pass = result == expect

    return did_pass, n, 'map_()', str(expect), str(result)