function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def _get_sz_max(self): got = self.cli('show virtual-service global') limits = got['TABLE_resource_limits']['ROW_resource_limits'] for resource in limits: name = resource['media_name'] max_val = int(resource['quota']) if 'CPU' in name: self.sz_m...
Apstra/aeon-venos
[ 2, 4, 2, 1, 1463407794 ]
def error(errtype, msg, code=42): sys.stderr.write("{t.red}[ERROR] {t.yellow}{er}: {msg}" "{t.normal}\n".format(er=errtype, msg=msg, t=log.term)) sys.exit(code)
yac/rdoupdate
[ 1, 3, 1, 2, 1380286143 ]
def _get_update_files(args): if args.files and args.git: error("invalid invocation", "-g and -f are exclusive.", 19) if args.files: files = args.files else: if not args.git: args.git = '.' f = actions.get_last_commit_update(args.git) files = [os.path.join(...
yac/rdoupdate
[ 1, 3, 1, 2, 1380286143 ]
def _parse_build_filter(fargs): bf = [] if not fargs: return bf for f in fargs: try: attr, rex = f.split(':', 1) except Exception as ex: raise exception.InvalidFilter(what=f) bf.append((attr, rex)) return bf
yac/rdoupdate
[ 1, 3, 1, 2, 1380286143 ]
def do_move(args): actions.move_files(args.files, args.dir)
yac/rdoupdate
[ 1, 3, 1, 2, 1380286143 ]
def run(*cargs): parser = get_parser() args = parser.parse_args(cargs) action = args.action return action(args)
yac/rdoupdate
[ 1, 3, 1, 2, 1380286143 ]
def do_GET(self): b_obj = self.barix NOT_CONNECTED = "<b>NOT CONNECTED</b>" left_level_avg = 0 right_level_avg = 0 level_avg_window_minutes = 0 if level_history: N = len(level_history) left_level_avg = sum(L for L, _ in level_history) / N ...
chirpradio/chirpradio-machine
[ 12, 8, 12, 2, 1315249848 ]
def log_message(self, format, *args): pass # Throw away log messages for now.
chirpradio/chirpradio-machine
[ 12, 8, 12, 2, 1315249848 ]
def poll_barix(b_obj, log_fh): try: if not b_obj.ping(): return level_history.append( (float(b_obj.left_level), float(b_obj.right_level))) if len(level_history) > LEVEL_HISTORY_MAX_SIZE: level_history.pop(0) if log_fh: now = int(b_obj...
chirpradio/chirpradio-machine
[ 12, 8, 12, 2, 1315249848 ]
def __init__(self, categories): """Constructor. Args: categories: A list of dicts, each of which has the following keys - 'id': (required) an integer id uniquely identifying this category. 'name': (required) string representing category name e.g., 'cat', 'dog'. """ self._categorie...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def add_single_ground_truth_image_info(self, image_id, groundtruth_dict): """Adds groundtruth for a single image to be used for evaluation. Args: image_id: A unique string/integer identifier for the image. groundtruth_dict: A dictionary of groundtruth numpy arrays required for evaluations. ...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def add_single_detected_image_info(self, image_id, detections_dict): """Adds detections for a single image to be used for evaluation. Args: image_id: A unique string/integer identifier for the image. detections_dict: A dictionary of detection numpy arrays required for evaluation. """ ...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def evaluate(self): """Evaluates detections and returns a dictionary of metrics.""" pass
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def clear(self): """Clears the state to prepare for a fresh evaluation.""" pass
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5, evaluate_corlocs=False, metric_prefix=None, use_weighted_mean_ap=False, evaluate_masks=False, group_of_weight=0.0): """Constructor. Args: cat...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def add_single_detected_image_info(self, image_id, detections_dict): """Adds detections for a single image to be used for evaluation. Args: image_id: A unique string/integer identifier for the image. detections_dict: A dictionary containing - standard_fields.DetectionResultFields.detection_...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def clear(self): """Clears the state to prepare for a fresh evaluation.""" self._evaluation = ObjectDetectionEvaluation( num_groundtruth_classes=self._num_classes, matching_iou_threshold=self._matching_iou_threshold, use_weighted_mean_ap=self._use_weighted_mean_ap, label_id_offse...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5): super(PascalDetectionEvaluator, self).__init__( categories, matching_iou_threshold=matching_iou_threshold, evaluate_corlocs=False, metric_prefix='PascalBoxes', use_weighted_mean_ap=False)
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5): super(WeightedPascalDetectionEvaluator, self).__init__( categories, matching_iou_threshold=matching_iou_threshold, evaluate_corlocs=False, metric_prefix='WeightedPascalBoxes', use_weighted_mean_ap=True)
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5): super(PascalInstanceSegmentationEvaluator, self).__init__( categories, matching_iou_threshold=matching_iou_threshold, evaluate_corlocs=False, metric_prefix='PascalMasks', use_weighted_mean_ap=False, evaluate_...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5): super(WeightedPascalInstanceSegmentationEvaluator, self).__init__( categories, matching_iou_threshold=matching_iou_threshold, evaluate_corlocs=False, metric_prefix='WeightedPascalMasks', use_weighted_mean_ap=True, ...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5, evaluate_corlocs=False, metric_prefix='OpenImagesV2', group_of_weight=0.0): """Constructor. Args: categories: A list of dicts, each of which has the following keys - ...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, categories, matching_iou_threshold=0.5, evaluate_corlocs=False, group_of_weight=1.0): """Constructor. Args: categories: A list of dicts, each of which has the following keys - 'id': (required) an integer id uniquely id...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def add_single_detected_image_info(self, image_id, detections_dict): """Adds detections for a single image to be used for evaluation. Args: image_id: A unique string/integer identifier for the image. detections_dict: A dictionary containing - standard_fields.DetectionResultFields.detection_...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def __init__(self, num_groundtruth_classes, matching_iou_threshold=0.5, nms_iou_threshold=1.0, nms_max_output_boxes=10000, use_weighted_mean_ap=False, label_id_offset=0, group_of_weight=0.0, per_image...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def clear_detections(self): self._initialize_detections()
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def add_single_detected_image_info(self, image_key, detected_boxes, detected_scores, detected_class_labels, detected_masks=None): """Adds detections for a single image to be used for evaluation. Args: image_key: A unique string/int...
cshallue/models
[ 6, 3, 6, 1, 1473384593 ]
def testNotImplemented(self): for name in jnp.linalg._NOT_IMPLEMENTED: func = getattr(jnp.linalg, name) with self.assertRaises(NotImplementedError): func()
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testCholesky(self, shape, dtype): rng = jtu.rand_default(self.rng()) def args_maker(): factor_shape = shape[:-1] + (2 * shape[-1],) a = rng(factor_shape, dtype) return [np.matmul(a, jnp.conj(T(a)))] self._CheckAgainstNumpy(np.linalg.cholesky, jnp.linalg.cholesky, args_maker, ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testDet(self, n, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng((n, n), dtype)] self._CheckAgainstNumpy(np.linalg.det, jnp.linalg.det, args_maker, tol=1e-3) self._CompileAndCheck(jnp.linalg.det, args_maker, rtol={np.float64: 1e-13, np.complex128: 1e-1...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testDetGrad(self, shape, dtype): rng = jtu.rand_default(self.rng()) a = rng(shape, dtype) jtu.check_grads(jnp.linalg.det, (a,), 2, atol=1e-1, rtol=1e-1) # make sure there are no NaNs when a matrix is zero if len(shape) == 2: pass jtu.check_grads( jnp.linalg.det, (jnp.zeros_li...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testDetGradOfSingularMatrixCorank1(self): # Rank 2 matrix with nonzero gradient a = jnp.array([[ 50, -30, 45], [-30, 90, -81], [ 45, -81, 81]], dtype=jnp.float32) jtu.check_grads(jnp.linalg.det, (a,), 1, atol=1e-1, rtol=1e-1)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testTensorsolve(self, m, nq, dtype): rng = jtu.rand_default(self.rng()) # According to numpy docs the shapes are as follows: # Coefficient tensor (a), of shape b.shape + Q. # And prod(Q) == prod(b.shape) # Therefore, n = prod(q) n, q = nq b_shape = (n, m) # To accomplish prod(Q) == ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSlogdet(self, shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] self._CheckAgainstNumpy(np.linalg.slogdet, jnp.linalg.slogdet, args_maker, tol=1e-3) self._CompileAndCheck(jnp.linalg.slogdet, args_maker)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSlogdetGrad(self, shape, dtype): rng = jtu.rand_default(self.rng()) a = rng(shape, dtype) jtu.check_grads(jnp.linalg.slogdet, (a,), 2, atol=1e-1, rtol=2e-1)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEig(self, shape, dtype, compute_left_eigenvectors, compute_right_eigenvectors): rng = jtu.rand_default(self.rng()) n = shape[-1] args_maker = lambda: [rng(shape, dtype)] # Norm, adjusted for dimension and type. def norm(x): norm = np.linalg.norm(x, axis=(-2, -1)) r...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigvalsGrad(self, shape, dtype): # This test sometimes fails for large matrices. I (@j-towns) suspect, but # haven't checked, that might be because of perturbations causing the # ordering of eigenvalues to change, which will trip up check_grads. So we # just test on small-ish matrices. rng =...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigvals(self, shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] a, = args_maker() w1, _ = jnp.linalg.eig(a) w2 = jnp.linalg.eigvals(a) self.assertAllClose(w1, w2, rtol={np.complex128: 1e-14})
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigvalsInf(self): # https://github.com/google/jax/issues/2661 x = jnp.array([[jnp.inf]]) self.assertTrue(jnp.all(jnp.isnan(jnp.linalg.eigvals(x))))
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigBatching(self, shape, dtype): rng = jtu.rand_default(self.rng()) shape = (10,) + shape args = rng(shape, dtype) ws, vs = vmap(jnp.linalg.eig)(args) self.assertTrue(np.all(np.linalg.norm( np.matmul(args, vs) - ws[..., None, :] * vs) < 1e-3))
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigh(self, n, dtype, lower): rng = jtu.rand_default(self.rng()) tol = 1e-3 args_maker = lambda: [rng((n, n), dtype)] uplo = "L" if lower else "U" a, = args_maker() a = (a + np.conj(a.T)) / 2 w, v = jnp.linalg.eigh(np.tril(a) if lower else np.triu(a), UPLO...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEigvalsh(self, shape, dtype): rng = jtu.rand_default(self.rng()) n = shape[-1] def args_maker(): a = rng((n, n), dtype) a = (a + np.conj(a.T)) / 2 return [a] self._CheckAgainstNumpy(np.linalg.eigvalsh, jnp.linalg.eigvalsh, args_maker, tol=1e-3)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEighGrad(self, shape, dtype, lower): rng = jtu.rand_default(self.rng()) self.skipTest("Test fails with numeric errors.") uplo = "L" if lower else "U" a = rng(shape, dtype) a = (a + np.conj(T(a))) / 2 ones = np.ones((a.shape[-1], a.shape[-1]), dtype=dtype) a *= np.tril(ones) if lower ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEighGradVectorComplex(self, shape, dtype, lower, eps): rng = jtu.rand_default(self.rng()) # Special case to test for complex eigenvector grad correctness. # Exact eigenvector coordinate gradients are hard to test numerically for complex # eigensystem solvers given the extra degrees of per-eigenv...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testEighBatching(self, shape, dtype): rng = jtu.rand_default(self.rng()) shape = (10,) + shape args = rng(shape, dtype) args = (args + np.conj(T(args))) / 2 ws, vs = vmap(jsp.linalg.eigh)(args) self.assertTrue(np.all(np.linalg.norm( np.matmul(args, vs) - ws[..., None, :] * vs) < 1e-3...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuPivotsToPermutation(self, shape, dtype): pivots_size = shape[-1] permutation_size = 2 * pivots_size pivots = jnp.arange(permutation_size - 1, pivots_size - 1, -1, dtype=dtype) pivots = jnp.broadcast_to(pivots, shape) actual = lax.linalg.lu_pivots_to_permutation(pivots, permutation_size) ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuPivotsToPermutationBatching(self, shape, dtype): shape = (10,) + shape pivots_size = shape[-1] permutation_size = 2 * pivots_size pivots = jnp.arange(permutation_size - 1, pivots_size - 1, -1, dtype=dtype) pivots = jnp.broadcast_to(pivots, shape) batched_fn = vmap( lambda x: l...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testNorm(self, shape, dtype, ord, axis, keepdims): rng = jtu.rand_default(self.rng()) if (ord in ('nuc', 2, -2) and ( jtu.device_under_test() != "cpu" or (isinstance(axis, tuple) and len(axis) == 2))): raise unittest.SkipTest("No adequate SVD implementation available") args_maker ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSVD(self, b, m, n, dtype, full_matrices, compute_uv, hermitian): if (jnp.issubdtype(dtype, np.complexfloating) and jtu.device_under_test() == "tpu"): raise unittest.SkipTest("No complex SVD implementation") rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(b + (m, n), dtype)...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testQr(self, shape, dtype, full_matrices): rng = jtu.rand_default(self.rng()) m, n = shape[-2:] if full_matrices: mode, k = "complete", m else: mode, k = "reduced", min(m, n) a = rng(shape, dtype) lq, lr = jnp.linalg.qr(a, mode=mode) # np.linalg.qr doesn't support batch di...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testQrBatching(self, shape, dtype): rng = jtu.rand_default(self.rng()) args = rng(shape, jnp.float32) qs, rs = vmap(jsp.linalg.qr)(args) self.assertTrue(np.all(np.linalg.norm(args - np.matmul(qs, rs)) < 1e-3))
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testCond(self, shape, pnorm, dtype): if (jnp.issubdtype(dtype, np.complexfloating) and jtu.device_under_test() == "tpu"): raise unittest.SkipTest("No complex SVD implementation") def gen_mat(): # arr_gen = jtu.rand_some_nan(self.rng()) arr_gen = jtu.rand_default(self.rng()) ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testTensorinv(self, shape, dtype): rng = jtu.rand_default(self.rng()) def tensor_maker(): invertible = False while not invertible: a = rng(shape, dtype) try: np.linalg.inv(a) invertible = True except np.linalg.LinAlgError: pass return ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSolve(self, lhs_shape, rhs_shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(lhs_shape, dtype), rng(rhs_shape, dtype)] self._CheckAgainstNumpy(np.linalg.solve, jnp.linalg.solve, args_maker, tol=1e-3) self._CompileAndCheck(jnp.linalg.solve, a...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testInv(self, shape, dtype): rng = jtu.rand_default(self.rng()) if jtu.device_under_test() == "gpu" and shape == (200, 200): raise unittest.SkipTest("Test is flaky on GPU") def args_maker(): invertible = False while not invertible: a = rng(shape, dtype) try: ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testPinv(self, shape, dtype): if (jnp.issubdtype(dtype, np.complexfloating) and jtu.device_under_test() == "tpu"): raise unittest.SkipTest("No complex SVD implementation") rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] self._CheckAgainstNumpy(np.linalg.pin...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testPinvGradIssue2792(self): def f(p): a = jnp.array([[0., 0.],[-p, 1.]], jnp.float32) * 1 / (1 + p**2) return jnp.linalg.pinv(a) j = jax.jacobian(f)(jnp.float32(2.)) self.assertAllClose(jnp.array([[0., -1.], [ 0., 0.]], jnp.float32), j) expected = jnp.array([[[[-1., 0.], [ 0., 0.]], [[...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testMatrixPower(self, shape, dtype, n): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] tol = 1e-1 if jtu.device_under_test() == "tpu" else 1e-3 self._CheckAgainstNumpy(partial(np.linalg.matrix_power, n=n), partial(jnp.linalg.matrix_power, n=n)...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testMatrixRank(self, shape, dtype): if (jnp.issubdtype(dtype, np.complexfloating) and jtu.device_under_test() == "tpu"): raise unittest.SkipTest("No complex SVD implementation") rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] a, = args_maker() self._Chec...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testMultiDot(self, shapes, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [[rng(shape, dtype) for shape in shapes]] np_fun = np.linalg.multi_dot jnp_fun = partial(jnp.linalg.multi_dot, precision=lax.Precision.HIGHEST) tol = {np.float32: 1e-4, np.float64: 1e-10, np.co...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLstsq(self, lhs_shape, rhs_shape, dtype, rcond): rng = jtu.rand_default(self.rng()) np_fun = partial(np.linalg.lstsq, rcond=rcond) jnp_fun = partial(jnp.linalg.lstsq, rcond=rcond) jnp_fun_numpy_resid = partial(jnp.linalg.lstsq, rcond=rcond, numpy_resid=True) tol = {np.float32: 1e-5, np.float...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testIssue669(self): def test(x): val, vec = jnp.linalg.eigh(x) return jnp.real(jnp.sum(val)) grad_test_jc = jit(grad(jit(test))) xc = np.eye(3, dtype=np.complex64) self.assertAllClose(xc, grad_test_jc(xc))
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testIssue1151(self): rng = self.rng() A = jnp.array(rng.randn(100, 3, 3), dtype=jnp.float32) b = jnp.array(rng.randn(100, 3), dtype=jnp.float32) x = jnp.linalg.solve(A, b) self.assertAllClose(vmap(jnp.dot)(A, x), b, atol=2e-3, rtol=1e-2) _ = jax.jacobian(jnp.linalg.solve, argnums=0)(A, b) ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testIssue1383(self): seed = jax.random.PRNGKey(0) tmp = jax.random.uniform(seed, (2,2)) a = jnp.dot(tmp, tmp.T) def f(inp): val, vec = jnp.linalg.eigh(inp) return jnp.dot(jnp.dot(vec, inp), vec.T) grad_func = jax.jacfwd(f) hess_func = jax.jacfwd(grad_func) cube_func = jax.j...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testBlockDiag(self, args): args_maker = lambda: args self._CheckAgainstNumpy(osp.linalg.block_diag, jsp.linalg.block_diag, args_maker) self._CompileAndCheck(jsp.linalg.block_diag, args_maker)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLu(self, shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] x, = args_maker() p, l, u = jsp.linalg.lu(x) self.assertAllClose(x, np.matmul(p, np.matmul(l, u)), rtol={np.float32: 1e-3, np.float64: 1e-12, ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuGrad(self, shape, dtype): rng = jtu.rand_default(self.rng()) a = rng(shape, dtype) lu = vmap(jsp.linalg.lu) if len(shape) > 2 else jsp.linalg.lu jtu.check_grads(lu, (a,), 2, atol=5e-2, rtol=3e-1)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuBatching(self, shape, dtype): rng = jtu.rand_default(self.rng()) args = [rng(shape, jnp.float32) for _ in range(10)] expected = list(osp.linalg.lu(x) for x in args) ps = np.stack([out[0] for out in expected]) ls = np.stack([out[1] for out in expected]) us = np.stack([out[2] for out in ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuCPUBackendOnGPU(self): # tests running `lu` on cpu when a gpu is present. jit(jsp.linalg.lu, backend="cpu")(np.ones((2, 2))) # does not crash
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuFactor(self, n, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng((n, n), dtype)] x, = args_maker() lu, piv = jsp.linalg.lu_factor(x) l = np.tril(lu, -1) + np.eye(n, dtype=dtype) u = np.triu(lu) for i in range(n): x[[i, piv[i]],] = x[[piv[i], i],] self...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testLuSolve(self, lhs_shape, rhs_shape, dtype, trans): rng = jtu.rand_default(self.rng()) osp_fun = lambda lu, piv, rhs: osp.linalg.lu_solve((lu, piv), rhs, trans=trans) jsp_fun = lambda lu, piv, rhs: jsp.linalg.lu_solve((lu, piv), rhs, trans=trans) def args_maker(): a = rng(lhs_shape, dtype)...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSolve(self, lhs_shape, rhs_shape, dtype, sym_pos, lower): rng = jtu.rand_default(self.rng()) osp_fun = lambda lhs, rhs: osp.linalg.solve(lhs, rhs, sym_pos=sym_pos, lower=lower) jsp_fun = lambda lhs, rhs: jsp.linalg.solve(lhs, rhs, sym_pos=sym_pos, lower=lower) def args_maker(): a = rng(lh...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSolveTriangular(self, lower, transpose_a, unit_diagonal, lhs_shape, rhs_shape, dtype): rng = jtu.rand_default(self.rng()) k = rng(lhs_shape, dtype) l = np.linalg.cholesky(np.matmul(k, T(k)) + lhs_shape[-1] * np.eye(lhs_shape[-1])) l = l.astyp...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testTriangularSolveGrad( self, lower, transpose_a, conjugate_a, unit_diagonal, left_side, a_shape, b_shape, dtype): rng = jtu.rand_default(self.rng()) # Test lax.linalg.triangular_solve instead of scipy.linalg.solve_triangular # because it exposes more options. A = jnp.tril(rng(a_shape, ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testTriangularSolveBatching(self, left_side, a_shape, b_shape, bdims): rng = jtu.rand_default(self.rng()) A = jnp.tril(rng(a_shape, np.float32) + 5 * np.eye(a_shape[-1], dtype=np.float32)) B = rng(b_shape, np.float32) solve = partial(lax.linalg.triangular_solve, lower=True, transpose...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testExpm(self, n, dtype): rng = jtu.rand_small(self.rng()) args_maker = lambda: [rng((n, n), dtype)] osp_fun = lambda a: osp.linalg.expm(a) jsp_fun = lambda a: jsp.linalg.expm(a) self._CheckAgainstNumpy(osp_fun, jsp_fun, args_maker) self._CompileAndCheck(jsp_fun, args_maker) args_maker...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testIssue2131(self, n, dtype): args_maker_zeros = lambda: [np.zeros((n, n), dtype)] osp_fun = lambda a: osp.linalg.expm(a) jsp_fun = lambda a: jsp.linalg.expm(a) self._CheckAgainstNumpy(osp_fun, jsp_fun, args_maker_zeros) self._CompileAndCheck(jsp_fun, args_maker_zeros)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testChoSolve(self, lhs_shape, rhs_shape, dtype, lower): rng = jtu.rand_default(self.rng()) def args_maker(): b = rng(rhs_shape, dtype) if lower: L = np.tril(rng(lhs_shape, dtype)) return [(L, lower), b] else: U = np.triu(rng(lhs_shape, dtype)) return [(U, lo...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testExpmFrechet(self, n, dtype): rng = jtu.rand_small(self.rng()) if dtype == np.float64 or dtype == np.complex128: target_norms = [1.0e-2, 2.0e-1, 9.0e-01, 2.0, 3.0] # TODO(zhangqiaorjc): Reduce tol to default 1e-15. tol = { np.dtype(np.float64): 1e-14, np.dtype(np.complex...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testExpmGrad(self, n, dtype): rng = jtu.rand_small(self.rng()) a = rng((n, n), dtype) if dtype == np.float64 or dtype == np.complex128: target_norms = [1.0e-2, 2.0e-1, 9.0e-01, 2.0, 3.0] elif dtype == np.float32 or dtype == np.complex64: target_norms = [4.0e-1, 1.0, 3.0] else: ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSchur(self, shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] self._CheckAgainstNumpy(osp.linalg.schur, jsp.linalg.schur, args_maker) self._CompileAndCheck(jsp.linalg.schur, args_maker)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSqrtmPSDMatrix(self, shape, dtype): # Checks against scipy.linalg.sqrtm when the principal square root # is guaranteed to be unique (i.e no negative real eigenvalue) rng = jtu.rand_default(self.rng()) arg = rng(shape, dtype) mat = arg @ arg.T args_maker = lambda : [mat] if dtype == n...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSqrtmGenMatrix(self, shape, dtype): rng = jtu.rand_default(self.rng()) arg = rng(shape, dtype) if dtype == np.float32 or dtype == np.complex64: tol = 1e-3 else: tol = 1e-8 R = jsp.linalg.sqrtm(arg) self.assertAllClose(R @ R, arg, atol=tol, check_dtypes=False)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSqrtmEdgeCase(self, diag, expected, dtype): """ Tests the zero numerator condition """ mat = jnp.diag(jnp.array(diag)).astype(dtype) expected = jnp.diag(jnp.array(expected)) root = jsp.linalg.sqrtm(mat) self.assertAllClose(root, expected, check_dtypes=False)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def run_test(self, alpha, beta): n = alpha.shape[-1] # scipy.linalg.eigh_tridiagonal doesn't support complex inputs, so for # this we call the slower numpy.linalg.eigh. if np.issubdtype(alpha.dtype, np.complexfloating): tridiagonal = np.diag(alpha) + np.diag(beta, 1) + np.diag( np.conj(b...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testToeplitz(self, n, dtype): for a, b in [[2, -1], [1, 0], [0, 1], [-1e10, 1e10], [-1e-10, 1e-10]]: alpha = a * np.ones([n], dtype=dtype) beta = b * np.ones([n - 1], dtype=dtype) self.run_test(alpha, beta)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testRandomUniform(self, n, dtype): alpha = jtu.rand_uniform(self.rng())((n,), dtype) beta = jtu.rand_uniform(self.rng())((n - 1,), dtype) self.run_test(alpha, beta)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSelect(self, dtype): n = 5 alpha = jtu.rand_uniform(self.rng())((n,), dtype) beta = jtu.rand_uniform(self.rng())((n - 1,), dtype) eigvals_all = jax.scipy.linalg.eigh_tridiagonal(alpha, beta, select="a", eigvals_only=True) eps = np.finfo(alp...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def test_tridiagonal_solve(self, dtype): dl = np.array([0.0, 2.0, 3.0], dtype=dtype) d = np.ones(3, dtype=dtype) du = np.array([1.0, 2.0, 0.0], dtype=dtype) m = 3 B = np.ones([m, 1], dtype=dtype) X = lax.linalg.tridiagonal_solve(dl, d, du, B) A = np.eye(3, dtype=dtype) A[[1, 2], [0, 1]] ...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSchur(self, shape, dtype): rng = jtu.rand_default(self.rng()) args_maker = lambda: [rng(shape, dtype)] self._CheckAgainstNumpy(osp.linalg.schur, lax.linalg.schur, args_maker) self._CompileAndCheck(lax.linalg.schur, args_maker)
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def testSchurBatching(self, shape, dtype): rng = jtu.rand_default(self.rng()) batch_size = 10 shape = (batch_size, ) + shape args = rng(shape, dtype) reconstruct = vmap(lambda S, T: S @ T @ jnp.conj(S.T)) Ts, Ss = vmap(lax.linalg.schur)(args) self.assertAllClose(reconstruct(Ss...
google/jax
[ 22193, 2080, 22193, 1296, 1540502702 ]
def initialize_options(self): self.test = False
puentesarrin/asyncflux
[ 26, 1, 26, 1, 1400633988 ]
def run(self): if self.test: path = "docs/_build/doctest" mode = "doctest" else: path = "docs/_build/%s" % __version__ mode = "html" try: os.makedirs(path) except: pass status = subprocess.cal...
puentesarrin/asyncflux
[ 26, 1, 26, 1, 1400633988 ]
def setUpTestData(cls): cls.user = User.objects.create_user(username='api_login', email='api_login@email.com', password='123456') cls.the_user = TheUser.objects.get(id_user=cls.user)
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_missing_params(self): response = self.client.post(reverse('user_login_api'), {'app_key': self.api_key, 'username': 'username'})
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_too_long_username(self): response = self.client.post(reverse('user_login_api'), {'app_key': self.api_key, 'username': 'a' * 40, 'password': 'somepassword'})
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_too_short_username(self): response = self.client.post(reverse('user_login_api'), {'app_key': self.api_key, 'username': 'a', 'password': 'somepassword'})
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_username_regex_not_valid(self): username_patterns = [ 'ab#$@cdev', '#$@username', 'username%#&#&', 'db24!!!db34', '#$@234234', '#123dkf%' ]
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_email_regex_not_valid(self): email_patterns = [ 'no_extension@ddd', '@first.missing', 'after_at_miss@', '$%#@474**.om', 'em#$@ail@m.com', '#em@ail@m.com' ]
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]
def test_user_login_too_long_password(self): response = self.client.post(reverse('user_login_api'), {'app_key': self.api_key, 'username': 'test_username', 'password': 'p' * 17})
OlegKlimenko/Plamber
[ 9, 1, 9, 28, 1487368387 ]