Here are the examples of the python api numpy.array_equal taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2485 Examples
5
Source : test_models.py
with MIT License
from eellak
with MIT License
from eellak
def test_de_models_vectors(example):
# if vectors are available, they should differ on different words
# this isn't a perfect test since this could in principle fail
# in a sane model as well,
# but that's very unlikely and a good indicator if something is wrong
vector0 = example[0].vector
vector1 = example[1].vector
vector2 = example[2].vector
assert not numpy.array_equal(vector0,vector1)
assert not numpy.array_equal(vector0,vector2)
assert not numpy.array_equal(vector1,vector2)
@pytest.mark.xfail
5
Source : test_models.py
with MIT License
from eellak
with MIT License
from eellak
def test_en_models_vectors(example):
# if vectors are available, they should differ on different words
# this isn't a perfect test since this could in principle fail
# in a sane model as well,
# but that's very unlikely and a good indicator if something is wrong
if example.vocab.vectors_length:
vector0 = example[0].vector
vector1 = example[1].vector
vector2 = example[2].vector
assert not numpy.array_equal(vector0,vector1)
assert not numpy.array_equal(vector0,vector2)
assert not numpy.array_equal(vector1,vector2)
@pytest.mark.xfail
3
Source : test_settings.py
with BSD 3-Clause "New" or "Revised" License
from 4DNucleome
with BSD 3-Clause "New" or "Revised" License
from 4DNucleome
def test_set_segmentation_result(self, stack_settings, stack_segmentation1, stack_image):
stack_settings.set_project_info(stack_image)
seg = ROIExtractionResult(
roi=stack_segmentation1.roi_info.roi,
parameters=ROIExtractionProfile(name="test", algorithm="test2", values={}),
)
stack_settings.set_segmentation_result(seg)
assert stack_settings.last_executed_algorithm == "test2"
assert np.array_equal(stack_settings.roi, stack_segmentation1.roi_info.roi)
def test_selected_components(self, stack_settings, stack_segmentation1):
3
Source : test_settings.py
with BSD 3-Clause "New" or "Revised" License
from 4DNucleome
with BSD 3-Clause "New" or "Revised" License
from 4DNucleome
def test_selected_components(self, stack_settings, stack_segmentation1):
stack_settings.set_project_info(stack_segmentation1)
assert stack_settings.chosen_components() == [1, 3]
assert stack_settings.component_is_chosen(1)
assert not stack_settings.component_is_chosen(2)
assert np.array_equal(stack_settings.components_mask(), [0, 1, 0, 1, 0])
stack_settings.chosen_components_widget.un_check_all()
assert stack_settings.chosen_components() == []
stack_settings.chosen_components_widget.check_all()
assert stack_settings.chosen_components() == list(range(1, stack_segmentation1.roi_info.roi.max() + 1))
class TestBaseSettings:
3
Source : ant_collect_sac.py
with MIT License
from abbyvansoest
with MIT License
from abbyvansoest
def get_state(env, obs, wrapped=False):
if wrapped:
state = env.unwrapped.state_vector()
else:
state = env.env.state_vector()
if not np.array_equal(obs[:len(state) - 2], state[2:]):
utils.log_statement(obs)
utils.log_statement(state)
raise ValueError("state and observation are not equal")
return state
def compute_states_visited_xy(env, policies, T, n, norm=[],
3
Source : ant_soft_actor_critic.py
with MIT License
from abbyvansoest
with MIT License
from abbyvansoest
def get_state(env, obs):
state = env.env.state_vector()
if not np.array_equal(obs[:len(state) - 2], state[2:]):
print(obs)
print(state)
raise ValueError("state and observation are not equal")
return state
class ReplayBuffer:
3
Source : cheetah_utils.py
with MIT License
from abbyvansoest
with MIT License
from abbyvansoest
def get_state(env, obs, wrapped=False):
if wrapped:
state = env.unwrapped.state_vector()
else:
state = env.env.state_vector()
if not np.array_equal(obs[:len(state) - 1], state[1:]):
utils.log_statement(obs)
utils.log_statement(state)
raise ValueError("state and observation are not equal")
# print(state[special])
return state
3
Source : swimmer_utils.py
with MIT License
from abbyvansoest
with MIT License
from abbyvansoest
def get_state(env, obs, wrapped=False):
if wrapped:
state = env.unwrapped.state_vector()
else:
state = env.env.state_vector()
if not np.array_equal(obs[:len(state) - 2], state[2:]):
utils.log_statement(obs)
utils.log_statement(state)
raise ValueError("state and observation are not equal")
# state[2:5] = np.unwrap(state[2:5])
return state
3
Source : humanoid_utils.py
with MIT License
from abbyvansoest
with MIT License
from abbyvansoest
def get_state(env, obs, wrapped=False):
if wrapped:
state = env.unwrapped.state_vector()
else:
state = env.env.state_vector()
if not np.array_equal(obs[:len(state) - 2], state[2:]):
utils.log_statement(obs)
utils.log_statement(state)
raise ValueError("state and observation are not equal")
return state
def discretize_range(lower_bound, upper_bound, num_bins):
3
Source : test_transform.py
with Apache License 2.0
from Accenture
with Apache License 2.0
from Accenture
def assert_is_shear(transform):
assert transform.shape == (3, 3)
assert np.array_equal(transform[:, 0], [1, 0, 0])
assert np.array_equal(transform[:, 2], [0, 0, 1])
assert transform[2, 1] == 0
# sin^2 + cos^2 == 1
assert_almost_equal(1, transform[0, 1] ** 2 + transform[1, 1] ** 2)
def test_random_shear():
3
Source : test_transform.py
with Apache License 2.0
from Accenture
with Apache License 2.0
from Accenture
def assert_is_scaling(transform, min, max):
assert transform.shape == (3, 3)
assert np.array_equal(transform[2, :], [0, 0, 1])
assert np.array_equal(transform[:, 2], [0, 0, 1])
assert transform[1, 0] == 0
assert transform[0, 1] == 0
assert np.greater_equal(np.diagonal(transform)[:2], min).all()
assert np.less( np.diagonal(transform)[:2], max).all()
def test_random_scaling():
3
Source : test_transform.py
with Apache License 2.0
from Accenture
with Apache License 2.0
from Accenture
def assert_is_flip(transform):
assert transform.shape == (3, 3)
assert np.array_equal(transform[2, :], [0, 0, 1])
assert np.array_equal(transform[:, 2], [0, 0, 1])
assert transform[1, 0] == 0
assert transform[0, 1] == 0
assert abs(transform[0, 0]) == 1
assert abs(transform[1, 1]) == 1
def test_random_flip():
3
Source : test_normalized_matrix.py
with Apache License 2.0
from ADALabUCSD
with Apache License 2.0
from ADALabUCSD
def test_transpose(self):
n_matrix = self.n_matrix
assert_equal(n_matrix.T.T.sum(axis=0), n_matrix.sum(axis=0))
assert_equal(np.array_equal(n_matrix.T.sum(
axis=0), n_matrix.sum(axis=0)), False)
def test_inverse(self):
3
Source : mbpt.py
with GNU General Public License v3.0
from adgproject
with GNU General Public License v3.0
from adgproject
def is_complex_conjug_of(self, test_diagram):
"""Return True if self and test_diagram are complex conjugate.
Args:
test_diagram (MbptDiagram): A diagram to compare with.
Return:
(bool): The complex conjugate status of the pair of diagrams.
"""
# Check the adjacency mat against the anti-transposed one of test_diag
return np.array_equal(self.adjacency_mat,
test_diagram.adjacency_mat[::-1, ::-1].T)
def attribute_ph_labels(self):
3
Source : _differentiable_functions.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def fun(self, x):
if not np.array_equal(x, self.x):
self._update_x_impl(x)
self._update_fun()
return self.f
def grad(self, x):
3
Source : _differentiable_functions.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def grad(self, x):
if not np.array_equal(x, self.x):
self._update_x_impl(x)
self._update_grad()
return self.g
def hess(self, x):
3
Source : _differentiable_functions.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def hess(self, x):
if not np.array_equal(x, self.x):
self._update_x_impl(x)
self._update_hess()
return self.H
class VectorFunction(object):
3
Source : _differentiable_functions.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def _update_v(self, v):
if not np.array_equal(v, self.v):
self.v = v
self.H_updated = False
def _update_x(self, x):
3
Source : _differentiable_functions.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def _update_x(self, x):
if not np.array_equal(x, self.x):
self.x = x
self.f_updated = False
def fun(self, x):
3
Source : test_letter.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_minimum_pixels_per_cc(self):
"""minimum_pixels_per_cc"""
out_img1 = self.tdata.get('swtimage.letters').get('param_mippc.mat1')
out_img2 = self.tdata.get('swtimage.letters').get('param_mippc.mat2')
_ = self.swtImgObj0.localizeLetters(display=False)
res1 = self.swtImgObj0.image_original_masked_letter_localized
_ = self.swtImgObj0.localizeLetters(minimum_pixels_per_cc=9000, display=False)
res2 = self.swtImgObj0.image_original_masked_letter_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_maximum_pixels_per_cc(self):
3
Source : test_letter.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_maximum_pixels_per_cc(self):
"""maximum_pixels_per_cc"""
out_img1 = self.tdata.get('swtimage.letters').get('param_mxppc.mat1')
out_img2 = self.tdata.get('swtimage.letters').get('param_mxppc.mat2')
_ = self.swtImgObj0.localizeLetters(maximum_pixels_per_cc=3_000, display=False)
res1 = self.swtImgObj0.image_original_masked_letter_localized
_ = self.swtImgObj0.localizeLetters(maximum_pixels_per_cc=5_000, display=False)
res2 = self.swtImgObj0.image_original_masked_letter_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_acceptable_aspect_ratio(self):
3
Source : test_letter.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_acceptable_aspect_ratio(self):
"""acceptable_aspect_ratio"""
out_img1 = self.tdata.get('swtimage.letters').get('param_aar.mat1')
out_img2 = self.tdata.get('swtimage.letters').get('param_aar.mat2')
_ = self.swtImgObj1.localizeLetters(acceptable_aspect_ratio=0.5, display=False)
res1 = self.swtImgObj1.image_original_masked_letter_localized
_ = self.swtImgObj1.localizeLetters(acceptable_aspect_ratio=0.005, display=False)
res2 = self.swtImgObj1.image_original_masked_letter_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_localize_by(self):
3
Source : test_letter.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_localize_by(self):
"""localize_by"""
out_img1 = self.tdata.get('swtimage.letters').get('param_lb.mat1')
out_img2 = self.tdata.get('swtimage.letters').get('param_lb.mat2')
out_img3 = self.tdata.get('swtimage.letters').get('param_lb.mat3')
_ = self.swtImgObj1.localizeLetters(localize_by='min_bbox', display=False)
res1 = self.swtImgObj1.image_original_masked_letter_localized
_ = self.swtImgObj1.localizeLetters(localize_by='ext_bbox', display=False)
res2 = self.swtImgObj1.image_original_masked_letter_localized
_ = self.swtImgObj1.localizeLetters(localize_by='outline', display=False)
res3 = self.swtImgObj1.image_original_masked_letter_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
self.assertTrue(np.array_equal(res3, out_img3, equal_nan=True))
def test_padding_pct(self):
3
Source : test_letter.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_padding_pct(self):
"""padding_pct"""
out_img1 = self.tdata.get('swtimage.letters').get('param_pp.mat1')
out_img2 = self.tdata.get('swtimage.letters').get('param_pp.mat2')
_ = self.swtImgObj1.localizeLetters(display=False)
res1 = self.swtImgObj1.image_original_masked_letter_localized
_ = self.swtImgObj1.localizeLetters(padding_pct=0.1, display=False)
res2 = self.swtImgObj1.image_original_masked_letter_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def tearDown(self) -> None:
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_text_mode(self):
"""text_mode"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_tm.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_tm.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', display=False)
res2 = self.swtImgObj0.transformImage(text_mode='lb_df', display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_engine_time(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_gaussian_blurr(self):
"""gaussian_blurr"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_gb.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_gb.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', gaussian_blurr=True, display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', gaussian_blurr=False, display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_gaussian_blurr_kernel(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_gaussian_blurr_kernel(self):
"""gaussian_blurr_kernel"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_gbk.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_gbk.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', gaussian_blurr=True,
gaussian_blurr_kernel=(7, 7), display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', gaussian_blurr=True,
gaussian_blurr_kernel=(13, 13), display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_edge_function(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_edge_function(self):
"""edge_function"""
def custom_edge_func(gray_image):
gauss_image = cv2.GaussianBlur(gray_image, (5, 5), 1)
laplacian_conv = cv2.Laplacian(gauss_image, -1, (5, 5))
canny_edge = cv2.Canny(laplacian_conv, 20, 140)
return canny_edge
out_img1 = self.tdata.get('swtimage.transformimage').get('param_efce.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_efce.mat2')
res1 = self.swtImgObj1.transformImage(edge_function=custom_edge_func, display=False)
res2 = self.swtImgObj1.transformImage(edge_function='ac', display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_auto_canny_sigma(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_auto_canny_sigma(self):
"""auto_canny_sigma"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_eac_sig.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_eac_sig.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', auto_canny_sigma=0.1, display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', auto_canny_sigma=1.0, display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_include_edges_in_swt(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_include_edges_in_swt(self):
"""include_edges_in_swt"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_ince.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_ince.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', include_edges_in_swt=True,
gaussian_blurr_kernel=(11, 11), display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', include_edges_in_swt=False,
gaussian_blurr_kernel=(11, 11), display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_minimum_stroke_width(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_minimum_stroke_width(self):
"""minimum_stroke_width"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_misw.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_misw.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', minimum_stroke_width=10,
include_edges_in_swt=False, display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', minimum_stroke_width=20,
include_edges_in_swt=False, display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_maximum_stroke_width(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_maximum_stroke_width(self):
"""maximum_stroke_width"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_masw.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_masw.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', maximum_stroke_width=20, display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', maximum_stroke_width=70, display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_check_angle_deviation(self):
3
Source : test_transform.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_check_angle_deviation(self):
"""check_angle_deviation"""
out_img1 = self.tdata.get('swtimage.transformimage').get('param_cad.mat1')
out_img2 = self.tdata.get('swtimage.transformimage').get('param_cad.mat2')
res1 = self.swtImgObj0.transformImage(text_mode='db_lf', check_angle_deviation=True, display=False)
res2 = self.swtImgObj0.transformImage(text_mode='db_lf', check_angle_deviation=False, display=False)
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def test_maximum_angle_deviation(self):
3
Source : test_utils.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_auto_canny(self):
"""auto_canny"""
# Will match the result of test_img2 with (9, 9)
# gaussian blurr for sigma=0.33(default)
inp_img = self.tdata.get('utils.ac').get('inp_img')
out_img = self.tdata.get('utils.ac').get('out_img')
res = auto_canny(inp_img)
self.assertTrue(np.array_equal(res, out_img, equal_nan=True))
def test_image_1C_to_3C(self):
3
Source : test_utils.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_image_1C_to_3C(self):
"""image_1C_to_3C"""
swtl = SWTLocalizer(images=self.tdata.get('utils.i1c3c').get('inp_img').copy())
swtl_img_obj = swtl.swtimages[0]
swtmat = swtl_img_obj.transformImage(text_mode='lb_df', gaussian_blurr_kernel=(11, 11),
include_edges_in_swt=False, display=False)
swtmat[swtmat.nonzero()] = 255
_, swtmat, _, _ = get_connected_components_with_stats(swtmat)
res1 = image_1C_to_3C(swtmat)
out_img1 = self.tdata.get('utils.i1c3c').get('out_img.default').copy()
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
res2 = image_1C_to_3C(swtmat, scale_with_values=True)
out_img2 = self.tdata.get('utils.i1c3c').get('out_img.scale').copy()
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
def tearDown(self) -> None:
3
Source : test_word.py
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
with BSD 3-Clause "New" or "Revised" License
from ag-ds-bubble
def test_localize_by(self):
"""localize_by"""
out_img1 = self.tdata.get('swtimage.words').get('param_lb.mat1')
out_img2 = self.tdata.get('swtimage.words').get('param_lb.mat2')
out_img3 = self.tdata.get('swtimage.words').get('param_lb.mat3')
_ = self.swtImgObj0.localizeWords(localize_by='bubble', display=False)
res1 = self.swtImgObj0.image_original_masked_word_localized
_ = self.swtImgObj0.localizeWords(localize_by='bbox', display=False)
res2 = self.swtImgObj0.image_original_masked_word_localized
_ = self.swtImgObj0.localizeWords(localize_by='polygon', display=False)
res3 = self.swtImgObj0.image_original_masked_word_localized
self.assertTrue(np.array_equal(res1, out_img1, equal_nan=True))
self.assertTrue(np.array_equal(res2, out_img2, equal_nan=True))
self.assertTrue(np.array_equal(res3, out_img3, equal_nan=True))
def tearDown(self) -> None:
3
Source : run_model_page.py
with MIT License
from AIforGoodSimulator
with MIT License
from AIforGoodSimulator
def update_save_button_state(model, profile, profile_table_data, profile_table_columns):
if model is not None and profile is not None:
original_df = facade.ps.get_params(model, profile).drop(columns=['Profile'])
new_df = pd.DataFrame(profile_table_data, columns=[c['name'] for c in profile_table_columns])
return np.array_equal(original_df.values,new_df.values)
else:
return True
@dash_app.callback(
3
Source : test_medoids.py
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
def test_medoids():
"""Test medoids."""
X = create_test_distance_numpy(10, 3, 3, random_state=2)
test_medoids = medoids(X).tolist()
assert np.array_equal(
test_medoids,
[
[-0.16783866926192373, 0.3056703897868587, 0.023985295934094188],
[-0.41456764450738937, 0.04385510920416571, 0.5001829432753475],
[-0.19054625875767497, -0.18783471153949682, -0.03723538144699049],
],
)
3
Source : test_kernel_k_means.py
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
def test_kernel_k_means():
"""Test implementation of kernel k means."""
X_train, y_train = load_basic_motions(split="train")
X_test, y_test = load_basic_motions(split="test")
kernel_kmeans = TimeSeriesKernelKMeans(random_state=1, n_clusters=3)
kernel_kmeans.fit(X_train)
test_shape_result = kernel_kmeans.predict(X_test)
score = kernel_kmeans.score(X_test)
proba = kernel_kmeans.predict_proba(X_test)
assert np.array_equal(test_shape_result, expected_results)
np.testing.assert_almost_equal(score, expected_score)
assert kernel_kmeans.n_iter_ == expected_iters
assert np.array_equal(kernel_kmeans.labels_, expected_labels)
assert proba.shape == (40, 3)
for val in proba:
assert np.count_nonzero(val == 1.0) == 1
3
Source : test_k_shapes.py
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
def test_kshapes():
"""Test implementation of Kshapes."""
X_train, y_train = load_basic_motions(split="train")
X_test, y_test = load_basic_motions(split="test")
kshapes = TimeSeriesKShapes(random_state=1, n_clusters=3)
kshapes.fit(X_train)
test_shape_result = kshapes.predict(X_test)
score = kshapes.score(X_test)
proba = kshapes.predict_proba(X_test)
assert np.array_equal(test_shape_result, expected_results)
np.testing.assert_almost_equal(score, expected_score)
assert kshapes.n_iter_ == expected_iters
assert np.array_equal(kshapes.labels_, expected_labels)
assert proba.shape == (40, 3)
for val in proba:
assert np.count_nonzero(val == 1.0) == 1
3
Source : shapelet_transform.py
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
with BSD 3-Clause "New" or "Revised" License
from alan-turing-institute
def _remove_identical_shapelets(shapelets):
to_keep = [True] * len(shapelets)
for i in range(len(shapelets)):
for n in range(i + 1, len(shapelets)):
if (
to_keep[n]
and shapelets[i][1] == shapelets[n][1]
and np.array_equal(shapelets[i][6], shapelets[n][6])
):
to_keep[n] = False
return to_keep
@njit(fastmath=True, cache=True)
3
Source : test_augmentations.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_augmentations_wont_change_input(augmentation_cls, params, image, mask):
image_copy = image.copy()
mask_copy = mask.copy()
aug = augmentation_cls(p=1, **params)
aug(image=image, mask=mask)
assert np.array_equal(image, image_copy)
assert np.array_equal(mask, mask_copy)
@pytest.mark.parametrize(
3
Source : test_augmentations.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_augmentations_wont_change_float_input(augmentation_cls, params, float_image):
float_image_copy = float_image.copy()
aug = augmentation_cls(p=1, **params)
aug(image=float_image)
assert np.array_equal(float_image, float_image_copy)
@pytest.mark.parametrize(
3
Source : test_core.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_image_only_transform(image, mask):
height, width = image.shape[:2]
with mock.patch.object(ImageOnlyTransform, "apply") as mocked_apply:
with mock.patch.object(ImageOnlyTransform, "get_params", return_value={"interpolation": cv2.INTER_LINEAR}):
aug = ImageOnlyTransform(p=1)
data = aug(image=image, mask=mask)
mocked_apply.assert_called_once_with(image, interpolation=cv2.INTER_LINEAR, cols=width, rows=height)
assert np.array_equal(data["mask"], mask)
def test_dual_transform(image, mask):
3
Source : test_functional.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_compare_rotate_and_shift_scale_rotate(image):
rotated_img_1 = FGeometric.rotate(image, angle=60)
rotated_img_2 = FGeometric.shift_scale_rotate(image, angle=60, scale=1, dx=0, dy=0)
assert np.array_equal(rotated_img_1, rotated_img_2)
def test_compare_rotate_float_and_shift_scale_rotate_float(float_image):
3
Source : test_functional.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_compare_rotate_float_and_shift_scale_rotate_float(float_image):
rotated_img_1 = FGeometric.rotate(float_image, angle=60)
rotated_img_2 = FGeometric.shift_scale_rotate(float_image, angle=60, scale=1, dx=0, dy=0)
assert np.array_equal(rotated_img_1, rotated_img_2)
@pytest.mark.parametrize("target", ["image", "mask"])
3
Source : test_imgaug.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_imgaug_augmentations_serialization(augmentation_cls, params, p, seed, image, mask, always_apply):
aug = augmentation_cls(p=p, always_apply=always_apply, **params)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
ia.seed(seed)
aug_data = aug(image=image, mask=mask)
set_seed(seed)
ia.seed(seed)
deserialized_aug_data = deserialized_aug(image=image, mask=mask)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["mask"], deserialized_aug_data["mask"])
@pytest.mark.parametrize(
3
Source : test_imgaug.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_imgaug_augmentations_for_bboxes_serialization(
augmentation_cls, params, p, seed, image, albumentations_bboxes, always_apply
):
aug = augmentation_cls(p=p, always_apply=always_apply, **params)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
ia.seed(seed)
aug_data = aug(image=image, bboxes=albumentations_bboxes)
set_seed(seed)
ia.seed(seed)
deserialized_aug_data = deserialized_aug(image=image, bboxes=albumentations_bboxes)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["bboxes"], deserialized_aug_data["bboxes"])
@pytest.mark.parametrize(
3
Source : test_imgaug.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_imgaug_augmentations_for_keypoints_serialization(
augmentation_cls, params, p, seed, image, keypoints, always_apply
):
aug = augmentation_cls(p=p, always_apply=always_apply, **params)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
ia.seed(seed)
aug_data = aug(image=image, keypoints=keypoints)
set_seed(seed)
ia.seed(seed)
deserialized_aug_data = deserialized_aug(image=image, keypoints=keypoints)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["keypoints"], deserialized_aug_data["keypoints"])
@pytest.mark.parametrize(
3
Source : test_serialization.py
with MIT License
from albumentations-team
with MIT License
from albumentations-team
def test_augmentations_serialization(augmentation_cls, params, p, seed, image, mask, always_apply):
aug = augmentation_cls(p=p, always_apply=always_apply, **params)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
aug_data = aug(image=image, mask=mask)
set_seed(seed)
deserialized_aug_data = deserialized_aug(image=image, mask=mask)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["mask"], deserialized_aug_data["mask"])
AUGMENTATION_CLS_PARAMS = [
See More Examples