input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getAp1(self): ret = math.acos(((self.getLenp2() * self.getLenp2() + self.getLenp3() * self.getLenp3()) - self.getLenp1() * self.getLenp1()) / (2* self.getLenp2() * self.getLenp3())) return ret
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getAp2(self): ret =math.acos(((self.getLenp1() * self.getLenp1() + self.getLenp3() * self.getLenp3()) - self.getLenp2() * self.getLenp2()) / (2* self.getLenp1() * self.getLenp3())) return ret
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getAp3(self): ret = math.acos(((self.getLenp1() * self.getLenp1() + self.getLenp2() * self.getLenp2()) - self.getLenp3() * self.getLenp3()) / (2* self.getLenp1() * self.getLenp2())) return ret
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def drawMe(self, g): self.g = g r = 5 # 繪出三個頂點 self.p1.drawMe(self.g,r) self.p2.drawMe(self.g,r) self.p3.drawMe(self.g,r) line1 = Line(self.p1,self.p2) line2 = Line(self.p1,self.p3) line3 = Line(self.p2,self.p3) # 繪出三邊線 line1.drawMe...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def setSSS(self, lenp3, lenp1, lenp2): self.lenp3 = lenp3 self.lenp1 = lenp1 self.lenp2 = lenp2 self.ap1 = math.acos(((self.lenp2 * self.lenp2 + self.lenp3 * self.lenp3) - self.lenp1 * self.lenp1) / (2* self.lenp2 * self.lenp3)) self.ap2 = math.acos(((self.lenp1 * self.lenp1 + se...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def setSAS(self, lenp3, ap2, lenp1): self.lenp3 = lenp3 self.ap2 = ap2 self.lenp1 = lenp1 self.lenp2 = math.sqrt((self.lenp3 * self.lenp3 + self.lenp1 * self.lenp1) - 2* self.lenp3 * self.lenp1 * math.cos(self.ap2)) #等於 SSS(AB, BC, CA)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def setSaSS(self, lenp2, lenp3, lenp1): self.lenp2 = lenp2 self.lenp3 = lenp3 self.lenp1 = lenp1 if(self.lenp1 > (self.lenp2 + self.lenp3)): #<CAB 夾角為 180 度, 三點共線且 A 介於 BC 之間 ret = math.pi else : # <CAB 夾角為 0, 三點共線且 A 不在 BC 之間 if((self....
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getSSS(self): temp = [] temp.append( self.getLenp1() ) temp.append( self.getLenp2() ) temp.append( self.getLenp3() ) return temp
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getAAA(self): temp = [] temp.append( self.getAp1() ) temp.append( self.getAp2() ) temp.append( self.getAp3() ) return temp
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
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 __init__(self, x=0.0, y=0.0): self.x = x self.y = y
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 __init__(self, x=0.0, y=0.0): self.x = x self.y = y
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 __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, store): self.store = store
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, name): self._name = name
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, x, y): self.x = x self.y = y
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, action: str = None) -> None: super().__init__(prefix, action)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def draw(self, context): pass
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def conversion_fn(): """Temporary function.""" pass
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _files(self): return []
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def no_op(*args, **kwargs): pass
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def open(read_server_info=True): return
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def query_vpp_config(self): NotImplemented
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def tag(g, p): None
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def vsParseFd(self, fd): raise NotImplementedError()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def test_should_encode_false(self): encoded = cypher_repr(False) assert encoded == u"false"
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def residual_with_slice_fn(inp, out): inp_sliced = array_ops.slice(inp, [0, 0], [-1, 3]) return inp_sliced + out
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def _restore_checkpoint(self, master, saver=None, checkpoint_dir=None, checkpoint_filename_with_path=None, wait_for_checkpoint=False, max_wait_secs=7200, ...
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def testWrapperV2Build(self, wrapper): cell = rnn_cell_impl.LSTMCell(10) wrapper = wrapper(cell) wrapper.build((1,)) self.assertTrue(cell.built)
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def residual_fn(inputs, outputs): return inputs * 3 + outputs
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def dropout_state_filter_visitor(unused_state): return False
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self, duration_secs): self._start_time_secs = time.time() self._duration_secs = duration_secs
def __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self, name: str, get_converter: t.Optional[t.Callable] = None) -> None: self.__name__ = name self.get_converter = get_converter
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def __set__(self, obj: t.Any, value: t.Any) -> None: obj.config[self.__name__] = value
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self, root_path: str, defaults: t.Optional[dict] = None) -> None: dict.__init__(self, defaults or {}) self.root_path = root_path
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def test_can_write_simple_identifier(self): escaped = cypher_escape("foo") assert escaped == "foo"
def __init__(self,params,parent): self.params=params self.parent=parent
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle an options update.""" await hass.config_entries.async_reload(entry.entry_id)
def __init__(self,params,parent): self.params=params self.parent=parent
def test_can_write_identifier_with_odd_chars(self): escaped = cypher_escape("foo bar") assert escaped == "`foo bar`"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_can_write_identifier_containing_back_ticks(self): escaped = cypher_escape("foo `bar`") assert escaped == "`foo ``bar```"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_cannot_write_empty_identifier(self): with self.assertRaises(ValueError): _ = cypher_escape("")
def __init__(self,params,parent): self.params=params self.parent=parent
def test_cannot_write_none_identifier(self): with self.assertRaises(TypeError): _ = cypher_escape(None)
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_none(self): encoded = cypher_repr(None) assert encoded == u"null"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_true(self): encoded = cypher_repr(True) assert encoded == u"true"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_zero(self): encoded = cypher_repr(0) assert encoded == u"0"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_positive_integer(self): encoded = cypher_repr(123) assert encoded == u"123"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_negative_integer(self): encoded = cypher_repr(-123) assert encoded == u"-123"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_zero(self): encoded = cypher_repr(0.0) assert encoded == u"0.0"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_positive_float(self): encoded = cypher_repr(123.456) assert encoded == u"123.456"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_negative_float(self): encoded = cypher_repr(-123.456) assert encoded == u"-123.456"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_bytes_with_escaped_chars(self): encoded = cypher_repr(b"hello, 'world'", quote=u"'") assert encoded == u"'hello, \\'world\\''"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_empty_string(self): encoded = cypher_repr(u"") assert encoded == u"''"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_backspace(self): encoded = cypher_repr(u"\b") assert encoded == u"'\\b'"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_horizontal_tab(self): encoded = cypher_repr(u"\t") assert encoded == u"'\\t'"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_single_quote_when_single_quoted(self): encoded = cypher_repr(u"'", quote=u"'") assert encoded == u"'\\''"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_list(self): encoded = cypher_repr([1, 2.0, u"three"]) assert encoded == u"[1, 2.0, 'three']"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_empty_list(self): encoded = cypher_repr([]) assert encoded == u"[]"
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_empty_map(self): encoded = cypher_repr({}) assert encoded == u"{}"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_empty_node(self): a = Node() encoded = cypher_repr(a, node_template="{labels} {properties}") assert encoded == u"({})"
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
def test_should_encode_node_with_label(self): a = Node("Person") encoded = cypher_repr(a, node_template="{labels} {properties}") assert encoded == u"(:Person {})"
def __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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 __init__(self,params,parent): self.params=params self.parent=parent
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...