Here are the examples of the python api numpy.array.T taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
166 Examples
3
Example 1
Project: lifelines Source File: test_estimation.py
def test_kmf_survival_curve_output_against_R(self):
df = load_g3()
ix = df['group'] == 'RIT'
kmf = KaplanMeierFitter()
expected = np.array([[0.909, 0.779]]).T
kmf.fit(df.ix[ix]['time'], df.ix[ix]['event'], timeline=[25, 53])
npt.assert_array_almost_equal(kmf.survival_function_.values, expected, decimal=3)
expected = np.array([[0.833, 0.667, 0.5, 0.333]]).T
kmf.fit(df.ix[~ix]['time'], df.ix[~ix]['event'], timeline=[9, 19, 32, 34])
npt.assert_array_almost_equal(kmf.survival_function_.values, expected, decimal=3)
3
Example 2
def _run_test(A, B, data, n, p, num_perm, b):
logging.info("Running MinHash with num_perm = %d" % num_perm)
minhash_runs, bbit_runs = np.array([_run_minhash(A, B, data,
i, num_perm, b)
for i in xrange(n)]).T
logging.info("Running HyperLogLog with p = %d" % p)
hll_runs = [_run_hyperloglog(A, B, data, i, p) for i in xrange(n)]
return (minhash_runs, bbit_runs, hll_runs)
3
Example 3
Project: stingray Source File: test_io.py
def test_save_ascii_with_format(self):
time = ["bla", 1, 2, 3]
counts = [2,3,41,4]
write(np.array([time, counts]).T,
filename="ascii_test.txt", format_="ascii",
fmt=["%s", "%s"])
3
Example 4
def group_data(data, degree=2, hash=hash):
"""
numpy.array -> numpy.array
Groups all columns of data into all combinations of triples
"""
new_data = []
m,n = data.shape
for indices in combinations(range(n), degree):
new_data.append([hash(tuple(v)) for v in data[:,indices]])
return array(new_data).T
3
Example 5
def group_data(data, degree=3, hash=hash):
"""
numpy.array -> numpy.array
Groups all columns of data into all combinations of triples
"""
new_data = []
m,n = data.shape
for indicies in combinations(range(n), degree):
new_data.append([hash(tuple(v)) for v in data[:,indicies]])
return array(new_data).T
3
Example 6
Project: rdfspace Source File: rdf_space_tests.py
def test_centrality():
rdf_space = Space('tests/example.n3')
# Overriding _ut
rdf_space._ut = np.array([[-1,1,0,0],[1,0,0,0],[2,1,0,0],[3,1,1,1]], dtype=float).T
# Overriding uri_index
rdf_space._uri_index = {'http://0': 0, 'http://1': 1, 'http://2': 2, 'http://3': 3}
assert_equal(rdf_space.centrality('http://0'), 1)
assert_equal(rdf_space.centrality('http://1'), 1)
assert_equal(rdf_space.centrality('http://2'), 2)
assert_equal(rdf_space.centrality('http://3'), 3)
3
Example 7
Project: mindpark Source File: reader.py
def _collect_columns(self, engine, table):
result = engine.execute(sql.select([table]))
columns = np.array([x for x in result]).T
if not len(columns) or not columns.shape[1]:
return None
columns = Metric(
id=np.array([int(x, 16) for x in columns[0]]),
timestamp=columns[1],
step=columns[2].astype(int),
epoch=columns[3].astype(int),
training=columns[4].astype(bool),
episode=columns[5].astype(int),
data=columns[6:].T.astype(float))
columns = self._sort_columns(columns)
return columns
3
Example 8
Project: scikit-image Source File: adapt_rgb.py
def each_channel(image_filter, image, *args, **kwargs):
"""Return color image by applying `image_filter` on channels of `image`.
Note that this function is intended for use with `adapt_rgb`.
Parameters
----------
image_filter : function
Function that filters a gray-scale image.
image : array
Input image.
"""
c_new = [image_filter(c, *args, **kwargs) for c in image.T]
return np.array(c_new).T
3
Example 9
Project: deepTools Source File: test_countReadsPerBin.py
def test_countReadsInRegions_min_mapping_quality(self):
# Test min mapping quality.
self.c.minMappingQuality = 40
self.c.skipZeros = False
resp, _ = self.c.count_reads_in_region(self. chrom, 0, 200)
nt.assert_equal(resp, np.array([[0, 0, 0, 1.],
[0, 0, 0, 1.]]).T)
3
Example 10
Project: scikit-image Source File: test_colorconv.py
def test_rgb2luv_brucelindbloom(self):
"""
Test the RGB->Lab conversion by comparing to the calculator on the
authoritative Bruce Lindbloom
[website](http://brucelindbloom.com/index.html?ColorCalculator.html).
"""
# Obtained with D65 white point, sRGB model and gamma
gt_for_colbars = np.array([
[100, 0, 0],
[97.1393, 7.7056, 106.7866],
[91.1132, -70.4773, -15.2042],
[87.7347, -83.0776, 107.3985],
[60.3242, 84.0714, -108.6834],
[53.2408, 175.0151, 37.7564],
[32.2970, -9.4054, -130.3423],
[0, 0, 0]]).T
gt_array = np.swapaxes(gt_for_colbars.reshape(3, 4, 2), 0, 2)
assert_array_almost_equal(rgb2luv(self.colbars_array),
gt_array, decimal=2)
3
Example 11
Project: tracer Source File: test_tracer_engine.py
def setUp(self):
dir = N.array([[1,1,-1],[-1,1,-1],[-1,-1,-1],[1,-1,-1]]).T/math.sqrt(3)
position = N.c_[[0,0,1],[1,-1,1],[1,1,1],[-1,1,1]]
self._bund = RayBundle(position, dir, energy=N.ones(4))
self.assembly = Assembly()
object = AssembledObject()
object.add_surface(Surface(FlatGeometryManager(), opt.perfect_mirror))
self.assembly.add_object(object)
self.engine = TracerEngine(self.assembly)
3
Example 12
Project: PyFR Source File: polys.py
@clean
def ortho_basis_at(self, pts):
if len(pts) and not isinstance(pts[0], Iterable):
pts = [(p,) for p in pts]
return np.array([self.ortho_basis_at_py(*p) for p in pts]).T
3
Example 13
Project: Chimp Source File: dqn_learner.py
def save_training_history(self, path='.'):
''' save training history '''
train_hist = np.array([range(len(self.train_rewards)),self.train_losses,self.train_rewards, self.train_qval_avgs, self.train_episodes, self.train_times]).T
eval_hist = np.array([range(len(self.val_rewards)),self.val_losses,self.val_rewards, self.val_qval_avgs, self.val_episodes, self.val_times]).T
# TODO: why is this here and not in agent?
np.savetxt(path + '/training_hist.csv', train_hist, delimiter=',')
np.savetxt(path + '/evaluation_hist.csv', eval_hist, delimiter=',')
3
Example 14
Project: acoular Source File: trajectory.py
@property_depends_on('points[]')
def _get_tck( self ):
t = sort(self.points.keys())
xp = array([self.points[i] for i in t]).T
k = min(3, len(self.points)-1)
tcku = splprep(xp, u=t, s=0, k=k)
return tcku[0]
3
Example 15
Project: PRST Source File: test_utils.py
def test_mul_ad_ad(self):
# Answers computed using MRST's initVariablesADI
x, y = initVariablesADI(np.array([[1,2]]).T, np.array([[4,5]]).T)
z = x*y
assert np.array_equal(z.val, np.array([[4, 10]]).T)
assert np.array_equal(np.array([[4,0],[0,5]]), z.jac[0].toarray())
assert np.array_equal(np.array([[1,0],[0,2]]), z.jac[1].toarray())
f = x*x*y
g = x*y*z
h = f*g
assert np.array_equal(h.val, np.array([[64, 2000]]).T)
assert np.array_equal(np.array([[256,0],[0,4000]]), h.jac[0].toarray())
assert np.array_equal(np.array([[48,0],[0,1200]]), h.jac[1].toarray())
w = f*g + f + g*x*y
assert np.array_equal(w.val, np.array([[132, 3020]]).T)
assert np.array_equal(np.array([[456,0],[0,5520]]), w.jac[0].toarray())
assert np.array_equal(np.array([[97,0],[0,1804]]), w.jac[1].toarray())
3
Example 16
Project: gala Source File: test_composite.py
def test_shit(self):
potential = self.Cls(one=self.p1, two=self.p2)
q = np.ascontiguousarray(np.array([[1.1,0,0]]).T)
print("val", potential.value(q))
q = np.ascontiguousarray(np.array([[1.1,0,0]]).T)
print("grad", potential.gradient(q))
3
Example 17
def smoothed(self, exog):
'''get smoothed prediction for each component
'''
#bug: with exog in predict I get a shape error
#print 'smoothed', exog.shape, self.smoothers[0].predict(exog).shape
#there was a mistake exog didn't have column index i
return np.array([self.smoothers[i].predict(exog[:,i]) + self.offset[i]
#shouldn't be a mistake because exog[:,i] is attached to smoother, but
#it is for different exog
#return np.array([self.smoothers[i].predict() + self.offset[i]
for i in range(exog.shape[1])]).T
3
Example 18
Project: RITSAR Source File: signal.py
def sph2cart(sph):
azimuth = np.array([sph[:,0]]).T
elevation = np.array([sph[:,1]]).T
r = np.array([sph[:,2]]).T
x = r * np.cos(elevation) * np.cos(azimuth)
y = r * np.cos(elevation) * np.sin(azimuth)
z = r * np.sin(elevation)
cart = np.hstack([x,y,z])
return cart
3
Example 19
def group_data(data, degree=3, hash=hash):
new_data = []
m, n = data.shape
for indices in combinations(range(n), degree):
new_data.append([hash(tuple(v)) for v in data[:, indices]])
return np.array(new_data).T
3
Example 20
def test_masked(self):
index = linspace(0.0, 10.0, 11)
value = linspace(0.0, 1.0, 11)
index_mask = zeros(11, dtype=bool)
index_mask[2:6] = 1
value_mask = zeros(11, dtype=bool)
value_mask[4:8] = 1
points, selection = self.func(index, 0, 10, value, 0, 1,
index_mask = index_mask)
desired = array([[2, 3, 4, 5], [0.2, 0.3, 0.4, 0.5]]).T
assert_close(desired, points)
points, selection = self.func(index, 0, 10, value, 0, 1,
index_mask = index_mask,
value_mask = value_mask)
desired = array([[4, 0.4], [5, 0.5]])
assert_close(desired, points)
3
Example 21
Project: properscoring Source File: test_crps.py
def test_grad(self):
from scipy import optimize
f = lambda z: crps_gaussian(self.obs[0, 0], z[0], z[1], grad=False)
g = lambda z: crps_gaussian(self.obs[0, 0], z[0], z[1], grad=True)[1]
x0 = np.array([self.mu.reshape(-1),
self.sig.reshape(-1)]).T
for x in x0:
self.assertLessEqual(optimize.check_grad(f, g, x), 1e-6)
3
Example 22
Project: thunder Source File: test_series.py
def test_stat_by_index_multi(eng):
index = [
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1],
[0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3]
]
data = fromlist([arange(12)], index=array(index).T, engine=eng)
result = data.stat_by_index('sum', level=[0, 1])
assert allclose(result.toarray(), array([1, 14, 13, 38]))
assert allclose(result.index, array([[0, 0], [0, 1], [1, 0], [1, 1]]))
result = data.sum_by_index(level=[0, 1])
assert allclose(result.toarray(), array([1, 14, 13, 38]))
assert allclose(result.index, array([[0, 0], [0, 1], [1, 0], [1, 1]]))
3
Example 23
Project: pykalman Source File: test_unscented.py
def test_qr():
A = np.array([[1, 0.2, 1], [0.2, 0.8, 2]]).T
R = qr(A)
assert R.shape == (2, 2)
assert_array_almost_equal(R.T.dot(R), A.T.dot(A))
3
Example 24
def Samples(self):
import numpy as np
xy,xy,z = self.Trajectories()
xy = np.vstack((np.array(xy).T,z))
if self._inv: xy[-1,:] = -xy[-1]
return xy #NOTE: actually xyz
3
Example 25
def predict(self, X):
"""Predict multi-class targets using underlying estimators.
Parameters
----------
X : (sparse) array-like, shape = [n_samples, n_features]
Data.
Returns
-------
y : numpy array of shape [n_samples]
Predicted multi-class targets.
"""
check_is_fitted(self, 'estimators_')
Y = np.array([_predict_binary(e, X) for e in self.estimators_]).T
pred = euclidean_distances(Y, self.code_book_).argmin(axis=1)
return self.classes_[pred]
3
Example 26
Project: tracer Source File: test_flat_surface.py
def setUp(self):
self._surf = Surface(FlatGeometryManager(), perfect_mirror)
dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]]).T / math.sqrt(3)
position = c_[[0,0,1], [1,-1,1], [1,1,1], [-1,1,1]]
self._bund = RayBundle(position, dir, energy=N.ones(4)*100)
3
Example 27
def rotate(M, angle, x, y, z, point=None):
angle = math.pi * angle / 180
c, s = math.cos(angle), math.sin(angle)
n = math.sqrt(x * x + y * y + z * z)
x /= n
y /= n
z /= n
cx, cy, cz = (1 - c) * x, (1 - c) * y, (1 - c) * z
R = np.array([[cx * x + c, cy * x - z * s, cz * x + y * s, 0],
[cx * y + z * s, cy * y + c, cz * y - x * s, 0],
[cx * z - y * s, cy * z + x * s, cz * z + c, 0],
[0, 0, 0, 1]], dtype=M.dtype).T
M[...] = np.dot(M, R)
return M
3
Example 28
Project: iris Source File: test_rotate_winds.py
def test_transposed(self):
# Test case where the coordinates are not ordered yx in the cube.
u, v = self._uv_cubes_limited_extent()
# Slice out 4 points that lie in and outside OSGB extent.
u = u[1:3, 3:5]
v = v[1:3, 3:5]
# Transpose cubes (in-place)
u.transpose()
v.transpose()
ut, vt = rotate_winds(u, v, iris.coord_systems.OSGB())
# Values precalculated and checked.
expected_ut_data = np.array([[0.16285514, 0.35323639],
[1.82650698, 2.62455840]]).T
expected_vt_data = np.array([[19.88979966, 19.01921346],
[19.88018847, 19.01424281]]).T
# Compare u and v data values against previously calculated values.
self.assertArrayAllClose(ut.data, expected_ut_data, rtol=1e-5)
self.assertArrayAllClose(vt.data, expected_vt_data, rtol=1e-5)
3
Example 29
def _select_coords(self, coords, prm):
"""
Select from dual intersections by checking which of the impact points
is contained in a volume defined at object creation time.
"""
select = SphericalGM._select_coords(self, coords, prm)
if self._bound is None:
return select
#in_bd = self._bound.in_bounds(coords) & (prm > 0)
in_bd = N.array([self._bound.in_bounds(coords[...,c]) for c in xrange(prm.shape[1])]).T
in_bd &= prm > 0
select[~N.logical_or(*in_bd)] = N.nan
one_hit = N.logical_xor(*in_bd)
select[one_hit] = N.nonzero(in_bd[:,one_hit])[0]
return select
3
Example 30
def test_rsub(self):
x, y = initVariablesADI(np.array([[1,2]]).T, np.array([[4]]).T)
z = 5 - x
assert np.array_equal(z.val, 5-x.val)
assert (x+z).jac[0].nnz == 0
assert (x+z).jac[1].nnz == 0
3
Example 31
def __call__(self, points):
'''Apply a 3D pivoted rotation to a set of points'''
points = points - self._origin
points = np.dot(self._dcm, np.array(points).T).T
points += self._origin
return points
3
Example 32
Project: rdfspace Source File: rdf_space_tests.py
def test_similarity():
rdf_space = Space('tests/example.n3')
# Overriding _ut
rdf_space._ut = np.array([[0,1,0,0],[1,0,0,0],[0,1,0,0],[1,1,1,1]], dtype=float).T
# Overriding uri_index
rdf_space._uri_index = {'http://0': 0, 'http://1': 1, 'http://2': 2, 'http://3': 3}
assert_equal(rdf_space.similarity('http://0', 'http://0'), 1.0)
assert_equal(rdf_space.similarity('http://0', 'http://1'), 0)
assert_equal(rdf_space.similarity('http://0', 'http://2'), 1.0)
assert_equal(rdf_space.similarity('http://0', 'http://3'), 0.5)
3
Example 33
def __init__(self, x, y, n_blocks=None, nn=False, separators=None):
Jackknife.__init__(self, x, y, n_blocks, separators)
if nn: # non-negative least squares
func = lambda x, y: np.atleast_2d(nnls(x, np.array(y).T[0])[0])
else:
func = lambda x, y: np.atleast_2d(
np.linalg.lstsq(x, np.array(y).T[0])[0])
self.est = func(x, y)
self.delete_values = self.delete_values(x, y, func, self.separators)
self.pseudovalues = self.delete_values_to_pseudovalues(
self.delete_values, self.est)
(self.jknife_est, self.jknife_var, self.jknife_se, self.jknife_cov) =\
self.jknife(self.pseudovalues)
3
Example 34
def group_data(data, degree=3, hash=hash):
"""
numpy.array -> numpy.array
Groups all columns of data into all combinations of triples
"""
new_data = []
m,n = data.shape
for indicies in combinations(range(n), degree):
if 5 in indicies and 7 in indicies:
print "feature Xd"
elif 2 in indicies and 3 in indicies:
print "feature Xd"
else:
new_data.append([hash(tuple(v)) for v in data[:,indicies]])
return array(new_data).T
3
Example 35
Project: gala Source File: test_nonlinear.py
@pytest.mark.skipif(True, reason="too slow")
def test_surface_of_section(tmpdir):
# TODO: needs overhaul
# from mpl_toolkits.mplot3d import Axes3D
from ...potential import LogarithmicPotential
from ...units import galactic
pot = LogarithmicPotential(v_c=1., r_h=1., q1=1., q2=0.9, q3=0.8, units=galactic)
w0 = np.array([[0.,0.8,0.,1.,0.,0.],
[0.,0.9,0.,1.,0.,0.]]).T
orbit = pot.integrate_orbit(w0, dt=0.02, n_steps=100000)
sos = surface_of_section(orbit, plane_ix=1)
3
Example 36
Project: rdfspace Source File: rdf_space_tests.py
def test_centroid():
rdf_space = Space('tests/example.n3')
# Overriding _ut
rdf_space._ut = np.array([[0,1,0,0],[1,0,0,0],[0,1,0,0],[1,1,1,1]], dtype=float).T
# Overriding uri_index
rdf_space._uri_index = {'http://0': 0, 'http://1': 1, 'http://2': 2, 'http://3': 3}
centroid = rdf_space.centroid(['http://0', 'http://1', 'http://2', 'http://3'])
assert_array_equal(centroid, np.array([0.5, 0.75, 0.25, 0.25]))
centroid = rdf_space.centroid(['http://0', 'http://3'])
assert_array_equal(centroid, np.array([0.5, 1, 0.5, 0.5]))
centroid = rdf_space.centroid(['http://0', 'http://1'])
assert_array_equal(centroid, np.array([0.5, 0.5, 0, 0]))
centroid = rdf_space.centroid(['http://0', 'http://6'])
assert_array_equal(centroid, np.array([0, 1, 0, 0]))
centroid = rdf_space.centroid([])
assert_array_equal(centroid, None)
3
Example 37
def _create_subplots(self, rows, cols, **kwargs):
size = [4 * cols, 3 * rows]
fig, ax = plt.subplots(ncols=cols, nrows=rows, figsize=size, **kwargs)
if cols == 1:
ax = np.array([ax]).T
return fig, ax
3
Example 38
Project: PRST Source File: test_utils.py
def test_mul_ad_vector(self):
x, y = initVariablesADI(np.array([[1,2,3]]).T, np.array([[4,5,6]]).T)
w = x*x*y*np.array([[3],[3],[3]]) + x*y*y*np.array([[5],[5],[5]])
assert np.array_equal(np.array([[92, 310, 702]]).T, w.val)
assert np.array_equal(np.array([[104,0,0],[0,185,0], [0,0,288]]), w.jac[0].toarray())
assert np.array_equal(np.array([[43,0,0],[0,112,0], [0,0,207]]), w.jac[1].toarray())
z = np.array([[2]])
f = x*z
assert np.array_equal(np.array([[2, 4, 6]]).T, f.val)
assert np.array_equal(np.array([[2,0,0],[0,2,0], [0,0,2]]), f.jac[0].toarray())
assert np.array_equal(np.array([[0,0,0],[0,0,0], [0,0,0]]), f.jac[1].toarray())
with pytest.raises(ValueError):
x*np.array([[1,2]]).T
3
Example 39
def cart2sph(cart):
x = np.array([cart[:,0]]).T
y = np.array([cart[:,1]]).T
z = np.array([cart[:,2]]).T
azimuth = np.arctan2(y,x)
elevation = np.arctan2(z,np.sqrt(x**2 + y**2))
r = np.sqrt(x**2 + y**2 + z**2)
sph = np.hstack([azimuth, elevation, r])
return sph
3
Example 40
Project: stingray Source File: test_io.py
def test_save_ascii_with_mixed_types(self):
time = ["bla", 1, 2, 3]
counts = [2,3,41,4]
with pytest.raises(Exception):
write(np.array([time, counts]).T,
"ascii_test.txt", "ascii")
3
Example 41
def _run_test(A, B, data, n, bs, num_perm):
logging.info("Run tests with A = (%d, %d), B = (%d, %d), n = %d"
% (A[0], A[1], B[0], B[1], n))
runs = np.array([_run_minhash(A, B, data, i, bs, num_perm)
for i in xrange(n)]).T
return runs
3
Example 42
Project: pvlib-python Source File: test_spa.py
def test_solar_position(self):
assert_almost_equal(
np.array([[theta, theta0, e, e0, Phi]]).T, self.spa.solar_position(
unixtimes, lat, lon, elev, pressure, temp, delta_t,
atmos_refract)[:-1], 5)
assert_almost_equal(
np.array([[v, alpha, delta]]).T, self.spa.solar_position(
unixtimes, lat, lon, elev, pressure, temp, delta_t,
atmos_refract, sst=True)[:3], 5)
3
Example 43
def test_basic(self):
index = linspace(0.0, 20.0, 21)
value = linspace(0.0, 1.0, 21)
points, selection = self.func(index, 4.5, 14.5, value, -1.0, 2.4)
desired = array([[5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
[0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.8]]).T
self.assert_(selection == None)
assert_close(desired, points)
3
Example 44
def test_read_ascii(self):
time = [1,2,3,4,5]
counts = [5,7,8,2,3]
np.savetxt("ascii_test.txt", np.array([time, counts]).T)
read("ascii_test.txt", "ascii")
os.remove("ascii_test.txt")
3
Example 45
Project: scikit-image Source File: test_colorconv.py
def test_rgb2lab_brucelindbloom(self):
"""
Test the RGB->Lab conversion by comparing to the calculator on the
authoritative Bruce Lindbloom
[website](http://brucelindbloom.com/index.html?ColorCalculator.html).
"""
# Obtained with D65 white point, sRGB model and gamma
gt_for_colbars = np.array([
[100,0,0],
[97.1393, -21.5537, 94.4780],
[91.1132, -48.0875, -14.1312],
[87.7347, -86.1827, 83.1793],
[60.3242, 98.2343, -60.8249],
[53.2408, 80.0925, 67.2032],
[32.2970, 79.1875, -107.8602],
[0,0,0]]).T
gt_array = np.swapaxes(gt_for_colbars.reshape(3, 4, 2), 0, 2)
assert_array_almost_equal(rgb2lab(self.colbars_array), gt_array, decimal=2)
3
Example 46
Project: popupcad Source File: solidworksimport.py
@staticmethod
def transform_loop(loop, R1, b1, R2, b2, scalefactor):
looparray = numpy.array(loop).T
v2 = R1.T.dot(R2.T.dot(looparray) + b2)
v2 = v2[0:2, :].T
v2 = v2 * scalefactor * popupcad.solidworks_mm_conversion
return v2.tolist()
3
Example 47
Project: pvlib-python Source File: test_spa.py
def test_solar_position_singlethreaded(self):
assert_almost_equal(
np.array([[theta, theta0, e, e0, Phi]]).T, self.spa.solar_position(
unixtimes, lat, lon, elev, pressure, temp, delta_t,
atmos_refract, numthreads=1)[:-1], 5)
assert_almost_equal(
np.array([[v, alpha, delta]]).T, self.spa.solar_position(
unixtimes, lat, lon, elev, pressure, temp, delta_t,
atmos_refract, numthreads=1, sst=True)[:3], 5)
3
Example 48
def transform(self, profile):
"""Transform a vector of read counts or parameter values
into a multiscale representation.
.. note::
See msCentipede manual for more details.
"""
for j in xrange(self.J):
size = self.L/(2**(j+1))
self.total[j] = np.array([profile[:,k*size:(k+2)*size,:].sum(1) for k in xrange(0,2**(j+1),2)]).T
self.value[j] = np.array([profile[:,k*size:(k+1)*size,:].sum(1) for k in xrange(0,2**(j+1),2)]).T
3
Example 49
def test_polyder():
cases = [
([5], 0, [5]),
([5], 1, [0]),
([3, 2, 1], 0, [3, 2, 1]),
([3, 2, 1], 1, [6, 2]),
([3, 2, 1], 2, [6]),
([3, 2, 1], 3, [0]),
([[3, 2, 1], [5, 6, 7]], 0, [[3, 2, 1], [5, 6, 7]]),
([[3, 2, 1], [5, 6, 7]], 1, [[6, 2], [10, 6]]),
([[3, 2, 1], [5, 6, 7]], 2, [[6], [10]]),
([[3, 2, 1], [5, 6, 7]], 3, [[0], [0]]),
]
for p, m, expected in cases:
yield check_polyder, np.array(p).T, m, np.array(expected).T
3
Example 50
def translate(M, x, y=None, z=None):
y = x if y is None else y
z = x if z is None else z
T = np.array([[1.0, 0.0, 0.0, x],
[0.0, 1.0, 0.0, y],
[0.0, 0.0, 1.0, z],
[0.0, 0.0, 0.0, 1.0]], dtype=M.dtype).T
M[...] = np.dot(M, T)
return M