function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def link_fn(latent_mean):
return latent_mean | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def statistical_linear_regression_quadrature(self, m, v, hyp=None, num_quad_points=20):
"""
Perform statistical linear regression (SLR) using Gauss-Hermite quadrature.
We aim to find a likelihood approximation p(yₙ|fₙ) ≈ 𝓝(yₙ|Afₙ+b,Ω+Var[yₙ|fₙ]).
"""
x, w = hermgauss(num_quad_po... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def statistical_linear_regression(self, m, v, hyp=None):
"""
If no custom SLR method is provided, we use Gauss-Hermite quadrature.
"""
return self.statistical_linear_regression_quadrature(m, v, hyp) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def observation_model(self, f, r, hyp=None):
"""
The implicit observation model is:
h(fₙ,rₙ) = E[yₙ|fₙ] + √Var[yₙ|fₙ] rₙ
"""
conditional_expectation, conditional_variance = self.conditional_moments(f, hyp)
obs_model = conditional_expectation + cholesky(conditional_var... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def analytical_linearisation(self, m, hyp=None):
"""
Compute the Jacobian of the state space observation model w.r.t. the
function fₙ and the noise term rₙ.
The implicit observation model is:
h(fₙ,rₙ) = E[yₙ|fₙ] + √Var[yₙ|fₙ] rₙ
The Jacobians are evaluated at the mean... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def variational_expectation_quadrature(self, y, m, v, hyp=None, num_quad_points=20):
"""
Computes the "variational expectation" via Gauss-Hermite quadrature, i.e. the
expected log-likelihood, and its derivatives w.r.t. the posterior mean
E[log p(yₙ|fₙ)] = log ∫ p(yₙ|fₙ) 𝓝(fₙ|mₙ,vₙ) ... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def variational_expectation(self, y, m, v, hyp=None):
"""
If no custom variational expectation method is provided, we use Gauss-Hermite quadrature.
"""
return self.variational_expectation_quadrature(y, m, v, hyp) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp):
"""
:param hyp: The observation noise variance, σ²
"""
super().__init__(hyp=hyp)
if self.hyp is None:
print('using default likelihood parameter since none was supplied')
self.hyp = 0.1
self.name = 'Gaussian' | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
"""
Evaluate the Gaussian function 𝓝(yₙ|fₙ,σ²).
Can be used to evaluate Q quadrature points.
:param y: observed data yₙ [scalar]
:param f: mean, i.e. the latent function value fₙ [Q, 1]
:param hyp: likelihood variance σ² [sc... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_log_likelihood(self, y, f, hyp=None):
"""
Evaluate the log-Gaussian function log𝓝(yₙ|fₙ,σ²).
Can be used to evaluate Q quadrature points.
:param y: observed data yₙ [scalar]
:param f: mean, i.e. the latent function value fₙ [Q, 1]
:param hyp: likelihood vari... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def conditional_moments(self, f, hyp=None):
"""
The first two conditional moments of a Gaussian are the mean and variance:
E[y|f] = f
Var[y|f] = σ²
"""
hyp = softplus(self.hyp) if hyp is None else hyp
return f, hyp | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def moment_match(self, y, m, v, hyp=None, power=1.0):
"""
Closed form Gaussian moment matching.
Calculates the log partition function of the EP tilted distribution:
logZₙ = log ∫ 𝓝ᵃ(yₙ|fₙ,σ²) 𝓝(fₙ|mₙ,vₙ) dfₙ = E[𝓝(yₙ|fₙ,σ²)]
and its derivatives w.r.t. mₙ, which are require... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp):
"""
:param hyp: None. This likelihood model has no hyperparameters.
"""
super().__init__(hyp=hyp)
self.name = 'Probit' | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def link_fn(latent_mean):
return erfc(-latent_mean / np.sqrt(2.0)) - 1.0 | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def eval(self, mu, var):
"""
ported from GPML toolbox - not used.
"""
lp, _, _ = self.moment_match(1, mu, var)
p = np.exp(lp)
ymu = 2 * p - 1
yvar = 4 * p * (1 - p)
return lp, ymu, yvar | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
"""
Evaluate the Gaussian CDF likelihood model,
Φ(yₙfₙ) = (1 + erf(yₙfₙ / √2)) / 2
for erf(z) = (2/√π) ∫ exp(-x²) dx, where the integral is over [0, z]
Can be used to evaluate Q quadrature points when performing moment matching.
... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_log_likelihood(self, y, f, hyp=None):
"""
Evaluate the Gaussian CDF log-likelihood,
log Φ(yₙfₙ) = log[(1 + erf(yₙfₙ / √2)) / 2]
for erf(z) = (2/√π) ∫ exp(-x²) dx, where the integral is over [0, z].
Can be used to evaluate Q quadrature points when performing momen... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def conditional_moments(self, f, hyp=None):
"""
The first two conditional moments of a Probit likelihood are:
E[yₙ|fₙ] = Φ(fₙ)
Var[yₙ|fₙ] = Φ(fₙ) (1 - Φ(fₙ))
where Φ(fₙ) = (1 + erf(fₙ / √2)) / 2
"""
# TODO: not working
# phi = (1.0 + erf(f / np... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def moment_match(self, y, m, v, hyp=None, power=1.0):
"""
Probit likelihood moment matching.
Calculates the log partition function of the EP tilted distribution:
logZₙ = log ∫ Φᵃ(yₙfₙ) 𝓝(fₙ|mₙ,vₙ) dfₙ
and its derivatives w.r.t. mₙ, which are required for moment matching.
... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp=None, link='exp'):
"""
:param hyp: None. This likelihood model has no hyperparameters
:param link: link function, either 'exp' or 'logistic'
"""
super().__init__(hyp=hyp)
if link is 'exp':
self.link_fn = lambda mu: np.exp(mu)
eli... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
"""
Evaluate the Poisson likelihood:
p(yₙ|fₙ) = Poisson(fₙ) = μʸ exp(-μ) / yₙ!
for μ = g(fₙ), where g() is the link function (exponential or logistic).
We use the gamma function to evaluate yₙ! = gamma(yₙ + 1).
Can be use... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_log_likelihood(self, y, f, hyp=None):
"""
Evaluate the Poisson log-likelihood:
log p(yₙ|fₙ) = log Poisson(fₙ) = log(μʸ exp(-μ) / yₙ!)
for μ = g(fₙ), where g() is the link function (exponential or logistic).
We use the gamma function to evaluate yₙ! = gamma(yₙ + 1... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def conditional_moments(self, f, hyp=None):
"""
The first two conditional moments of a Poisson distribution are equal to the intensity:
E[yₙ|fₙ] = link(fₙ)
Var[yₙ|fₙ] = link(fₙ)
"""
return self.link_fn(f), self.link_fn(f) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp=None, p1=0.5, p2=0.5):
"""
:param hyp: None
"""
self.p1 = p1
self.p2 = p2
super().__init__(hyp=hyp)
self.name = 'Beta' | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
return beta() | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp=None, omega=0.8, var1=0.3, var2=0.5):
"""
:param hyp: None
"""
self.omega = omega
self.var1 = var1
self.var2 = var2
super().__init__(hyp=hyp)
self.name = 'sum of Gaussians' | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
return (npdf(y, f+self.omega, self.var1) + npdf(y, f-self.omega, self.var2)) / 2. | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_log_likelihood(self, y, f, hyp=None):
return np.log(self.evaluate_likelihood(y, f, hyp)) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def conditional_moments(self, f, hyp=None):
return f, (self.var1 + self.var2) / 2 | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def __init__(self, hyp, rho=1.2, p=0.2):
"""
:param hyp: the noise variance σ² [scalar]
"""
self.rho = rho
self.p = p
super().__init__(hyp=hyp)
if self.hyp is None:
print('using default likelihood parameter since none was supplied')
self.hy... | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def link_fn(self, latent_mean):
return (1 - self.rho) * latent_mean + self.rho * threshold_func(latent_mean, self.p) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_likelihood(self, y, f, hyp=None):
hyp = self.hyp if hyp is None else hyp
return npdf(y, f, hyp) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def evaluate_log_likelihood(self, y, f, hyp=None):
hyp = self.hyp if hyp is None else hyp
return log_npdf(y, f, hyp) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def conditional_moments(self, f, hyp=None):
hyp = self.hyp if hyp is None else hyp
lik_expectation = self.link_fn(f)
return lik_expectation, hyp | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def log_npdf(x, m, v):
return -(x - m) ** 2 / (2 * v) - 0.5 * np.log(2 * pi * v) | AaltoML/kalman-jax | [
85,
12,
85,
2,
1585896736
] |
def parse(nt, model, encoding='utf-8', disjoint=None, only_rel=None, exclude_rel=None):
'''
nt - string or file-like object with NTriples to parse
model - Versa model into which to parse the data
encoding character encoding for NTriples (default UTF-8)
disjoint - if not None a list or set of link tu... | uogbuji/versa | [
10,
5,
10,
4,
1394141786
] |
def _add(o, r, t, a=None):
'''
Conditionally add a statement to model, if not a duplicate
'''
a = a or {}
parts = (o, r, t, tuple(a.items()))
if (parts in added_links) or (parts in disjoint):
return False
model.add(o, r, t, a)
added_links.add((... | uogbuji/versa | [
10,
5,
10,
4,
1394141786
] |
def parse_iter(nt_fp, model_fact=newmodel):
raise NotImplementedError | uogbuji/versa | [
10,
5,
10,
4,
1394141786
] |
def write(models, out=None, base=None):
'''
models - one or more input Versa models from which output is generated.
'''
assert out is not None #Output stream required
if not isinstance(models, list): models = [models]
for m in models:
for link in m.match():
s, p, o = link[:3]... | uogbuji/versa | [
10,
5,
10,
4,
1394141786
] |
def setUp(self):
u = get_user_model()
u.objects.create_superuser('admin', 'john@snow.com', self.PW)
self.user = u.objects.create_user('user', 'me@snow.com', self.PW)
self.user2 = u.objects.create_user('user1', 'me1@snow.com', self.PW) | pstrinkle/drf-coupons | [
1,
2,
1,
2,
1483745217
] |
def describe_location(location, locations):
if location.can_describe:
final_location = locations.get(location.pk)
if final_location is not None:
location = final_location
result = location.serialize(include_type=True, detailed=False, simple_geometry=True)
if hasattr(location, 'se... | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def __init__(self, router, origin, destination, path_nodes, options,
origin_addition, destination_addition, origin_xyz, destination_xyz):
self.router = router
self.origin = origin
self.destination = destination
self.path_nodes = path_nodes
self.options = options
... | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def __init__(self, route, node, edge, last_item):
self.route = route
self.node = node
self.edge = edge
self.last_item = last_item
self.descriptions = [] | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def waytype(self):
if self.edge and self.edge.waytype:
return self.route.router.waytypes[self.edge.waytype] | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def router_waytype(self):
if self.edge:
return self.route.router.waytypes[self.edge.waytype] | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def space(self):
return self.route.router.spaces[self.node.space] | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def level(self):
return self.route.router.levels[self.space.level_id] | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def new_space(self):
return not self.last_item or self.space.pk != self.last_item.space.pk | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def new_level(self):
return not self.last_item or self.level.pk != self.last_item.level.pk | c3nav/c3nav | [
137,
31,
137,
17,
1461327231
] |
def onEndSpeaking(text):
mouth.setmouth(90,120)
jaw.moveTo(95)
sleep(.5)
mouth.setmouth(110,120) | MyRobotLab/pyrobotlab | [
62,
140,
62,
5,
1413898155
] |
def setUp(self):
super(JoinTest, self).setUp()
self.form_data = {'nick': 'johndoe',
'first_name': 'John',
'last_name': 'Doe',
'email': 'johndoe@google.com',
'password': 'good*password',
'confirm': 'goo... | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def assert_join_validation_error(self, response, content):
self.assertContains(response, content)
self.assertTemplateUsed(response, 'join.html')
self.assertTemplateUsed(response, 'form_error.html') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_join_with_valid_data(self):
r = self.client.post('/join', self.form_data)
r = self.assertRedirectsPrefix(r, '/welcome') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_join_with_used_email(self):
self.form_data['email'] = 'popular@example.com'
r = self.client.post('/join', self.form_data)
self.assert_join_validation_error(r, 'already associated') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_join_with_invalid_nick(self):
self.form_data['nick'] = 'a'
r = self.client.post('/join', self.form_data)
self.assert_join_validation_error(r, 'Invalid nick') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_join_with_banned_nick(self):
self.form_data['nick'] = 'json'
r = self.client.post('/join', self.form_data)
self.assert_join_validation_error(r, 'not allowed') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_join_with_used_nick_case_insensitive(self):
self.form_data['nick'] = 'Popular'
r = self.client.post('/join', self.form_data)
self.assert_join_validation_error(r, 'already in use') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def setUp(self):
super(WelcomeTest, self).setUp()
self.login('girlfriend') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_photo_view(self):
r = self.client.get('/welcome/1')
self.assertContains(r, 'Your photo')
self.assertTemplateUsed(r, 'welcome_photo.html') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def test_mobile_activation_view(self):
r = self.client.get('/welcome/2')
self.assertContains(r, 'SIGN IN')
self.assertTemplateUsed(r, 'welcome_mobile.html') | tallstreet/jaikuenginepatch | [
14,
3,
14,
1,
1238305655
] |
def route(unrouted):
"""
Route an UnroutedNotification to the appropriate repositories
The function will extract all the metadata and match data from any binary content associated with
the notification, and in combination from match data taken from the notification metadata itself will
determine if... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def enhance(routed, metadata):
"""
Enhance the routed notification with the extracted metadata
:param routed: a RoutedNotification whose metadata is to be enhanced
:param metadata: a NotificationMetadata object
:return:
"""
# some of the fields are easy - we just want to accept the existing... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def repackage(unrouted, repo_ids):
"""
Repackage any binary content associated with the notification for consumption by
the repositories identified by the list of repo_ids.
Note that this takes an unrouted notification, because of the point in the routing workflow at
which it is invoked, although i... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def domain_url(domain, url):
"""
normalise the domain: strip prefixes and URL paths. If either ends with the other, it is a match
:param domain: domain string
:param url: any url
:return: True if match, False if not
"""
# keep a copy of these for the provenance reporting
od = domain
... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def author_match(author_obj_1, author_obj_2):
"""
Match two author objects against eachother
:param author_obj_1: first author object
:param author_obj_2: second author object
:return: True if match, False if not
"""
t1 = author_obj_1.get("type", "")
i1 = _normalise(author_obj_1.get("id... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def postcode_match(pc1, pc2):
"""
Normalise postcodes: strip whitespace and lowercase, then exact match required
:param pc1: first postcode
:param pc2: second postcode
:return: True if match, False if not
"""
# first do the usual normalisation
npc1 = _normalise(pc1)
npc2 = _normalis... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def exact(s1, s2):
"""
normalised s1 must be identical to normalised s2
:param s1: first string
:param s2: second string
:return: True if match, False if not
"""
# keep a copy of these for the provenance reporting
os1 = s1
os2 = s2
# normalise the strings
s1 = _normalise(s1... | JiscPER/jper | [
1,
4,
1,
14,
1430814969
] |
def __init__(self, course_id=None, partner_id=None, group_id=None,
export_type=None, anonymity_level=None,
statement_of_purpose=None, schema_names=None,
interval=None, ignore_existing=None, **kwargs):
self._course_id = course_id
if partner_id is not Non... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def from_args(cls, **kwargs):
"""
Create a ExportResource object using the parameters required. Performs
course_id/partner_id inference if possible.
:param kwargs:
:return export_request: ExportRequest
"""
if kwargs.get('course_slug') and not kwargs.get('course_id... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def from_json(cls, json_request):
"""
Deserialize ExportRequest from json object.
:param json_request:
:return export_request: ExportRequest
"""
kwargs = {}
request_scope = json_request['scope']
request_scope_context = request_scope['typeName']
if... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def course_id(self):
return self._course_id | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def partner_id(self):
return self._partner_id | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def export_type(self):
return self._export_type | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def export_type_display(self):
if self._export_type == EXPORT_TYPE_GRADEBOOK:
return 'GRADEBOOK'
elif self._export_type == EXPORT_TYPE_CLICKSTREAM:
return 'CLICKSTREAM'
elif self._export_type == EXPORT_TYPE_TABLES:
return 'TABLES'
else:
ret... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def anonymity_level(self):
return self._anonymity_level | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def formatted_anonymity_level(self):
if self.anonymity_level == ANONYMITY_LEVEL_COORDINATOR:
return 'Linked'
elif self.anonymity_level == ANONYMITY_LEVEL_ISOLATED:
return 'Isolated'
else:
return 'Unknown' | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def statement_of_purpose(self):
return self._statement_of_purpose | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def interval(self):
return self._interval | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def ignore_existing(self):
return self._ignore_existing | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def scope_context(self):
"""
Context for this ExportRequest, assume that only one identifier for
partner/course/group is defined.
"""
if self._course_id:
return 'COURSE'
elif self._partner_id:
return 'PARTNER'
elif self._group_id:
... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def scope_id(self):
"""
Identifier for the scope, assume that only one of course/partner/group
is defined for a valid request.
:return scope_id:
"""
return self._course_id or self._partner_id or self._group_id | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def scope_name(self):
"""
Human readable name for this scope context. course slugs for courses,
partner short names for partners, but only group ids for groups (api is
not open)
:return:
"""
if self._course_id:
return utils.lookup_course_slug_by_id(sel... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def schema_names(self):
return self._schema_names | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def schema_names_display(self):
"""
Display only property for schemas names.
:return schemas:
"""
if self._schema_names:
if set(self._schema_names) == set(SCHEMA_NAMES):
return 'all'
else:
return ','.join(self._schema_names)... | coursera/courseraresearchexports | [
19,
11,
19,
12,
1472053751
] |
def _get_variable_value(variable):
return BuiltIn().replace_variables('${%s}' % variable) | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def __init__(self, path):
self.path = path | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def url(self):
return "%s%s" % (_get_variable_value('HOST'), self.path) | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def of(klass, model_instance):
if isinstance(model_instance, basestring):
model_instance = _get_variable_value(model_instance)
return klass(model_instance.get_absolute_url()) | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def __init__(self, locator):
self.locator = locator | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def is_css(self):
return self.locator.startswith('css=') | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def is_xpath(self):
return self.locator.startswith('//') | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def in_(self, other):
other = _get_variable_value(other)
assert self.is_css == other.is_css, "Both locators must be of same type"
if self.is_css:
return Element(other.locator + " " + self.locator[len('css='):])
elif self.is_xpath:
return Element(other.locator + se... | ox-it/talks.ox | [
5,
5,
5,
58,
1400079086
] |
def mock_pipeline_service_create():
with mock.patch.object(
pipeline_service_client.PipelineServiceClient, "create_training_pipeline"
) as mock_create_training_pipeline:
mock_create_training_pipeline.return_value = gca_training_pipeline.TrainingPipeline(
name=_TEST_PIPELINE_RESOURCE_... | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def mock_pipeline_service_get():
with mock.patch.object(
pipeline_service_client.PipelineServiceClient, "get_training_pipeline"
) as mock_get_training_pipeline:
mock_get_training_pipeline.return_value = gca_training_pipeline.TrainingPipeline(
name=_TEST_PIPELINE_RESOURCE_NAME,
... | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def mock_pipeline_service_create_and_get_with_fail():
with mock.patch.object(
pipeline_service_client.PipelineServiceClient, "create_training_pipeline"
) as mock_create_training_pipeline:
mock_create_training_pipeline.return_value = gca_training_pipeline.TrainingPipeline(
name=_TEST_... | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def mock_model_service_get():
with mock.patch.object(
model_service_client.ModelServiceClient, "get_model"
) as mock_get_model:
mock_get_model.return_value = gca_model.Model()
yield mock_get_model | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def mock_dataset_time_series():
ds = mock.MagicMock(datasets.TimeSeriesDataset)
ds.name = _TEST_DATASET_NAME
ds._latest_future = None
ds._exception = None
ds._gca_resource = gca_dataset.Dataset(
display_name=_TEST_DATASET_DISPLAY_NAME,
metadata_schema_uri=_TEST_METADATA_SCHEMA_URI_TI... | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def mock_dataset_nontimeseries():
ds = mock.MagicMock(datasets.ImageDataset)
ds.name = _TEST_DATASET_NAME
ds._latest_future = None
ds._exception = None
ds._gca_resource = gca_dataset.Dataset(
display_name=_TEST_DATASET_DISPLAY_NAME,
metadata_schema_uri=_TEST_METADATA_SCHEMA_URI_NONTI... | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def setup_method(self):
importlib.reload(initializer)
importlib.reload(aiplatform) | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
def test_run_call_pipeline_service_create(
self,
mock_pipeline_service_create,
mock_pipeline_service_get,
mock_dataset_time_series,
mock_model_service_get,
sync, | googleapis/python-aiplatform | [
306,
205,
306,
52,
1600875819
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.