Best Python code snippet using assertpy_python
datareader_wave.py
Source: datareader_wave.py
1import os2import numpy as np3import pandas as pd4from dataframe import DataFrame5class DataReader(object):6 def __init__(self, data_dir):7 data_cols = [8 'data',9 'is_nan',10 'page_id',11 'project',12 'access',13 'agent',14 'test_data',15 'test_is_nan'16 ]17 data = [np.load(os.path.join(data_dir, '{}.npy'.format(i))) for i in data_cols]18 self.test_df = DataFrame(columns=data_cols, data=data)19 self.train_df, self.val_df = self.test_df.train_test_split(train_size=0.95)20 21 def describe(self, logger):22 logger.info('')23 logger.info('Data dimensions:')24 logger.info('train size', len(self.train_df))25 logger.info('val size', len(self.val_df))26 logger.info('test size', len(self.test_df))27 # logger.info(' [[data]] {}'.format(self.data.shape))28 #logger.info('Split seed = {}'.format(self.seed))29 logger.info('')30 def train_batch_generator(self, batch_size):31 return self.batch_generator(32 batch_size=batch_size,33 df=self.train_df,34 shuffle=True,35 num_epochs=10000,36 is_test=False37 )38 def val_batch_generator(self, batch_size):39 return self.batch_generator(40 batch_size=batch_size,41 df=self.val_df,42 shuffle=True,43 num_epochs=10000,44 is_test=False45 )46 def test_batch_generator(self, batch_size):47 return self.batch_generator(48 batch_size=batch_size,49 df=self.test_df,50 shuffle=True,51 num_epochs=1,52 is_test=True53 )54 def batch_generator(self, batch_size, df, shuffle=True, num_epochs=10000, is_test=False):55 batch_gen = df.batch_generator(56 batch_size=batch_size,57 shuffle=shuffle,58 num_epochs=num_epochs,59 allow_smaller_final_batch=is_test60 )61 data_col = 'test_data' if is_test else 'data'62 is_nan_col = 'test_is_nan' if is_test else 'is_nan'63 for batch in batch_gen:64 num_decode_steps = 6465 full_seq_len = batch[data_col].shape[1]66 max_encode_length = full_seq_len - num_decode_steps if not is_test else full_seq_len67 x_encode = np.zeros([len(batch), max_encode_length])68 y_decode = np.zeros([len(batch), num_decode_steps])69 is_nan_encode = np.zeros([len(batch), max_encode_length])70 is_nan_decode = np.zeros([len(batch), num_decode_steps])71 encode_len = np.zeros([len(batch)])72 decode_len = np.zeros([len(batch)])73 for i, (seq, nan_seq) in enumerate(zip(batch[data_col], batch[is_nan_col])):74 rand_len = np.random.randint(max_encode_length - 365 + 1, max_encode_length + 1)75 x_encode_len = max_encode_length if is_test else rand_len76 x_encode[i, :x_encode_len] = seq[:x_encode_len]77 is_nan_encode[i, :x_encode_len] = nan_seq[:x_encode_len]78 encode_len[i] = x_encode_len79 decode_len[i] = num_decode_steps80 if not is_test:81 y_decode[i, :] = seq[x_encode_len: x_encode_len + num_decode_steps]82 is_nan_decode[i, :] = nan_seq[x_encode_len: x_encode_len + num_decode_steps]83 batch['x_encode'] = x_encode84 batch['encode_len'] = encode_len85 batch['y_decode'] = y_decode86 batch['decode_len'] = decode_len87 batch['is_nan_encode'] = is_nan_encode88 batch['is_nan_decode'] = is_nan_decode...
my_mod_test.py
Source: my_mod_test.py
...7class TestMyMod(unittest.TestCase):8 def test_add_col(self):9 df.add_col('Name', ['Connecticut', 'Colorado', 'California', 'Texas'])10 self.assertTrue('Name'in df.df.columns.tolist())11 def test_is_nan(self):12 self.assertTrue(isinstance(df.df.isna().sum(), pd.Series))13 def test_split_df(self):14 train, test = df.split_df()15 self.assertTrue(type(train), pd.DataFrame)16 self.assertTrue(type(test), pd.DataFrame)17if __name__ == '__main__':...
test_core.py
Source: test_core.py
1import numpy as np2import unittest3from py_ebay import is_nan4class TestCore(unittest.TestCase):5 def test_is_nan(self):6 assert(is_nan(np.NAN))7 assert(not is_nan(1))8 assert(not is_nan('1'))...
Check out the latest blogs from LambdaTest on this topic:
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
The best agile teams are built from people who work together as one unit, where each team member has both the technical and the personal skills to allow the team to become self-organized, cross-functional, and self-motivated. These are all big words that I hear in almost every agile project. Still, the criteria to make a fantastic agile team are practically impossible to achieve without one major factor: motivation towards a common goal.
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!!