How to use test_sizing method in Molotov

Best Python code snippet using molotov_python

test_TextureAtlas.py

Source:test_TextureAtlas.py Github

copy

Full Screen

1# author: Zach Crabtree zacharyc@alleninstitute.org2import unittest3from aicsimageio import AICSImage4from aicsimageprocessing.textureAtlas import generate_texture_atlas5class TestTextureAtlas(unittest.TestCase):6 def test_Save(self):7 image = AICSImage("aicsimageprocessing/tests/img/img40_1.ome.tif")8 atlas = generate_texture_atlas(9 im=image,10 pack_order=[[0, 1, 2], [3], [4]],11 name="test_Sizing",12 max_edge=1024,13 )14 atlas.save("img/atlas_max")15 def test_Sizing(self):16 # arrange17 image = AICSImage("aicsimageprocessing/tests/img/img40_1.ome.tif")18 max_edge = 204819 # act20 atlas = generate_texture_atlas(21 im=image,22 name="test_Sizing",23 max_edge=max_edge,24 pack_order=[[3, 2, 1, 0], [4]],25 )26 atlas_maxedge = max(atlas.dims.atlas_width, atlas.dims.atlas_height)27 # assert28 self.assertTrue(atlas_maxedge <= max_edge)29 def test_pickChannels(self):30 packing_list = [[0], [1, 2], [3, 4]]31 # arrange32 image = AICSImage("aicsimageprocessing/tests/img/img40_1.ome.tif")33 # act34 atlas = generate_texture_atlas(35 image, name="test_pickChannels", pack_order=packing_list36 )37 # returns as dict38 # metadata = atlas.get_metadata()39 # returns list of dicts40 image_dicts = atlas.atlas_list41 output_packed = [img.metadata["channels"] for img in image_dicts]42 # assert43 self.assertEqual(packing_list, output_packed)44 def test_metadata(self):45 packing_list = [[0], [1, 2], [3, 4]]46 prefix = "atlas"47 # arrange48 image = AICSImage("aicsimageprocessing/tests/img/img40_1.ome.tif")49 # act50 atlas = generate_texture_atlas(51 image, name=prefix, pack_order=packing_list52 )53 # assert54 metadata = atlas.get_metadata()55 self.assertTrue(56 all(57 key in metadata58 for key in (59 "tile_width",60 "tile_height",61 "width",62 "height",63 "channels",64 "channel_names",65 "tiles",66 "rows",67 "cols",68 "atlas_width",69 "atlas_height",70 "images",71 )72 )73 )...

Full Screen

Full Screen

supervisedpolynomial.py

Source:supervisedpolynomial.py Github

copy

Full Screen

1import pandas as pd 2import numpy as np3import matplotlib.pyplot as plt4from sklearn.model_selection import train_test_split5from sklearn.preprocessing import PolynomialFeatures6from sklearn.linear_model import LinearRegression7from sklearn.pipeline import Pipeline8from sklearn.model_selection import GridSearchCV910class Polynomialfit():11 12 def __init__(self, data_frame, low_degree, high_degree, x_curve_start, x_curve_stop, linspace_num=50, test_size = 0.2, random_state = None):13 self.data_frame = data_frame14 self.low_degree = low_degree15 self.high_degree = high_degree16 self.dataFrameHandler(self.data_frame)17 self.stratifiedHandler(test_size, random_state)18 self.polynomialEstimatorHandler()19 self.X_curve = self.getXCurve(x_curve_start, x_curve_stop, linspace_num)20 self.y_curve = self.getYCurve()21 22 def dataFrameHandler(self, data_frame):23 self.X = data_frame.values[:,0].reshape(-1,1)24 self.y = data_frame.values[:,1]25 26 def stratifiedHandler(self, test_sizing, rdm_state):27 bins = np.round(self.X)28 self.X_train, self.X_test, self.y_train, self.y_test = train_test_split(self.X,self.y,test_size = test_sizing, stratify = bins, random_state=rdm_state)29 30 def polynomialEstimatorHandler(self):31 pipeline = Pipeline((32 ("poly_features", PolynomialFeatures(degree=2)),33 ("lin_reg", LinearRegression(fit_intercept=False)),))3435 degrees = range(1,20)36 parameters = {"poly_features__degree": degrees}3738 grid_search = GridSearchCV(pipeline, parameters, cv=5)3940 # Fit GridSearchCV object41 grid_search.fit(self.X_train, self.y_train)42 43 # extract the selected model44 self.best_model = grid_search.best_estimator_45 46 def getXCurve(self, x_curve_start, x_curve_stop, linspace_num):47 return np.linspace(x_curve_start, x_curve_stop, linspace_num).reshape(-1, 1)48 49 def getYCurve(self):50 return self.best_model.predict(self.X_curve)51 52 def plot(self):53 plt.title('Polynomial fit')54 plt.xlabel('Feature')55 plt.ylabel('Target value') 56 plt.plot(self.X_train, self.y_train, 'o', label='Training Data')57 plt.plot(self.X_test, self.y_test, 'o', label='Test Data')58 plt.plot(self.X_curve, self.y_curve, 'r')59 plt.legend() ...

Full Screen

Full Screen

test_pairs.py

Source:test_pairs.py Github

copy

Full Screen

1from math import floor2from twcli.pairs import sizing3def test_sizing():4 """Apply test cases for pairs sizing"""5 args = dict(price_left=100, price_right=25, vol_left=2, vol_right=7,6 unit_size_left=100, multiplier_left=1, multiplier_right=1)7 def msg():8 return f"Expected {exp:.2f} units, but calculated {act:.2f}."9 pair_specs = sizing.size(**args)10 exp = 11411 act = floor(pair_specs['unit_size_right'])12 assert act == exp, msg()13 args['multiplier_left'] = 10014 args['multiplier_right'] = 1015 pair_specs = sizing.size(**args)16 exp = 114217 act = floor(pair_specs['unit_size_right'])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Molotov automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful