Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
DummyDrivers.dummy_write | (self, address, data) | The "dummy" write function which does not write and just logs a warning
:param address: The address to do a dummy write to
:type address: int
:param data: The data to dummy write
:type address: int
:return: Always returns True
:rtype: bool
| The "dummy" write function which does not write and just logs a warning | def dummy_write(self, address, data):
"""The "dummy" write function which does not write and just logs a warning
:param address: The address to do a dummy write to
:type address: int
:param data: The data to dummy write
:type address: int
:return: Always returns True
... | [
"def",
"dummy_write",
"(",
"self",
",",
"address",
",",
"data",
")",
":",
"self",
".",
"_logger",
".",
"warning",
"(",
"\"DUMMY DEVICE WRITE: A 0x{:08X} D: 0x{:08X}\"",
".",
"format",
"(",
"address",
",",
"data",
")",
")",
"return",
"True"
] | [
70,
4
] | [
83,
19
] | python | en | ['en', 'en', 'en'] | True |
TestChip.adp_sock | (self) | Returns the ADP Socket object for reading and writing directly via the ADP connection
:return: The ADP Socket object
:rtype: adp_socket.ADP_Conn object
| Returns the ADP Socket object for reading and writing directly via the ADP connection
:return: The ADP Socket object
:rtype: adp_socket.ADP_Conn object
| def adp_sock(self):
"""Returns the ADP Socket object for reading and writing directly via the ADP connection
:return: The ADP Socket object
:rtype: adp_socket.ADP_Conn object
"""
return self._adp_sock | [
"def",
"adp_sock",
"(",
"self",
")",
":",
"return",
"self",
".",
"_adp_sock"
] | [
169,
4
] | [
175,
29
] | python | en | ['en', 'en', 'en'] | True |
TestChip.ctrl_regs | (self) | Returns the object for reading and writing to/from the M0N0 Control Registers
:return: The Control Register object
:rtype: registers_model.Registers_Model object
| Returns the object for reading and writing to/from the M0N0 Control Registers
:return: The Control Register object
:rtype: registers_model.Registers_Model object
| def ctrl_regs(self):
"""Returns the object for reading and writing to/from the M0N0 Control Registers
:return: The Control Register object
:rtype: registers_model.Registers_Model object
"""
return self._ctrl_regs | [
"def",
"ctrl_regs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ctrl_regs"
] | [
178,
4
] | [
184,
30
] | python | en | ['en', 'en', 'en'] | True |
TestChip.status_regs | (self) | Returns the object for reading and writing to/from the M0N0 Status Registers
:return: The Status Register object
:rtype: registers_model.Registers_Model object
| Returns the object for reading and writing to/from the M0N0 Status Registers
:return: The Status Register object
:rtype: registers_model.Registers_Model object
| def status_regs(self):
"""Returns the object for reading and writing to/from the M0N0 Status Registers
:return: The Status Register object
:rtype: registers_model.Registers_Model object
"""
return self._status_regs | [
"def",
"status_regs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status_regs"
] | [
187,
4
] | [
193,
32
] | python | en | ['en', 'en', 'en'] | True |
TestChip.gpio_regs | (self) | Returns the object for reading and writing to/from the M0N0 GPIO Registers
:return: The GPIO Register object
:rtype: registers_model.Registers_Model object
| Returns the object for reading and writing to/from the M0N0 GPIO Registers
:return: The GPIO Register object
:rtype: registers_model.Registers_Model object
| def gpio_regs(self):
"""Returns the object for reading and writing to/from the M0N0 GPIO Registers
:return: The GPIO Register object
:rtype: registers_model.Registers_Model object
"""
return self._gpio_regs | [
"def",
"gpio_regs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_gpio_regs"
] | [
196,
4
] | [
202,
30
] | python | en | ['en', 'en', 'en'] | True |
TestChip.spi_regs | (self) | Returns the object for reading and writing to/from the M0N0 SPI Registers
:return: The SPI Register object
:rtype: registers_model.Registers_Model object
| Returns the object for reading and writing to/from the M0N0 SPI Registers
:return: The SPI Register object
:rtype: registers_model.Registers_Model object
| def spi_regs(self):
"""Returns the object for reading and writing to/from the M0N0 SPI Registers
:return: The SPI Register object
:rtype: registers_model.Registers_Model object
"""
return self._spi_regs | [
"def",
"spi_regs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_spi_regs"
] | [
205,
4
] | [
211,
29
] | python | en | ['en', 'en', 'en'] | True |
TestChip.pcsm_regs | (self) | Returns the object for reading and writing to/from the M0N0 PCSM Registers
:return: The PCSM Register object
:rtype: registers_model.Registers_Model object
| Returns the object for reading and writing to/from the M0N0 PCSM Registers
:return: The PCSM Register object
:rtype: registers_model.Registers_Model object
| def pcsm_regs(self):
"""Returns the object for reading and writing to/from the M0N0 PCSM Registers
:return: The PCSM Register object
:rtype: registers_model.Registers_Model object
"""
return self._pcsm_regs | [
"def",
"pcsm_regs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pcsm_regs"
] | [
214,
4
] | [
220,
30
] | python | en | ['en', 'en', 'en'] | True |
TestChip.pcsm | (self) | Alias for pcsm_regs property
| Alias for pcsm_regs property
| def pcsm(self):
""" Alias for pcsm_regs property
"""
return self._pcsm_regs | [
"def",
"pcsm",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pcsm_regs"
] | [
223,
4
] | [
226,
30
] | python | en | ['es', 'la', 'en'] | False |
TestChip.mem_map | (self) | Returns the object for reading information about the memory map (e.g. base address or size)
:return: The Memory Map object
:rtype: registers_model.MemoryMap object
| Returns the object for reading information about the memory map (e.g. base address or size)
:return: The Memory Map object
:rtype: registers_model.MemoryMap object
| def mem_map(self):
"""Returns the object for reading information about the memory map (e.g. base address or size)
:return: The Memory Map object
:rtype: registers_model.MemoryMap object
"""
return self._mem_map | [
"def",
"mem_map",
"(",
"self",
")",
":",
"return",
"self",
".",
"_mem_map"
] | [
231,
4
] | [
237,
28
] | python | en | ['en', 'en', 'en'] | True |
TestChip.tcs | (self) | Returns the object for working with the database of testcases in the ROM/DEVRAM/CODERAM software
:return: The Testcases object
:rtype: testcase_control.TestcaseController object
| Returns the object for working with the database of testcases in the ROM/DEVRAM/CODERAM software
:return: The Testcases object
:rtype: testcase_control.TestcaseController object
| def tcs(self):
"""Returns the object for working with the database of testcases in the ROM/DEVRAM/CODERAM software
:return: The Testcases object
:rtype: testcase_control.TestcaseController object
"""
return self._tcs | [
"def",
"tcs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tcs"
] | [
240,
4
] | [
246,
24
] | python | en | ['en', 'en', 'en'] | True |
TestChip.perf_labels | (self) | Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
| Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
| def perf_labels(self):
"""Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
"""
return self._perf_labels | [
"def",
"perf_labels",
"(",
"self",
")",
":",
"return",
"self",
".",
"_perf_labels"
] | [
249,
4
] | [
255,
32
] | python | en | ['en', 'en', 'en'] | True |
TestChip.load_trim_settings | (self, load_trims) | Loads the trim for the current chip using the specified YAML trim database and chip ID.
:param load_trims: Path to the trim database YAML file
:type load_trims: str
| Loads the trim for the current chip using the specified YAML trim database and chip ID.
:param load_trims: Path to the trim database YAML file
:type load_trims: str
| def load_trim_settings(self, load_trims):
"""Loads the trim for the current chip using the specified YAML trim database and chip ID.
:param load_trims: Path to the trim database YAML file
:type load_trims: str
"""
self._logger.info("Loading trims from: {}".format(load_t... | [
"def",
"load_trim_settings",
"(",
"self",
",",
"load_trims",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Loading trims from: {}\"",
".",
"format",
"(",
"load_trims",
")",
")",
"trim_db",
"=",
"{",
"}",
"with",
"open",
"(",
"load_trims",
",",
"'r... | [
259,
4
] | [
294,
65
] | python | en | ['en', 'en', 'en'] | True |
TestChip.connect | (self,
adp_port,
skip_reload=False,
load_trims=False,
safe_tcro=False
) | Connects to the chip via ADP
:param adp_port: Path to ADP serial port
:type adp_port: str
:param skip_reload: Flag specifying whether to skip any loading of software (i.e. in repetitive testing where VDEV power is not interrupted between tests)
:type skip_reload: bool, optional
... | Connects to the chip via ADP
:param adp_port: Path to ADP serial port
:type adp_port: str
:param skip_reload: Flag specifying whether to skip any loading of software (i.e. in repetitive testing where VDEV power is not interrupted between tests)
:type skip_reload: bool, optional
... | def connect(self,
adp_port,
skip_reload=False,
load_trims=False,
safe_tcro=False
):
"""Connects to the chip via ADP
:param adp_port: Path to ADP serial port
:type adp_port: str
:param skip_reload: Flag specifying whether to... | [
"def",
"connect",
"(",
"self",
",",
"adp_port",
",",
"skip_reload",
"=",
"False",
",",
"load_trims",
"=",
"False",
",",
"safe_tcro",
"=",
"False",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Connecting to Device\"",
")",
"# ADP Connection",
"self"... | [
295,
4
] | [
345,
57
] | python | en | ['en', 'en', 'en'] | True |
TestChip.initialise_software | (self, skip_reload=False) | Sets up the chip software - loads software (if necessary) and loads the testcases (tcs - workloads built into binary) database (if necessary)
:param skip_reload: Flag specifying whether to skip the reloading of
software (i.e. for repetitive testing without VDEV
... | Sets up the chip software - loads software (if necessary) and loads the testcases (tcs - workloads built into binary) database (if necessary)
:param skip_reload: Flag specifying whether to skip the reloading of
software (i.e. for repetitive testing without VDEV
... | def initialise_software(self, skip_reload=False):
"""Sets up the chip software - loads software (if necessary) and loads the testcases (tcs - workloads built into binary) database (if necessary)
:param skip_reload: Flag specifying whether to skip the reloading of
so... | [
"def",
"initialise_software",
"(",
"self",
",",
"skip_reload",
"=",
"False",
")",
":",
"# Set up DEVRAM and testcases",
"if",
"self",
".",
"_sw_directory",
":",
"# Get bin path (if there) and load it if (load_devram=True) ",
"# gets testcase list and optionally loads devram",
"se... | [
347,
4
] | [
375,
72
] | python | en | ['en', 'en', 'en'] | True |
TestChip.exit | (self) | Cleanly closes the chip (closing ports and read threads)
| Cleanly closes the chip (closing ports and read threads)
| def exit(self):
""" Cleanly closes the chip (closing ports and read threads)
"""
if self._adp_sock:
self._adp_sock.close()
if self.mbed:
self.mbed.close()
self._logger.info("Chip Exited") | [
"def",
"exit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_adp_sock",
":",
"self",
".",
"_adp_sock",
".",
"close",
"(",
")",
"if",
"self",
".",
"mbed",
":",
"self",
".",
"mbed",
".",
"close",
"(",
")",
"self",
".",
"_logger",
".",
"info",
"(",
... | [
381,
4
] | [
388,
40
] | python | en | ['en', 'en', 'en'] | True |
TestChip.setup_software | (self, sw_dir, load_devram=False, skip_reload=False) | Analyses the provided software directory and works out what files to load (if necessary) and sets up testcase (tc) database (if necessary)
:param sw_dir: Path to software directory to load (or already loaded
in chip)
:type sw_dir: str
:param load_devram: Whether to load... | Analyses the provided software directory and works out what files to load (if necessary) and sets up testcase (tc) database (if necessary) | def setup_software(self, sw_dir, load_devram=False, skip_reload=False):
"""Analyses the provided software directory and works out what files to load (if necessary) and sets up testcase (tc) database (if necessary)
:param sw_dir: Path to software directory to load (or already loaded
... | [
"def",
"setup_software",
"(",
"self",
",",
"sw_dir",
",",
"load_devram",
"=",
"False",
",",
"skip_reload",
"=",
"False",
")",
":",
"# find testcase list and bin/hex32",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Looking in {} for .bin/.hex32 and testcase_list.csv\"",
... | [
390,
4
] | [
434,
21
] | python | en | ['en', 'en', 'en'] | True |
TestChip.remap_to_rom | (self) | Remaps the memory map so that instructions are executed from ROM
| Remaps the memory map so that instructions are executed from ROM
| def remap_to_rom(self):
"""Remaps the memory map so that instructions are executed from ROM
"""
self._logger.info("Remapping to ROM")
self._pcsm_regs.write('code_ctrl', 0, bit_group='memory_remap') | [
"def",
"remap_to_rom",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Remapping to ROM\"",
")",
"self",
".",
"_pcsm_regs",
".",
"write",
"(",
"'code_ctrl'",
",",
"0",
",",
"bit_group",
"=",
"'memory_remap'",
")"
] | [
436,
4
] | [
440,
71
] | python | en | ['en', 'en', 'en'] | True |
TestChip.remap_to_devram | (self) | Remaps the memory map so that instructions are executed from DEVRAM
| Remaps the memory map so that instructions are executed from DEVRAM
| def remap_to_devram(self):
"""Remaps the memory map so that instructions are executed from DEVRAM
"""
self._logger.info("Remapping to DEVRAM")
self._pcsm_regs.write('code_ctrl', 1, bit_group='memory_remap') | [
"def",
"remap_to_devram",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Remapping to DEVRAM\"",
")",
"self",
".",
"_pcsm_regs",
".",
"write",
"(",
"'code_ctrl'",
",",
"1",
",",
"bit_group",
"=",
"'memory_remap'",
")"
] | [
442,
4
] | [
446,
71
] | python | en | ['en', 'en', 'en'] | True |
TestChip.remap_to_coderam | (self) | Remaps the memory map so that instructions are executed from CODERAM
| Remaps the memory map so that instructions are executed from CODERAM
| def remap_to_coderam(self):
"""Remaps the memory map so that instructions are executed from CODERAM
"""
self._logger.info("Remapping to CODERAM")
self._pcsm_regs.write('code_ctrl',1,bit_group='memory_remap') | [
"def",
"remap_to_coderam",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Remapping to CODERAM\"",
")",
"self",
".",
"_pcsm_regs",
".",
"write",
"(",
"'code_ctrl'",
",",
"1",
",",
"bit_group",
"=",
"'memory_remap'",
")"
] | [
448,
4
] | [
452,
69
] | python | en | ['en', 'en', 'en'] | True |
TestChip.read_memory_region | (self, name, words=None, save_to_file=None) | Read content a memory map region
:param name: The name of the memory region (as per the memory map
in the register models)
:type name: str
:param words: The number of words to read. Reads entire region if
"None"
:type words: int, optional
... | Read content a memory map region | def read_memory_region(self, name, words=None, save_to_file=None):
""" Read content a memory map region
:param name: The name of the memory region (as per the memory map
in the register models)
:type name: str
:param words: The number of words to read. Reads entire ... | [
"def",
"read_memory_region",
"(",
"self",
",",
"name",
",",
"words",
"=",
"None",
",",
"save_to_file",
"=",
"None",
")",
":",
"base",
"=",
"self",
".",
"_mem_map",
".",
"get_base",
"(",
"name",
")",
"size",
"=",
"self",
".",
"_mem_map",
".",
"get_size"... | [
454,
4
] | [
483,
24
] | python | en | ['en', 'en', 'en'] | True |
TestChip.flash | (self, code_path, mem_map_location='DEVRAM', check_lines=10) | Writes binary/hex file to a memory region
:param code_path: Path to binary or hex file to load
:type code_path: str
:param mem_map_location: The memory region to write the memory
to (as per the name in the memory map table
... | Writes binary/hex file to a memory region
:param code_path: Path to binary or hex file to load
:type code_path: str
:param mem_map_location: The memory region to write the memory
to (as per the name in the memory map table
... | def flash(self, code_path, mem_map_location='DEVRAM', check_lines=10):
"""Writes binary/hex file to a memory region
:param code_path: Path to binary or hex file to load
:type code_path: str
:param mem_map_location: The memory region to write the memory
... | [
"def",
"flash",
"(",
"self",
",",
"code_path",
",",
"mem_map_location",
"=",
"'DEVRAM'",
",",
"check_lines",
"=",
"10",
")",
":",
"# Hold reset",
"self",
".",
"reset_hold",
"(",
")",
"# Write devram code",
"temp_base",
"=",
"self",
".",
"_mem_map",
".",
"get... | [
485,
4
] | [
553,
62
] | python | en | ['en', 'en', 'en'] | True |
TestChip.reset | (self,delays=None) | Resets the chip
| Resets the chip
| def reset(self,delays=None):
"""Resets the chip
"""
self.reset_hold()
time.sleep(0.1)
self.reset_release() | [
"def",
"reset",
"(",
"self",
",",
"delays",
"=",
"None",
")",
":",
"self",
".",
"reset_hold",
"(",
")",
"time",
".",
"sleep",
"(",
"0.1",
")",
"self",
".",
"reset_release",
"(",
")"
] | [
555,
4
] | [
560,
28
] | python | en | ['en', 'en', 'en'] | True |
TestChip.reset_hold | (self) | Holds the reset
| Holds the reset
| def reset_hold(self):
"""Holds the reset
"""
pass | [
"def",
"reset_hold",
"(",
"self",
")",
":",
"pass"
] | [
563,
4
] | [
566,
12
] | python | en | ['en', 'en', 'en'] | True |
TestChip.reset_release | (self) | Releases the reset
| Releases the reset
| def reset_release(self):
"""Releases the reset
"""
pass | [
"def",
"reset_release",
"(",
"self",
")",
":",
"pass"
] | [
569,
4
] | [
572,
12
] | python | en | ['en', 'en', 'en'] | True |
TestChip.setup_chip | (params, logger, chip=None, skip_reload=False) | A non-member utility function for setting up the chip with command-line options
:param params: Parameters, including forwarded command line options
:type params: dict
:param logger: The logger to use for logging messages to console and file
:type logger: logging.Logger object, optional... | A non-member utility function for setting up the chip with command-line options | def setup_chip(params, logger, chip=None, skip_reload=False):
""" A non-member utility function for setting up the chip with command-line options
:param params: Parameters, including forwarded command line options
:type params: dict
:param logger: The logger to use for logging messages ... | [
"def",
"setup_chip",
"(",
"params",
",",
"logger",
",",
"chip",
"=",
"None",
",",
"skip_reload",
"=",
"False",
")",
":",
"pass"
] | [
576,
4
] | [
592,
12
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.perf_labels | (self) | Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
| Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
| def perf_labels(self):
"""Returns the perf labels list (e.g. min, high, max etc.)
:return: A list of the perf lables strings
:rtype: list
"""
return self._perf_labels | [
"def",
"perf_labels",
"(",
"self",
")",
":",
"return",
"self",
".",
"_perf_labels"
] | [
613,
4
] | [
619,
32
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.ordered_perfs | (self) | Returns a list of perfs (HW IDs) in order (lowest TCRO frequency to highests)
:return: List of integers of the perf (DVFS) HW ID
:rtype: list
| Returns a list of perfs (HW IDs) in order (lowest TCRO frequency to highests) | def ordered_perfs(self):
"""Returns a list of perfs (HW IDs) in order (lowest TCRO frequency to highests)
:return: List of integers of the perf (DVFS) HW ID
:rtype: list
"""
return [ 28,24,29,20,30,25,31,16,26,21,27,22,17,23,18,19 ] | [
"def",
"ordered_perfs",
"(",
"self",
")",
":",
"return",
"[",
"28",
",",
"24",
",",
"29",
",",
"20",
",",
"30",
",",
"25",
",",
"31",
",",
"16",
",",
"26",
",",
"21",
",",
"27",
",",
"22",
",",
"17",
",",
"23",
",",
"18",
",",
"19",
"]"
] | [
622,
4
] | [
628,
66
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.vbat_max | (self) | Maximum safe VBAT voltage value without causing chip damage (used to set instrument safety limits)
:return: Voltage level
:rtype: float
| Maximum safe VBAT voltage value without causing chip damage (used to set instrument safety limits)
:return: Voltage level
:rtype: float
| def vbat_max(self):
"""Maximum safe VBAT voltage value without causing chip damage (used to set instrument safety limits)
:return: Voltage level
:rtype: float
"""
return 1.6 | [
"def",
"vbat_max",
"(",
"self",
")",
":",
"return",
"1.6"
] | [
631,
4
] | [
637,
18
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.chip_id | (self) | Returns the Chip ID
:return: Chip ID
:rtype: int
| Returns the Chip ID
:return: Chip ID
:rtype: int
| def chip_id(self):
"""Returns the Chip ID
:return: Chip ID
:rtype: int
"""
return self._chip_id | [
"def",
"chip_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_chip_id"
] | [
640,
4
] | [
646,
28
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.perf_to_freq_estimate | (self, perf) | Returns an estimation of the TCRO frequency for the specified perf level using previously characterised example values
:param perf: The perf level to get a TCRO estimation for. Can be a perf label (str) or a HW ID (int)
:type perf: int or str
:return: perf
:rtype: float
| Returns an estimation of the TCRO frequency for the specified perf level using previously characterised example values | def perf_to_freq_estimate(self, perf):
"""Returns an estimation of the TCRO frequency for the specified perf level using previously characterised example values
:param perf: The perf level to get a TCRO estimation for. Can be a perf label (str) or a HW ID (int)
:type perf: int or str
:r... | [
"def",
"perf_to_freq_estimate",
"(",
"self",
",",
"perf",
")",
":",
"if",
"isinstance",
"(",
"perf",
",",
"(",
"str",
")",
")",
":",
"perf",
"=",
"self",
".",
"_perf_label_lookup",
"[",
"perf",
"]",
"return",
"self",
".",
"_pcsm_regs",
".",
"get_value_ta... | [
648,
4
] | [
658,
72
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.set_perf | (self, perf) | Sets the current perf (DVFS level) of the chip
:param perf: The perf level to change to as a HW ID (int) or perf
label (str)
:type perf: int or str
| Sets the current perf (DVFS level) of the chip | def set_perf(self, perf):
"""Sets the current perf (DVFS level) of the chip
:param perf: The perf level to change to as a HW ID (int) or perf
label (str)
:type perf: int or str
"""
self._logger.info("Setting perf to: {}".format(perf))
if isinstance(... | [
"def",
"set_perf",
"(",
"self",
",",
"perf",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Setting perf to: {}\"",
".",
"format",
"(",
"perf",
")",
")",
"if",
"isinstance",
"(",
"perf",
",",
"(",
"int",
")",
")",
":",
"self",
".",
"_pcsm_reg... | [
660,
4
] | [
679,
58
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.get_perf | (self) | Gets the current perf (DVFS level) of the chip (read from STATUS7)
:return: The current perf (HW ID)
:rtype: int
| Gets the current perf (DVFS level) of the chip (read from STATUS7) | def get_perf(self):
"""Gets the current perf (DVFS level) of the chip (read from STATUS7)
:return: The current perf (HW ID)
:rtype: int
"""
return self._status_regs.read('STATUS_7',bit_group="perf") | [
"def",
"get_perf",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status_regs",
".",
"read",
"(",
"'STATUS_7'",
",",
"bit_group",
"=",
"\"perf\"",
")"
] | [
681,
4
] | [
687,
66
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.set_dvfs | (self, level) | Sets the current perf (DVFS level) using the perf ID (0-15)
:param level: Perf level (0-15)
:type level: int
| Sets the current perf (DVFS level) using the perf ID (0-15)
:param level: Perf level (0-15)
:type level: int
| def set_dvfs(self, level):
"""Sets the current perf (DVFS level) using the perf ID (0-15)
:param level: Perf level (0-15)
:type level: int
"""
if level < 0 or level > 15:
raise ValueError("DVFS Leve must be 0-15")
perf = self.ordered_perfs[level]
... | [
"def",
"set_dvfs",
"(",
"self",
",",
"level",
")",
":",
"if",
"level",
"<",
"0",
"or",
"level",
">",
"15",
":",
"raise",
"ValueError",
"(",
"\"DVFS Leve must be 0-15\"",
")",
"perf",
"=",
"self",
".",
"ordered_perfs",
"[",
"level",
"]",
"self",
".",
"_... | [
689,
4
] | [
703,
33
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.get_dvfs | (self) | Reads the current perf level (0-15) using STATUS7
:return: The current perf level (0-15)
:rtype: int
| Reads the current perf level (0-15) using STATUS7
:return: The current perf level (0-15)
:rtype: int
| def get_dvfs(self):
"""Reads the current perf level (0-15) using STATUS7
:return: The current perf level (0-15)
:rtype: int
"""
return self.ordered_perfs.index(
self._status_regs.read('STATUS_7',bit_group="perf")) | [
"def",
"get_dvfs",
"(",
"self",
")",
":",
"return",
"self",
".",
"ordered_perfs",
".",
"index",
"(",
"self",
".",
"_status_regs",
".",
"read",
"(",
"'STATUS_7'",
",",
"bit_group",
"=",
"\"perf\"",
")",
")"
] | [
705,
4
] | [
712,
68
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.get_rtc | (self, unit=None) | Reads the current RTC counter value
:param unit: The unit of the return value. Options: "cycles"
(raw RTC clock cycles), "us" (microseconds), "ms"
(milliseconds), "s" (seconds). Default is RTC cycles
:type unit: str, optional
:return: The RTC t... | Reads the current RTC counter value
:param unit: The unit of the return value. Options: "cycles"
(raw RTC clock cycles), "us" (microseconds), "ms"
(milliseconds), "s" (seconds). Default is RTC cycles
:type unit: str, optional
:return: The RTC t... | def get_rtc(self, unit=None):
"""Reads the current RTC counter value
:param unit: The unit of the return value. Options: "cycles"
(raw RTC clock cycles), "us" (microseconds), "ms"
(milliseconds), "s" (seconds). Default is RTC cycles
:type unit:... | [
"def",
"get_rtc",
"(",
"self",
",",
"unit",
"=",
"None",
")",
":",
"lsbs",
"=",
"self",
".",
"_status_regs",
".",
"read",
"(",
"'STATUS_2'",
")",
"msbs",
"=",
"self",
".",
"_status_regs",
".",
"read",
"(",
"'STATUS_4'",
",",
"bit_group",
"=",
"\"rtc_ms... | [
714,
4
] | [
738,
35
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.get_cfsr | (self) | Returns the Configurable Fault Status Register (CFSR) value
:rtype: int
| Returns the Configurable Fault Status Register (CFSR) value
:rtype: int
| def get_cfsr(self):
"""Returns the Configurable Fault Status Register (CFSR) value
:rtype: int
"""
res = self._adp_sock.memory_read(0xE000ED28)
return res | [
"def",
"get_cfsr",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_adp_sock",
".",
"memory_read",
"(",
"0xE000ED28",
")",
"return",
"res"
] | [
740,
4
] | [
746,
18
] | python | en | ['en', 'no', 'en'] | True |
M0N0S2.power_off_roms | () | Powers off the ROM banks (which switch on automatically as required)
| Powers off the ROM banks (which switch on automatically as required)
| def power_off_roms():
"""Powers off the ROM banks (which switch on automatically as required)
"""
self._ctrl_regs.write("CTRL_2", 0) | [
"def",
"power_off_roms",
"(",
")",
":",
"self",
".",
"_ctrl_regs",
".",
"write",
"(",
"\"CTRL_2\"",
",",
"0",
")"
] | [
748,
4
] | [
751,
42
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.get_results | (self) | Returns an ordered dict of key current system variables for logging to a results file
:rtype: collections.OrderedDict
| Returns an ordered dict of key current system variables for logging to a results file
:rtype: collections.OrderedDict
| def get_results(self):
"""Returns an ordered dict of key current system variables for logging to a results file
:rtype: collections.OrderedDict
"""
d = collections.OrderedDict()
d['chip_model'] = 'M0N0S2'
d['chip_id'] = self._chip_id
d['adp_port'] = self.... | [
"def",
"get_results",
"(",
"self",
")",
":",
"d",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"d",
"[",
"'chip_model'",
"]",
"=",
"'M0N0S2'",
"d",
"[",
"'chip_id'",
"]",
"=",
"self",
".",
"_chip_id",
"d",
"[",
"'adp_port'",
"]",
"=",
"self",
".... | [
753,
4
] | [
797,
16
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.__str__ | (self) | Returns string representation of TestChip object including key status information
| Returns string representation of TestChip object including key status information
| def __str__(self):
"""Returns string representation of TestChip object including key status information
"""
res = "M0N0S2 Testchip (chip: {})".format(
"NA" if not self._chip_id else "{:03d}".format(self._chip_id))
res += "\nADP Connected: {}\nMBED Connected: {}".format(
... | [
"def",
"__str__",
"(",
"self",
")",
":",
"res",
"=",
"\"M0N0S2 Testchip (chip: {})\"",
".",
"format",
"(",
"\"NA\"",
"if",
"not",
"self",
".",
"_chip_id",
"else",
"\"{:03d}\"",
".",
"format",
"(",
"self",
".",
"_chip_id",
")",
")",
"res",
"+=",
"\"\\nADP C... | [
800,
4
] | [
841,
18
] | python | en | ['en', 'da', 'en'] | True |
M0N0S2.get_sanity | (self) | Utility method for printing all of the status and control registers to check that registers can be read and to check system status
| Utility method for printing all of the status and control registers to check that registers can be read and to check system status
| def get_sanity(self):
"""Utility method for printing all of the status and control registers to check that registers can be read and to check system status
"""
self._logger.info("Reading ctrl_regs for sanity...")
res = "CTRL_REG:\n0x0: 0x{:08X}\n0x1: 0x{:08X}\n0x2: 0x{:08X}\n".format(
... | [
"def",
"get_sanity",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Reading ctrl_regs for sanity...\"",
")",
"res",
"=",
"\"CTRL_REG:\\n0x0: 0x{:08X}\\n0x1: 0x{:08X}\\n0x2: 0x{:08X}\\n\"",
".",
"format",
"(",
"self",
".",
"_ctrl_regs",
".",
"read"... | [
843,
4
] | [
865,
18
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2._initialise | (self) | TestChip initialisation before ADP connection. Includes setting up the registers models and setting their read and write drivers to the dummy drivers for basic code testing even without a real chip and ADP connection.
| TestChip initialisation before ADP connection. Includes setting up the registers models and setting their read and write drivers to the dummy drivers for basic code testing even without a real chip and ADP connection.
| def _initialise(self):
"""TestChip initialisation before ADP connection. Includes setting up the registers models and setting their read and write drivers to the dummy drivers for basic code testing even without a real chip and ADP connection.
"""
self._logger.info("Reading ctrl_regs for sanity... | [
"def",
"_initialise",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Reading ctrl_regs for sanity...\"",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Initialising M0N0S2\"",
")",
"mem_map_path",
"=",
"os",
".",
"path",
".",
"join",
... | [
867,
4
] | [
906,
73
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.set_adp_tx_callbacks | (self, callbacks) | Set callbacks functions for ADP transaction protocol.
:param callbacks: dictionary where the keys are the transaction name
and the values are the callback functions to call
when a transaction of that name is received.
:type callbacks: dict
... | Set callbacks functions for ADP transaction protocol.
:param callbacks: dictionary where the keys are the transaction name
and the values are the callback functions to call
when a transaction of that name is received.
:type callbacks: dict
... | def set_adp_tx_callbacks(self, callbacks):
"""Set callbacks functions for ADP transaction protocol.
:param callbacks: dictionary where the keys are the transaction name
and the values are the callback functions to call
when a transaction of ... | [
"def",
"set_adp_tx_callbacks",
"(",
"self",
",",
"callbacks",
")",
":",
"self",
".",
"_adp_sock",
".",
"set_adp_tx_callbacks",
"(",
"callbacks",
")"
] | [
908,
4
] | [
916,
54
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.reset_hold | (self) | Holds the chip in reset
| Holds the chip in reset
| def reset_hold(self):
"""Holds the chip in reset
"""
self._ctrl_regs.write_set('CTRL_0',0x1)
self._logger.info("Reset held") | [
"def",
"reset_hold",
"(",
"self",
")",
":",
"self",
".",
"_ctrl_regs",
".",
"write_set",
"(",
"'CTRL_0'",
",",
"0x1",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Reset held\"",
")"
] | [
918,
4
] | [
922,
39
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.reset_release | (self) | Releases the chip reset reset
| Releases the chip reset reset
| def reset_release(self):
"""Releases the chip reset reset
"""
self._ctrl_regs.write_clear('CTRL_0',0x1)
self._logger.info("Reset released") | [
"def",
"reset_release",
"(",
"self",
")",
":",
"self",
".",
"_ctrl_regs",
".",
"write_clear",
"(",
"'CTRL_0'",
",",
"0x1",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Reset released\"",
")"
] | [
924,
4
] | [
928,
43
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2._spi_write_through_adp | (self,data) | Makes M0N0 SPI write data via ADP (manipulating the M0N0 SPI registers)
:param data: data to send via SPI
:type data: int
| Makes M0N0 SPI write data via ADP (manipulating the M0N0 SPI registers)
:param data: data to send via SPI
:type data: int
| def _spi_write_through_adp(self,data):
"""Makes M0N0 SPI write data via ADP (manipulating the M0N0 SPI registers)
:param data: data to send via SPI
:type data: int
"""
self._spi_regs.write("data_write", data,read_device=True)
self._spi_regs.write("command", 0x1, ... | [
"def",
"_spi_write_through_adp",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_spi_regs",
".",
"write",
"(",
"\"data_write\"",
",",
"data",
",",
"read_device",
"=",
"True",
")",
"self",
".",
"_spi_regs",
".",
"write",
"(",
"\"command\"",
",",
"0x1",
... | [
930,
4
] | [
942,
20
] | python | en | ['en', 'da', 'en'] | True |
M0N0S2._adp_to_pcsm_write | (self, address, value) | Writes to the M0N0 PCSM register via on-chip SPI
:param address: PCSM register address to write to
:type address: int
:param data: The (24-bit) data to write to the PCSM register
:type address: int
| Writes to the M0N0 PCSM register via on-chip SPI
:param address: PCSM register address to write to
:type address: int
:param data: The (24-bit) data to write to the PCSM register
:type address: int
| def _adp_to_pcsm_write(self, address, value):
"""Writes to the M0N0 PCSM register via on-chip SPI
:param address: PCSM register address to write to
:type address: int
:param data: The (24-bit) data to write to the PCSM register
:type address: int
"""
self... | [
"def",
"_adp_to_pcsm_write",
"(",
"self",
",",
"address",
",",
"value",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"ADP to PCSM via SPI. A: 0x{:X}, D: 0x{:X}\"",
".",
"format",
"(",
"address",
",",
"value",
")",
")",
"# Create 3 data byte packets: ",
"... | [
944,
4
] | [
978,
56
] | python | en | ['en', 'no', 'en'] | True |
M0N0S2.measure_rtc | (self, time_period_s=5) | Measures the RTC frequency and error from target 33 kHz frequency
:param time_period_s: The time interval over which to estimate the
RTC frequency. The larger the time period, the
smaller the errors due to ADP communication time
... | Measures the RTC frequency and error from target 33 kHz frequency | def measure_rtc(self, time_period_s=5):
"""Measures the RTC frequency and error from target 33 kHz frequency
:param time_period_s: The time interval over which to estimate the
RTC frequency. The larger the time period, the
smaller the errors ... | [
"def",
"measure_rtc",
"(",
"self",
",",
"time_period_s",
"=",
"5",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Measuring RTC over {:0.1f} seconds...\"",
".",
"format",
"(",
"time_period_s",
")",
")",
"rtc_s_before",
"=",
"self",
".",
"get_rtc",
"(",... | [
980,
4
] | [
1007,
71
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.measure_timed_shutdown | (self, time_ms) | Puts the chip into timed shutdown (requires chip to be in 'wait for ADP' mode and CALL WFI testcase to be included in the embedded software) and measures the time.
:param time_ms: The time duration to go into timed shutdown for in milliseconds
:type time_ms: int
:return: Dictionary of results ... | Puts the chip into timed shutdown (requires chip to be in 'wait for ADP' mode and CALL WFI testcase to be included in the embedded software) and measures the time. | def measure_timed_shutdown(self, time_ms):
"""Puts the chip into timed shutdown (requires chip to be in 'wait for ADP' mode and CALL WFI testcase to be included in the embedded software) and measures the time.
:param time_ms: The time duration to go into timed shutdown for in milliseconds
:typ... | [
"def",
"measure_timed_shutdown",
"(",
"self",
",",
"time_ms",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Requires further testing\"",
")",
"# 1. derive rtc ticks",
"rtc_ticks",
"=",
"int",
"(",
"time_ms",
"*",
"self",
".",
"RTC_ONE_MS_TICKS",
")",
"self",
"."... | [
1009,
4
] | [
1054,
42
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.derive_rtc_trim | (self, time_period_s=5, recursion_depth=14) | Derives the RTC trim value for active mode. The result is printed to screen.
:param time_period_s: The time duration over which to measure the RTC
frequency. The longer the duration, the lower
the error due to ADP timing overheads.
:type ti... | Derives the RTC trim value for active mode. The result is printed to screen. | def derive_rtc_trim(self, time_period_s=5, recursion_depth=14):
""" Derives the RTC trim value for active mode. The result is printed to screen.
:param time_period_s: The time duration over which to measure the RTC
frequency. The longer the duration, the lower
... | [
"def",
"derive_rtc_trim",
"(",
"self",
",",
"time_period_s",
"=",
"5",
",",
"recursion_depth",
"=",
"14",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Enabling RTC Forward Body Bias (FBB)\"",
")",
"self",
".",
"_pcsm_regs",
".",
"write",
"(",
"'rtc_c... | [
1085,
4
] | [
1123,
28
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.derive_rtc_trim_timed_shutdown | (self, time_period_s=5, recursion_depth=14) | Derives the RTC trim value for timed-shutdown mode. The result is printed to screen.
:param time_period_s: The time duration over which to measure the RTC
frequency. The longer the duration, the lower the
error due to ADP timing overheads.
... | Derives the RTC trim value for timed-shutdown mode. The result is printed to screen. | def derive_rtc_trim_timed_shutdown(self, time_period_s=5, recursion_depth=14):
""" Derives the RTC trim value for timed-shutdown mode. The result is printed to screen.
:param time_period_s: The time duration over which to measure the RTC
frequency. The longer the duration... | [
"def",
"derive_rtc_trim_timed_shutdown",
"(",
"self",
",",
"time_period_s",
"=",
"5",
",",
"recursion_depth",
"=",
"14",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Requires testing\"",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Enabling RTC Forward Bod... | [
1125,
4
] | [
1164,
28
] | python | en | ['en', 'en', 'en'] | True |
M0N0S2.setup_chip | (params, logger, chip=None, skip_reload=False) | Creates a M0N0S2 chip instance using the parameters (includes command line options).
:param params: Dictionary of parameters, including forwarded command line options
:type params: dict
:param logger: The logger to use for logging messages to console and file
:type logger: logging.Logge... | Creates a M0N0S2 chip instance using the parameters (includes command line options). | def setup_chip(params, logger, chip=None, skip_reload=False):
"""Creates a M0N0S2 chip instance using the parameters (includes command line options).
:param params: Dictionary of parameters, including forwarded command line options
:type params: dict
:param logger: The logger to use for... | [
"def",
"setup_chip",
"(",
"params",
",",
"logger",
",",
"chip",
"=",
"None",
",",
"skip_reload",
"=",
"False",
")",
":",
"if",
"chip",
":",
"chip",
".",
"exit",
"(",
")",
"del",
"chip",
"if",
"'mbed_port'",
"not",
"in",
"params",
":",
"params",
"[",
... | [
1167,
4
] | [
1225,
19
] | python | en | ['en', 'en', 'en'] | True |
TestProperties.test_sum | (self) | Test whether matrix.sum(axis=1) preserves orientation.
Fails in NumPy <= 0.9.6.2127.
| Test whether matrix.sum(axis=1) preserves orientation.
Fails in NumPy <= 0.9.6.2127.
| def test_sum(self):
"""Test whether matrix.sum(axis=1) preserves orientation.
Fails in NumPy <= 0.9.6.2127.
"""
M = matrix([[1, 2, 0, 0],
[3, 4, 0, 0],
[1, 2, 1, 2],
[3, 4, 3, 4]])
sum0 = matrix([8, 12, 4, 6])
sum1 ... | [
"def",
"test_sum",
"(",
"self",
")",
":",
"M",
"=",
"matrix",
"(",
"[",
"[",
"1",
",",
"2",
",",
"0",
",",
"0",
"]",
",",
"[",
"3",
",",
"4",
",",
"0",
",",
"0",
"]",
",",
"[",
"1",
",",
"2",
",",
"1",
",",
"2",
"]",
",",
"[",
"3",
... | [
66,
4
] | [
83,
39
] | python | en | ['en', 'el-Latn', 'en'] | True |
TestAlgebra.test_pow | (self) | Test raising a matrix to an integer power works as expected. | Test raising a matrix to an integer power works as expected. | def test_pow(self):
"""Test raising a matrix to an integer power works as expected."""
m = matrix("1. 2.; 3. 4.")
m2 = m.copy()
m2 **= 2
mi = m.copy()
mi **= -1
m4 = m2.copy()
m4 **= 2
assert_array_almost_equal(m2, m**2)
assert_array_almost... | [
"def",
"test_pow",
"(",
"self",
")",
":",
"m",
"=",
"matrix",
"(",
"\"1. 2.; 3. 4.\"",
")",
"m2",
"=",
"m",
".",
"copy",
"(",
")",
"m2",
"**=",
"2",
"mi",
"=",
"m",
".",
"copy",
"(",
")",
"mi",
"**=",
"-",
"1",
"m4",
"=",
"m2",
".",
"copy",
... | [
243,
4
] | [
254,
59
] | python | en | ['en', 'en', 'en'] | True |
TestAlgebra.test_notimplemented | (self) | Check that 'not implemented' operations produce a failure. | Check that 'not implemented' operations produce a failure. | def test_notimplemented(self):
'''Check that 'not implemented' operations produce a failure.'''
A = matrix([[1., 2.],
[3., 4.]])
# __rpow__
with assert_raises(TypeError):
1.0**A
# __mul__ with something not a list, ndarray, tuple, or scalar
... | [
"def",
"test_notimplemented",
"(",
"self",
")",
":",
"A",
"=",
"matrix",
"(",
"[",
"[",
"1.",
",",
"2.",
"]",
",",
"[",
"3.",
",",
"4.",
"]",
"]",
")",
"# __rpow__",
"with",
"assert_raises",
"(",
"TypeError",
")",
":",
"1.0",
"**",
"A",
"# __mul__ ... | [
262,
4
] | [
273,
22
] | python | en | ['en', 'en', 'en'] | True |
Metric.add_state | (
self, name: str, default, dist_reduce_fx: Optional[Union[str, Callable]] = None, persistent: bool = False
) |
Adds metric state variable. Only used by subclasses.
Args:
name: The name of the state variable. The variable will then be accessible at ``self.name``.
default: Default value of the state; can either be a ``torch.Tensor`` or an empty list. The state will be
rese... |
Adds metric state variable. Only used by subclasses. | def add_state(
self, name: str, default, dist_reduce_fx: Optional[Union[str, Callable]] = None, persistent: bool = False
):
"""
Adds metric state variable. Only used by subclasses.
Args:
name: The name of the state variable. The variable will then be accessible at ``self... | [
"def",
"add_state",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
",",
"dist_reduce_fx",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Callable",
"]",
"]",
"=",
"None",
",",
"persistent",
":",
"bool",
"=",
"False",
")",
":",
"if",
"(",
"... | [
87,
4
] | [
142,
47
] | python | en | ['en', 'error', 'th'] | False |
Metric.forward | (self, *args, **kwargs) |
Automatically calls ``update()``. Returns the metric value over inputs if ``compute_on_step`` is True.
|
Automatically calls ``update()``. Returns the metric value over inputs if ``compute_on_step`` is True.
| def forward(self, *args, **kwargs):
"""
Automatically calls ``update()``. Returns the metric value over inputs if ``compute_on_step`` is True.
"""
# add current step
with torch.no_grad():
self.update(*args, **kwargs)
self._forward_cache = None
if self... | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# add current step",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"self",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_forward_... | [
145,
4
] | [
171,
38
] | python | en | ['en', 'error', 'th'] | False |
Metric.update | (self) |
Override this method to update the state variables of your metric class.
|
Override this method to update the state variables of your metric class.
| def update(self) -> None: # pylint: disable=E0202
"""
Override this method to update the state variables of your metric class.
"""
pass | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"# pylint: disable=E0202",
"pass"
] | [
235,
4
] | [
239,
12
] | python | en | ['en', 'error', 'th'] | False |
Metric.compute | (self) |
Override this method to compute the final metric value from state variables
synchronized across the distributed backend.
|
Override this method to compute the final metric value from state variables
synchronized across the distributed backend.
| def compute(self): # pylint: disable=E0202
"""
Override this method to compute the final metric value from state variables
synchronized across the distributed backend.
"""
pass | [
"def",
"compute",
"(",
"self",
")",
":",
"# pylint: disable=E0202",
"pass"
] | [
242,
4
] | [
247,
12
] | python | en | ['en', 'error', 'th'] | False |
Metric.reset | (self) |
This method automatically resets the metric state variables to their default value.
|
This method automatically resets the metric state variables to their default value.
| def reset(self):
"""
This method automatically resets the metric state variables to their default value.
"""
for attr, default in self._defaults.items():
current_val = getattr(self, attr)
if isinstance(default, torch.Tensor):
setattr(self, attr, de... | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"attr",
",",
"default",
"in",
"self",
".",
"_defaults",
".",
"items",
"(",
")",
":",
"current_val",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"if",
"isinstance",
"(",
"default",
",",
"torch",
".",
... | [
249,
4
] | [
258,
54
] | python | en | ['en', 'error', 'th'] | False |
Metric.clone | (self) | Make a copy of the metric | Make a copy of the metric | def clone(self):
""" Make a copy of the metric """
return deepcopy(self) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"deepcopy",
"(",
"self",
")"
] | [
260,
4
] | [
262,
29
] | python | en | ['en', 'en', 'en'] | True |
Metric._apply | (self, fn) | Overwrite _apply function such that we can also move metric states
to the correct device when `.to`, `.cuda`, etc methods are called
| Overwrite _apply function such that we can also move metric states
to the correct device when `.to`, `.cuda`, etc methods are called
| def _apply(self, fn):
"""Overwrite _apply function such that we can also move metric states
to the correct device when `.to`, `.cuda`, etc methods are called
"""
self = super()._apply(fn)
# Also apply fn to metric states
for key in self._defaults.keys():
curre... | [
"def",
"_apply",
"(",
"self",
",",
"fn",
")",
":",
"self",
"=",
"super",
"(",
")",
".",
"_apply",
"(",
"fn",
")",
"# Also apply fn to metric states",
"for",
"key",
"in",
"self",
".",
"_defaults",
".",
"keys",
"(",
")",
":",
"current_val",
"=",
"getattr... | [
274,
4
] | [
291,
19
] | python | en | ['en', 'en', 'en'] | True |
Metric.persistent | (self, mode: bool = False) | Method for post-init to change if metric states should be saved to
its state_dict
| Method for post-init to change if metric states should be saved to
its state_dict
| def persistent(self, mode: bool = False):
"""Method for post-init to change if metric states should be saved to
its state_dict
"""
for key in self._persistent.keys():
self._persistent[key] = mode | [
"def",
"persistent",
"(",
"self",
",",
"mode",
":",
"bool",
"=",
"False",
")",
":",
"for",
"key",
"in",
"self",
".",
"_persistent",
".",
"keys",
"(",
")",
":",
"self",
".",
"_persistent",
"[",
"key",
"]",
"=",
"mode"
] | [
293,
4
] | [
298,
40
] | python | en | ['en', 'en', 'en'] | True |
Metric._filter_kwargs | (self, **kwargs) | filter kwargs such that they match the update signature of the metric | filter kwargs such that they match the update signature of the metric | def _filter_kwargs(self, **kwargs):
""" filter kwargs such that they match the update signature of the metric """
# filter all parameters based on update signature except those of
# type VAR_POSITIONAL (*args) and VAR_KEYWORD (**kwargs)
_params = (inspect.Parameter.VAR_POSITIONAL, inspe... | [
"def",
"_filter_kwargs",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# filter all parameters based on update signature except those of",
"# type VAR_POSITIONAL (*args) and VAR_KEYWORD (**kwargs)",
"_params",
"=",
"(",
"inspect",
".",
"Parameter",
".",
"VAR_POSITIONAL",
"... | [
314,
4
] | [
329,
30
] | python | en | ['en', 'en', 'sw'] | True |
MetricCollection.forward | (self, *args, **kwargs) |
Iteratively call forward for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the individual metric.
|
Iteratively call forward for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the individual metric.
| def forward(self, *args, **kwargs) -> Dict[str, Any]: # pylint: disable=E0202
"""
Iteratively call forward for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the indiv... | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# pylint: disable=E0202",
"return",
"{",
"k",
":",
"m",
"(",
"*",
"args",
",",
"*",
"*",
"m",
".",
"_filter_kwargs",
"... | [
575,
4
] | [
581,
83
] | python | en | ['en', 'error', 'th'] | False |
MetricCollection.update | (self, *args, **kwargs) |
Iteratively call update for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the individual metric.
|
Iteratively call update for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the individual metric.
| def update(self, *args, **kwargs): # pylint: disable=E0202
"""
Iteratively call update for each metric. Positional arguments (args) will
be passed to every metric in the collection, while keyword arguments (kwargs)
will be filtered based on the signature of the individual metric.
... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=E0202",
"for",
"_",
",",
"m",
"in",
"self",
".",
"items",
"(",
")",
":",
"m_kwargs",
"=",
"m",
".",
"_filter_kwargs",
"(",
"*",
"*",
"kwargs",
")"... | [
583,
4
] | [
591,
39
] | python | en | ['en', 'error', 'th'] | False |
MetricCollection.reset | (self) | Iteratively call reset for each metric | Iteratively call reset for each metric | def reset(self):
""" Iteratively call reset for each metric """
for _, m in self.items():
m.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"_",
",",
"m",
"in",
"self",
".",
"items",
"(",
")",
":",
"m",
".",
"reset",
"(",
")"
] | [
596,
4
] | [
599,
21
] | python | en | ['en', 'en', 'en'] | True |
MetricCollection.clone | (self) | Make a copy of the metric collection | Make a copy of the metric collection | def clone(self):
""" Make a copy of the metric collection """
return deepcopy(self) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"deepcopy",
"(",
"self",
")"
] | [
601,
4
] | [
603,
29
] | python | en | ['en', 'en', 'en'] | True |
MetricCollection.persistent | (self, mode: bool = True) | Method for post-init to change if metric states should be saved to
its state_dict
| Method for post-init to change if metric states should be saved to
its state_dict
| def persistent(self, mode: bool = True):
"""Method for post-init to change if metric states should be saved to
its state_dict
"""
for _, m in self.items():
m.persistent(mode) | [
"def",
"persistent",
"(",
"self",
",",
"mode",
":",
"bool",
"=",
"True",
")",
":",
"for",
"_",
",",
"m",
"in",
"self",
".",
"items",
"(",
")",
":",
"m",
".",
"persistent",
"(",
"mode",
")"
] | [
605,
4
] | [
610,
30
] | python | en | ['en', 'en', 'en'] | True |
maximum_sctype | (t) |
Return the scalar type of highest precision of the same kind as the input.
Parameters
----------
t : dtype or dtype specifier
The input data type. This can be a `dtype` object or an object that
is convertible to a `dtype`.
Returns
-------
out : dtype
The highest pr... |
Return the scalar type of highest precision of the same kind as the input. | def maximum_sctype(t):
"""
Return the scalar type of highest precision of the same kind as the input.
Parameters
----------
t : dtype or dtype specifier
The input data type. This can be a `dtype` object or an object that
is convertible to a `dtype`.
Returns
-------
out ... | [
"def",
"maximum_sctype",
"(",
"t",
")",
":",
"g",
"=",
"obj2sctype",
"(",
"t",
")",
"if",
"g",
"is",
"None",
":",
"return",
"t",
"t",
"=",
"g",
"base",
"=",
"_kind_name",
"(",
"dtype",
"(",
"t",
")",
")",
"if",
"base",
"in",
"sctypes",
":",
"re... | [
143,
0
] | [
189,
16
] | python | en | ['en', 'error', 'th'] | False |
issctype | (rep) |
Determines whether the given object represents a scalar data-type.
Parameters
----------
rep : any
If `rep` is an instance of a scalar dtype, True is returned. If not,
False is returned.
Returns
-------
out : bool
Boolean result of check whether `rep` is a scalar d... |
Determines whether the given object represents a scalar data-type. | def issctype(rep):
"""
Determines whether the given object represents a scalar data-type.
Parameters
----------
rep : any
If `rep` is an instance of a scalar dtype, True is returned. If not,
False is returned.
Returns
-------
out : bool
Boolean result of check w... | [
"def",
"issctype",
"(",
"rep",
")",
":",
"if",
"not",
"isinstance",
"(",
"rep",
",",
"(",
"type",
",",
"dtype",
")",
")",
":",
"return",
"False",
"try",
":",
"res",
"=",
"obj2sctype",
"(",
"rep",
")",
"if",
"res",
"and",
"res",
"!=",
"object_",
"... | [
193,
0
] | [
235,
20
] | python | en | ['en', 'error', 'th'] | False |
obj2sctype | (rep, default=None) |
Return the scalar dtype or NumPy equivalent of Python type of an object.
Parameters
----------
rep : any
The object of which the type is returned.
default : any, optional
If given, this is returned for objects whose types can not be
determined. If not given, None is returne... |
Return the scalar dtype or NumPy equivalent of Python type of an object. | def obj2sctype(rep, default=None):
"""
Return the scalar dtype or NumPy equivalent of Python type of an object.
Parameters
----------
rep : any
The object of which the type is returned.
default : any, optional
If given, this is returned for objects whose types can not be
... | [
"def",
"obj2sctype",
"(",
"rep",
",",
"default",
"=",
"None",
")",
":",
"# prevent abstract classes being upcast",
"if",
"isinstance",
"(",
"rep",
",",
"type",
")",
"and",
"issubclass",
"(",
"rep",
",",
"generic",
")",
":",
"return",
"rep",
"# extract dtype fr... | [
239,
0
] | [
289,
23
] | python | en | ['en', 'error', 'th'] | False |
issubclass_ | (arg1, arg2) |
Determine if a class is a subclass of a second class.
`issubclass_` is equivalent to the Python built-in ``issubclass``,
except that it returns False instead of raising a TypeError if one
of the arguments is not a class.
Parameters
----------
arg1 : class
Input class. True is retu... |
Determine if a class is a subclass of a second class. | def issubclass_(arg1, arg2):
"""
Determine if a class is a subclass of a second class.
`issubclass_` is equivalent to the Python built-in ``issubclass``,
except that it returns False instead of raising a TypeError if one
of the arguments is not a class.
Parameters
----------
arg1 : cla... | [
"def",
"issubclass_",
"(",
"arg1",
",",
"arg2",
")",
":",
"try",
":",
"return",
"issubclass",
"(",
"arg1",
",",
"arg2",
")",
"except",
"TypeError",
":",
"return",
"False"
] | [
293,
0
] | [
329,
20
] | python | en | ['en', 'error', 'th'] | False |
issubsctype | (arg1, arg2) |
Determine if the first argument is a subclass of the second argument.
Parameters
----------
arg1, arg2 : dtype or dtype specifier
Data-types.
Returns
-------
out : bool
The result.
See Also
--------
issctype, issubdtype, obj2sctype
Examples
--------
... |
Determine if the first argument is a subclass of the second argument. | def issubsctype(arg1, arg2):
"""
Determine if the first argument is a subclass of the second argument.
Parameters
----------
arg1, arg2 : dtype or dtype specifier
Data-types.
Returns
-------
out : bool
The result.
See Also
--------
issctype, issubdtype, obj... | [
"def",
"issubsctype",
"(",
"arg1",
",",
"arg2",
")",
":",
"return",
"issubclass",
"(",
"obj2sctype",
"(",
"arg1",
")",
",",
"obj2sctype",
"(",
"arg2",
")",
")"
] | [
333,
0
] | [
361,
57
] | python | en | ['en', 'error', 'th'] | False |
issubdtype | (arg1, arg2) |
Returns True if first argument is a typecode lower/equal in type hierarchy.
Parameters
----------
arg1, arg2 : dtype_like
dtype or string representing a typecode.
Returns
-------
out : bool
See Also
--------
issubsctype, issubclass_
numpy.core.numerictypes : Overv... |
Returns True if first argument is a typecode lower/equal in type hierarchy. | def issubdtype(arg1, arg2):
"""
Returns True if first argument is a typecode lower/equal in type hierarchy.
Parameters
----------
arg1, arg2 : dtype_like
dtype or string representing a typecode.
Returns
-------
out : bool
See Also
--------
issubsctype, issubclass_
... | [
"def",
"issubdtype",
"(",
"arg1",
",",
"arg2",
")",
":",
"if",
"not",
"issubclass_",
"(",
"arg1",
",",
"generic",
")",
":",
"arg1",
"=",
"dtype",
"(",
"arg1",
")",
".",
"type",
"if",
"not",
"issubclass_",
"(",
"arg2",
",",
"generic",
")",
":",
"arg... | [
365,
0
] | [
424,
33
] | python | en | ['en', 'error', 'th'] | False |
sctype2char | (sctype) |
Return the string representation of a scalar dtype.
Parameters
----------
sctype : scalar dtype or object
If a scalar dtype, the corresponding string character is
returned. If an object, `sctype2char` tries to infer its scalar type
and then return the corresponding string chara... |
Return the string representation of a scalar dtype. | def sctype2char(sctype):
"""
Return the string representation of a scalar dtype.
Parameters
----------
sctype : scalar dtype or object
If a scalar dtype, the corresponding string character is
returned. If an object, `sctype2char` tries to infer its scalar type
and then retur... | [
"def",
"sctype2char",
"(",
"sctype",
")",
":",
"sctype",
"=",
"obj2sctype",
"(",
"sctype",
")",
"if",
"sctype",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"unrecognized type\"",
")",
"if",
"sctype",
"not",
"in",
"_concrete_types",
":",
"# for compatibili... | [
460,
0
] | [
508,
29
] | python | en | ['en', 'error', 'th'] | False |
find_common_type | (array_types, scalar_types) |
Determine common type following standard coercion rules.
Parameters
----------
array_types : sequence
A list of dtypes or dtype convertible objects representing arrays.
scalar_types : sequence
A list of dtypes or dtype convertible objects representing scalars.
Returns
----... |
Determine common type following standard coercion rules. | def find_common_type(array_types, scalar_types):
"""
Determine common type following standard coercion rules.
Parameters
----------
array_types : sequence
A list of dtypes or dtype convertible objects representing arrays.
scalar_types : sequence
A list of dtypes or dtype convert... | [
"def",
"find_common_type",
"(",
"array_types",
",",
"scalar_types",
")",
":",
"array_types",
"=",
"[",
"dtype",
"(",
"x",
")",
"for",
"x",
"in",
"array_types",
"]",
"scalar_types",
"=",
"[",
"dtype",
"(",
"x",
")",
"for",
"x",
"in",
"scalar_types",
"]",
... | [
602,
0
] | [
674,
19
] | python | en | ['en', 'error', 'th'] | False |
random_sentence | () | Creates random and return sentences. | Creates random and return sentences. | def random_sentence():
"""Creates random and return sentences."""
return ("{} {} {} {} {} {}"
.format(article[random_int()]
, noun[random_int()]
, verb[random_int()]
, preposition[random_int()]
, article[random_int()]
... | [
"def",
"random_sentence",
"(",
")",
":",
"return",
"(",
"\"{} {} {} {} {} {}\"",
".",
"format",
"(",
"article",
"[",
"random_int",
"(",
")",
"]",
",",
"noun",
"[",
"random_int",
"(",
")",
"]",
",",
"verb",
"[",
"random_int",
"(",
")",
"]",
",",
"prepos... | [
19,
0
] | [
27,
55
] | python | en | ['en', 'pt', 'en'] | True |
ValDataloaderVariations.dataloader | (self, *args, **kwargs) | placeholder | placeholder | def dataloader(self, *args, **kwargs):
"""placeholder""" | [
"def",
"dataloader",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
21,
4
] | [
22,
25
] | python | en | ['en', 'da', 'en'] | False |
User_Info.user | (self,ctx,name,**flags) | Sends different outputs depending on the flags passed. I don't know if this is the best way to do it. | Sends different outputs depending on the flags passed. I don't know if this is the best way to do it. | async def user(self,ctx,name,**flags):
if ctx.guild:
pass
else:
return
try:
username = jikanjson(f'https://api.jikan.moe/v3/user/{name}')
except:
await ctx.send('No such user found.')
return
msg = await ctx.send('Searching for your query, please wait. <a:bot_loading:... | [
"async",
"def",
"user",
"(",
"self",
",",
"ctx",
",",
"name",
",",
"*",
"*",
"flags",
")",
":",
"if",
"ctx",
".",
"guild",
":",
"pass",
"else",
":",
"return",
"try",
":",
"username",
"=",
"jikanjson",
"(",
"f'https://api.jikan.moe/v3/user/{name}'",
")",
... | [
89,
2
] | [
160,
33
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testNorm | (self) | Test norm function | Test norm function | def testNorm(self):
"Test norm function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
norm = Tensor.__dict__[self.typeStr + "Norm"]
tensor = [[[0, 1], [2, 3]],
[[3, 2], [1, 0]]]
if isinstance(self.result, int):
self.assertEqual(norm(tensor),... | [
"def",
"testNorm",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"norm",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Norm\... | [
29,
4
] | [
38,
64
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testNormBadList | (self) | Test norm function with bad list | Test norm function with bad list | def testNormBadList(self):
"Test norm function with bad list"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
norm = Tensor.__dict__[self.typeStr + "Norm"]
tensor = [[[0, "one"], [2, 3]],
[[3, "two"], [1, 0]]]
self.assertRaises(BadListError, norm, tensor) | [
"def",
"testNormBadList",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"norm",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"... | [
41,
4
] | [
47,
53
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testNormWrongDim | (self) | Test norm function with wrong dimensions | Test norm function with wrong dimensions | def testNormWrongDim(self):
"Test norm function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
norm = Tensor.__dict__[self.typeStr + "Norm"]
tensor = [[0, 1, 2, 3],
[3, 2, 1, 0]]
self.assertRaises(TypeError, norm, tensor) | [
"def",
"testNormWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"norm",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
50,
4
] | [
56,
50
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testNormWrongSize | (self) | Test norm function with wrong size | Test norm function with wrong size | def testNormWrongSize(self):
"Test norm function with wrong size"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
norm = Tensor.__dict__[self.typeStr + "Norm"]
tensor = [[[0, 1, 0], [2, 3, 2]],
[[3, 2, 3], [1, 0, 1]]]
self.assertRaises(TypeError, norm, ten... | [
"def",
"testNormWrongSize",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"norm",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
59,
4
] | [
65,
50
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testNormNonContainer | (self) | Test norm function with non-container | Test norm function with non-container | def testNormNonContainer(self):
"Test norm function with non-container"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
norm = Tensor.__dict__[self.typeStr + "Norm"]
self.assertRaises(TypeError, norm, None) | [
"def",
"testNormNonContainer",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"norm",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+"... | [
68,
4
] | [
72,
48
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMax | (self) | Test max function | Test max function | def testMax(self):
"Test max function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
max = Tensor.__dict__[self.typeStr + "Max"]
tensor = [[[1, 2], [3, 4]],
[[5, 6], [7, 8]]]
self.assertEqual(max(tensor), 8) | [
"def",
"testMax",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"max",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Max\"",... | [
75,
4
] | [
81,
40
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMaxBadList | (self) | Test max function with bad list | Test max function with bad list | def testMaxBadList(self):
"Test max function with bad list"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
max = Tensor.__dict__[self.typeStr + "Max"]
tensor = [[[1, "two"], [3, 4]],
[[5, "six"], [7, 8]]]
self.assertRaises(BadListError, max, tensor) | [
"def",
"testMaxBadList",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"max",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"... | [
84,
4
] | [
90,
52
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMaxNonContainer | (self) | Test max function with non-container | Test max function with non-container | def testMaxNonContainer(self):
"Test max function with non-container"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
max = Tensor.__dict__[self.typeStr + "Max"]
self.assertRaises(TypeError, max, None) | [
"def",
"testMaxNonContainer",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"max",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
93,
4
] | [
97,
47
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMaxWrongDim | (self) | Test max function with wrong dimensions | Test max function with wrong dimensions | def testMaxWrongDim(self):
"Test max function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
max = Tensor.__dict__[self.typeStr + "Max"]
self.assertRaises(TypeError, max, [0, -1, 2, -3]) | [
"def",
"testMaxWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"max",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\... | [
100,
4
] | [
104,
57
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMin | (self) | Test min function | Test min function | def testMin(self):
"Test min function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
min = Tensor.__dict__[self.typeStr + "Min"]
tensor = [[[9, 8], [7, 6]],
[[5, 4], [3, 2]]]
self.assertEqual(min(tensor), 2) | [
"def",
"testMin",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"min",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Min\"",... | [
107,
4
] | [
113,
40
] | python | en | ['de', 'en', 'en'] | True |
TensorTestCase.testMinBadList | (self) | Test min function with bad list | Test min function with bad list | def testMinBadList(self):
"Test min function with bad list"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
min = Tensor.__dict__[self.typeStr + "Min"]
tensor = [[["nine", 8], [7, 6]],
[["five", 4], [3, 2]]]
self.assertRaises(BadListError, min, tensor) | [
"def",
"testMinBadList",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"min",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"... | [
116,
4
] | [
122,
52
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMinNonContainer | (self) | Test min function with non-container | Test min function with non-container | def testMinNonContainer(self):
"Test min function with non-container"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
min = Tensor.__dict__[self.typeStr + "Min"]
self.assertRaises(TypeError, min, True) | [
"def",
"testMinNonContainer",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"min",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
125,
4
] | [
129,
47
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testMinWrongDim | (self) | Test min function with wrong dimensions | Test min function with wrong dimensions | def testMinWrongDim(self):
"Test min function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
min = Tensor.__dict__[self.typeStr + "Min"]
self.assertRaises(TypeError, min, [[1, 3], [5, 7]]) | [
"def",
"testMinWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"min",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\... | [
132,
4
] | [
136,
59
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testScale | (self) | Test scale function | Test scale function | def testScale(self):
"Test scale function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Tensor.__dict__[self.typeStr + "Scale"]
tensor = np.array([[[1, 0, 1], [0, 1, 0], [1, 0, 1]],
[[0, 1, 0], [1, 0, 1], [0, 1, 0]],
[[... | [
"def",
"testScale",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Sca... | [
139,
4
] | [
149,
86
] | python | en | ['it', 'en', 'en'] | True |
TensorTestCase.testScaleWrongType | (self) | Test scale function with wrong type | Test scale function with wrong type | def testScaleWrongType(self):
"Test scale function with wrong type"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Tensor.__dict__[self.typeStr + "Scale"]
tensor = np.array([[[1, 0, 1], [0, 1, 0], [1, 0, 1]],
[[0, 1, 0], [1, 0, 1], [0, 1, 0]],
... | [
"def",
"testScaleWrongType",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",... | [
152,
4
] | [
159,
51
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testScaleWrongDim | (self) | Test scale function with wrong dimensions | Test scale function with wrong dimensions | def testScaleWrongDim(self):
"Test scale function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Tensor.__dict__[self.typeStr + "Scale"]
tensor = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1],
[0, 1, 0], [1, 0, 1], [0, 1, 0]], s... | [
"def",
"testScaleWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
162,
4
] | [
168,
51
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testScaleWrongSize | (self) | Test scale function with wrong size | Test scale function with wrong size | def testScaleWrongSize(self):
"Test scale function with wrong size"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Tensor.__dict__[self.typeStr + "Scale"]
tensor = np.array([[[1, 0], [0, 1], [1, 0]],
[[0, 1], [1, 0], [0, 1]],
... | [
"def",
"testScaleWrongSize",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",... | [
171,
4
] | [
178,
51
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testScaleNonArray | (self) | Test scale function with non-array | Test scale function with non-array | def testScaleNonArray(self):
"Test scale function with non-array"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Tensor.__dict__[self.typeStr + "Scale"]
self.assertRaises(TypeError, scale, True) | [
"def",
"testScaleNonArray",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
181,
4
] | [
185,
49
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testFloor | (self) | Test floor function | Test floor function | def testFloor(self):
"Test floor function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Tensor.__dict__[self.typeStr + "Floor"]
tensor = np.array([[[1, 2], [3, 4]],
[[5, 6], [7, 8]]], self.typeCode)
floor(tensor, 4)
np.testing.as... | [
"def",
"testFloor",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Flo... | [
188,
4
] | [
196,
73
] | python | nl | ['nl', 'nl', 'en'] | True |
TensorTestCase.testFloorWrongType | (self) | Test floor function with wrong type | Test floor function with wrong type | def testFloorWrongType(self):
"Test floor function with wrong type"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Tensor.__dict__[self.typeStr + "Floor"]
tensor = np.array([[[1, 2], [3, 4]],
[[5, 6], [7, 8]]], 'c')
self.assertRaises(TypeE... | [
"def",
"testFloorWrongType",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",... | [
199,
4
] | [
205,
51
] | python | en | ['en', 'en', 'en'] | True |
TensorTestCase.testFloorWrongDim | (self) | Test floor function with wrong type | Test floor function with wrong type | def testFloorWrongDim(self):
"Test floor function with wrong type"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Tensor.__dict__[self.typeStr + "Floor"]
tensor = np.array([[1, 2], [3, 4], [5, 6], [7, 8]], self.typeCode)
self.assertRaises(TypeError, floor, tensor) | [
"def",
"testFloorWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Tensor",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
208,
4
] | [
213,
51
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.