Best Python code snippet using pyatom_python
ssindex.py
Source: ssindex.py
1class SSIndexBase( object ):2 def __init__(self, col, source):3 self._col = col4 self._src = source5 def getIndexRef( self, key, outRslt, index_level = 0):6 pass7class SSIndexM1( SSIndexBase ):8 def __init__(self, col, source, useIdx ):9 super(SSIndexM1, self).__init__( col[useIdx], source)10 self._keyMap = {}11 def registerRow( self, idxRow, row ):12 row_value = row[self._col]13 v = self._keyMap.get( row_value )14 if not v:15 self._keyMap[ row_value ] = set()16 v = self._keyMap[ row_value ]17 v.add( idxRow )18 19 def getIndexRef( self, keys, outRslt, index_level = 0):20 if index_level >= len(keys):21 self.getAllItem( outRslt )22 return23 #row_value = set()24 row_value = self._keyMap.get( keys[ index_level ] )25 if not row_value:26 return27 for v in row_value:28 outRslt.append( v )29 30 def unregisterRow( self, rowIdx, row ):31 v = row[self._col]32 33 try:34 self._keyMap[v].remove( rowIdx )35 except KeyError as e:36 return True37 38 if len( self._keyMap[v] ) == 0:39 del self._keyMap[v] 40 return True41 return False42 43 def getAllItem( self, outRslt ):44 for k, v in self._keyMap.items():45 for y in v:46 outRslt.append( y )47 def getColumnIndex( self, vIndex ):48 super( SSIndexM1, self).getColumnIndex( vIndex )49class SSIndex( SSIndexBase ):50 def __init__(self, cols, source, iUseIdx=0):51 super(SSIndex, self).__init__( cols[iUseIdx], source )52 self._colIndex = cols53 self._ref_Value = {}54 self._next_index = iUseIdx +155 def _clearIndex( self ):56 self._ref_Value = {}57 def registerRow( self, idxRow, row ):58 refIndex = None59 try:60 refIndex = self._ref_Value.get( row[ self._col ] )61 except Exception as e:62 pass63 if not refIndex:64 if( self._next_index +1 ) >= len(self._colIndex):65 refIndex = SSIndexM1( self._colIndex, self._src, self._next_index )66 else:67 refIndex = SSIndex( self._colIndex, self._src, self._next_index )68 self._ref_Value[ row[ self._col ] ] = refIndex69 refIndex.registerRow( idxRow, row )70 def getIndexRef( self, keys, outRslt, index_level =0 ):71 if( index_level >= len(keys) ):72 getAll( outRslt )73 return 74 nextIndex = self._ref_Value.get( keys[index_level] )75 if not nextIndex:76 return77 nextIndex.getIndexRef( keys, outRslt, index_level +1 )78 def unregisterRow( self, idxRow, row ):79 ''' return true if empty80 '''81# for k, y in self._ref_Value.items(): 82 v = row[self._col]83 y = self._ref_Value.get( v )84 if not y:85 return True86 if y.unregisterRow( idxRow, row ): 87 del self._ref_Value[ v ]88 if len(self._ref_Value) == 0:89 return True90 return False91 def getAllItem( self, outRs ):92 for k,v in self._ref_Value.items():93 v.getAllItem( outRs )94 def isIndex( self, col ):95 if super( SSIndex, self).isIndex( col ):96 return True97 for i in xrange(0, len(self._colIndex) ):98 if col == i :99 return True...
item.py
Source: item.py
1from typing import Any2from app.schema.common import Base, GetAllItem3from app.schema.user import BaseUser4from pydantic import BaseModel, Extra, HttpUrl, validator5class CreateItem(BaseModel):6 description: str7 name: str8 price: int9 image_url: HttpUrl10 @validator("price", pre=True, always=True)11 def price_validator(cls: Any, v: Any) -> Any:12 if not 300 <= v <= 9999999:13 raise ValueError("price must be between 300 and 9999999")14 return v15 class Config:16 extra = Extra.forbid17 orm_mode = True18class AddItem(Base):19 price: int20 image_url: HttpUrl21 name: str22 class Config:23 extra = Extra.forbid24 orm_mode = True25class ReadItems(BaseModel):26 data: list[GetAllItem]27 skip: int | None28 class Config:29 extra = Extra.forbid30 orm_mode = True31class GetItemById(GetAllItem):32 description: str33 user: BaseUser34 liked_users: list[Base]35 class Config:36 extra = Extra.forbid...
main.py
Source: main.py
1from hashmap import HashMap2dic= {}3hm = HashMap(dic)4hm.addItems("asd", [1,3,4,5,6])5hm.getItems("asd")6hm.getAllItem()7hm.addItems("tol", 2)8hm.getAllItem()9hm.deleteItems("asd")10hm.getAllItem()...
Check out the latest blogs from LambdaTest on this topic:
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
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.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
Dries Buytaert, a graduate student at the University of Antwerp, came up with the idea of developing something similar to a chat room. Moreover, he modified the conventional chat rooms into a website where his friends could post their queries and reply through comments. However, for this project, he thought of creating a temporary archive of posts.
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!!