input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def getAAA(self):
temp = []
temp.append( self.getAp1() )
temp.append( self.getAp2() )
temp.append( self.getAp3() )
return temp |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def getASASAS(self):
temp = []
temp.append(self.getAp1())
temp.append(self.getLenp1())
temp.append(self.getAp2())
temp.append(self.getLenp2())
temp.append(self.getAp3())
temp.append(self.getLenp3())
return temp |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def setPPSS(self, p1, p3, lenp1, lenp3):
temp = []
self.p1 = p1
self.p3 = p3
self.lenp1 = lenp1
self.lenp3 = lenp3
#bp3 is the angle beside p3 point, cp3 is the angle for line23, p2 is the output
line31 = Line(p3, p1)
self.lenp2 = line31.getR()
#s... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def draw():
global theta
context.clearRect(0, 0, canvas.width, canvas.height)
line1.drawMe(context)
line2.drawMe(context)
line3.drawMe(context)
#triangle1.drawMe(context)
#triangle2.drawMe(context)
theta += dx
p2.x = p1.x + line1.length*math.cos(theta*degree)
p2.y = p1.y - line1.... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, store):
self.store = store |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, name):
self._name = name |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, x, y):
self.x = x
self.y = y |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, action: str = None) -> None:
super().__init__(prefix, action) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def draw(self, context):
pass |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def conversion_fn():
"""Temporary function."""
pass |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _files(self):
return [] |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def no_op(*args, **kwargs):
pass |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def open(read_server_info=True):
return |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def query_vpp_config(self):
NotImplemented |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def tag(g, p):
None |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def vsParseFd(self, fd):
raise NotImplementedError() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_should_encode_false(self):
encoded = cypher_repr(False)
assert encoded == u"false" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _maybe_name(obj):
"""Returns object name if it has one, or a message otherwise.
This is useful for names that apper in error messages.
Args:
obj: Object to get the name of.
Returns:
name, "None", or a "no name" message.
"""
if obj is None:
return "None"
elif hasattr(obj, "name"):
retu... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testResidualWrapper(self):
wrapper_type = rnn_cell_wrapper_v2.ResidualWrapper
x = ops.convert_to_tensor_v2_with_dispatch(
np.array([[1., 1., 1.]]), dtype="float32")
m = ops.convert_to_tensor_v2_with_dispatch(
np.array([[0.1, 0.1, 0.1]]), dtype="float32")
base_cell = rnn_cell_impl.GRU... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _restore_checkpoint_and_maybe_run_saved_model_initializers(
sess, saver, path):
"""Restores checkpoint values and SavedModel initializers if found."""
# NOTE: All references to SavedModel refer to SavedModels loaded from the
# load_v2 API (which does not require the `sess` argument).
# If the graph con... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def residual_with_slice_fn(inp, out):
inp_sliced = array_ops.slice(inp, [0, 0], [-1, 3])
return inp_sliced + out |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __init__(self,
local_init_op=None,
ready_op=None,
ready_for_local_init_op=None,
graph=None,
recovery_wait_secs=30,
local_init_run_options=None,
local_init_feed_dict=None):
"""Creates a SessionManager.
T... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testDeviceWrapper(self):
wrapper_type = rnn_cell_wrapper_v2.DeviceWrapper
x = array_ops.zeros([1, 3])
m = array_ops.zeros([1, 3])
cell = rnn_cell_impl.GRUCell(3)
wrapped_cell = wrapper_type(cell, "/cpu:0")
children = wrapped_cell._trackable_children()
wrapped_cell.get_config() # Should ... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _restore_checkpoint(self,
master,
saver=None,
checkpoint_dir=None,
checkpoint_filename_with_path=None,
wait_for_checkpoint=False,
max_wait_secs=7200,
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testWrapperKerasStyle(self, wrapper, wrapper_v2):
"""Tests if wrapper cell is instantiated in keras style scope."""
wrapped_cell_v2 = wrapper_v2(rnn_cell_impl.BasicRNNCell(1))
self.assertIsNone(getattr(wrapped_cell_v2, "_keras_style", None))
wrapped_cell = wrapper(rnn_cell_impl.BasicRNNCell(1))
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def prepare_session(self,
master,
init_op=None,
saver=None,
checkpoint_dir=None,
checkpoint_filename_with_path=None,
wait_for_checkpoint=False,
max_wait_secs=7200,
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testWrapperWeights(self, wrapper):
"""Tests that wrapper weights contain wrapped cells weights."""
base_cell = layers.SimpleRNNCell(1, name="basic_rnn_cell")
rnn_cell = wrapper(base_cell)
rnn_layer = layers.RNN(rnn_cell)
inputs = ops.convert_to_tensor_v2_with_dispatch([[[1]]],
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def recover_session(self,
master,
saver=None,
checkpoint_dir=None,
checkpoint_filename_with_path=None,
wait_for_checkpoint=False,
max_wait_secs=7200,
config=None):
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testWrapperV2Caller(self, wrapper):
"""Tests that wrapper V2 is using the LayerRNNCell's caller."""
with legacy_base_layer.keras_style_scope():
base_cell = rnn_cell_impl.MultiRNNCell(
[rnn_cell_impl.BasicRNNCell(1) for _ in range(2)])
rnn_cell = wrapper(base_cell)
inputs = ops.conve... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def wait_for_session(self, master, config=None, max_wait_secs=float("Inf")):
"""Creates a new `Session` and waits for model to be ready.
Creates a new `Session` on 'master'. Waits for the model to be
initialized or recovered from a checkpoint. It's expected that
another thread or process will make th... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testWrapperV2Build(self, wrapper):
cell = rnn_cell_impl.LSTMCell(10)
wrapper = wrapper(cell)
wrapper.build((1,))
self.assertTrue(cell.built) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _safe_close(self, sess):
"""Closes a session without raising an exception.
Just like sess.close() but ignores exceptions.
Args:
sess: A `Session`.
"""
# pylint: disable=broad-except
try:
sess.close()
except Exception:
# Intentionally not logging to avoid user complain... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testDeviceWrapperSerialization(self):
wrapper_cls = rnn_cell_wrapper_v2.DeviceWrapper
cell = layers.LSTMCell(10)
wrapper = wrapper_cls(cell, "/cpu:0")
config = wrapper.get_config()
reconstructed_wrapper = wrapper_cls.from_config(config)
self.assertDictEqual(config, reconstructed_wrapper.get... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _model_ready(self, sess):
"""Checks if the model is ready or not.
Args:
sess: A `Session`.
Returns:
A tuple (is_ready, msg), where is_ready is True if ready and False
otherwise, and msg is `None` if the model is ready, a `String` with the
reason why it is not ready otherwise.
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def residual_fn(inputs, outputs):
return inputs * 3 + outputs |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _model_ready_for_local_init(self, sess):
"""Checks if the model is ready to run local_init_op.
Args:
sess: A `Session`.
Returns:
A tuple (is_ready, msg), where is_ready is True if ready to run
local_init_op and False otherwise, and msg is `None` if the model is
ready to run loc... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def dropout_state_filter_visitor(unused_state):
return False |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _try_run_local_init_op(self, sess):
"""Tries to run _local_init_op, if not None, and is ready for local init.
Args:
sess: A `Session`.
Returns:
A tuple (is_successful, msg), where is_successful is True if
_local_init_op is None, or we ran _local_init_op, and False otherwise;
an... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def testDropoutWrapperWithKerasLSTMCell(self):
wrapper_cls = rnn_cell_wrapper_v2.DropoutWrapper
cell = layers.LSTMCell(10)
with self.assertRaisesRegex(ValueError, "does not work with "):
wrapper_cls(cell)
cell = layers.LSTMCellV2(10)
with self.assertRaisesRegex(ValueError, "does not work wit... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def _ready(op, sess, msg):
"""Checks if the model is ready or not, as determined by op.
Args:
op: An op, either _ready_op or _ready_for_local_init_op, which defines the
readiness of the model.
sess: A `Session`.
msg: A message to log to warning if not ready
Returns:
A tuple (is_ready, msg)... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __init__(self, duration_secs):
self._start_time_secs = time.time()
self._duration_secs = duration_secs |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __init__(self, name: str, get_converter: t.Optional[t.Callable] = None) -> None:
self.__name__ = name
self.get_converter = get_converter |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_refraction_angle():
n1, n2 = symbols('n1, n2')
m1 = Medium('m1')
m2 = Medium('m2')
r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
i = Matrix([1, 1, 1])
n = Matrix([0, 0, 1])
normal_ray = Ray3D(Point3D(0, 0, 0), Point3D(0, 0, 1))
P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0,... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __get__(self, obj: t.Any, owner: t.Any = None) -> t.Any:
if obj is None:
return self
rv = obj.config[self.__name__]
if self.get_converter is not None:
rv = self.get_converter(rv)
return rv |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_fresnel_coefficients():
assert all(ae(i, j, 5) for i, j in zip(
fresnel_coefficients(0.5, 1, 1.33),
[0.11163, -0.17138, 0.83581, 0.82862]))
assert all(ae(i, j, 5) for i, j in zip(
fresnel_coefficients(0.5, 1.33, 1),
[-0.07726, 0.20482, 1.22724, 1.20482]))
m1 = Medium... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __set__(self, obj: t.Any, value: t.Any) -> None:
obj.config[self.__name__] = value |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_deviation():
n1, n2 = symbols('n1, n2')
r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
n = Matrix([0, 0, 1])
i = Matrix([-1, -1, -1])
normal_ray = Ray3D(Point3D(0, 0, 0), Point3D(0, 0, 1))
P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1])
assert deviation(r1, 1, 1, normal=n) ==... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __init__(self, root_path: str, defaults: t.Optional[dict] = None) -> None:
dict.__init__(self, defaults or {})
self.root_path = root_path |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_brewster_angle():
m1 = Medium('m1', n=1)
m2 = Medium('m2', n=1.33)
assert ae(brewster_angle(m1, m2), 0.93, 2)
m1 = Medium('m1', permittivity=e0, n=1)
m2 = Medium('m2', permittivity=e0, n=1.33)
assert ae(brewster_angle(m1, m2), 0.93, 2)
assert ae(brewster_angle(1, 1.33), 0.93, 2) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_envvar(self, variable_name: str, silent: bool = False) -> bool:
"""Loads a configuration from an environment variable pointing to
a configuration file. This is basically just a shortcut with nicer
error messages for this line of code::
app.config.from_pyfile(os.environ['YO... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_critical_angle():
m1 = Medium('m1', n=1)
m2 = Medium('m2', n=1.33)
assert ae(critical_angle(m2, m1), 0.85, 2) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_pyfile(self, filename: str, silent: bool = False) -> bool:
"""Updates the values in the config from a Python file. This function
behaves as if the file was imported as module with the
:meth:`from_object` function.
:param filename: the filename of the config. This can either b... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_lens_makers_formula():
n1, n2 = symbols('n1, n2')
m1 = Medium('m1', permittivity=e0, n=1)
m2 = Medium('m2', permittivity=e0, n=1.33)
assert lens_makers_formula(n1, n2, 10, -10) == 5*n2/(n1 - n2)
assert ae(lens_makers_formula(m1, m2, 10, -10), -20.15, 2)
assert ae(lens_makers_formula(1.3... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_object(self, obj: t.Union[object, str]) -> None:
"""Updates the values from the given object. An object can be of one
of the following two types:
- a string: in this case the object with that name will be imported
- an actual object reference: that object is used directly
... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_mirror_formula():
u, v, f = symbols('u, v, f')
assert mirror_formula(focal_length=f, u=u) == f*u/(-f + u)
assert mirror_formula(focal_length=f, v=v) == f*v/(-f + v)
assert mirror_formula(u=u, v=v) == u*v/(u + v)
assert mirror_formula(u=oo, v=v) == v
assert mirror_formula(u=oo, v=oo) is ... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_file(
self,
filename: str,
load: t.Callable[[t.IO[t.Any]], t.Mapping],
silent: bool = False,
) -> bool:
"""Update the values in the config from a file that is loaded
using the ``load`` parameter. The loaded data is passed to the
:meth:`from_mapping` m... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_lens_formula():
u, v, f = symbols('u, v, f')
assert lens_formula(focal_length=f, u=u) == f*u/(f + u)
assert lens_formula(focal_length=f, v=v) == f*v/(f - v)
assert lens_formula(u=u, v=v) == u*v/(u - v)
assert lens_formula(u=oo, v=v) == v
assert lens_formula(u=oo, v=oo) is oo
assert ... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_json(self, filename: str, silent: bool = False) -> bool:
"""Update the values in the config from a JSON file. The loaded
data is passed to the :meth:`from_mapping` method.
:param filename: The path to the JSON file. This can be an
absolute path or relative to the config roo... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_hyperfocal_distance():
f, N, c = symbols('f, N, c')
assert hyperfocal_distance(f=f, N=N, c=c) == f**2/(N*c)
assert ae(hyperfocal_distance(f=0.5, N=8, c=0.0033), 9.47, 2) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def from_mapping(
self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any
) -> bool:
"""Updates the config like :meth:`update` ignoring items with non-upper
keys.
.. versionadded:: 0.11
"""
mappings: t.Dict[str, t.Any] = {}
if mapping is not ... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def get_namespace(
self, namespace: str, lowercase: bool = True, trim_namespace: bool = True
) -> t.Dict[str, t.Any]:
"""Returns a dictionary containing a subset of configuration options
that match the specified namespace/prefix. Example usage::
app.config['IMAGE_STORE_TYPE'] = ... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | async def async_get_pickup_events() -> list[PickupEvent]:
"""Get the next pickup."""
try:
return await client.async_get_pickup_events(
start_date=date.today(), end_date=date.today() + timedelta(weeks=4)
)
except RecollectError as err:
raise Upd... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_write_simple_identifier(self):
escaped = cypher_escape("foo")
assert escaped == "foo" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Handle an options update."""
await hass.config_entries.async_reload(entry.entry_id) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_write_identifier_with_odd_chars(self):
escaped = cypher_escape("foo bar")
assert escaped == "`foo bar`" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_write_identifier_containing_back_ticks(self):
escaped = cypher_escape("foo `bar`")
assert escaped == "`foo ``bar```" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_cannot_write_empty_identifier(self):
with self.assertRaises(ValueError):
_ = cypher_escape("") |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_cannot_write_none_identifier(self):
with self.assertRaises(TypeError):
_ = cypher_escape(None) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_none(self):
encoded = cypher_repr(None)
assert encoded == u"null" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_true(self):
encoded = cypher_repr(True)
assert encoded == u"true" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_zero(self):
encoded = cypher_repr(0)
assert encoded == u"0" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_positive_integer(self):
encoded = cypher_repr(123)
assert encoded == u"123" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_negative_integer(self):
encoded = cypher_repr(-123)
assert encoded == u"-123" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_zero(self):
encoded = cypher_repr(0.0)
assert encoded == u"0.0" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_positive_float(self):
encoded = cypher_repr(123.456)
assert encoded == u"123.456" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_negative_float(self):
encoded = cypher_repr(-123.456)
assert encoded == u"-123.456" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_bytes_with_escaped_chars(self):
encoded = cypher_repr(b"hello, 'world'", quote=u"'")
assert encoded == u"'hello, \\'world\\''" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_empty_string(self):
encoded = cypher_repr(u"")
assert encoded == u"''" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_backspace(self):
encoded = cypher_repr(u"\b")
assert encoded == u"'\\b'" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_horizontal_tab(self):
encoded = cypher_repr(u"\t")
assert encoded == u"'\\t'" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_single_quote_when_single_quoted(self):
encoded = cypher_repr(u"'", quote=u"'")
assert encoded == u"'\\''" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_list(self):
encoded = cypher_repr([1, 2.0, u"three"])
assert encoded == u"[1, 2.0, 'three']" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_empty_list(self):
encoded = cypher_repr([])
assert encoded == u"[]" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_map(self):
encoded = cypher_repr(OrderedDict([("one", 1), ("two", 2.0), ("number three", u"three")]))
assert encoded == u"{one: 1, two: 2.0, `number three`: 'three'}" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_empty_map(self):
encoded = cypher_repr({})
assert encoded == u"{}" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_empty_node(self):
a = Node()
encoded = cypher_repr(a, node_template="{labels} {properties}")
assert encoded == u"({})" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_node_with_property(self):
a = Node(name="Alice")
encoded = cypher_repr(a, node_template="{labels} {properties}")
assert encoded == u"({name: 'Alice'})" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_node_with_label(self):
a = Node("Person")
encoded = cypher_repr(a, node_template="{labels} {properties}")
assert encoded == u"(:Person {})" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_should_encode_node_with_label_and_property(self):
a = Node("Person", name="Alice")
encoded = cypher_repr(a, node_template="{labels} {properties}")
assert encoded == u"(:Person {name: 'Alice'})" |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_encode_relationship(self):
a = Node(name="Alice")
b = Node(name="Bob")
ab = KNOWS(a, b)
encoded = cypher_repr(ab, related_node_template="{property.name}")
self.assertEqual("(Alice)-[:KNOWS {}]->(Bob)", encoded) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_encode_relationship_with_names(self):
a = Node("Person", name="Alice")
b = Node("Person", name="Bob")
ab = KNOWS(a, b)
encoded = cypher_repr(ab, related_node_template="{property.name}")
self.assertEqual("(Alice)-[:KNOWS {}]->(Bob)", encoded) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_encode_relationship_with_alternative_names(self):
a = Node("Person", nom=u"Aimée")
b = Node("Person", nom=u"Baptiste")
ab = KNOWS_FR(a, b)
encoded = cypher_repr(ab, related_node_template=u"{property.nom}")
self.assertEqual(u"(Aimée)-[:CONNAÎT {}]->(Baptiste)", encode... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def test_can_encode_relationship_with_properties(self):
a = Node("Person", name="Alice")
b = Node("Person", name="Bob")
ab = KNOWS(a, b, since=1999)
encoded = cypher_repr(ab, related_node_template="{property.name}")
self.assertEqual("(Alice)-[:KNOWS {since: 1999}]->(Bob)", encode... |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def __getattr__(cls, name):
return MagicMock() |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def combinationSum(self, candidates, target):
candidates.sort()
self.result = []
self.dfs(candidates,target,0,[])
return self.result |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def dfs(self,candidates,target,start,reslist):
length = len(candidates)
if target == 0:
return self.result.append(reslist) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def combinationSum(self, candidates, target):
self.result = []
self.dfs(candidates,0,target,[])
return self.result |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def dfs(self,can,cursum,target,res):
if cursum > target: return
if cursum == target:
self.result.append(res)
return
for i in xrange(len(can)):
if not res or res[len(res)-1] <= can[i]:
self.dfs(can,cursum+can[i],target,res+[can[i]]) |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def gpio_init(pin, output):
try:
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
f.write(b"out" if output else b"in")
except Exception as e:
print(f"Failed to set gpio {pin} direction: {e}") |
def save(self, doc):
if doc.id:
return self.update(doc)
else:
return self.insert(doc) | def batch_norm(inputs, training, data_format, name=''):
"""Performs a batch normalization using a standard set of parameters."""
# We set fused=True for a significant performance boost. See
# https://www.tensorflow.org/performance/performance_guide#common_fused_ops
return tf.compat.v1.layers.batch_normalization... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.