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
3
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
3
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))
0
Example 3
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])
0
Example 4
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])
0
Example 5
def gcd(a, b):
'''Greatest common divider'''
f = _np.frompyfunc(_fractions.gcd, 2, 1)
return f(a, b)