Here are the examples of the python api numpy.alltrue taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
83 Examples
3
Source : test_array_from_pyobj.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def arr_equal(self, arr1, arr2):
if arr1.shape != arr2.shape:
return False
s = arr1 == arr2
return alltrue(s.flatten())
def __str__(self):
3
Source : testutils.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def fail_if_array_equal(x, y, err_msg='', verbose=True):
"""
Raises an assertion error if two masked arrays are not equal elementwise.
"""
def compare(x, y):
return (not np.alltrue(approx(x, y)))
assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
header='Arrays are not equal')
def assert_array_approx_equal(x, y, decimal=6, err_msg='', verbose=True):
3
Source : optimize.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def derivative(self, x, *args):
if self.jac is not None and numpy.alltrue(x == self.x):
return self.jac
else:
self(x, *args)
return self.jac
class OptimizeResult(dict):
3
Source : colors.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def is_gray(self):
if not self._isinit:
self._init()
return (np.alltrue(self._lut[:, 0] == self._lut[:, 1]) and
np.alltrue(self._lut[:, 0] == self._lut[:, 2]))
class LinearSegmentedColormap(Colormap):
3
Source : lines.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def _is_sorted(self, x):
"""return true if x is sorted"""
if len(x) < 2:
return 1
return np.alltrue(x[1:] - x[0:-1] >= 0)
@allow_rasterization
3
Source : testutils.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def fail_if_array_equal(x, y, err_msg='', verbose=True):
"Raises an assertion error if two masked arrays are not equal (elementwise)."
def compare(x, y):
return (not np.alltrue(approx(x, y)))
assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
header='Arrays are not equal')
def assert_array_approx_equal(x, y, decimal=6, err_msg='', verbose=True):
3
Source : blk_diag_matrix.py
with GNU General Public License v3.0
from ComputationalCryoEM
with GNU General Public License v3.0
from ComputationalCryoEM
def check_psd(self):
"""
Check the positive semidefinite property of all blocks
:return: True if all blocks have non-negative eigenvalues.
"""
return np.alltrue(self.eigvals() > 0.0)
def make_psd(self):
3
Source : grid_search.py
with MIT License
from CPJKU
with MIT License
from CPJKU
def random(self):
"""
Get random combination
"""
while True:
if np.alltrue(self.visited):
break
not_visited = np.nonzero(self.visited == False)[0]
rand_idx = np.random.randint(0, len(not_visited))
self.comb_idx = not_visited[rand_idx]
yield self._prep_params(self.combinations[self.comb_idx])
def set_value(self, value, values=None):
3
Source : grid_search.py
with MIT License
from CPJKU
with MIT License
from CPJKU
def all_visited(self):
"""
Check if all visited
"""
return np.alltrue(self.visited)
def missing_combinations(self):
3
Source : test_cones.py
with Apache License 2.0
from cvxgrp
with Apache License 2.0
from cvxgrp
def test_contains(self):
for x, isin in zip(self.sample_vecs, self.sample_vecs_are_in):
cache = self.make_cache(len(x))
res = self.test_cone.Pi(x, cache)
Pix = res
self.assertTrue(np.alltrue(Pix == x) == isin)
def test_proj(self):
3
Source : test_u_methods.py
with MIT License
from DanielBok
with MIT License
from DanielBok
def test_forecast(model, returns):
horizon, start = 2, 3
forecast = model.forecast(start=start, horizon=horizon)
ideal_shape = len(returns), horizon
assert forecast.residual_variance.shape == ideal_shape
assert forecast.mean.shape == ideal_shape
assert forecast.variance.shape == ideal_shape
# nas for the skipped starts
assert np.alltrue(forecast.mean.iloc[:start].isna())
assert np.alltrue(~forecast.mean.iloc[start:].isna())
@pytest.mark.filterwarnings('ignore::FutureWarning')
3
Source : test_data.py
with MIT License
from deeprob-org
with MIT License
from deeprob-org
def test_data_flatten(self):
transform = DataFlatten()
transform.fit(self.tensor_data)
data = transform.forward(self.tensor_data)
orig_data = transform.backward(data)
self.assertEqual(data.shape, (5, 8))
self.assertTrue(np.alltrue(orig_data == self.tensor_data))
def test_data_normalizer(self):
3
Source : test_sample.py
with GNU Lesser General Public License v3.0
from deeptime-ml
with GNU Lesser General Public License v3.0
from deeptime-ml
def test_sample_by_sequence():
dtraj = [0, 1, 2, 3, 2, 1, 0]
idx = sample.compute_index_states(dtraj)
seq = [0, 1, 1, 1, 0, 0, 0, 0, 1, 1]
sidx = sample.indices_by_sequence(idx, seq)
assert (np.alltrue(sidx.shape == (len(seq), 2)))
for t in range(sidx.shape[0]):
assert (sidx[t, 0] == 0) # did we pick the right traj?
assert (dtraj[sidx[t, 1]] == seq[t]) # did we pick the right states?
@pytest.mark.parametrize("replace", [True, False])
3
Source : matrix_gates.py
with Apache License 2.0
from epiqc
with Apache License 2.0
from epiqc
def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
return np.alltrue(self._matrix == other._matrix)
def __ne__(self, other):
3
Source : matrix_gates_test.py
with Apache License 2.0
from epiqc
with Apache License 2.0
from epiqc
def test_two_qubit_init():
x2 = cirq.TwoQubitMatrixGate(QFT2)
assert np.alltrue(cirq.unitary(x2) == QFT2)
def test_two_qubit_eq():
3
Source : test_roenneberg.py
with GNU General Public License v3.0
from ghammad
with GNU General Public License v3.0
from ghammad
def test_roenneberg_sinewave():
test = raw_sinewave.Roenneberg(threshold=0.5, min_trend_period='24h')
index_equality = np.alltrue(raw_sleepwave.data.index == test.index)
value_equality = np.isclose(raw_sleepwave.data, test, equal_nan=True)
assert (
index_equality and
np.sum(value_equality)/len(value_equality) == approx(1, rel=0.01)
)
3
Source : trunc_normal_aux_sampler.py
with GNU General Public License v3.0
from grburgess
with GNU General Public License v3.0
from grburgess
def true_sampler(self, size):
lower = (self.lower - self.mu) / self.tau
upper = (self.upper - self.mu) / self.tau
self._true_values = stats.truncnorm.rvs(
lower,
upper,
loc=self.mu,
scale=self.tau,
size=size,
)
assert np.alltrue(self._true_values >= self.lower)
assert np.alltrue(self._true_values < = self.upper)
def observation_sampler(self, size):
3
Source : test_very_simple_train.py
with MIT License
from hristo-vrigazov
with MIT License
from hristo-vrigazov
def test_evaluation_is_shown():
model, nested_loaders, datasets, full_flow_for_development, tensorboard_converters = synthetic_dataset_preparation()
runner = DnnCoolSupervisedRunner(model=model,
full_flow=full_flow_for_development,
project_dir='./security_project',
runner_name='default_experiment',
tensoboard_converters=tensorboard_converters,
balance_dataparallel_memory=True)
evaluation = runner.evaluate()
accuracy_df = evaluation[evaluation['metric_name'] == 'accuracy']
assert np.alltrue(accuracy_df['metric_res'] > 0.98)
mae_df = evaluation[evaluation['metric_name'] == 'mean_absolute_error']
assert np.alltrue(mae_df['metric_res'] < 5e-2)
pd.set_option('display.max_columns', None)
def test_composite_activation():
3
Source : test_data.py
with MIT License
from JarnoRFB
with MIT License
from JarnoRFB
def test_time_series_classification_generator_train_spacing(tsc_data):
frame_lengths = [len(X) for X, _ in tsc_data.train_gen]
assert np.alltrue(pd.Series(frame_lengths).diff().dropna() == 1)
def test_time_series_classification_generator_test_spacing(tsc_data):
3
Source : test_data.py
with MIT License
from JarnoRFB
with MIT License
from JarnoRFB
def test_time_series_classification_generator_test_spacing(tsc_data):
frame_lengths = [len(X) for X, _ in tsc_data.test_gen]
assert np.alltrue(pd.Series(frame_lengths).diff().dropna() == 1)
def test_train_ends_before_test(tsc_data):
3
Source : optimize.py
with MIT License
from ktraunmueller
with MIT License
from ktraunmueller
def derivative(self, x, *args):
if self.jac is not None and numpy.alltrue(x == self.x):
return self.jac
else:
self(x, *args)
return self.jac
class Result(dict):
3
Source : size_check.py
with MIT License
from ktraunmueller
with MIT License
from ktraunmueller
def __cmp__(self,other):
# This isn't an exact compare, but does work for ==
# cluge for Numeric
if isnumeric(other):
return 0
if len(self.shape) == len(other.shape) == 0:
return 0
return not alltrue(equal(self.shape,other.shape),axis=0)
def __add__(self,other):
3
Source : test_array_from_pyobj.py
with MIT License
from mgotovtsev
with MIT License
from mgotovtsev
def arr_equal(self, arr1, arr2):
if arr1.shape != arr2.shape:
return False
s = arr1==arr2
return alltrue(s.flatten())
def __str__(self):
3
Source : ctr.py
with Apache License 2.0
from PreferredAI
with Apache License 2.0
from PreferredAI
def _is_on_simplex(v, s):
if v.sum() < s + 1e-10 and np.alltrue(v > 0):
return True
return False
def _simplex_project(v, s=1):
3
Source : test_nonparametric.py
with GNU General Public License v3.0
from raphaelvallat
with GNU General Public License v3.0
from raphaelvallat
def test_madmedianrule(self):
"""Test function madmedianrule."""
a = [1.2, 3, 4.5, 2.4, 5, 12.7, 0.4]
assert np.alltrue(madmedianrule(a) == [False, False, False,
False, False, True, False])
def test_mwu(self):
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_gd_cc():
u.vector()[:] = 0.0
ocp_cc._erase_pde_memory()
ocp_cc.solve("gd", rtol=1e-2, atol=0.0, max_iter=22)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_cg_fr_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_cg_fr_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoCG", "cg_method", "FR")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("cg", rtol=1e-2, atol=0.0, max_iter=48)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_cg_pr_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_cg_pr_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoCG", "cg_method", "PR")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("cg", rtol=1e-2, atol=0.0, max_iter=25)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_cg_hs_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_cg_hs_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoCG", "cg_method", "HS")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("cg", rtol=1e-2, atol=0.0, max_iter=30)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_cg_dy_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_cg_dy_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoCG", "cg_method", "DY")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("cg", rtol=1e-2, atol=0.0, max_iter=9)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_cg_hz_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_cg_hz_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoCG", "cg_method", "HZ")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("cg", rtol=1e-2, atol=0.0, max_iter=37)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_lbfgs_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_lbfgs_cc():
u.vector()[:] = 0.0
ocp_cc._erase_pde_memory()
ocp_cc.solve("lbfgs", rtol=1e-2, atol=0.0, max_iter=11)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_newton_cg_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_newton_cg_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoTNM", "inner_newton", "cg")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("newton", rtol=1e-2, atol=0.0, max_iter=8)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_control_newton_cr_cc():
3
Source : test_optimal_control.py
with GNU General Public License v3.0
from sblauth
with GNU General Public License v3.0
from sblauth
def test_control_newton_cr_cc():
config = cashocs.load_config(dir_path + "/config_ocp.ini")
config.set("AlgoTNM", "inner_newton", "cr")
u.vector()[:] = 0.0
ocp_cc = cashocs.OptimalControlProblem(
F, bcs, J, y, u, p, config, control_constraints=cc
)
ocp_cc.solve("newton", rtol=1e-2, atol=0.0, max_iter=9)
assert ocp_cc.solver.relative_norm < = ocp_cc.solver.rtol
assert np.alltrue(ocp_cc.controls[0].vector()[:] >= cc[0])
assert np.alltrue(ocp_cc.controls[0].vector()[:] < = cc[1])
def test_custom_supply_control():
3
Source : base.py
with Apache License 2.0
from seung-lab
with Apache License 2.0
from seung-lab
def maskout(self, chunk):
""" Make part of the chunk to be black.
"""
assert chunk.voxel_size
assert self.voxel_size
# the voxel size should be divisible
div = tuple(s%c==0 for s, c in zip(self.voxel_size, chunk.voxel_size))
assert np.alltrue(div)
factor = tuple(s//c for s, c in zip(self.voxel_size, chunk.voxel_size))
for offset in np.ndindex(factor):
chunk.array[
...,
np.s_[offset[0]::factor[0]],
np.s_[offset[1]::factor[1]],
np.s_[offset[2]::factor[2]]] *= self.array
def _get_overlap_slices(self, other_slices):
3
Source : test_integration.py
with MIT License
from smacke
with MIT License
from smacke
def timestamps_roughly_match(f1, f2):
parser = GenericSubtitleParser(skip_ssa_info=True)
extractor = SubtitleSpeechTransformer(sample_rate=ffsubsync.DEFAULT_FRAME_RATE)
pipe = make_pipeline(parser, extractor)
f1_bitstring = pipe.fit_transform(f1).astype(bool)
f2_bitstring = pipe.fit_transform(f2).astype(bool)
return np.alltrue(f1_bitstring == f2_bitstring)
def detected_encoding(fname):
3
Source : test_common.py
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
def test_rw_all_set_one(las):
for dim_name in las.point_format.dimension_names:
las[dim_name][:] = 1
for dim_name in las.point_format.dimension_names:
assert np.alltrue(las[dim_name] == 1), "{} not equal".format(dim_name)
las2 = write_then_read_again(las)
for dim_name in las.point_format.dimension_names:
assert np.alltrue(las[dim_name] == las2[dim_name]), "{} not equal".format(
dim_name
)
def test_coords_do_not_break(las):
3
Source : test_extrabytes.py
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
def test_extra_bytes_with_spaces_in_name(simple_las_path):
"""
Test that we can create extra bytes with spaces in their name
and that they can be accessed using __getitem__ ( [] )
as de normal '.name' won't work
"""
las = pylas.read(simple_las_path)
las.add_extra_dim(pylas.ExtraBytesParams(name="Name With Spaces", type="int32"))
assert np.alltrue(las["Name With Spaces"] == 0)
las["Name With Spaces"][:] = 789_464
las = write_then_read_again(las)
np.alltrue(las["Name With Spaces"] == 789_464)
def test_conversion_keeps_eb(las_file_path_with_extra_bytes):
3
Source : test_modif_1_4.py
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
def test_classification(las):
las.classification[:] = 234
assert np.alltrue(las.classification == 234)
res = write_then_read_again(las)
assert np.alltrue(las.classification == res.classification)
def test_intensity(las):
3
Source : test_modif_1_4.py
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
with BSD 3-Clause "New" or "Revised" License
from tmontaigu
def test_intensity(las):
las.intensity[:] = 89
assert np.alltrue(las.intensity == 89)
res = write_then_read_again(las)
assert np.alltrue(las.intensity == res.intensity)
def test_writing_las_with_evlrs():
3
Source : test_quantum.py
with Apache License 2.0
from XanaduAI
with Apache License 2.0
from XanaduAI
def test_loss_is_nonnegative_matrix(eta):
"""Test the loss matrix is a nonnegative matrix"""
n = 50
M = loss_mat(eta, n)
assert np.alltrue(M >= 0.0)
@pytest.mark.parametrize("eta", [-1.0, 2.0])
3
Source : test_chain.py
with BSD 3-Clause "New" or "Revised" License
from zfit
with BSD 3-Clause "New" or "Revised" License
from zfit
def test_kstargamma():
"""Test B0 -> K*gamma."""
decay = decays.b0_to_kstar_gamma()
norm_weights, particles = decay.generate(n_events=1000)
assert norm_weights.shape[0] == 1000
assert np.alltrue(norm_weights < 1)
assert len(particles) == 4
assert set(particles.keys()) == {"K*0", "gamma", "K+", "pi-"}
assert all(part.shape == (1000, 4) for part in particles.values())
def test_k1gamma():
3
Source : test_chain.py
with BSD 3-Clause "New" or "Revised" License
from zfit
with BSD 3-Clause "New" or "Revised" License
from zfit
def test_k1gamma():
"""Test B+ -> K1 (K*pi) gamma."""
decay = decays.bp_to_k1_kstar_pi_gamma()
norm_weights, particles = decay.generate(n_events=1000)
assert norm_weights.shape[0] == 1000
assert np.alltrue(norm_weights < 1)
assert len(particles) == 6
assert set(particles.keys()) == {"K1+", "K*0", "gamma", "K+", "pi-", "pi+"}
assert all(part.shape == (1000, 4) for part in particles.values())
def test_repr():
3
Source : test_generate.py
with BSD 3-Clause "New" or "Revised" License
from zfit
with BSD 3-Clause "New" or "Revised" License
from zfit
def test_one_event():
"""Test B->pi pi pi."""
decay = phasespace.nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
norm_weights, particles = decay.generate(n_events=1)
assert norm_weights.shape[0] == 1
assert np.alltrue(norm_weights < 1)
assert len(particles) == 3
assert all(part.shape == (1, 4) for part in particles.values())
def test_one_event_tf():
3
Source : test_generate.py
with BSD 3-Clause "New" or "Revised" License
from zfit
with BSD 3-Clause "New" or "Revised" License
from zfit
def test_one_event_tf():
"""Test B->pi pi pi."""
decay = phasespace.nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
norm_weights, particles = decay.generate(n_events=1)
assert norm_weights.shape[0] == 1
assert np.alltrue(norm_weights < 1)
assert len(particles) == 3
assert all(part.shape == (1, 4) for part in particles.values())
@pytest.mark.parametrize("n_events", argvalues=[5, 523])
3
Source : test_generate.py
with BSD 3-Clause "New" or "Revised" License
from zfit
with BSD 3-Clause "New" or "Revised" License
from zfit
def test_n_events(n_events):
"""Test 5 B->pi pi pi."""
decay = phasespace.nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
norm_weights, particles = decay.generate(n_events=n_events)
assert norm_weights.shape[0] == n_events
assert np.alltrue(norm_weights < 1)
assert len(particles) == 3
assert all(part.shape == (n_events, 4) for part in particles.values())
def test_deterministic_events():
0
Source : fitpack2.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def __init__(self, x, y, t, w=None, bbox=[None]*2, k=3,
ext=0, check_finite=False):
if check_finite:
w_finite = np.isfinite(w).all() if w is not None else True
if (not np.isfinite(x).all() or not np.isfinite(y).all() or
not w_finite or not np.isfinite(t).all()):
raise ValueError("Input(s) must not contain NaNs or infs.")
if not all(diff(x) > 0.0):
raise ValueError('x must be strictly increasing')
# _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier
xb = bbox[0]
xe = bbox[1]
if xb is None:
xb = x[0]
if xe is None:
xe = x[-1]
t = concatenate(([xb]*(k+1), t, [xe]*(k+1)))
n = len(t)
if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0, axis=0):
raise ValueError('Interior knots t must satisfy '
'Schoenberg-Whitney conditions')
if not dfitpack.fpchec(x, t, k) == 0:
raise ValueError(_fpchec_error_string)
data = dfitpack.fpcurfm1(x, y, k, t, w=w, xb=xb, xe=xe)
self._data = data[:-3] + (None, None, data[-1])
self._reset_class()
try:
self.ext = _extrap_modes[ext]
except KeyError:
raise ValueError("Unknown extrapolation mode %s." % ext)
################ Bivariate spline ####################
class _BivariateSplineBase(object):
0
Source : figure.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
"""
Date ticklabels often overlap, so it is useful to rotate them
and right align them. Also, a common use case is a number of
subplots with shared xaxes where the x-axis is date data. The
ticklabels are often long, and it helps to rotate them on the
bottom subplot and turn them off on other subplots, as well as
turn off xlabels.
*bottom*
The bottom of the subplots for :meth:`subplots_adjust`
*rotation*
The rotation of the xtick labels
*ha*
The horizontal alignment of the xticklabels
"""
allsubplots = np.alltrue([hasattr(ax, 'is_last_row') for ax
in self.axes])
if len(self.axes) == 1:
for label in self.axes[0].get_xticklabels():
label.set_ha(ha)
label.set_rotation(rotation)
else:
if allsubplots:
for ax in self.get_axes():
if ax.is_last_row():
for label in ax.get_xticklabels():
label.set_ha(ha)
label.set_rotation(rotation)
else:
for label in ax.get_xticklabels():
label.set_visible(False)
ax.set_xlabel('')
if allsubplots:
self.subplots_adjust(bottom=bottom)
def get_children(self):
0
Source : functions.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def alltrue(x, axis=0):
return np.alltrue(x, axis)
def and_(a, b):
0
Source : functions.py
with GNU General Public License v3.0
from Artikash
with GNU General Public License v3.0
from Artikash
def alltrue(x, axis=0):
return np.alltrue(x, axis)
def cumsum(x, axis=0):
See More Examples