How to use describe_limits method in localstack

Best Python code snippet using localstack_python

scan_generator.py

Source:scan_generator.py Github

copy

Full Screen

...16 def points_for_level(self, level: int, rng=None) -> List[Any]:17 """18 """19 raise NotImplementedError20 def describe_limits(self, target: Dict[str, Any]) -> None:21 """22 """23 raise NotImplementedError24class RefiningGenerator(ScanGenerator):25 """Generates progressively finer grid by halving distance between points each level.26 """27 def __init__(self, lower, upper, randomise_order):28 self.lower = float(min(lower, upper))29 self.upper = float(max(lower, upper))30 self.randomise_order = randomise_order31 def has_level(self, level: int) -> bool:32 ""33 # For floating-point parameters, a refining scan, in practical terms, never runs34 # out of points. Will need to be amended for integer parameters.35 return True36 def points_for_level(self, level: int, rng=None) -> List[Any]:37 ""38 if level == 0:39 return [self.lower, self.upper]40 d = self.upper - self.lower41 num = 2**(level - 1)42 points = np.arange(num) * d / num + d / (2 * num) + self.lower43 if self.randomise_order:44 rng.shuffle(points)45 return points46 def describe_limits(self, target: Dict[str, Any]) -> None:47 ""48 target["min"] = self.lower49 target["max"] = self.upper50class ExpandingGenerator(ScanGenerator):51 """Generates points with given, constant spacing in progressively growing range52 around a given centre.53 """54 def __init__(self,55 centre,56 spacing,57 randomise_order: bool,58 limit_lower=None,59 limit_upper=None):60 """61 :param limit_lower: Optional lower limit (inclusive) to the range of generated62 points. Useful for representing scans on parameters the range of which is63 limited (e.g. to be non-negative).64 :param limit_upper: See `limit_lower`.65 """66 self.centre = centre67 self.spacing = abs(spacing)68 self.randomise_order = randomise_order69 self.limit_lower = limit_lower if limit_lower is not None else float("-inf")70 if centre < self.limit_lower:71 raise ValueError("Given scan centre exceeds lower limit")72 self.limit_upper = limit_upper if limit_upper is not None else float("inf")73 if centre > self.limit_upper:74 raise ValueError("Given scan centre exceeds upper limit")75 def has_level(self, level: int) -> bool:76 ""77 def num_points(limit):78 return np.floor(abs(self.centre - limit) / self.spacing)79 return level <= max(num_points(self.limit_lower), num_points(self.limit_upper))80 def points_for_level(self, level: int, rng=None) -> List[Any]:81 ""82 if level == 0:83 return [self.centre]84 points = []85 lower = self.centre - level * self.spacing86 if lower >= self.limit_lower:87 points.append(lower)88 upper = self.centre + level * self.spacing89 if upper <= self.limit_upper:90 points.append(upper)91 if self.randomise_order:92 rng.shuffle(points)93 return points94 def describe_limits(self, target: Dict[str, Any]) -> None:95 ""96 if self.limit_lower > float("-inf"):97 target["min"] = self.limit_lower98 if self.limit_upper < float("inf"):99 target["max"] = self.limit_upper100 target["increment"] = self.spacing101class LinearGenerator(ScanGenerator):102 """Generates equally spaced points between two endpoints."""103 def __init__(self, start, stop, num_points, randomise_order):104 if num_points < 2:105 raise ValueError("Need at least 2 points in linear scan")106 self.start = start107 self.stop = stop108 self.num_points = num_points109 self.randomise_order = randomise_order110 def has_level(self, level: int) -> bool:111 ""112 return level == 0113 def points_for_level(self, level: int, rng=None) -> List[Any]:114 ""115 assert level == 0116 points = np.linspace(start=self.start,117 stop=self.stop,118 num=self.num_points,119 endpoint=True)120 if self.randomise_order:121 rng.shuffle(points)122 return points.tolist()123 def describe_limits(self, target: Dict[str, Any]) -> None:124 ""125 target["min"] = min(self.start, self.stop)126 target["max"] = max(self.start, self.stop)127 target["increment"] = abs(self.stop - self.start) / (self.num_points - 1)128class CentreSpanGenerator(LinearGenerator):129 """Generates equally spaced points in ``centre``±``half_span``."""130 def __init__(self,131 centre,132 half_span,133 num_points: int,134 randomise_order: bool,135 limit_lower=None,136 limit_upper=None):137 """138 :param limit_lower: Optional lower limit (inclusive) to the range of generated139 points. Useful for representing scans on parameters the range of which is140 limited (e.g. to be non-negative).141 :param limit_upper: See `limit_lower`.142 """143 if num_points < 1:144 raise ValueError("Need at least one point in centre/span scan")145 self.num_points = num_points146 self.randomise_order = randomise_order147 self.start = centre - half_span148 if limit_lower is not None:149 self.start = max(self.start, limit_lower)150 self.stop = centre + half_span151 if limit_upper is not None:152 self.stop = min(self.stop, limit_upper)153 if self.start > self.stop:154 raise ValueError("Empty centre/span scan (lower limit larger than upper)")155 if num_points == 1:156 self.start = self.stop = centre157class ListGenerator(ScanGenerator):158 """Generates points by reading from an explicitly specified list."""159 def __init__(self, values, randomise_order):160 self.values = values161 self.randomise_order = randomise_order162 def has_level(self, level: int) -> bool:163 ""164 return level == 0165 def points_for_level(self, level: int, rng=None) -> List[Any]:166 ""167 assert level == 0168 values = self.values169 if self.randomise_order:170 values = np.array(self.values)171 rng.shuffle(values)172 return values173 def describe_limits(self, target: Dict[str, Any]) -> None:174 ""175 values = np.array(self.values)176 if np.issubdtype(values.dtype, np.number):177 target["min"] = np.min(values)178 target["max"] = np.max(values)179GENERATORS = {180 "refining": RefiningGenerator,181 "expanding": ExpandingGenerator,182 "linear": LinearGenerator,183 "centre_span": CentreSpanGenerator,184 "list": ListGenerator185}186class ScanOptions:187 """...

Full Screen

Full Screen

dynamo_limit_handler.py

Source:dynamo_limit_handler.py Github

copy

Full Screen

1class DynamoLimitHandler:2 def __init__(self, attribute):3 self.attribute = attribute4 def handle(self, client, stream_name):5 response = client.describe_limits()6 return attributes.get(self.attribute)7 def handle_response(self, name, value):...

Full Screen

Full Screen

db.describe_limits.py

Source:db.describe_limits.py Github

copy

Full Screen

1#!/usr/bin/env python2import boto33ddb = boto3.client('dynamodb')...

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 localstack 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