query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
List the four rotations of the given cube about the given axis. | def rotations4(polycube, axis):
for i in range(4):
yield rot90(polycube, i, axis) | [
"def orient_cube(cube):\n orient_sequence = []\n\n white_face = cube.get_face_with_color(color=Color.WHITE)\n if white_face != Face.UP:\n white_to_up = {\n Face.DOWN: [Move.X2],\n Face.LEFT: [Move.NOT_Y, Move.X],\n Face.RIGHT: [Move.Y, Move.X],\n Face.FRON... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
yields all 96 permutations of a cube | def permutations(cube):
yield from rotations24(cube)
yield from rotations24(np.flip(cube, 0))
yield from rotations24(np.flip(cube, 1))
yield from rotations24(np.flip(cube, 2)) | [
"def cubegraph():\n n = np.math.factorial(7) * 3**6\n g = []\n for i in range(n):\n cube = unpackcube(i)\n g.append([packcube(movecube(cube, move)) for move in cubemoves])\n return g",
"def permutides(n):\t\r\n\tnucl = [\"A\",\"C\",\"T\",\"G\"]\r\n\tbigSet = []\r\n\tfor i in range(n,0,-1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read the pointing file and return the content as a list of dictionaries called opsim_visits. The dictionary keys are stored in class variable_opsim_keys. | def readOpsimData(self):
if self.opsim_data:
good, string = self.checkOpsimData()
if good:
self.opsim_visits = self.opsim_data
else:
raise Exception(string)
elif self.opsim_filename:
dataDir = os.getenv('LSST_POINTING_DIR')
... | [
"def get_trackpoints(self, file_path, activities):\n trackpoints = []\n activity_pointer = 0\n current_activity = activities[activity_pointer]\n collecting_trackpoints = False\n\n with open(file_path) as file:\n records = file.readlines()[6:]\n if len(records... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the atmospheric parameters over time. Returns a list of dictionaries containing the modtran information for each opsim visit (in the same order). | def generateParameters(self, seed=_default_seed, output='atmos_db'):
self.initPointingSequence()
# Instantiate the Atmosphere class
self.atmos = Atmosphere(
self.mjds, self.mjde, self.npoints, seed)
# Generate main atmosphere parameters sequence
self.atmos.init_main_p... | [
"def GetAtoms(self,phasenam):\n phasedict = self.Phases[phasenam] # pointer to current phase info \n cx,ct,cs,cia = phasedict['General']['AtomPtrs']\n cfrac = cx+3\n fpfx = str(phasedict['pId'])+'::Afrac:' \n atomslist = []\n for i,at in enumerate(phasedic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call the modtranCards class in order to run MODTRAN for selected visits | def runModtran(self, run):
# Call for the MODTRAN card class
modcard = ModtranCards()
modcard.setDefaults()
# Write the cards to the disk
modcard.writeModtranCards(self.modtran_visits[run], self.outfilename)
modcard.runModtran() | [
"def creature_selected_call(self, *args):\n # clear history cache\n clear_module_list_data()\n\n # clear the current instructions\n self.parent.remove_modules()\n\n # fill the modules with the selected blueprint\n self.parent.initializer(selected_file=True)\n\n # if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load in memory the sorted tabulated wavelengths in nanometers at which MODTRAN outputs data. | def initModtranWavelengths(self):
main_dir = os.getenv('ATMOSPHERE_TRANSMISSION_DIR')
modtranwfile = os.path.join(main_dir, 'data/modtranwl.txt')
self.modtran_wl = numpy.loadtxt(modtranwfile) | [
"def early_table(filename):\n dir_name = globals.main_path + \"\\\\pkl tables\"\n if not os.path.exists(dir_name):\n os.mkdir(dir_name)\n pkl_name = filename+\".pkl\"\n file_path = os.path.join(dir_name, pkl_name)\n if filename == \"summary_table\":\n for i in range(len(globals.summary_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
_set_headers is an internal method that sends the proper headers for a given status code | def _set_headers(self, status):
self.send_response(status)
self.send_header('Content-type', 'application/json')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers() | [
"def _set_headers(self, status):\n # Notice this Docstring also includes information about the arguments passed to the function\n self.send_response(status)\n self.send_header(\"Content-type\", \"application/json\")\n self.send_header(\"Access-Control-Allow-Origin\", \"*\")\n self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns this project's version number based on the git repo's tags or from the RELEASEVERSION file if this is a packaged release without a .git directory. Calling this will update the RELEASEVERSION file if the calculated version number differs Calculated dev version numbers (nontagged commits) are PEP426, PEP440, and ... | def get_git_version(abbrev=4):
# Read in the version that's currently in RELEASE-VERSION.
release_version = read_release_version()
# First try to get the current version using "git describe".
tag, count, _ = call_git_describe(abbrev)
if count == '0':
if tag:
# Normal tagged rel... | [
"def get_release_info(version='v1.1-dev', date='2021-07-22'):\n # go to the repository directory\n dir_orig = os.getcwd()\n os.chdir(os.path.dirname(os.path.dirname(__file__)))\n\n # grab git info into string\n try:\n cmd = \"git describe --tags\"\n version = subprocess.check_output(cmd... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a consumer object that listen on the given topic and apply the callable function. | def create_consumer(self, topic_id: str, callback: Callable, gcp_subscription_id:str=None):
backend = None
if self.vendor == 'kafka':
backend = KafkaClient(topic_id, self.configs['kafka_servers'])
Consumer(backend, callback)
else:
project_id = os.getenv("GOOGL... | [
"def kafka_consumer_factory(config={}, topics=[]):\n consumer = Consumer(config)\n consumer.subscribe(topics)\n logger.info(f\"Create Kafka consumer for topics: {topics} \"\n f\"with config: {config}\"\n )\n return consumer",
"def kafka_consumer(kafka_consumer_factory):\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a producer object that pushes messages on the given topic. | def create_producer(self, topic_id: str) -> Producer:
backend = None
if self.vendor == 'kafka':
backend = KafkaClient(topic_id, self.configs['kafka_servers'])
else:
project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
subscription_id = os.getenv("GOOGLE_PUBSUB_SUB_I... | [
"def create(self):\n topic = self.__conn__.create_topic(self.__topic__)\n return topic.get_producer(*self.__args__, **self.__kargs__)",
"def producer(self,topic_name):\n return PyMomProducer(self.config.bootstrap_brokers(),topic_name)",
"def publish_message(producer_instance, topic_name, ke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test equality comparison of states. States are equal when their properties are equal and the substances are the same. | def test_eq(self):
st_1 = State(substance="water", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
st_2 = State(substance="water", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
assert st_1 == st_2 | [
"def is_state_equivalent(self, state1, state2):\n return state1 == state2",
"def test_eq_not_two_states(self):\n assert not State(substance=\"water\") == 3\n assert not 3 == State(substance=\"water\")",
"def __eq__(self, other):\n return self.state == other.state",
"def test_not_eq... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that comparing a state with something else doesn't work. | def test_eq_not_two_states(self):
assert not State(substance="water") == 3
assert not 3 == State(substance="water") | [
"def test_not_eq(self):\n st_1 = State(substance=\"water\", T=Q_(400.0, \"K\"), p=Q_(101325.0, \"Pa\"))\n st_2 = State(substance=\"water\", T=Q_(300.0, \"K\"), p=Q_(101325.0, \"Pa\"))\n assert not st_1 == st_2",
"def test_not_eq_sub(self):\n st_1 = State(substance=\"water\", T=Q_(400.0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
States are not equal when properties are not equal. | def test_not_eq(self):
st_1 = State(substance="water", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
st_2 = State(substance="water", T=Q_(300.0, "K"), p=Q_(101325.0, "Pa"))
assert not st_1 == st_2 | [
"def test_eq_not_two_states(self):\n assert not State(substance=\"water\") == 3\n assert not 3 == State(substance=\"water\")",
"def test_not_eq_sub(self):\n st_1 = State(substance=\"water\", T=Q_(400.0, \"K\"), p=Q_(101325.0, \"Pa\"))\n st_2 = State(substance=\"ammonia\", T=Q_(400.0, \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
States are not equal when substances are not the same. | def test_not_eq_sub(self):
st_1 = State(substance="water", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
st_2 = State(substance="ammonia", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
assert not st_1 == st_2 | [
"def test_eq_not_two_states(self):\n assert not State(substance=\"water\") == 3\n assert not 3 == State(substance=\"water\")",
"def test_not_eq(self):\n st_1 = State(substance=\"water\", T=Q_(400.0, \"K\"), p=Q_(101325.0, \"Pa\"))\n st_2 = State(substance=\"water\", T=Q_(300.0, \"K\"),... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Substances should be able to be specified with lowercase letters. | def test_lowercase_input(self):
State(substance="water")
State(substance="r22")
State(substance="r134a")
State(substance="ammonia")
State(substance="propane")
State(substance="air")
State(substance="isobutane")
State(substance="carbondioxide")
Stat... | [
"def test_casing(self):\n char = Character(type=['Fish', 'Great Ape'])\n assert char.type_key == 'fish'",
"def test_case_insensitive(self):\n self.check_4_way('Container', 'Pod')",
"def test_fails_on_lowercase_name(self):\n invalid_credentials_lowercase_name_twine = \"\"\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A substance not in the approved list should raise a ValueError. | def test_bad_substance(self):
with pytest.raises(ValueError):
State(substance="bad substance") | [
"def seal_is_valid(self):\n pass",
"def test_with_unnecessary_vulnerability_id_in_allowed_list():",
"def violated(self) -> bool:\n ...",
"def validate_sub(self):\n self._validate_claim_value('sub')",
"def checkseating(self):\n \n ls = [ seat for seat in self.getseatlist()\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specifying too many properties should raise a ValueError. | def test_too_many_props(self):
with pytest.raises(ValueError):
State(
substance="water",
T=Q_(300, "K"),
p=Q_(101325, "Pa"),
u=Q_(100, "kJ/kg"),
) | [
"def is_too_many_properties(self):\n return self._tag == 'too_many_properties'",
"def CheckProperties(self):\n for entry in self.entries:\n if entry.required and entry.key:\n if 'value' not in entry:\n entry.value = []\n for prop in entry.key.split(','):\n if not sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specifying too few properties should raise a value error. | def test_too_few_props(self):
with pytest.raises(ValueError):
State(substance="water", T=Q_(300, "K")) | [
"def test_too_many_props(self):\n with pytest.raises(ValueError):\n State(\n substance=\"water\",\n T=Q_(300, \"K\"),\n p=Q_(101325, \"Pa\"),\n u=Q_(100, \"kJ/kg\"),\n )",
"def CheckProperties(self):\n for entry in self.en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Negative absolute temperatures should raise a StateError. | def test_negative_temperature(self):
with pytest.raises(StateError):
State(substance="water", T=Q_(-100, "K"), p=Q_(101325, "Pa")) | [
"def test_negative_pressure(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(300, \"K\"), p=Q_(-101325, \"Pa\"))",
"def test_negative_volume(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(300, \"K\"), v=Q_(-10.13, \"m**3/kg\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Negative absolute pressures should raise a StateError. | def test_negative_pressure(self):
with pytest.raises(StateError):
State(substance="water", T=Q_(300, "K"), p=Q_(-101325, "Pa")) | [
"def test_negative_volume(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(300, \"K\"), v=Q_(-10.13, \"m**3/kg\"))",
"def test_quality_lt_zero(self):\n with pytest.raises(StateError):\n State(substance=\"water\", x=Q_(-1.0, \"dimensionless\"), p=Q_(101... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Negative absolute specific volumes should raise a StateError. | def test_negative_volume(self):
with pytest.raises(StateError):
State(substance="water", T=Q_(300, "K"), v=Q_(-10.13, "m**3/kg")) | [
"def test_negative_pressure(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(300, \"K\"), p=Q_(-101325, \"Pa\"))",
"def test_negative_temperature(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(-100, \"K\"), p=Q_(101325, \"Pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Vapor qualities less than 0.0 should raise a StateError. | def test_quality_lt_zero(self):
with pytest.raises(StateError):
State(substance="water", x=Q_(-1.0, "dimensionless"), p=Q_(101325, "Pa")) | [
"def test_quality_gt_one(self):\n with pytest.raises(StateError):\n State(substance=\"water\", x=Q_(2.0, \"dimensionless\"), p=Q_(101325, \"Pa\"))",
"def test_negative_pressure(self):\n with pytest.raises(StateError):\n State(substance=\"water\", T=Q_(300, \"K\"), p=Q_(-101325,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Vapor qualities greater than 1.0 should raise a StateError. | def test_quality_gt_one(self):
with pytest.raises(StateError):
State(substance="water", x=Q_(2.0, "dimensionless"), p=Q_(101325, "Pa")) | [
"def test_quality_lt_zero(self):\n with pytest.raises(StateError):\n State(substance=\"water\", x=Q_(-1.0, \"dimensionless\"), p=Q_(101325, \"Pa\"))",
"def test_too_few_props(self):\n with pytest.raises(ValueError):\n State(substance=\"water\", T=Q_(300, \"K\"))",
"def test_b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Invalid input properties should raise a ValueError. | def test_invalid_input_prop(self):
with pytest.raises(ValueError):
State(
substance="water", x=Q_(0.5, "dimensionless"), bad_prop=Q_(101325, "Pa")
) | [
"def _validate_input(self):\n pass",
"def check_set_noninput(method, uri, properties, prop_name, prop_value):\n if prop_name in properties:\n raise BadRequestError(\n method, uri, reason=6,\n message=\"Property cannot be provided as input: {!r}\".\n format(prop_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setting bad dimensions for the input property raises a StateError. | def test_bad_dimensions(self, prop: str):
kwargs = {prop: Q_(1.0, "dimensionless")}
if prop == "v":
kwargs["T"] = Q_(300.0, "K")
else:
kwargs["v"] = Q_(1.0, "m**3/kg")
with pytest.raises(StateError):
State(substance="water", **kwargs) | [
"def test_invalid_input_prop(self):\n with pytest.raises(ValueError):\n State(\n substance=\"water\", x=Q_(0.5, \"dimensionless\"), bad_prop=Q_(101325, \"Pa\")\n )",
"def test_bad_x_dimensions(self):\n with pytest.raises(StateError):\n State(substance=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setting bad dimensions for quality raises a StateError. Must be done in a separate test because the "dimensionless" sentinel value used in the other test is actually the correct dimension for quality. | def test_bad_x_dimensions(self):
with pytest.raises(StateError):
State(substance="water", T=Q_(300.0, "K"), x=Q_(1.01325, "K")) | [
"def test_bad_dimensions(self, prop: str):\n kwargs = {prop: Q_(1.0, \"dimensionless\")}\n if prop == \"v\":\n kwargs[\"T\"] = Q_(300.0, \"K\")\n else:\n kwargs[\"v\"] = Q_(1.0, \"m**3/kg\")\n with pytest.raises(StateError):\n State(substance=\"water\", *... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setting a twophase mixture with T and p should raise a StateError. | def test_TP_twophase(self):
with pytest.raises(StateError):
State(substance="water", T=Q_(373.1242958476844, "K"), p=Q_(101325.0, "Pa")) | [
"def set_T_and_P(self, T, P):\n chi, iota, eta, rotation = self.dm.get_input_photon_config()\n\n self.emitter.set_P(P, recalc=False)\n self.emitter.set_T(T)\n\n self.photon = light.PhotonProperties(self.emitter, chi, iota, eta)\n\n self.r0, self.theta0, self.phi0 = self.emitter.ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Accessing attributes that aren't one of the properties or pairs raises. | def test_bad_get_property(self):
s = State(substance="water", T=Q_(400.0, "K"), p=Q_(101325.0, "Pa"))
with pytest.raises(AttributeError):
s.bad_get | [
"def __getattribute__(self,name):\n try:\n return object.__getattribute__(self,name)\n except AttributeError:\n extraPO = object.__getattribute__(self,'_extraPO')\n\n if hasattr(extraPO,name):\n return getattr(extraPO,name) # HIDDEN!\n\n _attr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Trying to set a label that can't be converted to a string is a TypeError. | def test_label_cannot_be_converted_to_string(self):
class NoStr:
def __str__(self) -> str:
raise NotImplementedError
with pytest.raises(TypeError, match="The given label"):
State("water", label=NoStr()) | [
"def _mutate_label(label: str) -> str:\n return label",
"def _convert_missing(self, label):\n if label == '':\n return super().missing_value\n else:\n return label",
"def __init__(self, label):\n py_typecheck.check_type(label, six.string_types)\n self._label = st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set a state with EE units and check the properties. | def test_state_units_EE(self):
s = State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"), units="EE")
assert s.units == "EE"
assert s.cv.units == "british_thermal_unit / degree_Rankine / pound"
assert s.cp.units == "british_thermal_unit / degree_Rankine / pound"
assert s.s.units == ... | [
"def test_change_units(self):\n s = State(\"water\", T=Q_(100, \"degC\"), p=Q_(1.0, \"atm\"), units=\"EE\")\n assert s.units == \"EE\"\n s.units = \"SI\"\n assert s.units == \"SI\"\n assert s.cv.units == \"kilojoule / kelvin / kilogram\"\n assert s.cp.units == \"kilojoule /... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set a state with SI units and check the properties. | def test_state_units_SI(self):
s = State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"), units="SI")
assert s.units == "SI"
assert s.cv.units == "kilojoule / kelvin / kilogram"
assert s.cp.units == "kilojoule / kelvin / kilogram"
assert s.s.units == "kilojoule / kelvin / kilogram"
... | [
"def test_change_units(self):\n s = State(\"water\", T=Q_(100, \"degC\"), p=Q_(1.0, \"atm\"), units=\"EE\")\n assert s.units == \"EE\"\n s.units = \"SI\"\n assert s.units == \"SI\"\n assert s.cv.units == \"kilojoule / kelvin / kilogram\"\n assert s.cp.units == \"kilojoule /... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set default units and check for functionality. | def test_default_units(self):
s = State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"))
assert s.units is None
set_default_units("SI")
s2 = State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"))
assert s2.units == "SI"
set_default_units("EE")
s3 = State("water", T=Q_(1... | [
"def set_default_unit(unit):\n self.default_unit = unit",
"def SetDefaultUnit(self, category, unit):",
"def _update_units(self):\n self.options['gds_unit'] = 1.0 / self.design.parse_value('1 meter')",
"def add_default_units(self, u: dict):\n # TODO: Could look at replacing dict with defin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unsupported unit names should raise TypeError. | def test_unsupported_units(self):
with pytest.raises(TypeError):
set_default_units("bad")
with pytest.raises(TypeError):
State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"), units="bad") | [
"def test_list_of_available_units():\n unit_names = Unit.names\n assert len(unit_names) > 0\n assert \"meter\" in unit_names\n assert \"second\" in unit_names\n assert \"radian\" in unit_names",
"def test_invalid_units(self):\n with self.assertRaises(ValueError):\n UnitSystem(SYST... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change state units and check variable units have changed. | def test_change_units(self):
s = State("water", T=Q_(100, "degC"), p=Q_(1.0, "atm"), units="EE")
assert s.units == "EE"
s.units = "SI"
assert s.units == "SI"
assert s.cv.units == "kilojoule / kelvin / kilogram"
assert s.cp.units == "kilojoule / kelvin / kilogram"
... | [
"def test_state_units_SI(self):\n s = State(\"water\", T=Q_(100, \"degC\"), p=Q_(1.0, \"atm\"), units=\"SI\")\n assert s.units == \"SI\"\n assert s.cv.units == \"kilojoule / kelvin / kilogram\"\n assert s.cp.units == \"kilojoule / kelvin / kilogram\"\n assert s.s.units == \"kilojo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to create iam, redshift and ec2 clients | def create_clients(KEY, SECRET):
iam = boto3.client('iam',aws_access_key_id=KEY,
aws_secret_access_key=SECRET,
region_name='us-west-2'
)
redshift = boto3.client('redshift',
region_name="us-west-2",
aw... | [
"def create_clients(\n access_key_id,\n secret_access_key\n ):\n \n # Create IAM client\n iam = boto3.client(\n \"iam\",\n region_name = \"us-east-1\",\n aws_access_key_id = access_key_id,\n aws_secret_access_key = secret_access_key\n )\n \n \n # Cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to create an iam policy to allow Redshift read only access to S3 buckets | def create_iam_policy(DWH_IAM_ROLE_NAME):
# Create an iam role that allows Redshift to access S3 buckets with read only access
#1.1 Create the role,
try:
print("1.1 Creating a new IAM Role")
dwhRole = iam.create_role(
Path='/',
RoleName=DWH_IAM_ROLE_NAME,
... | [
"def create_iam_policy(bucket_name, policy_name=\"terraform_permissions\"):\n \n iam = boto3.client('iam')\n\n policy = {\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to open a TCP port to access the cluster endpoint | def open_tcp_port():
# Open an incoming tcp port to access the cluster endpoint
try:
vpc = ec2.Vpc(id=myClusterProps['VpcId'])
defaultSg = list(vpc.security_groups.all())[0]
print(defaultSg)
defaultSg.authorize_ingress(
GroupName=defaultSg.group_name,
... | [
"def port_open(self):\n sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n sk.settimeout(1)\n try:\n port = self.port.get('main', None)\n if port:\n return False\n sk.connect((self.ip, port))\n except Exception:\n return Fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the default number of significant figures used to print pint, pandas and numpy values quantities. Defaults to 4. | def set_sig_figs(n):
u.default_format = '.' + str(n) + 'g'
pd.options.display.float_format = ('{:,.' + str(n) + '}').format | [
"def array_output_precision(no_of_decimals):\n arrayprint.set_precision(no_of_decimals)",
"def array_output_precision(no_of_decimals):\n sys.float_output_precision = no_of_decimals",
"def significant_figures(x, n):\n if x == 0.0:\n return 0.0\n else:\n return round(x, int(n - m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the requests the client will need to make to get router credentials. | def get_credentials_requests(request, router_id):
router = models.Router.objects.get(pk=router_id)
manager = get_manager(router.manufacturer, router.model)
requests = manager.request_manager.get_login_credentials()
serializer = serializers.RouterRequestSerializer(requests, many=True)
return Response... | [
"def get_login_credentials(self):\n return [models.RouterRequest(method='get', url='/login.asp',\n request_type='login_credentials')]",
"def GetCreds():\n\n _username = input(\"Router username: \")\n _password = getpass(\"Password for {}: \".format(_username))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a synthetic external home object that maps to the actual remote home. | def _remoteHome(self, txn, uid):
from txdav.caldav.datastore.sql_external import CalendarHomeExternal
recipient = yield txn.store().directoryService().recordWithUID(uid)
resourceID = yield txn.store().conduit.send_home_resource_id(txn, recipient)
home = CalendarHomeExternal.makeSyntheti... | [
"def create_home(\n home=None, render=False, replace=False, runtime=None, no_runtime=None, **kw\n):\n homePath = get_home_config_path(home)\n if not homePath:\n return None\n exists = os.path.exists(homePath)\n if exists and not replace:\n return None\n\n homedir, filename = os.path.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home L{listChildren} works. | def test_homechild_listobjects(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
children01 = yield home01.listChildren()
yield self.commitTransaction(0)
home = yield self._remoteHome(se... | [
"def test_homechild_loadallobjects(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n children01 = yield home01.loadChildren()\n names01 = [child.name() for child in children01]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home L{loadChildren} works. | def test_homechild_loadallobjects(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
children01 = yield home01.loadChildren()
names01 = [child.name() for child in children01]
ids01 = [chil... | [
"def test_homechild_listobjects(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n children01 = yield home01.listChildren()\n yield self.commitTransaction(0)\n\n home = yield self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{objectResources} works. | def test_objectresource_loadallobjects(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.ics",... | [
"def test_objectresource_objectwith(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n resource01 = yield calendar01.createCalendar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{objectResourcesWithNames} works. | def test_objectresource_loadallobjectswithnames(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName... | [
"def test_objectresource_listobjects(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjectWithNa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{listObjectResources} works. | def test_objectresource_listobjects(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.ics", Co... | [
"def test_objectresource_loadallobjects(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjectWit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{countObjectResources} works. | def test_objectresource_countobjects(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.ics", C... | [
"def test_count_resources(ops_and_shots, expected_resources):\n ops, shots = ops_and_shots\n computed_resources = _count_resources(QuantumScript(ops=ops, shots=shots))\n assert computed_resources == expected_resources",
"def test_service_layer_objectids(self):\n ids = self.service_layer.object_ids... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{objectResourceWithName} and L{objectResourceWithUID} works. | def test_objectresource_objectwith(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
resource01 = yield calendar01.createCalendarObjectWithName... | [
"def test_objectresource_resourcenameforuid(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{resourceNameForUID} works. | def test_objectresource_resourcenameforuid(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.i... | [
"def test_objectresource_resourceuidforname(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote home child L{resourceUIDForName} works. | def test_objectresource_resourceuidforname(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.i... | [
"def test_objectresource_resourcenameforuid(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote object resource L{create} works. | def test_objectresource_create(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
yield home01.childWithName("calendar")
yield self.commitTransaction(0)
home = yield self._remoteHome(self... | [
"def test_create(client):\n rv = create(client, reponame='Michael', url='https://github.com/Michael')\n assert json.loads(rv.data.decode())['code'] == 0\n assert json.loads(rv.data.decode())['owner'] == 'Michael'\n assert json.loads(rv.data.decode())['url'] == 'https://github.com/Michael'",
"def test_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote object resource L{setComponent} works. | def test_objectresource_setcomponent(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.ics", C... | [
"def test_objectresource_component(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjectWithName... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test that a remote object resource L{component} works. | def test_objectresource_component(self):
home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
self.assertTrue(home01 is not None)
calendar01 = yield home01.childWithName("calendar")
yield calendar01.createCalendarObjectWithName("1.ics", Comp... | [
"def test_objectresource_setcomponent(self):\n\n home01 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=\"user01\", create=True)\n self.assertTrue(home01 is not None)\n calendar01 = yield home01.childWithName(\"calendar\")\n yield calendar01.createCalendarObjectWithN... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
BSR = bloody simple renderer | def example_BSR():
pts = [(1,1),(2,2),(3,3)]
lines = [ [ (1,1), (1,2), (2,1)], [ (6,1), (1,6), (5,-1)] ]
bloody_simple_2drender('2d_render.png', pts=pts, vecs=pts, lines=lines ) | [
"def dspyRender(self):\n pass",
"def createBasicRenderSetup():\n\n pass",
"def render(self, screen):\n pass",
"def __call__(self):\n return self.render()",
"def butterfly_effect():\t\n\tprint \"Loading butterfly effect\"\n\treturn render_template('butterfly.html')",
"def render(sim... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
make an animation of the bresenham algorithm this is not a full implementation of bresenham, but it works | def animate_bresenham( x1, y1, x2, y2):
dy = y2-y1
dx = x2-x1
d = 2*dy - dx
x = x1
y = y1
pixels_per_unit = 50
#print(' distances x %s y %s '%(dx,dy) )
#print(' d %s start x %s y %s '%(d,x,y) )
fb = pixel_op()
fb.create_buffer(800, 800)
fb.graticule(pixels_per_u... | [
"def methode_bresenham(A, B):\n a1, a2 = int(A[0]), int(A[1])\n b1, b2 = int(B[0]), int(B[1])\n\n pente = float(b2-a2) / float(b1-a1)\n\n # vérification des hypothèses 2/2\n assert 0 <= pente <= 1, f\"Erreur : la méthode de Bresenham demande 0 <= pente = {pente} <= 1.\"\n print(f\"Méthode de Brese... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
yes_no_choice and yes_no_answer are both of shape (batch, 2) | def predict(self, answer, start_logits, end_logits, mask, yes_no_choice_logits, yes_no_answer_logits,
sentence_logits=None, sentence_mask=None):
if len(answer) not in {5, 6}:
raise NotImplementedError()
if len(answer) == 6 and (sentence_logits is None or sentence_mask is None... | [
"def testQuestionTwo(self):\n self.assertEqual(AnswerQuestionTwo().shape, (5,5), \"Question two's output is not one dimension.\")",
"def natural_questions(output,\n prefix=\"answer:\",\n example=None,\n is_target=False):\n if is_target:\n a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes and binds a socket for the server on the host and port specified in the configuration file. | def initialize_socket(self):
try:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind((self._host, self._port))
self.sock.listen(10)
except socket.error, (value, messa... | [
"def setup_socket(self):\n self.server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n self.server_socket.bind((self.config['HOST_NAME'], self.config['BIND_PORT']))\n self.server_socket.listen(10)",
"def open_socket(self):\n try:\n self.server = socket.socket(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When a family reservation has more than 5 reservation childs, its fails | def test_family_reservation_max_amount_of_childs(self):
start_date = datetime.now()
reservation_list = [
BikeReservationPerHour(start_date)
,BikeReservationPerDay(start_date)
,BikeReservationPerDay(start_date)
,BikeReservationPerWeek(start_date)
... | [
"def test_family_reservation_min_amount_of_childs(self):\n start_date = datetime.now()\n\n reservation_list = [\n BikeReservationPerHour(start_date) \n ,BikeReservationPerDay(start_date)\n ]\n\n with self.assertRaises(InvalidAmountOfBikeReservationsOnFamiliyError):\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When a family reservation has less than 3 reservation childs, its fails | def test_family_reservation_min_amount_of_childs(self):
start_date = datetime.now()
reservation_list = [
BikeReservationPerHour(start_date)
,BikeReservationPerDay(start_date)
]
with self.assertRaises(InvalidAmountOfBikeReservationsOnFamiliyError):
f... | [
"def test_family_reservation_max_amount_of_childs(self):\n start_date = datetime.now()\n\n reservation_list = [\n BikeReservationPerHour(start_date) \n ,BikeReservationPerDay(start_date)\n ,BikeReservationPerDay(start_date)\n ,BikeReservationPerWeek(start_da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Locates the significant cells in a line of sight. Remove cells in order of increasing column density as determined by los7 until the ew changes by ewcut. These spectra are generated with specsynth with no noise. Results are reported in a file called ...iabs_cells.dat | def locateSigCells(run,ion,codeLoc,testing=0):
singleCount = 0
# Read in the galaxy's box
boxfile = '{0:s}_GZa{1:s}.{2:s}.h5'.format(run.galID,run.expn,ion.name)
box = pd.read_hdf(boxfile, 'data')
if testing==1:
print('Box read in')
# Read in the LOS info from lines.info
los_info ... | [
"def QDot_detection(self):\r\n\r\n # Creates a list with the total intensities from the lines as to analyze which lines contain quantum dots\r\n total_intensity_list = []\r\n for (columnName, columnData) in self.df4.iteritems():\r\n total_intensity = 0\r\n for i in columnD... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Heuristic bone name matching algorithm. | def bonenamematch(name1, name2):
if name1 == name2:
return True
if name1.startswith("Bip01 L "):
name1 = "Bip01 " + name1[8:] + ".L"
elif name1.startswith("Bip01 R "):
name1 = "Bip01 " + name1[8:] + ".R"
if name2.startswith("Bip01 L "):
name2 = "Bip01 " + name2[8:] + ".L"... | [
"def fuzz_by_name(self, name):\n self.fuzz_single_node_by_path(re.split('->', name))",
"def name_search(name):\n match_list = []\n \n for prefix,district in ocdids.iteritems():\n for dist_type,dist_names in district.iteritems():\n # pull the closest match from each set of distric... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register services with the same address. | def register(self, service_name, service_addr, service_ttl):
raise NotImplementedError | [
"def _register_services(self):\n base_url = self.bleemeo_base_url\n registration_url = urllib_parse.urljoin(base_url, '/v1/service/')\n\n for key, service_info in self.core.services.items():\n (service_name, instance) = key\n\n entry = {\n 'listen_addresses'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unregister services with the same address. | def unregister(self, service_name, service_addr):
raise NotImplementedError | [
"def _unregister_services(self):\n for service in self._services:\n self._dxl_client.unregister_service_sync(service, self.DXL_SERVICE_REGISTRATION_TIMEOUT)",
"def unregister_service(self, name):\n self._services.remove(name)",
"def unregister(self, service_name, service_addr, addr_cls=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize etcd service registry. | def __init__(self, etcd_host=None, etcd_port=None, etcd_client=None):
self._client = etcd_client if etcd_client else EtcdClient(
etcd_host, etcd_port)
self._leases = {}
self._services = {} | [
"def init_services():\n\n event_log_service = EventLogService()",
"def _init_services(self) -> None:\n pass",
"def initService(self):",
"def initialize_service(self):\r\n pass",
"def init_services(self):\n service_prefix = rospy.get_name() + \"/\"\n\n self._request_components_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a gRPC service lease from etcd. | def get_lease(self, service_addr, service_ttl):
lease = self._leases.get(service_addr)
if lease and lease.remaining_ttl > 0:
return lease
lease_id = hash(service_addr)
lease = self._client.lease(service_ttl, lease_id)
self._leases[service_addr] = lease
return... | [
"def get_etcd_client():\n return etcd.Client(host=TOTEM_ETCD_SETTINGS['host'],\n port=TOTEM_ETCD_SETTINGS['port'])",
"def __init__(self, etcd_host=None, etcd_port=None, etcd_client=None):\n self._client = etcd_client if etcd_client else EtcdClient(\n etcd_host, etcd_port... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unregister gRPC services with the same address. | def unregister(self, service_name, service_addr, addr_cls=None):
addr_cls = addr_cls or PlainAddress
etcd_delete = True
if addr_cls != PlainAddress:
etcd_delete = False
for service_name in service_name:
key = self._form_service_key(service_name, service_addr)
... | [
"def _unregister_services(self):\n for service in self._services:\n self._dxl_client.unregister_service_sync(service, self.DXL_SERVICE_REGISTRATION_TIMEOUT)",
"def unregister(self, service_name, service_addr):\n raise NotImplementedError",
"def unregister_service(self, name):\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a slim convolutional capsule layer. This layer performs 2D convolution given 5D input tensor of shape `[batch, input_dim, input_atoms, input_height, input_width]`. Then refines the votes with routing and applies Squash non linearity for each capsule. Each capsule in this layer is a convolutional unit and shares ... | def conv_slim_capsule(input_tensor,
input_dim,
output_dim,
layer_name,
input_atoms=8,
output_atoms=8,
stride=2,
kernel_size=5,
padding='SAME',
... | [
"def _build_capsule(self, input_tensor, num_classes):\n capsule1 = layers.conv_slim_capsule(\n input_tensor,\n input_dim=1,\n output_dim=self._hparams.num_prime_capsules,\n layer_name='conv_capsule1',\n num_routing=1,\n input_atoms=self._hparams.conv1_channel,\n o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs 2D convolution given a 5D input tensor. This layer given an input tensor of shape `[batch, input_dim, input_atoms, input_height, input_width]` squeezes the first two dimmensions to get a 4D tensor as the input of tf.nn.conv2d. Then splits the first dimmension and the last dimmension and returns the 6D convolut... | def _depthwise_conv3d(input_tensor,
kernel,
input_dim,
output_dim,
input_atoms=8,
output_atoms=8,
stride=2,
padding='SAME'):
with tf.name_scope('conv'):
i... | [
"def conv2d_config(input_shape, output_shape, filter_shape):\n input_shape = tf.TensorShape(input_shape).as_list()\n if len(input_shape) == 4:\n batch_size = input_shape[0]\n else:\n batch_size = None\n\n input_shape = np.array(input_shape[-3:])\n output_shape = np.array(tf.TensorShape(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a fully connected capsule layer. Given an input tensor of shape `[batch, input_dim, input_atoms]`, this op | def capsule(input_tensor,
input_dim,
output_dim,
layer_name,
input_atoms=8,
output_atoms=8,
**routing_args):
with tf.variable_scope(layer_name):
# weights variable will hold the state of the weights for the layer
weights = varia... | [
"def conv_slim_capsule(input_tensor,\n input_dim,\n output_dim,\n layer_name,\n input_atoms=8,\n output_atoms=8,\n stride=2,\n kernel_size=5,\n padd... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This function returns a list of calendar events results from the calendar service. | def get_events_results(calendar_id=None):
service = get_service()
start, end = get_time_constraints()
if calendar_id != None:
events_results = service.events().list(calendarId=calendar_id,
timeMin=start,
timeMax=end,
singleEvents=True,
... | [
"def get_events(calendars, service):\n app.logger.debug(\"Entering get_events\")\n time_min = arrow.get(flask.session['begin_datetime'])\n time_max = arrow.get(flask.session['end_datetime']).shift(days=+1)\n event_list = []\n calendars = ast.literal_eval(calendars)\n\n for calendar in calendars: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verifies the JWT from the HTTP header of the request. | def verify_jwt(*args, **kwargs):
auth = request.headers.get('Authorization', None)
if auth is None:
raise ProcessingException('Authorization header was missing', 401)
parts = auth.split()
if parts[0].lower() != 'Bearer'.lower():
raise ProcessingException('Unsupported authorization typ... | [
"def verify_jwt(auth_header, secret):\n if not auth_header or auth_header == 'null':\n #logging.warning(\"No Authorization header\")\n return [None, \"Unauthorized access: missing authentication\"]\n method, token = auth_header.split() # separate 'JWT' from the jwt itself\n token = bytes(tok... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a random cover from API | def get_random_cover(request):
logger.debug("get_random_cover called")
response_data = {}
validation = init_validation(request)
if 'error' in validation:
return JsonResponse(validation['data'], status=validation['error'])
headers = {'Content-Type': 'application/json'}
response = reques... | [
"def get_random_image(self):\n\n chosen_endpoint = \\\n self._get_random_endpoint_from_list_by_substring('/random')\n self.client.get(chosen_endpoint)",
"def _url_random(self):\n res = self.api + \"/cards/random\"\n return res",
"def get_random_doggo() -> str:\n\n try:\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get covers statistics from API | def get_covers_stats(request):
logger.debug("get_covers_stats called")
response_data = {}
validation = init_validation(request)
if 'error' in validation:
return JsonResponse(validation['data'], status=validation['error'])
headers = {'Content-Type': 'application/json'}
response = reques... | [
"def test_api_v1_defenders_summary_get(self):\n pass",
"def metrics(self) -> global___Response.Metrics:",
"def insights(self):\n return self._request(\"GET\", \"v2/insights\").json()",
"def _get_consumption(self, url, start, end, aggregation):\n start = self._to_milliseconds(start)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search covers from API | def get_covers_by_search_ng(request):
logger.debug("Entering search covers by query")
response_data = {}
validation = init_validation(request)
if 'error' in validation:
return JsonResponse(validation['data'], status=validation['error'])
headers = {'Content-Type': 'application/json'}
pa... | [
"def filtered_search():\n url = 'https://trackapi.nutritionix.com/v2/search/instant'\n\n # 203 - Protein\n # 204 - Fat\n # 205 - Carbohydrate\n # 208 - Calories\n # gte - Greater than or equal to\n # lte - Less than or equal to\n body = {\n \"query\": \"burgers\",\n \"full_nutr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns True if command for .hs can be invoked | def is_enabled_haskell_command(view = None, must_be_project=True, must_be_main=False, must_be_file = False):
window, view, file_shown_in_view = get_haskell_command_window_view_file_project(view)
if not window or not view:
return False
if must_be_file and not file_shown_in_view:
return Fals... | [
"def perform_is_executable(self):\n\t\treturn False",
"def perform_is_executable(self) -> bool:\n\t\treturn False",
"def hasCommand():\n args = sys.argv[1:]\n if '--help' in args:\n return False\n if '-h' in args:\n return False\n for arg in args:\n if arg and not arg.startswith... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns window, view and file | def get_haskell_command_window_view_file_project(view = None):
if view:
return view.window(), view, view.file_name()
window = sublime.active_window()
view = None
if window:
view = window.active_view()
file_name = None
if view:
file_name = view.file_name()
return wind... | [
"def get_window_info (self):\n \n # g.trace(self.w,self.h,self.x,self.y)\n \n return self.w,self.h,self.x,self.y",
"def get_window(self): # real signature unknown; restored from __doc__\n pass",
"def get_window_list(self):\n self.check_connect()\n window= self.buffer... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the specified command, block until it completes, and return the exit code, stdout, and stderr. Extends os.environment['PATH'] with the 'add_to_PATH' setting. Additional parameters to Popen can be specified as keyword parameters. | def call_and_wait_with_input(command, input_string, **popen_kwargs):
if subprocess.mswindows:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popen_kwargs['startupinfo'] = startupinfo
# For the subprocess, extend the env PATH to include the ... | [
"def call_and_wait_with_input(command, input_string, **popen_kwargs):\n if subprocess.mswindows:\n startupinfo = subprocess.STARTUPINFO()\n startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW\n popen_kwargs['startupinfo'] = startupinfo\n\n # For the subprocess, extend the env PATH to i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the path to the .cabal file project for the source file in the specified view. The view must show a saved file, the file must be Haskell source code, and the file must be under a directory containing a .cabal file. Otherwise, return None. | def get_cabal_project_dir_and_name_of_view(view):
# Check that the view is showing a saved file:
file_shown_in_view = view.file_name()
if file_shown_in_view is None:
return None, None
# Check that the file is Haskell source code:
syntax_file_for_view = view.settings().get('syntax').lower()
... | [
"def get_haskell_command_window_view_file_project(view = None):\n if view:\n return view.window(), view, view.file_name()\n\n window = sublime.active_window()\n view = None\n if window:\n view = window.active_view()\n file_name = None\n if view:\n file_name = view.file_name()\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the path to the .cabal file and name of project for the specified file. | def get_cabal_project_dir_and_name_of_file(filename):
# Check that a .cabal file is present:
directory_of_file = os.path.dirname(filename)
cabal_file_path = find_file_in_parent_dir(directory_of_file, '*.cabal')
if cabal_file_path is None:
return None, None
# Return the directory containing t... | [
"def get_cabal_project_dir_of_file(filename):\n return get_cabal_project_dir_and_name_of_file(filename)[0]",
"def projectFile(self):\n if self.project is not None:\n return pFile.conformPath(os.path.join(self.projectPath, '%s.py' % self.project))",
"def get_project_name(self, file_path):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the path to the .cabal file project for the specified file. | def get_cabal_project_dir_of_file(filename):
return get_cabal_project_dir_and_name_of_file(filename)[0] | [
"def get_cabal_project_dir_and_name_of_file(filename):\n # Check that a .cabal file is present:\n directory_of_file = os.path.dirname(filename)\n cabal_file_path = find_file_in_parent_dir(directory_of_file, '*.cabal')\n if cabal_file_path is None:\n return None, None\n # Return the directory c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return .cabal file for cabal directory | def get_cabal_in_dir(cabal_dir):
for entry in os.listdir(cabal_dir):
if entry.endswith(".cabal"):
project_name = os.path.splitext(entry)[0]
return (project_name, os.path.join(cabal_dir, entry))
return (None, None) | [
"def get_cabal_project_dir_of_file(filename):\n return get_cabal_project_dir_and_name_of_file(filename)[0]",
"def get_cabal_project_dir_and_name_of_file(filename):\n # Check that a .cabal file is present:\n directory_of_file = os.path.dirname(filename)\n cabal_file_path = find_file_in_parent_dir(direc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns current cabaldev sandbox or 'cabal' | def current_cabal():
if get_setting_async('use_cabal_dev'):
return get_setting_async('cabal_dev_sandbox')
else:
return 'cabal' | [
"def current_sandbox():\n if get_setting_async('use_cabal_dev'):\n return get_setting_async('cabal_dev_sandbox')\n else:\n return None",
"def get_current_environment():\n # Search for the environment variable set by the hutch python setup\n env = os.getenv('CONDA_ENVNAME')\n # Otherwi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns current cabaldef sandbox or None | def current_sandbox():
if get_setting_async('use_cabal_dev'):
return get_setting_async('cabal_dev_sandbox')
else:
return None | [
"def current_cabal():\n if get_setting_async('use_cabal_dev'):\n return get_setting_async('cabal_dev_sandbox')\n else:\n return 'cabal'",
"def get_current_environment():\n # Search for the environment variable set by the hutch python setup\n env = os.getenv('CONDA_ENVNAME')\n # Otherw... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attach sandbox arguments to command | def attach_sandbox(cmd, sandbox = None):
if not sandbox:
sandbox = get_setting_async('cabal_dev_sandbox')
if len(sandbox) > 0:
return cmd + ['-s', sandbox]
return cmd | [
"def attach_sandbox(cmd):\n sand = get_setting_async('cabal_dev_sandbox')\n if len(sand) > 0:\n return cmd + ['-s', sand]\n return cmd",
"def _setup_args(self):\n self.args_fp = tempfile.NamedTemporaryFile(\n prefix='ansible_mitogen',\n suffix='-args',\n dir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attach sandbox if use_cabal_dev enabled | def try_attach_sandbox(cmd, sandbox = None):
if not get_setting_async('use_cabal_dev'):
return cmd
return attach_sandbox(cmd, sandbox) | [
"def try_attach_sandbox(cmd):\n if not get_setting_async('use_cabal_dev'):\n return cmd\n return attach_sandbox(cmd)",
"def attach_sandbox(cmd, sandbox = None):\n if not sandbox:\n sandbox = get_setting_async('cabal_dev_sandbox')\n if len(sandbox) > 0:\n return cmd + ['-s', sandbo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get setting from any thread Note, that setting must be loaded before by get_setting from main thread | def get_setting_async(key, default=None):
# Reload it in main thread for future calls of get_setting_async
sublime.set_timeout(lambda: update_setting(key), 0)
with sublime_haskell_settings as settings:
if key not in settings:
# Load it in main thread, but for now all we can do is result ... | [
"def get_setting_async(key, default=None):\n # Reload it in main thread for future calls of get_setting_async\n sublime.set_timeout(lambda: update_setting(key), 0)\n with sublime_haskell_settings as settings:\n if key not in settings:\n # Load it in main thread, but for now all we can do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets ghc_opts, used in several tools, as list with extra 'packagedb' option and 'i' option if filename passed | def get_ghc_opts(filename = None, add_package_db = True, cabal = None):
ghc_opts = get_setting_async('ghc_opts')
if not ghc_opts:
ghc_opts = []
if add_package_db:
package_db = ghci_package_db(cabal = cabal)
if package_db:
ghc_opts.append('-package-db {0}'.format(package_d... | [
"def get_ghc_opts_args(filename = None, add_package_db = True, cabal = None):\n opts = get_ghc_opts(filename, add_package_db, cabal)\n args = []\n for opt in opts:\n args.extend([\"-g\", \"\\\"\" + opt + \"\\\"\"])\n return args",
"def get_glib_cflags():\n\tpkgcmd = os.popen(pkg_config_path +\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Same as ghc_opts, but uses 'g' option for each option | def get_ghc_opts_args(filename = None, add_package_db = True, cabal = None):
opts = get_ghc_opts(filename, add_package_db, cabal)
args = []
for opt in opts:
args.extend(["-g", "\"" + opt + "\""])
return args | [
"def get_ghc_opts(filename = None, add_package_db = True, cabal = None):\n ghc_opts = get_setting_async('ghc_opts')\n if not ghc_opts:\n ghc_opts = []\n if add_package_db:\n package_db = ghci_package_db(cabal = cabal)\n if package_db:\n ghc_opts.append('-package-db {0}'.form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls ghcmod with the given arguments. Shows a sublime error message if ghcmod is not available. | def call_ghcmod_and_wait(arg_list, filename=None, cabal = None):
ghc_opts_args = get_ghc_opts_args(filename, add_package_db = False, cabal = cabal)
try:
command = attach_cabal_sandbox(['ghc-mod'] + ghc_opts_args + arg_list, cabal)
# log('running ghc-mod: {0}'.format(command))
# Set c... | [
"def call_ghcmod_and_wait(arg_list, filename=None):\n\n ghc_cwd = (get_cabal_project_dir_of_file(filename) or os.path.dirname(filename)) if filename else None\n\n try:\n command = try_attach_sandbox(['ghc-mod'] + arg_list)\n\n log('running ghc-mod: {0}'.format(command))\n\n exit_code, out... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wait for window to appear on startup It's dirty hack, but I have no idea how to make it better | def wait_for_window(on_appear, seconds_to_wait=MAX_WAIT_FOR_WINDOW):
sublime.set_timeout(lambda: wait_for_window_callback(on_appear, seconds_to_wait), 0) | [
"def _show_window_cb (self, inspector):\n self.present()\n return True",
"def window_thread_start():\n window = WindowSingleton.get_instance().window\n global window_open\n width_value = window.winfo_screenwidth()\n height_value = window.winfo_screenheight()\n window.geometry(\"%dx%d+... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pure msg with 'SublimeHaskell' prefix and set_timeout | def sublime_status_message(msg):
sublime.set_timeout(lambda: sublime.status_message(u'SublimeHaskell: {0}'.format(msg)), 0) | [
"def show_status_message(msg, isok = None):\n mark = u'...'\n if isok is not None:\n mark = u' \\u2714' if isok else u' \\u2718'\n sublime_status_message(u'{0}{1}'.format(msg, mark))",
"def hello(msg: str):\n time.sleep(2)\n print(msg)",
"def safe_exec(command, msg):\n try:\n sig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show status message with check mark (isok = true), ballot x (isok = false) or ... (isok = None) | def show_status_message(msg, isok = None):
mark = u'...'
if isok is not None:
mark = u' \u2714' if isok else u' \u2718'
sublime_status_message(u'{0}{1}'.format(msg, mark)) | [
"def show_status_message(msg, is_ok = None, priority = 0):\n status_message_manager.add(StatusMessage.status(msg, priority = priority, is_ok = is_ok))",
"def show_msg(self):\n if self.result and self.success_msg:\n print color_str('g', '\\n'.join(self.success_msg))\n elif self.result =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show status message for action with check mark or with ballot x Returns whether action exited properly | def with_status_message(msg, action):
try:
show_status_message(msg)
action()
show_status_message(msg, True)
return True
except SublimeHaskellError as e:
show_status_message(msg, False)
log(e.reason)
return False | [
"def print_confirmation(action):\n\tprint(Fore.YELLOW + Style.BRIGHT + action + Style.RESET_ALL + \"\\n\")",
"def ok():\n print \"[ \\033[32mOK\\033[39m ]\"",
"def report_useraction():\n return session.waiting_msg",
"def show_msg(self):\n if self.result and self.success_msg:\n print colo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Same as show_status_message, but shows permanently until called with isok not None There can be only one message process in time, message with highest priority is shown For example, when building project, there must be only message about building | def show_status_message_process(msg, isok = None, timeout = 300, priority = 0):
if isok is not None:
if msg in StatusMessage.messages:
StatusMessage.messages[msg].cancel()
del StatusMessage.messages[msg]
show_status_message(msg, isok)
else:
if msg in StatusMessage... | [
"def show_status_message(msg, is_ok = None, priority = 0):\n status_message_manager.add(StatusMessage.status(msg, priority = priority, is_ok = is_ok))",
"def show_status_message(msg, isok = None):\n mark = u'...'\n if isok is not None:\n mark = u' \\u2714' if isok else u' \\u2718'\n sublime_sta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse a bytestring into protobuf pairs and make sure that all pairs have a valid wire type. | def _parse_proto(raw: bytes) -> list[google_protobuf.GoogleProtobuf.Pair]:
buf = google_protobuf.GoogleProtobuf(KaitaiStream(io.BytesIO(raw)))
for pair in buf.pairs:
if not isinstance(
pair.wire_type, google_protobuf.GoogleProtobuf.Pair.WireTypes
):
raise ValueError("Not ... | [
"def parse_pb(pb_bytes):\n matches = []\n for pb_class in PB_TYPES:\n pb = _maybe_parse(pb_bytes, pb_class)\n if pb is not None:\n matches.append(pb)\n\n matches = _parse_pb_prune(matches)\n if len(matches) != 1:\n raise ValueError(\n \"Serialized protobuf coul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Motivation calculate Green function at each grid point, 1/(4np.pir) where r is the distance from the origin (defined as the bottom left grid point) | def Green_func(self):
if self.bc == True:
size = self.grid_size
else:
size = 2*self.grid_size
self.Green = np.zeros([size, size])
for x in range(len(self.Green[0])):
for y in range(len(self.Green[1])):
radius = np.sqrt(x**2 + y**2)
... | [
"def compute_green_function(self,n):\n size = np.arange(n)\n xx,yy = np.meshgrid(size,size)\n vectors = np.array([xx.ravel(),yy.ravel()])\n norm = norm_on_grid(vectors)\n green = green_function(norm,self.grid,self.softner,self.G)\n try:\n green[n//2:, :n//2] = np... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Main Function to load data to S3 using spark. | def main():
spark = create_spark_session()
print("Spark Session Created")
#Print S3 bucket location
s3_bucket=os.environ["s3_bucket"]
s3_bucket = s3_bucket.replace("'", "")
print (s3_bucket)
#Invoke Functions to process data
process_data(spark, s3_bucket) | [
"def main():\n spark = create_spark_session()\n input_data = \"s3a://udacity-dend/\"\n output_data = \"s3a://udacity-my-bucket/\"\n \n process_song_data(spark, input_data, output_data) \n process_log_data(spark, input_data, output_data)",
"def load_data_s3(filename):\n \n global s3_clie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method configures the storage card for flex controller. | def configure_storage_flex_flash_controller(handle, parent_dn, flex_id,
operation_request,
admin_slot_number="NA",
wait_operation_completion=True):
from ucsmsdk.mometa.storage.Storage... | [
"def storage_flex_flash_controller(self, storage_flex_flash_controller):\n\n self._storage_flex_flash_controller = storage_flex_flash_controller",
"def storage_flex_util_controller(self, storage_flex_util_controller):\n\n self._storage_flex_util_controller = storage_flex_util_controller",
"def sto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count the number of rows in each child table. This function generates a derived column for each child table which contains the number of rows in each group. For example, if the target table is users, then it might generate a derived column containing the number of rows in the transaction table that belongs to each user... | def derive(self, dataset, table_name):
seen = set()
for fk in dataset.metadata.get_foreign_keys(table_name):
if fk["table"] == table_name:
# Skip this relationship if the target table is the child
continue
if not isinstance(fk["field"], str):
... | [
"def _make_generic_count_property(parent_table, children_table, where=None):\n children_id_field = '{}.id'.format(children_table)\n parent_id_field = '{}.id'.format(parent_table)\n children_rel_field = '{}.{}_id'.format(children_table, parent_table)\n query = (select([func.count(text(children_id_field))... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Travels down 'prev_node' dictionary starting from 'goal' to retrieve final path | def reconstruct_path(goal: Vector2D, prev_node: dict) -> list:
path = []
prev = prev_node[goal] # remove 'goal' from path
while prev != None:
path.append(prev)
prev = prev_node[prev]
path = path[:-1] # remove 'start' from path
path.reverse()
return path | [
"def get_path(prevs, goal, start):\n path = OD({goal: 0})\n cur = goal\n while cur != start:\n (cost, node) = prevs.get(cur)\n if node == None or node in path:\n print(\"ERROR: No path found from %s -> %s\" % (start, goal))\n return (0, None)\n path[node] = path[c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
L{AMPConfiguration.loginSystem}'s value should have been preserved. | def test_attributeCopied(self):
self.assertIdentical(
self.store.findUnique(AMPConfiguration).loginSystem,
self.store.findUnique(LoginSystem)) | [
"def enableLogin(self):\n\t\tself.log('Login enabled')\n\t\tself.loginEnabled = True",
"def default_login_works(self):\n return True if self.default_login_auth_header else False",
"def test_set_password_system_user(self):\n pass",
"def reset_login_attemtps(self):\r\n self.login_attempts =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |