How to use test_experimental method in pytest-play

Best Python code snippet using pytest-play_python

imageStats.py

Source:imageStats.py Github

copy

Full Screen

1import sys, copy2import numpy as np3import itk4import numpy as np5import pandas as pd6from scipy import ndimage7CPUImageType = itk.Image[itk.F,2]8ReaderType = itk.ImageFileReader[CPUImageType]9reader = ReaderType.New();10reader.SetFileName(sys.argv[1]);11reader.Update();12reference_CT_slice=itk.GetArrayFromImage(reader.GetOutput());13reader.SetFileName(sys.argv[2]);14reader.Update();15simulated_CT_slice=itk.GetArrayFromImage(reader.GetOutput());16roi_length = 4017reference_fibre_in_centre = reference_CT_slice[429 - roi_length:430 + roi_length, 520 - roi_length:521 + roi_length];18test_fibre_in_centre = simulated_CT_slice[429 - roi_length:430 + roi_length, 520 - roi_length:521 + roi_length];19def create_circular_mask(h, w, center=None, radius=None):20 if center is None: # use the middle of the image21 center = (int(w/2), int(h/2))22 if radius is None: # use the smallest distance between the center and image walls23 radius = min(center[0], center[1], w-center[0], h-center[1])24 Y, X = np.ogrid[:h, :w]25 dist_from_center = np.sqrt((X - center[0])**2 + (Y-center[1])**2)26 mask = dist_from_center <= radius27 return np.array(mask, dtype=bool);28def createMasks(mask_shape):29 fibre_radius_in_px = int(108 / 1.9) / 230 core_radius_in_px = int(16 / 1.9) / 231 core_mask = create_circular_mask(mask_shape[1], mask_shape[0], None, core_radius_in_px);32 fibre_mask = create_circular_mask(mask_shape[1], mask_shape[0], None, fibre_radius_in_px);33 matrix_mask = np.logical_not(fibre_mask);34 #fibre_mask = np.subtract(fibre_mask, core_mask);35 fibre_mask = np.bitwise_xor(fibre_mask, core_mask);36 #TypeError: numpy boolean subtract, the `-` operator, is not supported, use the bitwise_xor, the `^` operator, or the logical_xor function instead.37 return core_mask, fibre_mask, matrix_mask38mask_shape = reference_fibre_in_centre.shape;39core_mask, fibre_mask, matrix_mask = createMasks(mask_shape);40core_mask = ndimage.binary_erosion(core_mask).astype(core_mask.dtype);41for i in range(4):42 fibre_mask = ndimage.binary_erosion(fibre_mask).astype(fibre_mask.dtype);43 matrix_mask = ndimage.binary_erosion(matrix_mask, border_value=1).astype(matrix_mask.dtype);44core_mask.shape = [core_mask.shape[0], core_mask.shape[1]]45fibre_mask.shape = [fibre_mask.shape[0], fibre_mask.shape[1]]46matrix_mask.shape = [matrix_mask.shape[0], matrix_mask.shape[1]]47def getMuStatistics(reference_fibre_in_centre, test_fibre_in_centre, core_mask, fibre_mask, matrix_mask):48 data = [];49 index = np.nonzero(core_mask);50 data.append(["Theorical",51 "Core",52 "W",53 341.61,54 341.61,55 341.61,56 0.0]);57 data.append(["Experimental",58 "Core",59 "W",60 np.min(reference_fibre_in_centre[index]),61 np.max(reference_fibre_in_centre[index]),62 np.mean(reference_fibre_in_centre[index]),63 np.std(reference_fibre_in_centre[index])]);64 data.append(["Simulated",65 "Core",66 "W",67 np.min(test_fibre_in_centre[index]),68 np.max(test_fibre_in_centre[index]),69 np.mean(test_fibre_in_centre[index]),70 np.std(test_fibre_in_centre[index])]);71 index = np.nonzero(fibre_mask);72 data.append(["Theorical",73 "Fibre",74 "SiC",75 2.736,76 2.736,77 2.736,78 0.0]);79 data.append(["Experimental",80 "Fibre",81 "SiC",82 np.min(reference_fibre_in_centre[index]),83 np.max(reference_fibre_in_centre[index]),84 np.mean(reference_fibre_in_centre[index]),85 np.std(reference_fibre_in_centre[index])]);86 data.append(["Simulated",87 "Fibre",88 "SiC",89 np.min(test_fibre_in_centre[index]),90 np.max(test_fibre_in_centre[index]),91 np.mean(test_fibre_in_centre[index]),92 np.std(test_fibre_in_centre[index])]);93 index = np.nonzero(matrix_mask);94 data.append(["Theorical",95 "Matrix",96 "Ti90Al6V4",97 13.1274,98 13.1274,99 13.1274,100 0.0]);101 data.append(["Experimental",102 "Matrix",103 "Ti90Al6V4",104 np.min(reference_fibre_in_centre[index]),105 np.max(reference_fibre_in_centre[index]),106 np.mean(reference_fibre_in_centre[index]),107 np.std(reference_fibre_in_centre[index])]);108 data.append(["Simulated",109 "Matrix",110 "Ti90Al6V4",111 np.min(test_fibre_in_centre[index]),112 np.max(test_fibre_in_centre[index]),113 np.mean(test_fibre_in_centre[index]),114 np.std(test_fibre_in_centre[index])]);115 return pd.DataFrame(data,116 index=None,117 columns=['CT', 'Structure', "Composition", 'min', 'max', 'mean', 'stddev'])118df = getMuStatistics(reference_fibre_in_centre, test_fibre_in_centre, core_mask, fibre_mask, matrix_mask)119test_experimental=df["CT"] == "Experimental";120test_simulated=df["CT"] == "Simulated";121test_W=df["Composition"] == "W"122test_SiC=df["Composition"] == "SiC"123test_Ti90Al6V4=df["Composition"] == "Ti90Al6V4"124print(df[test_experimental & test_W]["mean"].astype(float)[1],125 df[test_experimental & test_W]["stddev"].astype(float)[1],126 df[test_simulated & test_W]["mean"].astype(float)[2],127 df[test_simulated & test_W]["stddev"].astype(float)[2],128 df[test_experimental & test_SiC]["mean"].astype(float)[4],129 df[test_experimental & test_SiC]["stddev"].astype(float)[4],130 df[test_simulated & test_SiC]["mean"].astype(float)[5],131 df[test_simulated & test_SiC]["stddev"].astype(float)[5],132 df[test_experimental & test_Ti90Al6V4]["mean"].astype(float)[7],133 df[test_experimental & test_Ti90Al6V4]["stddev"].astype(float)[7],134 df[test_simulated & test_Ti90Al6V4]["mean"].astype(float)[8],135 df[test_simulated & test_Ti90Al6V4]["stddev"].astype(float)[8])136# MEAN_CORE_SIM=`grep "After noise CORE SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 13`137# STDDEV_CORE_SIM=`grep "After noise CORE SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 14`138#139# MEAN_FIBRE_REF=`grep "After noise FIBRE REF (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 13`140# STDDEV_FIBRE_REF=`grep "After noise FIBRE REF (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 14`141#142# MEAN_FIBRE_SIM=`grep "After noise FIBRE SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 13`143# STDDEV_FIBRE_SIM=`grep "After noise FIBRE SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 14`144#145# MEAN_MATRIX_REF=`grep "After noise MATRIX REF (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 13`146# STDDEV_MATRIX_REF=`grep "After noise MATRIX REF (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 14`147#148# MEAN_MATRIX_SIM=`grep "After noise MATRIX SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 13`149# STDDEV_MATRIX_SIM=`grep "After noise MATRIX SIMULATED (MIN, MEDIAN, MAX, MEAN, STDDEV)" run_SCW_$i/optimisation-$i.out | cut -d " " -f 14`...

Full Screen

Full Screen

test_experimental.py

Source:test_experimental.py Github

copy

Full Screen

2# Simon Hulse3# simon.hulse@chem.ox.ac.uk4# Last Edited: Thu 13 Jan 2022 17:31:26 GMT5from nmr_sims. experimental import Experimental6def test_experimental():7 experimental = Experimental(8 channels=["1H", "13C"],9 sweep_widths=[10000, 100000],10 field="800MHz",11 temperature="25C",...

Full Screen

Full Screen

test_experimental_data.py

Source:test_experimental_data.py Github

copy

Full Screen

1from neuromodcell.experimental_data import Experimental2def test_experimental():3 exp_trial = Experimental()4 exp_trial.define_exp(mean = 2)...

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 pytest-play 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