numpy.frompyfunc

Here are the examples of the python api numpy.frompyfunc taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

Example 1

Project: scikit-rf Source File: networkSet.py
    def add_polar_noise(self, ntwk):
        from scipy import stats
        from numpy import frompyfunc

        gimme_norm = lambda x: stats.norm(loc=0,scale=x).rvs(1)[0]
        ugimme_norm = frompyfunc(gimme_norm,1,1)

        s_deg_rv = npy.array(map(ugimme_norm, self.std_s_deg.s_re), dtype=float)
        s_mag_rv = npy.array(map(ugimme_norm, self.std_s_mag.s_re), dtype=float)

        mag = ntwk.s_mag+s_mag_rv
        deg = ntwk.s_deg+s_deg_rv
        ntwk.s = mag* npy.exp(1j*npy.pi/180.*deg)
        return ntwk

Example 2

Project: robothon Source File: test_regression.py
    def test_frompyfunc_endian(self, level=rlevel):
        """Ticket #503"""
        from math import radians
        uradians = np.frompyfunc(radians, 1, 1)
        big_endian = np.array([83.4, 83.5], dtype='>f8')
        little_endian = np.array([83.4, 83.5], dtype='<f8')
        assert_almost_equal(uradians(big_endian).astype(float),
                            uradians(little_endian).astype(float))

Example 3

Project: hpelm Source File: test_correctness.py
Function: test_slfn_addufuncneurons_gotthem
    def test_SLFN_AddUfuncNeurons_GotThem(self):
        elm = ELM(1, 1)
        func = np.frompyfunc(lambda a: a + 1, 1, 1)
        elm.add_neurons(1, func)
        self.assertIs(func, elm.nnet.get_neurons()[0][1])

Example 4

Project: hpelm Source File: test_corr_hpelm.py
Function: test_slfn_addufuncneurons_gotthem
    def test_SLFN_AddUfuncNeurons_GotThem(self):
        hpelm = HPELM(1, 1)
        func = np.frompyfunc(lambda a: a+1, 1, 1)
        hpelm.add_neurons(1, func)
        self.assertIs(func, hpelm.nnet.get_neurons()[0][1])

Example 5

Project: ttpy Source File: utils.py
Function: gcd
def gcd(a, b):
    '''Greatest common divider'''
    f = _np.frompyfunc(_fractions.gcd, 2, 1)
    return f(a, b)