text stringlengths 0 828 |
|---|
tpl = '{%% extends ""%s"" %%}{%% block %s %%}%s{%% endblock %%}' % (layout_name, layout_block, content) |
return render_template_string(tpl, **context)" |
935,"def parse_template(app, filename): |
""""""Parses the given template using the jinja environment of the given app |
and returns the AST. ASTs are cached in parse_template.cache |
"""""" |
if not hasattr(parse_template, ""cache""): |
parse_template.cache = {} |
if filename not in parse_template.cache: |
source = get_template_source(app, filename) |
parse_template.cache[filename] = app.jinja_env.parse(source, filename=filename) |
return parse_template.cache[filename]" |
936,"def jinja_node_to_python(node): |
""""""Converts a Jinja2 node to its python equivalent |
"""""" |
if isinstance(node, nodes.Const): |
return node.value |
if isinstance(node, nodes.Neg): |
return -jinja_node_to_python(node.node) |
if isinstance(node, nodes.Name): |
return node.name |
if isinstance(node, (nodes.List, nodes.Tuple)): |
value = [] |
for i in node.items: |
value.append(jinja_node_to_python(i)) |
return value |
if isinstance(node, nodes.Dict): |
value = {} |
for pair in node.items: |
value[pair.key.value] = jinja_node_to_python(pair.value) |
return value |
if isinstance(node, nodes.Call): |
if not isinstance(node.node, nodes.Name) or node.node.name not in (""_"", ""translate"", ""gettext""): |
raise FormDefinitionError(""Cannot convert function calls from jinja to python other than translation calls"") |
return lazy_translate(jinja_node_to_python(node.args[0])) |
raise Exception(""Cannot convert jinja nodes to python"")" |
937,"def groups(self): |
""""""Get the list of Groups (by dn) that the bound CSH LDAP member object |
is in. |
"""""" |
group_list = [] |
all_groups = self.get('memberof') |
for group_dn in all_groups: |
if self.__ldap_group_ou__ in group_dn: |
group_list.append(group_dn) |
return group_list" |
938,"def in_group(self, group, dn=False): |
""""""Get whether or not the bound CSH LDAP member object is part of a |
group. |
Arguments: |
group -- the CSHGroup object (or distinguished name) of the group to |
check membership for |
"""""" |
if dn: |
return group in self.groups() |
return group.check_member(self)" |
939,"def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=-1, mode='interp', cval=0.0): |
''' |
Wrapper for the scipy.signal.savgol_filter function that handles Nan values. |
See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3 |
Returns |
------- |
y : ndarray, same shape as `x` |
The filtered data. |
''' |
# linearly interpolate missing values before filtering |
x = np.ma.masked_invalid(pd.Series(x).interpolate()) |
try: |
# start filtering from the first non-zero value since these won't be addressed by |
# the interpolation above |
ind = np.isfinite(x).nonzero()[0][0] |
x[ind:] = signal.savgol_filter(x[ind:], window_length, polyorder, deriv, |
delta, axis, mode, cval) |
except IndexError: |
pass |
return np.ma.masked_invalid(x)" |
940,"def feedback_results_to_measurements_frame(feedback_result): |
''' |
Extract measured data from `FeedbackResults` instance into |
`pandas.DataFrame`. |
''' |
index = pd.Index(feedback_result.time * 1e-3, name='seconds') |
df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_fb, |
feedback_result.V_hv, |
feedback_result.fb_resistor, |
feedback_result.hv_resistor]), |
columns=['V_fb', 'V_hv', 'fb_resistor', |
'hv_resistor'], |
index=index) |
df_feedback.insert(0, 'frequency', feedback_result.frequency) |
return df_feedback" |
941,"def feedback_results_to_impedance_frame(feedback_result): |
''' |
Extract computed impedance data from `FeedbackResults` instance into |
`pandas.DataFrame`. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.