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
KafkaBrokerIntegrationTest.test_kafka_producer_and_consumer
(self)
This test verifies that producer can send messages, and consumer can receive them.
This test verifies that producer can send messages, and consumer can receive them.
def test_kafka_producer_and_consumer(self): """ This test verifies that producer can send messages, and consumer can receive them. """ messages_to_send = 100 partition = TopicPartition('test_kafka_producer_and_consumer', 0) producer = KafkaProducer(bootstrap_servers=KafkaBroker...
[ "def", "test_kafka_producer_and_consumer", "(", "self", ")", ":", "messages_to_send", "=", "100", "partition", "=", "TopicPartition", "(", "'test_kafka_producer_and_consumer'", ",", "0", ")", "producer", "=", "KafkaProducer", "(", "bootstrap_servers", "=", "KafkaBrokerI...
[ 75, 4 ]
[ 108, 58 ]
python
en
['en', 'error', 'th']
False
KafkaBrokerIntegrationTest.test_consumer_with_consumer_groups
(self)
This test verifies that multiple consumers can form a Kafka consumer group.
This test verifies that multiple consumers can form a Kafka consumer group.
def test_consumer_with_consumer_groups(self): """ This test verifies that multiple consumers can form a Kafka consumer group. """ consumer_count = 10 consumers = [] for id in range(consumer_count): consumer = KafkaConsumer( bootstrap_servers=KafkaBrok...
[ "def", "test_consumer_with_consumer_groups", "(", "self", ")", ":", "consumer_count", "=", "10", "consumers", "=", "[", "]", "for", "id", "in", "range", "(", "consumer_count", ")", ":", "consumer", "=", "KafkaConsumer", "(", "bootstrap_servers", "=", "KafkaBroke...
[ 110, 4 ]
[ 142, 74 ]
python
en
['en', 'error', 'th']
False
KafkaBrokerIntegrationTest.worker
(consumer)
Worker thread for Kafka consumer. Multiple poll-s are done here, so that the group can safely form.
Worker thread for Kafka consumer. Multiple poll-s are done here, so that the group can safely form.
def worker(consumer): """ Worker thread for Kafka consumer. Multiple poll-s are done here, so that the group can safely form. """ poll_operations = 10 for i in range(poll_operations): consumer.poll(timeout_ms=1000)
[ "def", "worker", "(", "consumer", ")", ":", "poll_operations", "=", "10", "for", "i", "in", "range", "(", "poll_operations", ")", ":", "consumer", ".", "poll", "(", "timeout_ms", "=", "1000", ")" ]
[ 145, 4 ]
[ 153, 42 ]
python
en
['en', 'error', 'th']
False
KafkaBrokerIntegrationTest.test_admin_client
(self)
This test verifies that Kafka Admin Client can still be used to manage Kafka.
This test verifies that Kafka Admin Client can still be used to manage Kafka.
def test_admin_client(self): """ This test verifies that Kafka Admin Client can still be used to manage Kafka. """ admin_client = KafkaAdminClient( bootstrap_servers=KafkaBrokerIntegrationTest.kafka_address()) # Create a topic with 3 partitions. new_topic_spec = New...
[ "def", "test_admin_client", "(", "self", ")", ":", "admin_client", "=", "KafkaAdminClient", "(", "bootstrap_servers", "=", "KafkaBrokerIntegrationTest", ".", "kafka_address", "(", ")", ")", "# Create a topic with 3 partitions.", "new_topic_spec", "=", "NewTopic", "(", "...
[ 155, 4 ]
[ 195, 63 ]
python
en
['en', 'error', 'th']
False
MetricsHolder.get_envoy_stats
()
Grab request/response metrics from envoy's stats interface.
Grab request/response metrics from envoy's stats interface.
def get_envoy_stats(): """ Grab request/response metrics from envoy's stats interface. """ stats_url = KafkaBrokerIntegrationTest.envoy_stats_address() requests = {} responses = {} with urllib.request.urlopen(stats_url) as remote_metrics_url: payload = remote...
[ "def", "get_envoy_stats", "(", ")", ":", "stats_url", "=", "KafkaBrokerIntegrationTest", ".", "envoy_stats_address", "(", ")", "requests", "=", "{", "}", "responses", "=", "{", "}", "with", "urllib", ".", "request", ".", "urlopen", "(", "stats_url", ")", "as...
[ 227, 4 ]
[ 248, 36 ]
python
en
['en', 'error', 'th']
False
ServicesHolder.get_random_listener_port
()
Here we count on OS to give us some random socket. Obviously this method will need to be invoked in a try loop anyways, as in degenerate scenario someone else might have bound to it after we had closed the socket and before the service that's supposed to use it binds to it.
Here we count on OS to give us some random socket. Obviously this method will need to be invoked in a try loop anyways, as in degenerate scenario someone else might have bound to it after we had closed the socket and before the service that's supposed to use it binds to it.
def get_random_listener_port(): """ Here we count on OS to give us some random socket. Obviously this method will need to be invoked in a try loop anyways, as in degenerate scenario someone else might have bound to it after we had closed the socket and before the service that's supposed to use i...
[ "def", "get_random_listener_port", "(", ")", ":", "import", "socket", "with", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "as", "server_socket", ":", "server_socket", ".", "bind", "(", "(", "'0.0.0.0'", ","...
[ 264, 4 ]
[ 277, 30 ]
python
en
['en', 'error', 'th']
False
ServicesHolder.start
(self)
Starts all the services we need for integration tests.
Starts all the services we need for integration tests.
def start(self): """ Starts all the services we need for integration tests. """ # Find java installation that we are going to use to start Zookeeper & Kafka. java_directory = ServicesHolder.find_java() launcher_environment = os.environ.copy() # Make `java` visible to bu...
[ "def", "start", "(", "self", ")", ":", "# Find java installation that we are going to use to start Zookeeper & Kafka.", "java_directory", "=", "ServicesHolder", ".", "find_java", "(", ")", "launcher_environment", "=", "os", ".", "environ", ".", "copy", "(", ")", "# Make...
[ 279, 4 ]
[ 422, 44 ]
python
en
['en', 'error', 'th']
False
ServicesHolder.find_java
()
This method just locates the Java installation in current directory. We cannot hardcode the name, as the dirname changes as per: https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD#L491
This method just locates the Java installation in current directory. We cannot hardcode the name, as the dirname changes as per: https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD#L491
def find_java(): """ This method just locates the Java installation in current directory. We cannot hardcode the name, as the dirname changes as per: https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD#L491 """ external_dir = os.path.join('.', 'external') for directo...
[ "def", "find_java", "(", ")", ":", "external_dir", "=", "os", ".", "path", ".", "join", "(", "'.'", ",", "'external'", ")", "for", "directory", "in", "os", ".", "listdir", "(", "external_dir", ")", ":", "if", "'remotejdk11'", "in", "directory", ":", "r...
[ 425, 4 ]
[ 438, 66 ]
python
en
['en', 'error', 'th']
False
ServicesHolder.find_envoy
()
This method locates envoy binary. It's present at ./source/exe/envoy-static (at least for mac/bazel-asan/bazel-tsan), or at ./external/envoy/source/exe/envoy-static (for bazel-compile_time_options).
This method locates envoy binary. It's present at ./source/exe/envoy-static (at least for mac/bazel-asan/bazel-tsan), or at ./external/envoy/source/exe/envoy-static (for bazel-compile_time_options).
def find_envoy(): """ This method locates envoy binary. It's present at ./source/exe/envoy-static (at least for mac/bazel-asan/bazel-tsan), or at ./external/envoy/source/exe/envoy-static (for bazel-compile_time_options). """ candidate = os.path.join('.', 'source', 'exe', 'envoy-static')...
[ "def", "find_envoy", "(", ")", ":", "candidate", "=", "os", ".", "path", ".", "join", "(", "'.'", ",", "'source'", ",", "'exe'", ",", "'envoy-static'", ")", "if", "os", ".", "path", ".", "isfile", "(", "candidate", ")", ":", "return", "candidate", "c...
[ 441, 4 ]
[ 454, 47 ]
python
en
['en', 'error', 'th']
False
ProcessWorker.initialization_worker
(owner)
Worker thread. Responsible for detecting if service died during initialization steps and ensuring if enough time has passed since the startup message has been seen. When either of these happens, we just raise the initialization semaphore.
Worker thread. Responsible for detecting if service died during initialization steps and ensuring if enough time has passed since the startup message has been seen. When either of these happens, we just raise the initialization semaphore.
def initialization_worker(owner): """ Worker thread. Responsible for detecting if service died during initialization steps and ensuring if enough time has passed since the startup message has been seen. When either of these happens, we just raise the initialization semaphore. """ wh...
[ "def", "initialization_worker", "(", "owner", ")", ":", "while", "True", ":", "status", "=", "owner", ".", "process_handle", ".", "poll", "(", ")", "if", "status", ":", "# Service died.", "print", "(", "'%s did not initialize properly - finished with: %s'", "%", "...
[ 514, 4 ]
[ 546, 73 ]
python
en
['en', 'error', 'th']
False
ProcessWorker.pipe_handler
(owner, pipe, pipe_name)
Worker thread. If a service startup message is seen, then it just registers the timestamp of its appearance. Also prints every received message.
Worker thread. If a service startup message is seen, then it just registers the timestamp of its appearance. Also prints every received message.
def pipe_handler(owner, pipe, pipe_name): """ Worker thread. If a service startup message is seen, then it just registers the timestamp of its appearance. Also prints every received message. """ try: for raw_line in pipe: line = raw_line.decode().rstrip() ...
[ "def", "pipe_handler", "(", "owner", ",", "pipe", ",", "pipe_name", ")", ":", "try", ":", "for", "raw_line", "in", "pipe", ":", "line", "=", "raw_line", ".", "decode", "(", ")", ".", "rstrip", "(", ")", "print", "(", "'%s(%s):'", "%", "(", "owner", ...
[ 549, 4 ]
[ 567, 79 ]
python
en
['en', 'error', 'th']
False
ProcessWorker.await_startup
(self)
Awaits on initialization semaphore, and then verifies the initialization state. If everything is okay, we just continue (we can use the service), otherwise throw.
Awaits on initialization semaphore, and then verifies the initialization state. If everything is okay, we just continue (we can use the service), otherwise throw.
def await_startup(self): """ Awaits on initialization semaphore, and then verifies the initialization state. If everything is okay, we just continue (we can use the service), otherwise throw. """ print('Waiting for %s to start...' % (self.name)) self.initialization_semaphore.acquire...
[ "def", "await_startup", "(", "self", ")", ":", "print", "(", "'Waiting for %s to start...'", "%", "(", "self", ".", "name", ")", ")", "self", ".", "initialization_semaphore", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "initialization_ok", ":", ...
[ 569, 4 ]
[ 583, 51 ]
python
en
['en', 'error', 'th']
False
ProcessWorker.check_state
(self)
Verifies if the service is still running. Throws if it is not.
Verifies if the service is still running. Throws if it is not.
def check_state(self): """ Verifies if the service is still running. Throws if it is not. """ status = self.process_handle.poll() if status: raise Exception('%s died with: %s' % (self.name, str(status)))
[ "def", "check_state", "(", "self", ")", ":", "status", "=", "self", ".", "process_handle", ".", "poll", "(", ")", "if", "status", ":", "raise", "Exception", "(", "'%s died with: %s'", "%", "(", "self", ".", "name", ",", "str", "(", "status", ")", ")", ...
[ 585, 4 ]
[ 592, 74 ]
python
en
['en', 'error', 'th']
False
ProcessWorker.kill
(self)
Utility method to kill the main service thread and all related workers.
Utility method to kill the main service thread and all related workers.
def kill(self): """ Utility method to kill the main service thread and all related workers. """ print('Stopping service %s' % self.name) # Kill the real process. self.process_handle.kill() self.process_handle.wait() # The sub-workers are going to finish on thei...
[ "def", "kill", "(", "self", ")", ":", "print", "(", "'Stopping service %s'", "%", "self", ".", "name", ")", "# Kill the real process.", "self", ".", "process_handle", ".", "kill", "(", ")", "self", ".", "process_handle", ".", "wait", "(", ")", "# The sub-wor...
[ 594, 4 ]
[ 611, 56 ]
python
en
['en', 'error', 'th']
False
test_models
(tmpdir, data_class, model_class)
Test simple models
Test simple models
def test_models(tmpdir, data_class, model_class): """Test simple models""" dm = data_class() if data_class else data_class model = model_class() trainer = Trainer(default_root_dir=tmpdir, max_epochs=1) trainer.fit(model, datamodule=dm) trainer.test(model, datamodule=dm) model.to_torchscrip...
[ "def", "test_models", "(", "tmpdir", ",", "data_class", ",", "model_class", ")", ":", "dm", "=", "data_class", "(", ")", "if", "data_class", "else", "data_class", "model", "=", "model_class", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=",...
[ 34, 0 ]
[ 45, 84 ]
python
da
['da', 'da', 'en']
True
_cseries_to_zseries
(c)
Covert Chebyshev series to z-series. Covert a Chebyshev series to the equivalent z-series. The result is never an empty array. The dtype of the return is the same as that of the input. No checks are run on the arguments as this routine is for internal use. Parameters ---------- c : 1-D nda...
Covert Chebyshev series to z-series.
def _cseries_to_zseries(c): """Covert Chebyshev series to z-series. Covert a Chebyshev series to the equivalent z-series. The result is never an empty array. The dtype of the return is the same as that of the input. No checks are run on the arguments as this routine is for internal use. Parame...
[ "def", "_cseries_to_zseries", "(", "c", ")", ":", "n", "=", "c", ".", "size", "zs", "=", "np", ".", "zeros", "(", "2", "*", "n", "-", "1", ",", "dtype", "=", "c", ".", "dtype", ")", "zs", "[", "n", "-", "1", ":", "]", "=", "c", "/", "2", ...
[ 115, 0 ]
[ 137, 24 ]
python
en
['en', 'sk', 'it']
False
_zseries_to_cseries
(zs)
Covert z-series to a Chebyshev series. Covert a z series to the equivalent Chebyshev series. The result is never an empty array. The dtype of the return is the same as that of the input. No checks are run on the arguments as this routine is for internal use. Parameters ---------- zs : 1-D ...
Covert z-series to a Chebyshev series.
def _zseries_to_cseries(zs): """Covert z-series to a Chebyshev series. Covert a z series to the equivalent Chebyshev series. The result is never an empty array. The dtype of the return is the same as that of the input. No checks are run on the arguments as this routine is for internal use. Par...
[ "def", "_zseries_to_cseries", "(", "zs", ")", ":", "n", "=", "(", "zs", ".", "size", "+", "1", ")", "//", "2", "c", "=", "zs", "[", "n", "-", "1", ":", "]", ".", "copy", "(", ")", "c", "[", "1", ":", "n", "]", "*=", "2", "return", "c" ]
[ 140, 0 ]
[ 162, 12 ]
python
en
['en', 'sk', 'en']
True
_zseries_mul
(z1, z2)
Multiply two z-series. Multiply two z-series to produce a z-series. Parameters ---------- z1, z2 : 1-D ndarray The arrays must be 1-D but this is not checked. Returns ------- product : 1-D ndarray The product z-series. Notes ----- This is simply convolution. I...
Multiply two z-series.
def _zseries_mul(z1, z2): """Multiply two z-series. Multiply two z-series to produce a z-series. Parameters ---------- z1, z2 : 1-D ndarray The arrays must be 1-D but this is not checked. Returns ------- product : 1-D ndarray The product z-series. Notes ----- ...
[ "def", "_zseries_mul", "(", "z1", ",", "z2", ")", ":", "return", "np", ".", "convolve", "(", "z1", ",", "z2", ")" ]
[ 165, 0 ]
[ 189, 30 ]
python
en
['en', 'en', 'pl']
True
_zseries_div
(z1, z2)
Divide the first z-series by the second. Divide `z1` by `z2` and return the quotient and remainder as z-series. Warning: this implementation only applies when both z1 and z2 have the same symmetry, which is sufficient for present purposes. Parameters ---------- z1, z2 : 1-D ndarray The...
Divide the first z-series by the second.
def _zseries_div(z1, z2): """Divide the first z-series by the second. Divide `z1` by `z2` and return the quotient and remainder as z-series. Warning: this implementation only applies when both z1 and z2 have the same symmetry, which is sufficient for present purposes. Parameters ---------- ...
[ "def", "_zseries_div", "(", "z1", ",", "z2", ")", ":", "z1", "=", "z1", ".", "copy", "(", ")", "z2", "=", "z2", ".", "copy", "(", ")", "lc1", "=", "len", "(", "z1", ")", "lc2", "=", "len", "(", "z2", ")", "if", "lc2", "==", "1", ":", "z1"...
[ 192, 0 ]
[ 256, 23 ]
python
en
['en', 'en', 'en']
True
_zseries_der
(zs)
Differentiate a z-series. The derivative is with respect to x, not z. This is achieved using the chain rule and the value of dx/dz given in the module notes. Parameters ---------- zs : z-series The z-series to differentiate. Returns ------- derivative : z-series The de...
Differentiate a z-series.
def _zseries_der(zs): """Differentiate a z-series. The derivative is with respect to x, not z. This is achieved using the chain rule and the value of dx/dz given in the module notes. Parameters ---------- zs : z-series The z-series to differentiate. Returns ------- derivat...
[ "def", "_zseries_der", "(", "zs", ")", ":", "n", "=", "len", "(", "zs", ")", "//", "2", "ns", "=", "np", ".", "array", "(", "[", "-", "1", ",", "0", ",", "1", "]", ",", "dtype", "=", "zs", ".", "dtype", ")", "zs", "*=", "np", ".", "arange...
[ 259, 0 ]
[ 288, 12 ]
python
cs
['cs', 'en', 'pl']
False
_zseries_int
(zs)
Integrate a z-series. The integral is with respect to x, not z. This is achieved by a change of variable using dx/dz given in the module notes. Parameters ---------- zs : z-series The z-series to integrate Returns ------- integral : z-series The indefinite integral ...
Integrate a z-series.
def _zseries_int(zs): """Integrate a z-series. The integral is with respect to x, not z. This is achieved by a change of variable using dx/dz given in the module notes. Parameters ---------- zs : z-series The z-series to integrate Returns ------- integral : z-series ...
[ "def", "_zseries_int", "(", "zs", ")", ":", "n", "=", "1", "+", "len", "(", "zs", ")", "//", "2", "ns", "=", "np", ".", "array", "(", "[", "-", "1", ",", "0", ",", "1", "]", ",", "dtype", "=", "zs", ".", "dtype", ")", "zs", "=", "_zseries...
[ 291, 0 ]
[ 322, 13 ]
python
cs
['cs', 'en', 'pl']
False
poly2cheb
(pol)
Convert a polynomial to a Chebyshev series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Chebyshev series, ordered from lowest to highest degree. Param...
Convert a polynomial to a Chebyshev series.
def poly2cheb(pol): """ Convert a polynomial to a Chebyshev series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Chebyshev series, ordered from lowest to...
[ "def", "poly2cheb", "(", "pol", ")", ":", "[", "pol", "]", "=", "pu", ".", "as_series", "(", "[", "pol", "]", ")", "deg", "=", "len", "(", "pol", ")", "-", "1", "res", "=", "0", "for", "i", "in", "range", "(", "deg", ",", "-", "1", ",", "...
[ 329, 0 ]
[ 376, 14 ]
python
en
['en', 'error', 'th']
False
cheb2poly
(c)
Convert a Chebyshev series to a polynomial. Convert an array representing the coefficients of a Chebyshev series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest degree. Param...
Convert a Chebyshev series to a polynomial.
def cheb2poly(c): """ Convert a Chebyshev series to a polynomial. Convert an array representing the coefficients of a Chebyshev series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to h...
[ "def", "cheb2poly", "(", "c", ")", ":", "from", ".", "polynomial", "import", "polyadd", ",", "polysub", ",", "polymulx", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "n", "=", "len", "(", "c", ")", "if", "n", "<", "3", ...
[ 379, 0 ]
[ 437, 40 ]
python
en
['en', 'error', 'th']
False
chebline
(off, scl)
Chebyshev series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Chebyshev series for ``off + scl*x``. See Also -----...
Chebyshev series whose graph is a straight line.
def chebline(off, scl): """ Chebyshev series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Chebyshev series for ``off + s...
[ "def", "chebline", "(", "off", ",", "scl", ")", ":", "if", "scl", "!=", "0", ":", "return", "np", ".", "array", "(", "[", "off", ",", "scl", "]", ")", "else", ":", "return", "np", ".", "array", "(", "[", "off", "]", ")" ]
[ 458, 0 ]
[ 491, 30 ]
python
en
['en', 'error', 'th']
False
chebfromroots
(roots)
Generate a Chebyshev series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in Chebyshev form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must appear in `roots` n ti...
Generate a Chebyshev series with given roots.
def chebfromroots(roots): """ Generate a Chebyshev series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in Chebyshev form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, th...
[ "def", "chebfromroots", "(", "roots", ")", ":", "return", "pu", ".", "_fromroots", "(", "chebline", ",", "chebmul", ",", "roots", ")" ]
[ 494, 0 ]
[ 542, 50 ]
python
en
['en', 'error', 'th']
False
chebadd
(c1, c2)
Add one Chebyshev series to another. Returns the sum of two Chebyshev series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- c1, c2 : array_like ...
Add one Chebyshev series to another.
def chebadd(c1, c2): """ Add one Chebyshev series to another. Returns the sum of two Chebyshev series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- ...
[ "def", "chebadd", "(", "c1", ",", "c2", ")", ":", "return", "pu", ".", "_add", "(", "c1", ",", "c2", ")" ]
[ 545, 0 ]
[ 584, 26 ]
python
en
['en', 'error', 'th']
False
chebsub
(c1, c2)
Subtract one Chebyshev series from another. Returns the difference of two Chebyshev series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- c1, c2 : array_like 1-D ...
Subtract one Chebyshev series from another.
def chebsub(c1, c2): """ Subtract one Chebyshev series from another. Returns the difference of two Chebyshev series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- c1, ...
[ "def", "chebsub", "(", "c1", ",", "c2", ")", ":", "return", "pu", ".", "_sub", "(", "c1", ",", "c2", ")" ]
[ 587, 0 ]
[ 628, 26 ]
python
en
['en', 'error', 'th']
False
chebmulx
(c)
Multiply a Chebyshev series by x. Multiply the polynomial `c` by x, where x is the independent variable. Parameters ---------- c : array_like 1-D array of Chebyshev series coefficients ordered from low to high. Returns ------- out : ndarray Array representing ...
Multiply a Chebyshev series by x.
def chebmulx(c): """Multiply a Chebyshev series by x. Multiply the polynomial `c` by x, where x is the independent variable. Parameters ---------- c : array_like 1-D array of Chebyshev series coefficients ordered from low to high. Returns ------- out : ndarray ...
[ "def", "chebmulx", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "# The zero series needs special treatment", "if", "len", "(", "c", ")", "==", "1", "and", "c", "[", "0", "]", "==", ...
[ 631, 0 ]
[ 674, 14 ]
python
en
['en', 'en', 'en']
True
chebmul
(c1, c2)
Multiply one Chebyshev series by another. Returns the product of two Chebyshev series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- c1, c2 : array_like ...
Multiply one Chebyshev series by another.
def chebmul(c1, c2): """ Multiply one Chebyshev series by another. Returns the product of two Chebyshev series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- ...
[ "def", "chebmul", "(", "c1", ",", "c2", ")", ":", "# c1, c2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "pu", ".", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "z1", "=", "_cseries_to_zseries", "(", "c1", ")", "z2", "=", "_cseries_to_zs...
[ 677, 0 ]
[ 723, 26 ]
python
en
['en', 'error', 'th']
False
chebdiv
(c1, c2)
Divide one Chebyshev series by another. Returns the quotient-with-remainder of two Chebyshev series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameters ---------- c1, c2 ...
Divide one Chebyshev series by another.
def chebdiv(c1, c2): """ Divide one Chebyshev series by another. Returns the quotient-with-remainder of two Chebyshev series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``T_0 + 2*T_1 + 3*T_2``. Parameter...
[ "def", "chebdiv", "(", "c1", ",", "c2", ")", ":", "# c1, c2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "pu", ".", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "if", "c2", "[", "-", "1", "]", "==", "0", ":", "raise", "ZeroDivisionEr...
[ 726, 0 ]
[ 790, 23 ]
python
en
['en', 'error', 'th']
False
chebpow
(c, pow, maxpower=16)
Raise a Chebyshev series to a power. Returns the Chebyshev series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``T_0 + 2*T_1 + 3*T_2.`` Parameters ---------- c : array_like 1-D array of Chebyshev se...
Raise a Chebyshev series to a power.
def chebpow(c, pow, maxpower=16): """Raise a Chebyshev series to a power. Returns the Chebyshev series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``T_0 + 2*T_1 + 3*T_2.`` Parameters ---------- c : arr...
[ "def", "chebpow", "(", "c", ",", "pow", ",", "maxpower", "=", "16", ")", ":", "# note: this is more efficient than `pu._pow(chebmul, c1, c2)`, as it", "# avoids converting between z and c series repeatedly", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series...
[ 793, 0 ]
[ 848, 39 ]
python
en
['en', 'sk', 'en']
True
chebder
(c, m=1, scl=1, axis=0)
Differentiate a Chebyshev series. Returns the Chebyshev series coefficients `c` differentiated `m` times along `axis`. At each iteration the result is multiplied by `scl` (the scaling factor is for use in a linear change of variable). The argument `c` is an array of coefficients from low to high ...
Differentiate a Chebyshev series.
def chebder(c, m=1, scl=1, axis=0): """ Differentiate a Chebyshev series. Returns the Chebyshev series coefficients `c` differentiated `m` times along `axis`. At each iteration the result is multiplied by `scl` (the scaling factor is for use in a linear change of variable). The argument `c` is...
[ "def", "chebder", "(", "c", ",", "m", "=", "1", ",", "scl", "=", "1", ",", "axis", "=", "0", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", "1", ")", "if", "c", ".", "dtype", ".", "char", "in...
[ 851, 0 ]
[ 940, 12 ]
python
en
['en', 'error', 'th']
False
chebint
(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Integrate a Chebyshev series. Returns the Chebyshev series coefficients `c` integrated `m` times from `lbnd` along `axis`. At each iteration the resulting series is **multiplied** by `scl` and an integration constant, `k`, is added. The scaling factor is for use in a linear change of variable. ("...
Integrate a Chebyshev series.
def chebint(c, m=1, k=[], lbnd=0, scl=1, axis=0): """ Integrate a Chebyshev series. Returns the Chebyshev series coefficients `c` integrated `m` times from `lbnd` along `axis`. At each iteration the resulting series is **multiplied** by `scl` and an integration constant, `k`, is added. The scal...
[ "def", "chebint", "(", "c", ",", "m", "=", "1", ",", "k", "=", "[", "]", ",", "lbnd", "=", "0", ",", "scl", "=", "1", ",", "axis", "=", "0", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", "...
[ 943, 0 ]
[ 1068, 12 ]
python
en
['en', 'error', 'th']
False
chebval
(x, c, tensor=True)
Evaluate a Chebyshev series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * T_0(x) + c_1 * T_1(x) + ... + c_n * T_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case...
Evaluate a Chebyshev series at points x.
def chebval(x, c, tensor=True): """ Evaluate a Chebyshev series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * T_0(x) + c_1 * T_1(x) + ... + c_n * T_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it...
[ "def", "chebval", "(", "x", ",", "c", ",", "tensor", "=", "True", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", "1", ")", "if", "c", ".", "dtype", ".", "char", "in", "'?bBhHiIlLqQpP'", ":", "c", ...
[ 1071, 0 ]
[ 1155, 20 ]
python
en
['en', 'error', 'th']
False
chebval2d
(x, y, c)
Evaluate a 2-D Chebyshev series at points (x, y). This function returns the values: .. math:: p(x,y) = \\sum_{i,j} c_{i,j} * T_i(x) * T_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the s...
Evaluate a 2-D Chebyshev series at points (x, y).
def chebval2d(x, y, c): """ Evaluate a 2-D Chebyshev series at points (x, y). This function returns the values: .. math:: p(x,y) = \\sum_{i,j} c_{i,j} * T_i(x) * T_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scala...
[ "def", "chebval2d", "(", "x", ",", "y", ",", "c", ")", ":", "return", "pu", ".", "_valnd", "(", "chebval", ",", "c", ",", "x", ",", "y", ")" ]
[ 1158, 0 ]
[ 1204, 38 ]
python
en
['en', 'error', 'th']
False
chebgrid2d
(x, y, c)
Evaluate a 2-D Chebyshev series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \\sum_{i,j} c_{i,j} * T_i(a) * T_j(b), where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resulting points form a grid with ...
Evaluate a 2-D Chebyshev series on the Cartesian product of x and y.
def chebgrid2d(x, y, c): """ Evaluate a 2-D Chebyshev series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \\sum_{i,j} c_{i,j} * T_i(a) * T_j(b), where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resu...
[ "def", "chebgrid2d", "(", "x", ",", "y", ",", "c", ")", ":", "return", "pu", ".", "_gridnd", "(", "chebval", ",", "c", ",", "x", ",", "y", ")" ]
[ 1207, 0 ]
[ 1257, 39 ]
python
en
['en', 'error', 'th']
False
chebval3d
(x, y, z, c)
Evaluate a 3-D Chebyshev series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * T_i(x) * T_j(y) * T_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and ...
Evaluate a 3-D Chebyshev series at points (x, y, z).
def chebval3d(x, y, z, c): """ Evaluate a 3-D Chebyshev series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * T_i(x) * T_j(y) * T_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise ...
[ "def", "chebval3d", "(", "x", ",", "y", ",", "z", ",", "c", ")", ":", "return", "pu", ".", "_valnd", "(", "chebval", ",", "c", ",", "x", ",", "y", ",", "z", ")" ]
[ 1260, 0 ]
[ 1308, 41 ]
python
en
['en', 'error', 'th']
False
chebgrid3d
(x, y, z, c)
Evaluate a 3-D Chebyshev series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * T_i(a) * T_j(b) * T_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `x`, `b` from `y`, and `c` from `z`. Th...
Evaluate a 3-D Chebyshev series on the Cartesian product of x, y, and z.
def chebgrid3d(x, y, z, c): """ Evaluate a 3-D Chebyshev series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * T_i(a) * T_j(b) * T_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `x`,...
[ "def", "chebgrid3d", "(", "x", ",", "y", ",", "z", ",", "c", ")", ":", "return", "pu", ".", "_gridnd", "(", "chebval", ",", "c", ",", "x", ",", "y", ",", "z", ")" ]
[ 1311, 0 ]
[ 1364, 42 ]
python
en
['en', 'error', 'th']
False
chebvander
(x, deg)
Pseudo-Vandermonde matrix of given degree. Returns the pseudo-Vandermonde matrix of degree `deg` and sample points `x`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., i] = T_i(x), where `0 <= i <= deg`. The leading indices of `V` index the elements of `x` and the last index is the d...
Pseudo-Vandermonde matrix of given degree.
def chebvander(x, deg): """Pseudo-Vandermonde matrix of given degree. Returns the pseudo-Vandermonde matrix of degree `deg` and sample points `x`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., i] = T_i(x), where `0 <= i <= deg`. The leading indices of `V` index the elements of ...
[ "def", "chebvander", "(", "x", ",", "deg", ")", ":", "ideg", "=", "pu", ".", "_deprecate_as_int", "(", "deg", ",", "\"deg\"", ")", "if", "ideg", "<", "0", ":", "raise", "ValueError", "(", "\"deg must be non-negative\"", ")", "x", "=", "np", ".", "array...
[ 1367, 0 ]
[ 1417, 32 ]
python
ca
['nl', 'ca', 'en']
False
chebvander2d
(x, y, deg)
Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., (deg[1] + 1)*i + j] = T_i(x) * T_j(y), where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of ...
Pseudo-Vandermonde matrix of given degrees.
def chebvander2d(x, y, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., (deg[1] + 1)*i + j] = T_i(x) * T_j(y), where `0 <= i <= deg[0]` and `0 <= j <...
[ "def", "chebvander2d", "(", "x", ",", "y", ",", "deg", ")", ":", "return", "pu", ".", "_vander2d", "(", "chebvander", ",", "x", ",", "y", ",", "deg", ")" ]
[ 1420, 0 ]
[ 1470, 46 ]
python
ca
['nl', 'ca', 'en']
False
chebvander3d
(x, y, z, deg)
Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then The pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = T_i(x)*T_j(y)*T_k(z), wh...
Pseudo-Vandermonde matrix of given degrees.
def chebvander3d(x, y, z, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then The pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1...
[ "def", "chebvander3d", "(", "x", ",", "y", ",", "z", ",", "deg", ")", ":", "return", "pu", ".", "_vander3d", "(", "chebvander", ",", "x", ",", "y", ",", "z", ",", "deg", ")" ]
[ 1473, 0 ]
[ 1524, 49 ]
python
ca
['nl', 'ca', 'en']
False
chebfit
(x, y, deg, rcond=None, full=False, w=None)
Least squares fit of Chebyshev series to data. Return the coefficients of a Chebyshev series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple fits are done, one for each column...
Least squares fit of Chebyshev series to data.
def chebfit(x, y, deg, rcond=None, full=False, w=None): """ Least squares fit of Chebyshev series to data. Return the coefficients of a Chebyshev series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D...
[ "def", "chebfit", "(", "x", ",", "y", ",", "deg", ",", "rcond", "=", "None", ",", "full", "=", "False", ",", "w", "=", "None", ")", ":", "return", "pu", ".", "_fit", "(", "chebvander", ",", "x", ",", "y", ",", "deg", ",", "rcond", ",", "full"...
[ 1527, 0 ]
[ 1646, 57 ]
python
en
['en', 'error', 'th']
False
chebcompanion
(c)
Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is a Chebyshev basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if `nump...
Return the scaled companion matrix of c.
def chebcompanion(c): """Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is a Chebyshev basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guara...
[ "def", "chebcompanion", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "if", "len", "(", "c", ")", "<", "2", ":", "raise", "ValueError", "(", "'Series must have maximum degree of at least 1...
[ 1649, 0 ]
[ 1691, 14 ]
python
en
['en', 'sm', 'en']
True
chebroots
(c)
Compute the roots of a Chebyshev series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * T_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the roots of the series...
Compute the roots of a Chebyshev series.
def chebroots(c): """ Compute the roots of a Chebyshev series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * T_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array o...
[ "def", "chebroots", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "if", "len", "(", "c", ")", "<", "2", ":", "return", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "...
[ 1694, 0 ]
[ 1748, 12 ]
python
en
['en', 'error', 'th']
False
chebinterpolate
(func, deg, args=())
Interpolate a function at the Chebyshev points of the first kind. Returns the Chebyshev series that interpolates `func` at the Chebyshev points of the first kind in the interval [-1, 1]. The interpolating series tends to a minmax approximation to `func` with increasing `deg` if the function is continuo...
Interpolate a function at the Chebyshev points of the first kind.
def chebinterpolate(func, deg, args=()): """Interpolate a function at the Chebyshev points of the first kind. Returns the Chebyshev series that interpolates `func` at the Chebyshev points of the first kind in the interval [-1, 1]. The interpolating series tends to a minmax approximation to `func` with ...
[ "def", "chebinterpolate", "(", "func", ",", "deg", ",", "args", "=", "(", ")", ")", ":", "deg", "=", "np", ".", "asarray", "(", "deg", ")", "# check arguments.", "if", "deg", ".", "ndim", ">", "0", "or", "deg", ".", "dtype", ".", "kind", "not", "...
[ 1751, 0 ]
[ 1815, 12 ]
python
en
['en', 'en', 'en']
True
chebgauss
(deg)
Gauss-Chebyshev quadrature. Computes the sample points and weights for Gauss-Chebyshev quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-1, 1]` with the weight function :math:`f(x) = 1/\\sqrt{1 - x^2}`. ...
Gauss-Chebyshev quadrature.
def chebgauss(deg): """ Gauss-Chebyshev quadrature. Computes the sample points and weights for Gauss-Chebyshev quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-1, 1]` with the weight function :math:`f...
[ "def", "chebgauss", "(", "deg", ")", ":", "ideg", "=", "pu", ".", "_deprecate_as_int", "(", "deg", ",", "\"deg\"", ")", "if", "ideg", "<=", "0", ":", "raise", "ValueError", "(", "\"deg must be a positive integer\"", ")", "x", "=", "np", ".", "cos", "(", ...
[ 1818, 0 ]
[ 1860, 15 ]
python
en
['en', 'error', 'th']
False
chebweight
(x)
The weight function of the Chebyshev polynomials. The weight function is :math:`1/\\sqrt{1 - x^2}` and the interval of integration is :math:`[-1, 1]`. The Chebyshev polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters ---------- x : array_like ...
The weight function of the Chebyshev polynomials.
def chebweight(x): """ The weight function of the Chebyshev polynomials. The weight function is :math:`1/\\sqrt{1 - x^2}` and the interval of integration is :math:`[-1, 1]`. The Chebyshev polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters -----...
[ "def", "chebweight", "(", "x", ")", ":", "w", "=", "1.", "/", "(", "np", ".", "sqrt", "(", "1.", "+", "x", ")", "*", "np", ".", "sqrt", "(", "1.", "-", "x", ")", ")", "return", "w" ]
[ 1863, 0 ]
[ 1888, 12 ]
python
en
['en', 'error', 'th']
False
chebpts1
(npts)
Chebyshev points of the first kind. The Chebyshev points of the first kind are the points ``cos(x)``, where ``x = [pi*(k + .5)/npts for k in range(npts)]``. Parameters ---------- npts : int Number of sample points desired. Returns ------- pts : ndarray The Chebysh...
Chebyshev points of the first kind.
def chebpts1(npts): """ Chebyshev points of the first kind. The Chebyshev points of the first kind are the points ``cos(x)``, where ``x = [pi*(k + .5)/npts for k in range(npts)]``. Parameters ---------- npts : int Number of sample points desired. Returns ------- pts : ...
[ "def", "chebpts1", "(", "npts", ")", ":", "_npts", "=", "int", "(", "npts", ")", "if", "_npts", "!=", "npts", ":", "raise", "ValueError", "(", "\"npts must be integer\"", ")", "if", "_npts", "<", "1", ":", "raise", "ValueError", "(", "\"npts must be >= 1\"...
[ 1891, 0 ]
[ 1925, 20 ]
python
en
['en', 'error', 'th']
False
chebpts2
(npts)
Chebyshev points of the second kind. The Chebyshev points of the second kind are the points ``cos(x)``, where ``x = [pi*k/(npts - 1) for k in range(npts)]``. Parameters ---------- npts : int Number of sample points desired. Returns ------- pts : ndarray The Chebys...
Chebyshev points of the second kind.
def chebpts2(npts): """ Chebyshev points of the second kind. The Chebyshev points of the second kind are the points ``cos(x)``, where ``x = [pi*k/(npts - 1) for k in range(npts)]``. Parameters ---------- npts : int Number of sample points desired. Returns ------- pts :...
[ "def", "chebpts2", "(", "npts", ")", ":", "_npts", "=", "int", "(", "npts", ")", "if", "_npts", "!=", "npts", ":", "raise", "ValueError", "(", "\"npts must be integer\"", ")", "if", "_npts", "<", "2", ":", "raise", "ValueError", "(", "\"npts must be >= 2\"...
[ 1928, 0 ]
[ 1958, 20 ]
python
en
['en', 'error', 'th']
False
Chebyshev.interpolate
(cls, func, deg, domain=None, args=())
Interpolate a function at the Chebyshev points of the first kind. Returns the series that interpolates `func` at the Chebyshev points of the first kind scaled and shifted to the `domain`. The resulting series tends to a minmax approximation of `func` when the function is continuous in t...
Interpolate a function at the Chebyshev points of the first kind.
def interpolate(cls, func, deg, domain=None, args=()): """Interpolate a function at the Chebyshev points of the first kind. Returns the series that interpolates `func` at the Chebyshev points of the first kind scaled and shifted to the `domain`. The resulting series tends to a minmax ap...
[ "def", "interpolate", "(", "cls", ",", "func", ",", "deg", ",", "domain", "=", "None", ",", "args", "=", "(", ")", ")", ":", "if", "domain", "is", "None", ":", "domain", "=", "cls", ".", "domain", "xfunc", "=", "lambda", "x", ":", "func", "(", ...
[ 2002, 4 ]
[ 2041, 39 ]
python
en
['en', 'en', 'en']
True
Dimension.get_correlation_matrix
(X: pd.DataFrame)
Calculate the correlation matriz of data features. :param X: Dataset of features and samples :type X: pd.DataFrame :return: Dataframe with correlation between variables :rtype: pd.DataFrame
Calculate the correlation matriz of data features.
def get_correlation_matrix(X: pd.DataFrame): """Calculate the correlation matriz of data features. :param X: Dataset of features and samples :type X: pd.DataFrame :return: Dataframe with correlation between variables :rtype: pd.DataFrame """ samples, nvar = X.sha...
[ "def", "get_correlation_matrix", "(", "X", ":", "pd", ".", "DataFrame", ")", ":", "samples", ",", "nvar", "=", "X", ".", "shape", "corr_mat", "=", "np", ".", "corrcoef", "(", "np", ".", "c_", "[", "X", "]", ".", "T", ")", "etiquetas", "=", "X", "...
[ 13, 4 ]
[ 25, 73 ]
python
en
['en', 'en', 'en']
True
Dimension.get_PCA
(X: pd.DataFrame, **kwargs)
Apply PCA technique to reduce dimensionality. :param X: Dataset of features and samples :type X: pd.DataFrame :return: PCA results :rtype: obj
Apply PCA technique to reduce dimensionality.
def get_PCA(X: pd.DataFrame, **kwargs): """Apply PCA technique to reduce dimensionality. :param X: Dataset of features and samples :type X: pd.DataFrame :return: PCA results :rtype: obj """ samples, nvar = X.shape pca = PCA(**kwargs) pca.fit(X) ...
[ "def", "get_PCA", "(", "X", ":", "pd", ".", "DataFrame", ",", "*", "*", "kwargs", ")", ":", "samples", ",", "nvar", "=", "X", ".", "shape", "pca", "=", "PCA", "(", "*", "*", "kwargs", ")", "pca", ".", "fit", "(", "X", ")", "return", "pca" ]
[ 28, 4 ]
[ 39, 18 ]
python
en
['en', 'en', 'en']
True
test_wandb_logger_init
(wandb, recwarn)
Verify that basic functionality of wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here.
Verify that basic functionality of wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here.
def test_wandb_logger_init(wandb, recwarn): """Verify that basic functionality of wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here.""" # test wandb.init called when there is no W&B run wandb.run = None logger = WandbLogger() logger.log_metrics({'acc': 1.0})...
[ "def", "test_wandb_logger_init", "(", "wandb", ",", "recwarn", ")", ":", "# test wandb.init called when there is no W&B run", "wandb", ".", "run", "=", "None", "logger", "=", "WandbLogger", "(", ")", "logger", ".", "log_metrics", "(", "{", "'acc'", ":", "1.0", "...
[ 34, 0 ]
[ 102, 44 ]
python
en
['en', 'zu', 'en']
True
test_wandb_pickle
(wandb, tmpdir)
Verify that pickling trainer with wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here.
Verify that pickling trainer with wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here.
def test_wandb_pickle(wandb, tmpdir): """ Verify that pickling trainer with wandb logger works. Wandb doesn't work well with pytest so we have to mock it out here. """ class Experiment: """ """ id = 'the_id' step = 0 dir = 'wandb' def project_name(self): ...
[ "def", "test_wandb_pickle", "(", "wandb", ",", "tmpdir", ")", ":", "class", "Experiment", ":", "\"\"\" \"\"\"", "id", "=", "'the_id'", "step", "=", "0", "dir", "=", "'wandb'", "def", "project_name", "(", "self", ")", ":", "return", "'the_project_name'", "wan...
[ 106, 0 ]
[ 144, 32 ]
python
en
['en', 'error', 'th']
False
test_wandb_logger_dirs_creation
(wandb, tmpdir)
Test that the logger creates the folders and files in the right place.
Test that the logger creates the folders and files in the right place.
def test_wandb_logger_dirs_creation(wandb, tmpdir): """ Test that the logger creates the folders and files in the right place. """ logger = WandbLogger(save_dir=str(tmpdir), offline=True) assert logger.version is None assert logger.name is None # mock return values of experiment wandb.run = Non...
[ "def", "test_wandb_logger_dirs_creation", "(", "wandb", ",", "tmpdir", ")", ":", "logger", "=", "WandbLogger", "(", "save_dir", "=", "str", "(", "tmpdir", ")", ",", "offline", "=", "True", ")", "assert", "logger", ".", "version", "is", "None", "assert", "l...
[ 148, 0 ]
[ 177, 45 ]
python
en
['en', 'en', 'en']
True
test_wandb_sanitize_callable_params
(tmpdir)
Callback function are not serializiable. Therefore, we get them a chance to return something and if the returned type is not accepted, return None.
Callback function are not serializiable. Therefore, we get them a chance to return something and if the returned type is not accepted, return None.
def test_wandb_sanitize_callable_params(tmpdir): """ Callback function are not serializiable. Therefore, we get them a chance to return something and if the returned type is not accepted, return None. """ opt = "--max_epochs 1".split(" ") parser = ArgumentParser() parser = Trainer.add_argpar...
[ "def", "test_wandb_sanitize_callable_params", "(", "tmpdir", ")", ":", "opt", "=", "\"--max_epochs 1\"", ".", "split", "(", "\" \"", ")", "parser", "=", "ArgumentParser", "(", ")", "parser", "=", "Trainer", ".", "add_argparse_args", "(", "parent_parser", "=", "p...
[ 180, 0 ]
[ 208, 60 ]
python
en
['en', 'error', 'th']
False
test_wandb_logger_offline_log_model
(wandb, tmpdir)
Test that log_model=True raises an error in offline mode
Test that log_model=True raises an error in offline mode
def test_wandb_logger_offline_log_model(wandb, tmpdir): """ Test that log_model=True raises an error in offline mode """ with pytest.raises(MisconfigurationException, match='checkpoints cannot be uploaded in offline mode'): _ = WandbLogger(save_dir=str(tmpdir), offline=True, log_model=True)
[ "def", "test_wandb_logger_offline_log_model", "(", "wandb", ",", "tmpdir", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "'checkpoints cannot be uploaded in offline mode'", ")", ":", "_", "=", "WandbLogger", "(", "save...
[ 212, 0 ]
[ 215, 75 ]
python
en
['en', 'no', 'en']
True
is_unittest
(obj)
Is obj a subclass of unittest.TestCase? Lifted from older versions of py.test, as this seems to be removed.
Is obj a subclass of unittest.TestCase?
def is_unittest(obj): """Is obj a subclass of unittest.TestCase? Lifted from older versions of py.test, as this seems to be removed. """ unittest = sys.modules.get('unittest') if unittest is None: return # nobody can have derived unittest.TestCase try: return issubclass(obj, u...
[ "def", "is_unittest", "(", "obj", ")", ":", "unittest", "=", "sys", ".", "modules", ".", "get", "(", "'unittest'", ")", "if", "unittest", "is", "None", ":", "return", "# nobody can have derived unittest.TestCase", "try", ":", "return", "issubclass", "(", "obj"...
[ 8, 0 ]
[ 22, 20 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_automatic_versioning
(tmpdir)
Verify that automatic versioning works
Verify that automatic versioning works
def test_tensorboard_automatic_versioning(tmpdir): """Verify that automatic versioning works""" root_dir = tmpdir / "tb_versioning" root_dir.mkdir() (root_dir / "version_0").mkdir() (root_dir / "version_1").mkdir() logger = TensorBoardLogger(save_dir=tmpdir, name="tb_versioning") assert lo...
[ "def", "test_tensorboard_automatic_versioning", "(", "tmpdir", ")", ":", "root_dir", "=", "tmpdir", "/", "\"tb_versioning\"", "root_dir", ".", "mkdir", "(", ")", "(", "root_dir", "/", "\"version_0\"", ")", ".", "mkdir", "(", ")", "(", "root_dir", "/", "\"versi...
[ 73, 0 ]
[ 82, 30 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_manual_versioning
(tmpdir)
Verify that manual versioning works
Verify that manual versioning works
def test_tensorboard_manual_versioning(tmpdir): """Verify that manual versioning works""" root_dir = tmpdir / "tb_versioning" root_dir.mkdir() (root_dir / "version_0").mkdir() (root_dir / "version_1").mkdir() (root_dir / "version_2").mkdir() logger = TensorBoardLogger(save_dir=tmpdir, name...
[ "def", "test_tensorboard_manual_versioning", "(", "tmpdir", ")", ":", "root_dir", "=", "tmpdir", "/", "\"tb_versioning\"", "root_dir", ".", "mkdir", "(", ")", "(", "root_dir", "/", "\"version_0\"", ")", ".", "mkdir", "(", ")", "(", "root_dir", "/", "\"version_...
[ 85, 0 ]
[ 96, 30 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_named_version
(tmpdir)
Verify that manual versioning works for string versions, e.g. '2020-02-05-162402'
Verify that manual versioning works for string versions, e.g. '2020-02-05-162402'
def test_tensorboard_named_version(tmpdir): """Verify that manual versioning works for string versions, e.g. '2020-02-05-162402' """ name = "tb_versioning" (tmpdir / name).mkdir() expected_version = "2020-02-05-162402" logger = TensorBoardLogger(save_dir=tmpdir, name=name, version=expected_version...
[ "def", "test_tensorboard_named_version", "(", "tmpdir", ")", ":", "name", "=", "\"tb_versioning\"", "(", "tmpdir", "/", "name", ")", ".", "mkdir", "(", ")", "expected_version", "=", "\"2020-02-05-162402\"", "logger", "=", "TensorBoardLogger", "(", "save_dir", "=",...
[ 99, 0 ]
[ 111, 55 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_no_name
(tmpdir, name)
Verify that None or empty name works
Verify that None or empty name works
def test_tensorboard_no_name(tmpdir, name): """Verify that None or empty name works""" logger = TensorBoardLogger(save_dir=tmpdir, name=name) logger.log_hyperparams({"a": 1, "b": 2, 123: 3, 3.5: 4, 5j: 5}) # Force data to be written assert logger.root_dir == tmpdir assert os.listdir(tmpdir / "versi...
[ "def", "test_tensorboard_no_name", "(", "tmpdir", ",", "name", ")", ":", "logger", "=", "TensorBoardLogger", "(", "save_dir", "=", "tmpdir", ",", "name", "=", "name", ")", "logger", ".", "log_hyperparams", "(", "{", "\"a\"", ":", "1", ",", "\"b\"", ":", ...
[ 115, 0 ]
[ 120, 43 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_log_graph
(tmpdir, example_input_array)
test that log graph works with both model.example_input_array and if array is passed externaly
test that log graph works with both model.example_input_array and if array is passed externaly
def test_tensorboard_log_graph(tmpdir, example_input_array): """ test that log graph works with both model.example_input_array and if array is passed externaly """ model = BoringModel() if example_input_array is not None: model.example_input_array = None logger = TensorBoardLogger(t...
[ "def", "test_tensorboard_log_graph", "(", "tmpdir", ",", "example_input_array", ")", ":", "model", "=", "BoringModel", "(", ")", "if", "example_input_array", "is", "not", "None", ":", "model", ".", "example_input_array", "=", "None", "logger", "=", "TensorBoardLog...
[ 197, 0 ]
[ 206, 48 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_log_graph_warning_no_example_input_array
(tmpdir)
test that log graph throws warning if model.example_input_array is None
test that log graph throws warning if model.example_input_array is None
def test_tensorboard_log_graph_warning_no_example_input_array(tmpdir): """ test that log graph throws warning if model.example_input_array is None """ model = BoringModel() model.example_input_array = None logger = TensorBoardLogger(tmpdir, log_graph=True) with pytest.warns( UserWarning, ...
[ "def", "test_tensorboard_log_graph_warning_no_example_input_array", "(", "tmpdir", ")", ":", "model", "=", "BoringModel", "(", ")", "model", ".", "example_input_array", "=", "None", "logger", "=", "TensorBoardLogger", "(", "tmpdir", ",", "log_graph", "=", "True", ")...
[ 209, 0 ]
[ 219, 31 ]
python
en
['en', 'en', 'en']
True
test_tensorboard_with_accummulated_gradients
(mock_log_metrics, expected, tmpdir)
Tests to ensure that tensorboard log properly when accumulated_gradients > 1
Tests to ensure that tensorboard log properly when accumulated_gradients > 1
def test_tensorboard_with_accummulated_gradients(mock_log_metrics, expected, tmpdir): """ Tests to ensure that tensorboard log properly when accumulated_gradients > 1 """ class TestModel(BoringModel): def __init__(self): super().__init__() self._count = 0 se...
[ "def", "test_tensorboard_with_accummulated_gradients", "(", "mock_log_metrics", ",", "expected", ",", "tmpdir", ")", ":", "class", "TestModel", "(", "BoringModel", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")"...
[ 226, 0 ]
[ 283, 45 ]
python
en
['en', 'error', 'th']
False
test_tensorboard_finalize
(summary_writer, tmpdir)
Test that the SummaryWriter closes in finalize.
Test that the SummaryWriter closes in finalize.
def test_tensorboard_finalize(summary_writer, tmpdir): """ Test that the SummaryWriter closes in finalize. """ logger = TensorBoardLogger(save_dir=tmpdir) logger.finalize("any") summary_writer().flush.assert_called() summary_writer().close.assert_called()
[ "def", "test_tensorboard_finalize", "(", "summary_writer", ",", "tmpdir", ")", ":", "logger", "=", "TensorBoardLogger", "(", "save_dir", "=", "tmpdir", ")", "logger", ".", "finalize", "(", "\"any\"", ")", "summary_writer", "(", ")", ".", "flush", ".", "assert_...
[ 287, 0 ]
[ 292, 42 ]
python
en
['en', 'en', 'en']
True
rot6d_to_rotmat
(x)
Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 Input: (B,6) Batch of 6-D rotation representations Output: (B,3,3) Batch of corresponding rotation matrices
Convert 6D rotation representation to 3x3 rotation matrix.
def rot6d_to_rotmat(x): """Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 Input: (B,6) Batch of 6-D rotation representations Output: (B,3,3) Batch of corresponding rotatio...
[ "def", "rot6d_to_rotmat", "(", "x", ")", ":", "x", "=", "x", ".", "view", "(", "-", "1", ",", "3", ",", "2", ")", "a1", "=", "x", "[", ":", ",", ":", ",", "0", "]", "a2", "=", "x", "[", ":", ",", ":", ",", "1", "]", "b1", "=", "F", ...
[ 4, 0 ]
[ 20, 44 ]
python
ca
['en', 'ca', 'it']
False
batch_rodrigues
(theta)
Convert axis-angle representation to rotation matrix. Args: theta: size = [B, 3] Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]
Convert axis-angle representation to rotation matrix. Args: theta: size = [B, 3] Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]
def batch_rodrigues(theta): """Convert axis-angle representation to rotation matrix. Args: theta: size = [B, 3] Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3] """ l2norm = torch.norm(theta + 1e-8, p=2, dim=1) angle = torch.unsqueeze(l2nor...
[ "def", "batch_rodrigues", "(", "theta", ")", ":", "l2norm", "=", "torch", ".", "norm", "(", "theta", "+", "1e-8", ",", "p", "=", "2", ",", "dim", "=", "1", ")", "angle", "=", "torch", ".", "unsqueeze", "(", "l2norm", ",", "-", "1", ")", "normaliz...
[ 23, 0 ]
[ 38, 31 ]
python
en
['en', 'fil', 'en']
True
quat_to_rotmat
(quat)
Convert quaternion coefficients to rotation matrix. Args: quat: size = [B, 4] 4 <===>(w, x, y, z) Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]
Convert quaternion coefficients to rotation matrix. Args: quat: size = [B, 4] 4 <===>(w, x, y, z) Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]
def quat_to_rotmat(quat): """Convert quaternion coefficients to rotation matrix. Args: quat: size = [B, 4] 4 <===>(w, x, y, z) Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3] """ norm_quat = quat norm_quat = norm_quat / norm_quat.norm(p=2,...
[ "def", "quat_to_rotmat", "(", "quat", ")", ":", "norm_quat", "=", "quat", "norm_quat", "=", "norm_quat", "/", "norm_quat", ".", "norm", "(", "p", "=", "2", ",", "dim", "=", "1", ",", "keepdim", "=", "True", ")", "w", ",", "x", ",", "y", ",", "z",...
[ 41, 0 ]
[ 66, 17 ]
python
en
['en', 'fr', 'it']
False
stat_scores
( pred: torch.Tensor, target: torch.Tensor, class_index: int, argmax_dim: int = 1, )
Calculates the number of true positive, false positive, true negative and false negative for a specific class Args: pred: prediction tensor target: target tensor class_index: class to calculate over argmax_dim: if pred is a tensor of probabilities, this indicates the ...
Calculates the number of true positive, false positive, true negative and false negative for a specific class
def stat_scores( pred: torch.Tensor, target: torch.Tensor, class_index: int, argmax_dim: int = 1, ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: """ Calculates the number of true positive, false positive, true negative and false negative for a specific clas...
[ "def", "stat_scores", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "class_index", ":", "int", ",", "argmax_dim", ":", "int", "=", "1", ",", ")", "->", "Tuple", "[", "torch", ".", "Tensor", ",", "torch", ...
[ 25, 0 ]
[ 62, 30 ]
python
en
['en', 'error', 'th']
False
stat_scores_multiple_classes
( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, argmax_dim: int = 1, reduction: str = 'none', )
Calculates the number of true positive, false positive, true negative and false negative for each class .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.stat_scores`
Calculates the number of true positive, false positive, true negative and false negative for each class
def stat_scores_multiple_classes( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, argmax_dim: int = 1, reduction: str = 'none', ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: """ Calculates the number of true positive, false pos...
[ "def", "stat_scores_multiple_classes", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "Optional", "[", "int", "]", "=", "None", ",", "argmax_dim", ":", "int", "=", "1", ",", "reduction", ":"...
[ 66, 0 ]
[ 141, 75 ]
python
en
['en', 'error', 'th']
False
_confmat_normalize
(cm)
Normalization function for confusion matrix
Normalization function for confusion matrix
def _confmat_normalize(cm): """ Normalization function for confusion matrix """ cm = cm / cm.sum(-1, keepdim=True) nan_elements = cm[torch.isnan(cm)].nelement() if nan_elements != 0: cm[torch.isnan(cm)] = 0 rank_zero_warn(f'{nan_elements} nan values found in confusion matrix have been re...
[ "def", "_confmat_normalize", "(", "cm", ")", ":", "cm", "=", "cm", "/", "cm", ".", "sum", "(", "-", "1", ",", "keepdim", "=", "True", ")", "nan_elements", "=", "cm", "[", "torch", ".", "isnan", "(", "cm", ")", "]", ".", "nelement", "(", ")", "i...
[ 144, 0 ]
[ 151, 13 ]
python
en
['en', 'en', 'en']
True
precision_recall
( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', return_support: bool = False, return_state: bool = False )
Computes precision and recall for different thresholds .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.precision_recall`. Will be removed in v1.4.0. Args: pred: estimated probabilities target: ground-truth labels num_classes: number of c...
Computes precision and recall for different thresholds
def precision_recall( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', return_support: bool = False, return_state: bool = False ) -> Tuple[torch.Tensor, torch.Tensor]: """ Computes precision and recall for different thresholds ...
[ "def", "precision_recall", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "Optional", "[", "int", "]", "=", "None", ",", "class_reduction", ":", "str", "=", "'micro'", ",", "return_support", ...
[ 155, 0 ]
[ 210, 28 ]
python
en
['en', 'error', 'th']
False
precision
( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', )
Computes precision score. .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.recall`. Will be removed in v1.4.0. Args: pred: estimated probabilities target: ground-truth labels num_classes: number of classes class_reduction: method to re...
Computes precision score.
def precision( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', ) -> torch.Tensor: """ Computes precision score. .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.recall`. Will be removed in v1....
[ "def", "precision", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "Optional", "[", "int", "]", "=", "None", ",", "class_reduction", ":", "str", "=", "'micro'", ",", ")", "->", "torch", ...
[ 214, 0 ]
[ 254, 114 ]
python
en
['en', 'error', 'th']
False
recall
( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', )
Computes recall score. .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.recall`. Will be removed in v1.4.0. Args: pred: estimated probabilities target: ground-truth labels num_classes: number of classes class_reduction: method to reduc...
Computes recall score.
def recall( pred: torch.Tensor, target: torch.Tensor, num_classes: Optional[int] = None, class_reduction: str = 'micro', ) -> torch.Tensor: """ Computes recall score. .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.recall`. Will be removed in v1.4.0. ...
[ "def", "recall", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "Optional", "[", "int", "]", "=", "None", ",", "class_reduction", ":", "str", "=", "'micro'", ",", ")", "->", "torch", "."...
[ 258, 0 ]
[ 297, 114 ]
python
en
['en', 'error', 'th']
False
auc
( x: torch.Tensor, y: torch.Tensor, )
Computes Area Under the Curve (AUC) using the trapezoidal rule .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.auc.auc`. Will be removed in v1.4.0. Args: x: x-coordinates y: y-coordinates Return: Tensor containing AUC score (float) ...
Computes Area Under the Curve (AUC) using the trapezoidal rule
def auc( x: torch.Tensor, y: torch.Tensor, ) -> torch.Tensor: """ Computes Area Under the Curve (AUC) using the trapezoidal rule .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.auc.auc`. Will be removed in v1.4.0. Args: x: x-coordinates ...
[ "def", "auc", "(", "x", ":", "torch", ".", "Tensor", ",", "y", ":", "torch", ".", "Tensor", ",", ")", "->", "torch", ".", "Tensor", ":", "rank_zero_warn", "(", "\"This `auc` was deprecated in v1.2.0 in favor of\"", "\" `pytorch_lightning.metrics.functional.auc import ...
[ 301, 0 ]
[ 331, 22 ]
python
en
['en', 'error', 'th']
False
auroc
( pred: torch.Tensor, target: torch.Tensor, sample_weight: Optional[Sequence] = None, pos_label: int = 1., max_fpr: float = None, )
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.auroc.auroc`. Will be removed in v1.4.0. Args: pred: estimated probabilities target: ground-truth lab...
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores
def auroc( pred: torch.Tensor, target: torch.Tensor, sample_weight: Optional[Sequence] = None, pos_label: int = 1., max_fpr: float = None, ) -> torch.Tensor: """ Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores .. warning :: Deprecated in f...
[ "def", "auroc", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "sample_weight", ":", "Optional", "[", "Sequence", "]", "=", "None", ",", "pos_label", ":", "int", "=", "1.", ",", "max_fpr", ":", "float", "="...
[ 375, 0 ]
[ 414, 5 ]
python
en
['en', 'error', 'th']
False
multiclass_auroc
( pred: torch.Tensor, target: torch.Tensor, sample_weight: Optional[Sequence] = None, num_classes: Optional[int] = None, )
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from multiclass prediction scores .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.auroc.auroc`. Will be removed in v1.4.0. Args: pred: estimated probabilities, with shape [N, C...
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from multiclass prediction scores
def multiclass_auroc( pred: torch.Tensor, target: torch.Tensor, sample_weight: Optional[Sequence] = None, num_classes: Optional[int] = None, ) -> torch.Tensor: """ Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from multiclass prediction scores .. warning :: De...
[ "def", "multiclass_auroc", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "sample_weight", ":", "Optional", "[", "Sequence", "]", "=", "None", ",", "num_classes", ":", "Optional", "[", "int", "]", "=", "None", ...
[ 418, 0 ]
[ 477, 100 ]
python
en
['en', 'error', 'th']
False
dice_score
( pred: torch.Tensor, target: torch.Tensor, bg: bool = False, nan_score: float = 0.0, no_fg_score: float = 0.0, reduction: str = 'elementwise_mean', )
Compute dice score from prediction scores Args: pred: estimated probabilities target: ground-truth labels bg: whether to also compute dice for the background nan_score: score to return, if a NaN occurs during computation no_fg_score: score to return, if no foreground pi...
Compute dice score from prediction scores
def dice_score( pred: torch.Tensor, target: torch.Tensor, bg: bool = False, nan_score: float = 0.0, no_fg_score: float = 0.0, reduction: str = 'elementwise_mean', ) -> torch.Tensor: """ Compute dice score from prediction scores Args: pred: estimated probabilities tar...
[ "def", "dice_score", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "bg", ":", "bool", "=", "False", ",", "nan_score", ":", "float", "=", "0.0", ",", "no_fg_score", ":", "float", "=", "0.0", ",", "reduction...
[ 480, 0 ]
[ 533, 46 ]
python
en
['en', 'error', 'th']
False
iou
( pred: torch.Tensor, target: torch.Tensor, ignore_index: Optional[int] = None, absent_score: float = 0.0, num_classes: Optional[int] = None, reduction: str = 'elementwise_mean', )
Intersection over union, or Jaccard index calculation. .. warning :: Deprecated in favor of :func:`~pytorch_lightning.metrics.functional.iou.iou`. Will be removed in v1.4.0. Args: pred: Tensor containing integer predictions, with shape [N, d1, d2, ...] target: Tensor containing ...
Intersection over union, or Jaccard index calculation.
def iou( pred: torch.Tensor, target: torch.Tensor, ignore_index: Optional[int] = None, absent_score: float = 0.0, num_classes: Optional[int] = None, reduction: str = 'elementwise_mean', ) -> torch.Tensor: """ Intersection over union, or Jaccard index calculation. .. warning :: Depre...
[ "def", "iou", "(", "pred", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "ignore_index", ":", "Optional", "[", "int", "]", "=", "None", ",", "absent_score", ":", "float", "=", "0.0", ",", "num_classes", ":", "Optional", ...
[ 537, 0 ]
[ 596, 5 ]
python
en
['en', 'error', 'th']
False
change_new_to_init
(app, obj, bound_method)
When a __new__ method is defined for a class, Sphinx automatically uses the Signature of the __new__ method as signature for the class. Because __new__ normally does not specify the contructor arguments, the signature of __new__ has to be replaced with the signature of __init__
When a __new__ method is defined for a class, Sphinx automatically uses the Signature of the __new__ method as signature for the class. Because __new__ normally does not specify the contructor arguments, the signature of __new__ has to be replaced with the signature of __init__
def change_new_to_init(app, obj, bound_method): """ When a __new__ method is defined for a class, Sphinx automatically uses the Signature of the __new__ method as signature for the class. Because __new__ normally does not specify the contructor arguments, the signature of __new__ has to be replaced with...
[ "def", "change_new_to_init", "(", "app", ",", "obj", ",", "bound_method", ")", ":", "if", "obj", ".", "__qualname__", "==", "\"DataObject.__new__\"", ":", "import", "uspy", ".", "dataobject", "as", "dataobject", "init", "=", "dataobject", ".", "DataObject", "....
[ 64, 0 ]
[ 75, 45 ]
python
en
['en', 'error', 'th']
False
Tubes.createNewTubes
(self)
Método para criar 2 novos tubos (baixo e cima) numa mesma posição X
Método para criar 2 novos tubos (baixo e cima) numa mesma posição X
def createNewTubes(self): """ Método para criar 2 novos tubos (baixo e cima) numa mesma posição X """ # Cria uma lista para armazenar as partes do corpo do tubo de cima tube1 = [] # Define a posição X que o tubo de cima aparecerá inicialmente no background width...
[ "def", "createNewTubes", "(", "self", ")", ":", "# Cria uma lista para armazenar as partes do corpo do tubo de cima", "tube1", "=", "[", "]", "# Define a posição X que o tubo de cima aparecerá inicialmente no background", "width", "=", "self", ".", "__width", "+", "(", "self", ...
[ 81, 4 ]
[ 141, 27 ]
python
en
['en', 'error', 'th']
False
Tubes.deleteAll
(self)
Método para deletar todos os tubos gerados
Método para deletar todos os tubos gerados
def deleteAll(self): """ Método para deletar todos os tubos gerados """ # Deleta os tubos gerados no background for tubes in self.__tubes: for tube in tubes: for body in tube: self.__background.delete(body) self.__backgrou...
[ "def", "deleteAll", "(", "self", ")", ":", "# Deleta os tubos gerados no background", "for", "tubes", "in", "self", ".", "__tubes", ":", "for", "tube", "in", "tubes", ":", "for", "body", "in", "tube", ":", "self", ".", "__background", ".", "delete", "(", "...
[ 143, 4 ]
[ 155, 44 ]
python
en
['en', 'error', 'th']
False
Tubes.getPhotoImage
(image=None, image_path=None, width=None, height=None, closeAfter=False)
Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image (photoImage, new, original) @param image: Instância de PIL.Image.open @param image_path: Diretório da imagem @param width: Largura da imagem @param height: Altura da imag...
Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image (photoImage, new, original)
def getPhotoImage(image=None, image_path=None, width=None, height=None, closeAfter=False): """ Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image (photoImage, new, original) @param image: Instância de PIL.Image.open @param image_p...
[ "def", "getPhotoImage", "(", "image", "=", "None", ",", "image_path", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ",", "closeAfter", "=", "False", ")", ":", "if", "not", "image", ":", "if", "not", "image_path", ":", "return", ...
[ 158, 4 ]
[ 197, 42 ]
python
en
['en', 'error', 'th']
False
Tubes.move
(self)
Método para mover todos os tubos
Método para mover todos os tubos
def move(self): """ Método para mover todos os tubos """ # Cria uma variável auxilar para checar se o método de pontuar foi executado scored = False # Move os tubos gerados no background for tubes in self.__tubes: for tube in tubes: ...
[ "def", "move", "(", "self", ")", ":", "# Cria uma variável auxilar para checar se o método de pontuar foi executado", "scored", "=", "False", "# Move os tubos gerados no background", "for", "tubes", "in", "self", ".", "__tubes", ":", "for", "tube", "in", "tubes", ":", "...
[ 199, 4 ]
[ 232, 65 ]
python
en
['en', 'error', 'th']
False
Tubes.run
(self)
Método para gerar os tubos no background e fazer a sua animação em um loop infinito
Método para gerar os tubos no background e fazer a sua animação em um loop infinito
def run(self): """ Método para gerar os tubos no background e fazer a sua animação em um loop infinito """ # Se o método "stop" tiver sido chamado, a animação será encerrada if self.__stop: return # Se os tubos ( cima e baixo ) de uma posição X tiverem sumido da área do...
[ "def", "run", "(", "self", ")", ":", "# Se o método \"stop\" tiver sido chamado, a animação será encerrada", "if", "self", ".", "__stop", ":", "return", "# Se os tubos ( cima e baixo ) de uma posição X tiverem sumido da área do background,", "# eles serão apagados juntamente com suas ima...
[ 234, 4 ]
[ 274, 65 ]
python
en
['en', 'error', 'th']
False
Tubes.stop
(self)
Método para interromper a Thread
Método para interromper a Thread
def stop(self): """ Método para interromper a Thread """ self.__stop = True
[ "def", "stop", "(", "self", ")", ":", "self", ".", "__stop", "=", "True" ]
[ 276, 4 ]
[ 281, 26 ]
python
en
['en', 'error', 'th']
False
App.fetch_candidates
(self, available_amis=None, excluded_amis=None)
Collects created AMIs, AMIs from ec2 instances, launch configurations, autoscaling groups and returns unused AMIs.
Collects created AMIs, AMIs from ec2 instances, launch configurations, autoscaling groups and returns unused AMIs.
def fetch_candidates(self, available_amis=None, excluded_amis=None): """ Collects created AMIs, AMIs from ec2 instances, launch configurations, autoscaling groups and returns unused AMIs. """ f = Fetcher() available_amis = available_amis or f.fetch_available_ami...
[ "def", "fetch_candidates", "(", "self", ",", "available_amis", "=", "None", ",", "excluded_amis", "=", "None", ")", ":", "f", "=", "Fetcher", "(", ")", "available_amis", "=", "available_amis", "or", "f", ".", "fetch_available_amis", "(", ")", "excluded_amis", ...
[ 38, 4 ]
[ 59, 25 ]
python
en
['en', 'error', 'th']
False
App.prepare_candidates
(self, candidates_amis=None)
From an AMI list apply mapping strategy and filters
From an AMI list apply mapping strategy and filters
def prepare_candidates(self, candidates_amis=None): """ From an AMI list apply mapping strategy and filters """ candidates_amis = candidates_amis or self.fetch_candidates() if not candidates_amis: return None c = AMICleaner() mapped_amis = c.map_candidates( ...
[ "def", "prepare_candidates", "(", "self", ",", "candidates_amis", "=", "None", ")", ":", "candidates_amis", "=", "candidates_amis", "or", "self", ".", "fetch_candidates", "(", ")", "if", "not", "candidates_amis", ":", "return", "None", "c", "=", "AMICleaner", ...
[ 61, 4 ]
[ 96, 25 ]
python
en
['en', 'en', 'en']
True
App.prepare_delete_amis
(self, candidates, from_ids=False)
Prepare deletion of candidates AMIs
Prepare deletion of candidates AMIs
def prepare_delete_amis(self, candidates, from_ids=False): """ Prepare deletion of candidates AMIs""" failed = [] if from_ids: print(TERM.bold("\nCleaning from {} AMI id(s) ...".format( len(candidates)) )) failed = AMICleaner().remove_amis_f...
[ "def", "prepare_delete_amis", "(", "self", ",", "candidates", ",", "from_ids", "=", "False", ")", ":", "failed", "=", "[", "]", "if", "from_ids", ":", "print", "(", "TERM", ".", "bold", "(", "\"\\nCleaning from {} AMI id(s) ...\"", ".", "format", "(", "len",...
[ 98, 4 ]
[ 115, 50 ]
python
en
['en', 'la', 'en']
True
App.clean_orphans
(self)
Find and removes orphan snapshots
Find and removes orphan snapshots
def clean_orphans(self): """ Find and removes orphan snapshots """ cleaner = OrphanSnapshotCleaner() snaps = cleaner.fetch() if not snaps: return Printer.print_orphan_snapshots(snaps) answer = input( "Do you want to continue and remove {} orph...
[ "def", "clean_orphans", "(", "self", ")", ":", "cleaner", "=", "OrphanSnapshotCleaner", "(", ")", "snaps", "=", "cleaner", ".", "fetch", "(", ")", "if", "not", "snaps", ":", "return", "Printer", ".", "print_orphan_snapshots", "(", "snaps", ")", "answer", "...
[ 117, 4 ]
[ 137, 80 ]
python
en
['en', 'en', 'en']
True
test_error_on_more_than_1_optimizer
(tmpdir)
Check that error is thrown when more than 1 optimizer is passed
Check that error is thrown when more than 1 optimizer is passed
def test_error_on_more_than_1_optimizer(tmpdir): """ Check that error is thrown when more than 1 optimizer is passed """ model = EvalModelTemplate() model.configure_optimizers = model.configure_optimizers__multiple_schedulers # logger file to get meta trainer = Trainer( default_root_dir=tm...
[ "def", "test_error_on_more_than_1_optimizer", "(", "tmpdir", ")", ":", "model", "=", "EvalModelTemplate", "(", ")", "model", ".", "configure_optimizers", "=", "model", ".", "configure_optimizers__multiple_schedulers", "# logger file to get meta", "trainer", "=", "Trainer", ...
[ 27, 0 ]
[ 40, 36 ]
python
en
['en', 'en', 'en']
True
test_model_reset_correctly
(tmpdir)
Check that model weights are correctly reset after lr_find()
Check that model weights are correctly reset after lr_find()
def test_model_reset_correctly(tmpdir): """ Check that model weights are correctly reset after lr_find() """ model = EvalModelTemplate() # logger file to get meta trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, ) before_state_dict = deepcopy(model.state_dict()) ...
[ "def", "test_model_reset_correctly", "(", "tmpdir", ")", ":", "model", "=", "EvalModelTemplate", "(", ")", "# logger file to get meta", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", ")", "before_state_dict", "...
[ 43, 0 ]
[ 64, 65 ]
python
en
['en', 'en', 'en']
True
test_trainer_reset_correctly
(tmpdir)
Check that all trainer parameters are reset correctly after lr_find()
Check that all trainer parameters are reset correctly after lr_find()
def test_trainer_reset_correctly(tmpdir): """ Check that all trainer parameters are reset correctly after lr_find() """ model = EvalModelTemplate() # logger file to get meta trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, ) changed_attributes = [ 'callbacks',...
[ "def", "test_trainer_reset_correctly", "(", "tmpdir", ")", ":", "model", "=", "EvalModelTemplate", "(", ")", "# logger file to get meta", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", ")", "changed_attributes", ...
[ 67, 0 ]
[ 95, 35 ]
python
en
['en', 'en', 'en']
True
test_trainer_arg_bool
(tmpdir, use_hparams)
Test that setting trainer arg to bool works
Test that setting trainer arg to bool works
def test_trainer_arg_bool(tmpdir, use_hparams): """ Test that setting trainer arg to bool works """ hparams = EvalModelTemplate.get_default_hparams() model = EvalModelTemplate(**hparams) before_lr = hparams.get('learning_rate') if use_hparams: del model.learning_rate model.configure_...
[ "def", "test_trainer_arg_bool", "(", "tmpdir", ",", "use_hparams", ")", ":", "hparams", "=", "EvalModelTemplate", ".", "get_default_hparams", "(", ")", "model", "=", "EvalModelTemplate", "(", "*", "*", "hparams", ")", "before_lr", "=", "hparams", ".", "get", "...
[ 99, 0 ]
[ 122, 74 ]
python
en
['en', 'en', 'en']
True
test_trainer_arg_str
(tmpdir, use_hparams)
Test that setting trainer arg to string works
Test that setting trainer arg to string works
def test_trainer_arg_str(tmpdir, use_hparams): """ Test that setting trainer arg to string works """ hparams = EvalModelTemplate.get_default_hparams() model = EvalModelTemplate(**hparams) model.my_fancy_lr = 1.0 # update with non-standard field model.hparams['my_fancy_lr'] = 1.0 before_lr = mod...
[ "def", "test_trainer_arg_str", "(", "tmpdir", ",", "use_hparams", ")", ":", "hparams", "=", "EvalModelTemplate", ".", "get_default_hparams", "(", ")", "model", "=", "EvalModelTemplate", "(", "*", "*", "hparams", ")", "model", ".", "my_fancy_lr", "=", "1.0", "#...
[ 126, 0 ]
[ 151, 74 ]
python
en
['en', 'en', 'en']
True
test_call_to_trainer_method
(tmpdir, optimizer)
Test that directly calling the trainer method works
Test that directly calling the trainer method works
def test_call_to_trainer_method(tmpdir, optimizer): """ Test that directly calling the trainer method works """ hparams = EvalModelTemplate.get_default_hparams() model = EvalModelTemplate(**hparams) if optimizer == 'adagrad': model.configure_optimizers = model.configure_optimizers__adagrad ...
[ "def", "test_call_to_trainer_method", "(", "tmpdir", ",", "optimizer", ")", ":", "hparams", "=", "EvalModelTemplate", ".", "get_default_hparams", "(", ")", "model", "=", "EvalModelTemplate", "(", "*", "*", "hparams", ")", "if", "optimizer", "==", "'adagrad'", ":...
[ 155, 0 ]
[ 176, 74 ]
python
en
['en', 'en', 'en']
True
test_datamodule_parameter
(tmpdir)
Test that the datamodule parameter works
Test that the datamodule parameter works
def test_datamodule_parameter(tmpdir): """ Test that the datamodule parameter works """ dm = ClassifDataModule() model = ClassificationModel() before_lr = model.lr # logger file to get meta trainer = Trainer( default_root_dir=tmpdir, max_epochs=2, ) lrfinder = trainer....
[ "def", "test_datamodule_parameter", "(", "tmpdir", ")", ":", "dm", "=", "ClassifDataModule", "(", ")", "model", "=", "ClassificationModel", "(", ")", "before_lr", "=", "model", ".", "lr", "# logger file to get meta", "trainer", "=", "Trainer", "(", "default_root_d...
[ 179, 0 ]
[ 197, 74 ]
python
en
['en', 'en', 'en']
True
test_accumulation_and_early_stopping
(tmpdir)
Test that early stopping of learning rate finder works, and that accumulation also works for this feature
Test that early stopping of learning rate finder works, and that accumulation also works for this feature
def test_accumulation_and_early_stopping(tmpdir): """ Test that early stopping of learning rate finder works, and that accumulation also works for this feature """ hparams = EvalModelTemplate.get_default_hparams() model = EvalModelTemplate(**hparams) before_lr = hparams.get('learning_rate') ...
[ "def", "test_accumulation_and_early_stopping", "(", "tmpdir", ")", ":", "hparams", "=", "EvalModelTemplate", ".", "get_default_hparams", "(", ")", "model", "=", "EvalModelTemplate", "(", "*", "*", "hparams", ")", "before_lr", "=", "hparams", ".", "get", "(", "'l...
[ 200, 0 ]
[ 225, 45 ]
python
en
['en', 'en', 'en']
True
test_suggestion_parameters_work
(tmpdir)
Test that default skipping does not alter results in basic case
Test that default skipping does not alter results in basic case
def test_suggestion_parameters_work(tmpdir): """ Test that default skipping does not alter results in basic case """ dm = ClassifDataModule() model = ClassificationModel() # logger file to get meta trainer = Trainer( default_root_dir=tmpdir, max_epochs=3, ) lrfinder = trai...
[ "def", "test_suggestion_parameters_work", "(", "tmpdir", ")", ":", "dm", "=", "ClassifDataModule", "(", ")", "model", "=", "ClassificationModel", "(", ")", "# logger file to get meta", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epoc...
[ 228, 0 ]
[ 244, 75 ]
python
en
['en', 'en', 'en']
True