Best Python code snippet using keyboard
test_core.py
Source:test_core.py
1import numpy as np2import quakeio3def test_mul():4 from .test_csmip import test_read_event5 event = test_read_event()6def test_rotate():7 # pick an arbitrary time8 time = 239 angle = 21/7/310 rotation = np.array([11 [ np.cos(angle), np.sin(angle)],12 [-np.sin(angle), np.cos(angle)]13 ])14 # read event15 from .test_csmip import test_read_event16 event = test_read_event()17 assert type(event) == quakeio.core.QuakeCollection18 mot = event.motions["bent_4_north_column_grnd_level"]19 assert type(mot) == quakeio.core.QuakeMotion20 a_long, a_tran = mot.long.accel.data[time], mot.tran.accel.data[time]21 22 # Apply rotation to record23 mot.rotate(angle) 24 A_long_rot, A_tran_rot = mot.long.accel, mot.tran.accel25 # Ensure that rotation does not alter object types26 assert type(A_long_rot) == quakeio.core.QuakeSeries27 assert type(A_tran_rot) == quakeio.core.QuakeSeries28 # manually calculate values 29 a_calc_long, a_calc_tran = rotation @ np.array([[a_long],[a_tran]])30 # Assert rotation matches manual calc31 assert np.isclose(float(A_long_rot.data[time]), float(a_calc_long))32 assert np.isclose(float(A_tran_rot.data[time]), float(a_calc_tran))33def test_rotate_displ():34 # pick an arbitrary time35 time = 2336 angle = 21/7/337 rotation = np.array([38 [ np.cos(angle), np.sin(angle)],39 [-np.sin(angle), np.cos(angle)]40 ])41 # read event42 from .test_csmip import test_read_event43 event = test_read_event()44 assert type(event) == quakeio.core.QuakeCollection45 mot = event.motions["bent_4_north_column_grnd_level"]46 assert type(mot) == quakeio.core.QuakeMotion47 a_long, a_tran = mot.long.displ.data[time], mot.tran.displ.data[time]48 49 # Apply rotation to record50 mot.rotate(angle) 51 D_long_rot, D_tran_rot = mot.long.displ, mot.tran.displ52 # Ensure that rotation does not alter object types53 assert type(D_long_rot) == quakeio.core.QuakeSeries54 assert type(D_tran_rot) == quakeio.core.QuakeSeries55 # manually calculate values 56 a_calc_long, a_calc_tran = rotation @ np.array([[a_long],[a_tran]])57 # Assert rotation matches manual calc...
test_csmip.py
Source:test_csmip.py
...4csmip_dir = Path("dat/58658_007_20210426_10.09.54.P/")5#----------------------------------------------------------------------6# Record (.v2)7#----------------------------------------------------------------------8def test_read_event():9 return quakeio.csmip.read_event(csmip_archive)10def test_unique():11 event = test_read_event()12 all_components = [c for m in event.motions.values() for c in m.components]13 #all_components = [m for m in event.motions]# for c in m.components]14 assert len(all_components) == 2015#----------------------------------------------------------------------16# Record (.v2)17#----------------------------------------------------------------------18def test_2():19 csmip_record = quakeio.csmip.read_record(csmip_dir / "chan001.v2")20 quakeio.write("-", csmip_record, "json")21def test_read():22 csmip_record = quakeio.read(csmip_dir / "chan001.v2")23 quakeio.write("-", csmip_record, "yaml", summarize=True)24 return csmip_record25def test_peak():...
test_read_event.py
Source:test_read_event.py
1import brownie2def test_read_event(usdt, alice):3 value = 1000*10**18;4 aliceBeforeBalance = usdt.balanceOf(alice)5 assert aliceBeforeBalance == 06 tx = usdt._mint_for_testing(alice, value)7 assert tx.events[0].name == 'Transfer'8 assert tx.events['Transfer']['_value'] == value9 assert tx.events['Transfer']['_from'] == '0x0000000000000000000000000000000000000000'10 assert tx.events['Transfer']['_to'] == alice11 aliceAfterBalance = usdt.balanceOf(alice)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!