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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ModuleTester.test_0 | (self) |
Tests creation
|
Tests creation | def test_0(self):
"""
Tests creation
"""
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
xm = self.masked_array(x, mask=m)
xm[0] | [
"def",
"test_0",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"[",
"1.",
",",
"1.",
",",
"1.",
",",
"-",
"2.",
",",
"pi",
"/",
"2.0",
",",
"4.",
",",
"5.",
",",
"-",
"10.",
",",
"10.",
",",
"1.",
",",
"2.",
",",
"3.",
"]",
... | [
116,
4
] | [
124,
13
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_1 | (self) |
Tests creation
|
Tests creation | def test_1(self):
"""
Tests creation
"""
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1]... | [
"def",
"test_1",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"[",
"1.",
",",
"1.",
",",
"1.",
",",
"-",
"2.",
",",
"pi",
"/",
"2.0",
",",
"4.",
",",
"5.",
",",
"-",
"10.",
",",
"10.",
",",
"1.",
",",
"2.",
",",
"3.",
"]",
... | [
126,
4
] | [
151,
75
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_2 | (self) |
Tests conversions and indexing.
|
Tests conversions and indexing. | def test_2(self):
"""
Tests conversions and indexing.
"""
x1 = np.array([1, 2, 4, 3])
x2 = self.array(x1, mask=[1, 0, 0, 0])
x3 = self.array(x1, mask=[0, 1, 0, 1])
x4 = self.array(x1)
# test conversion to strings, no errors
str(x2)
repr(x2... | [
"def",
"test_2",
"(",
"self",
")",
":",
"x1",
"=",
"np",
".",
"array",
"(",
"[",
"1",
",",
"2",
",",
"4",
",",
"3",
"]",
")",
"x2",
"=",
"self",
".",
"array",
"(",
"x1",
",",
"mask",
"=",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
"... | [
153,
4
] | [
193,
27
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_3 | (self) |
Tests resize/repeat
|
Tests resize/repeat | def test_3(self):
"""
Tests resize/repeat
"""
x4 = self.arange(4)
x4[2] = self.masked
y4 = self.resize(x4, (8,))
assert self.allequal(self.concatenate([x4, x4]), y4)
assert self.allequal(self.getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0])
y5 = self.repeat... | [
"def",
"test_3",
"(",
"self",
")",
":",
"x4",
"=",
"self",
".",
"arange",
"(",
"4",
")",
"x4",
"[",
"2",
"]",
"=",
"self",
".",
"masked",
"y4",
"=",
"self",
".",
"resize",
"(",
"x4",
",",
"(",
"8",
",",
")",
")",
"assert",
"self",
".",
"all... | [
195,
4
] | [
212,
36
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_4 | (self) |
Test of take, transpose, inner, outer products.
|
Test of take, transpose, inner, outer products. | def test_4(self):
"""
Test of take, transpose, inner, outer products.
"""
x = self.arange(24)
y = np.arange(24)
x[5:6] = self.masked
x = x.reshape(2, 3, 4)
y = y.reshape(2, 3, 4)
assert self.allequal(np.transpose(y, (2, 0, 1)), self.transpose(x, (... | [
"def",
"test_4",
"(",
"self",
")",
":",
"x",
"=",
"self",
".",
"arange",
"(",
"24",
")",
"y",
"=",
"np",
".",
"arange",
"(",
"24",
")",
"x",
"[",
"5",
":",
"6",
"]",
"=",
"self",
".",
"masked",
"x",
"=",
"x",
".",
"reshape",
"(",
"2",
","... | [
214,
4
] | [
235,
24
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_5 | (self) |
Tests inplace w/ scalar
|
Tests inplace w/ scalar | def test_5(self):
"""
Tests inplace w/ scalar
"""
x = self.arange(10)
y = self.arange(10)
xm = self.arange(10)
xm[2] = self.masked
x += 1
assert self.allequal(x, y+1)
xm += 1
assert self.allequal(xm, y+1)
x = self.arange(1... | [
"def",
"test_5",
"(",
"self",
")",
":",
"x",
"=",
"self",
".",
"arange",
"(",
"10",
")",
"y",
"=",
"self",
".",
"arange",
"(",
"10",
")",
"xm",
"=",
"self",
".",
"arange",
"(",
"10",
")",
"xm",
"[",
"2",
"]",
"=",
"self",
".",
"masked",
"x"... | [
237,
4
] | [
287,
39
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_6 | (self) |
Tests inplace w/ array
|
Tests inplace w/ array | def test_6(self):
"""
Tests inplace w/ array
"""
x = self.arange(10, dtype=float_)
y = self.arange(10)
xm = self.arange(10, dtype=float_)
xm[2] = self.masked
m = xm.mask
a = self.arange(10, dtype=float_)
a[-1] = self.masked
x += a
... | [
"def",
"test_6",
"(",
"self",
")",
":",
"x",
"=",
"self",
".",
"arange",
"(",
"10",
",",
"dtype",
"=",
"float_",
")",
"y",
"=",
"self",
".",
"arange",
"(",
"10",
")",
"xm",
"=",
"self",
".",
"arange",
"(",
"10",
",",
"dtype",
"=",
"float_",
"... | [
289,
4
] | [
338,
15
] | python | en | ['en', 'error', 'th'] | False |
ModuleTester.test_7 | (self) | Tests ufunc | Tests ufunc | def test_7(self):
"Tests ufunc"
d = (self.array([1.0, 0, -1, pi/2]*2, mask=[0, 1]+[0]*6),
self.array([1.0, 0, -1, pi/2]*2, mask=[1, 0]+[0]*6),)
for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate',
# 'sin', 'cos', 'tan',
# 'arcsin', 'arccos', 'arcta... | [
"def",
"test_7",
"(",
"self",
")",
":",
"d",
"=",
"(",
"self",
".",
"array",
"(",
"[",
"1.0",
",",
"0",
",",
"-",
"1",
",",
"pi",
"/",
"2",
"]",
"*",
"2",
",",
"mask",
"=",
"[",
"0",
",",
"1",
"]",
"+",
"[",
"0",
"]",
"*",
"6",
")",
... | [
340,
4
] | [
372,
55
] | python | en | ['en', 'xh', 'tr'] | False |
BaseTemplateTest._create_validator | (self, markdown) | Create validator object from markdown string; useful for failures | Create validator object from markdown string; useful for failures | def _create_validator(self, markdown):
"""Create validator object from markdown string; useful for failures"""
return self.VALIDATOR(markdown=markdown) | [
"def",
"_create_validator",
"(",
"self",
",",
"markdown",
")",
":",
"return",
"self",
".",
"VALIDATOR",
"(",
"markdown",
"=",
"markdown",
")"
] | [
27,
4
] | [
29,
48
] | python | en | ['en', 'en', 'en'] | True |
TestAstHelpers.test_link_text_extracted | (self) | Verify that link text and destination are extracted correctly | Verify that link text and destination are extracted correctly | def test_link_text_extracted(self):
"""Verify that link text and destination are extracted correctly"""
validator = self._create_validator("""[This is a link](discussion.html)""")
links = validator.ast.find_external_links(validator.ast.children[0])
dest, link_text = validator.ast.get_li... | [
"def",
"test_link_text_extracted",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[This is a link](discussion.html)\"\"\"",
")",
"links",
"=",
"validator",
".",
"ast",
".",
"find_external_links",
"(",
"validator",
".",
"ast",
... | [
36,
4
] | [
43,
53
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_headers_missing_a_line | (self) | One of the required headers is missing | One of the required headers is missing | def test_headers_missing_a_line(self):
"""One of the required headers is missing"""
validator = self._create_validator("""---
layout: lesson
---""")
self.assertFalse(validator._validate_doc_headers()) | [
"def",
"test_headers_missing_a_line",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"---\nlayout: lesson\n---\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_doc_headers",
"(",
")",
")"
] | [
68,
4
] | [
73,
59
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_fail_when_headers_not_yaml_dict | (self) | Fail when the headers can't be parsed to a dict of YAML data | Fail when the headers can't be parsed to a dict of YAML data | def test_fail_when_headers_not_yaml_dict(self):
"""Fail when the headers can't be parsed to a dict of YAML data"""
validator = self._create_validator("""---
This will parse as a string, not a dictionary
---""")
self.assertFalse(validator._validate_doc_headers()) | [
"def",
"test_fail_when_headers_not_yaml_dict",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"---\nThis will parse as a string, not a dictionary\n---\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_doc_headers... | [
84,
4
] | [
89,
59
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_index_has_valid_section_headings | (self) | The provided index page | The provided index page | def test_index_has_valid_section_headings(self):
"""The provided index page"""
validator = self._create_validator("""## Topics
1. [Topic Title One](01-one.html)
2. [Topic Title Two](02-two.html)
## Other Resources
* [Reference Guide](reference.html)
* [Next Steps](discussion.html)
* [Instruct... | [
"def",
"test_index_has_valid_section_headings",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"## Topics\n\n1. [Topic Title One](01-one.html)\n2. [Topic Title Two](02-two.html)\n\n## Other Resources\n\n* [Reference Guide](reference.html)\n* [Next... | [
92,
4
] | [
105,
28
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_fail_when_section_heading_is_wrong_level | (self) | All headings must be exactly level 2 | All headings must be exactly level 2 | def test_fail_when_section_heading_is_wrong_level(self):
"""All headings must be exactly level 2"""
validator = self._create_validator("""---
layout: page
title: Lesson Title
---
Paragraph of introductory material.
> ## Prerequisites
>
> A short paragraph describing what learners need to know
> before ... | [
"def",
"test_fail_when_section_heading_is_wrong_level",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"---\nlayout: page\ntitle: Lesson Title\n---\nParagraph of introductory material.\n\n> ## Prerequisites\n>\n> A short paragraph describing what learne... | [
121,
4
] | [
144,
69
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_should_check_text_of_all_links_in_index | (self) | Text of every local-html link in index.md should
match dest page title | Text of every local-html link in index.md should
match dest page title | def test_should_check_text_of_all_links_in_index(self):
"""Text of every local-html link in index.md should
match dest page title"""
validator = self._create_validator("""
## [This link is in a heading](reference.html)
[Topic Title One](01-one.html#anchor)""")
links = validator.ast.find_... | [
"def",
"test_should_check_text_of_all_links_in_index",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\n## [This link is in a heading](reference.html)\n[Topic Title One](01-one.html#anchor)\"\"\"",
")",
"links",
"=",
"validator",
".",
"ast"... | [
195,
4
] | [
205,
44
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_file_links_validate | (self) | Verify that all links in a sample file validate.
Involves checking for example files; may fail on "core" branch | Verify that all links in a sample file validate.
Involves checking for example files; may fail on "core" branch | def test_file_links_validate(self):
"""Verify that all links in a sample file validate.
Involves checking for example files; may fail on "core" branch"""
sample_validator = self.VALIDATOR(self.SAMPLE_FILE)
res = sample_validator._validate_links()
self.assertTrue(res) | [
"def",
"test_file_links_validate",
"(",
"self",
")",
":",
"sample_validator",
"=",
"self",
".",
"VALIDATOR",
"(",
"self",
".",
"SAMPLE_FILE",
")",
"res",
"=",
"sample_validator",
".",
"_validate_links",
"(",
")",
"self",
".",
"assertTrue",
"(",
"res",
")"
] | [
207,
4
] | [
212,
28
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_html_link_to_extant_md_file_passes | (self) | Verify that an HTML link with corresponding MD file will pass
Involves checking for example files; may fail on "core" branch | Verify that an HTML link with corresponding MD file will pass
Involves checking for example files; may fail on "core" branch | def test_html_link_to_extant_md_file_passes(self):
"""Verify that an HTML link with corresponding MD file will pass
Involves checking for example files; may fail on "core" branch"""
validator = self._create_validator("""[Topic Title One](01-one.html)""")
self.assertTrue(validator._valida... | [
"def",
"test_html_link_to_extant_md_file_passes",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[Topic Title One](01-one.html)\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
".",
"_validate_links",
"(",
")",
")"
] | [
214,
4
] | [
218,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_html_link_with_anchor_to_extant_md_passes | (self) | Verify that link is identified correctly even if to page anchor
For now this just tests that the regex handles #anchors.
It doesn't validate that the named anchor exists in the md file
Involves checking for example files; may fail on "core" branch
| Verify that link is identified correctly even if to page anchor | def test_html_link_with_anchor_to_extant_md_passes(self):
"""Verify that link is identified correctly even if to page anchor
For now this just tests that the regex handles #anchors.
It doesn't validate that the named anchor exists in the md file
Involves checking for example files; ma... | [
"def",
"test_html_link_with_anchor_to_extant_md_passes",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[Topic Title One](01-one.html#anchor)\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
".",
"_validate_links",
"(",
")"... | [
220,
4
] | [
229,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_inpage_anchor_passes_validation | (self) | Links that reference anchors within the page should be ignored | Links that reference anchors within the page should be ignored | def test_inpage_anchor_passes_validation(self):
"""Links that reference anchors within the page should be ignored"""
# TODO: Revisit once anchor rules are available
validator = self._create_validator("""Most databases also support Booleans and date/time values;
SQLite uses the integers 0 and 1 f... | [
"def",
"test_inpage_anchor_passes_validation",
"(",
"self",
")",
":",
"# TODO: Revisit once anchor rules are available",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"Most databases also support Booleans and date/time values;\nSQLite uses the integers 0 and 1 for the form... | [
231,
4
] | [
236,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_missing_markdown_file_fails_validation | (self) | Fail validation when an html file is linked without corresponding
markdown file | Fail validation when an html file is linked without corresponding
markdown file | def test_missing_markdown_file_fails_validation(self):
"""Fail validation when an html file is linked without corresponding
markdown file"""
validator = self._create_validator("""[Broken link](nonexistent.html)""")
self.assertFalse(validator._validate_links()) | [
"def",
"test_missing_markdown_file_fails_validation",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[Broken link](nonexistent.html)\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_links",
"(",
")",
")"
... | [
238,
4
] | [
242,
53
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_website_link_ignored_by_validator | (self) | Don't look for markdown if the file linked isn't local-
remote website links are ignored | Don't look for markdown if the file linked isn't local-
remote website links are ignored | def test_website_link_ignored_by_validator(self):
"""Don't look for markdown if the file linked isn't local-
remote website links are ignored"""
validator = self._create_validator("""[Broken link](http://website.com/filename.html)""")
self.assertTrue(validator._validate_links()) | [
"def",
"test_website_link_ignored_by_validator",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[Broken link](http://website.com/filename.html)\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
".",
"_validate_links",
"(",
"... | [
244,
4
] | [
248,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_malformed_website_link_fails_validator | (self) | If the link isn't prefixed by http(s):// or ftp://, fail.
This is because there are a lot of edge cases in distinguishing
between filenames and URLs: err on the side of certainty. | If the link isn't prefixed by http(s):// or ftp://, fail.
This is because there are a lot of edge cases in distinguishing
between filenames and URLs: err on the side of certainty. | def test_malformed_website_link_fails_validator(self):
"""If the link isn't prefixed by http(s):// or ftp://, fail.
This is because there are a lot of edge cases in distinguishing
between filenames and URLs: err on the side of certainty."""
validator = self._create_validator("""[Bro... | [
"def",
"test_malformed_website_link_fails_validator",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"[Broken link](www.website.com/filename.html)\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_links",
"(",
... | [
250,
4
] | [
255,
53
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_finds_image_asset | (self) | Image asset is found in the expected file location
Involves checking for example files; may fail on "core" branch | Image asset is found in the expected file location
Involves checking for example files; may fail on "core" branch | def test_finds_image_asset(self):
"""Image asset is found in the expected file location
Involves checking for example files; may fail on "core" branch"""
validator = self._create_validator(
"""""")
se... | [
"def",
"test_finds_image_asset",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
".",
"_validate_lin... | [
257,
4
] | [
262,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_image_asset_not_found | (self) | Image asset can't be found if path is invalid | Image asset can't be found if path is invalid | def test_image_asset_not_found(self):
"""Image asset can't be found if path is invalid"""
validator = self._create_validator(
"""""")
self.assertFalse(validator._validate_links()) | [
"def",
"test_image_asset_not_found",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validat... | [
264,
4
] | [
268,
53
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_non_html_link_finds_csv | (self) | Look for CSV file in appropriate folder
Involves checking for example files; may fail on "core" branch
| Look for CSV file in appropriate folder
Involves checking for example files; may fail on "core" branch
| def test_non_html_link_finds_csv(self):
"""Look for CSV file in appropriate folder
Involves checking for example files; may fail on "core" branch
"""
validator = self._create_validator(
"""Use [this CSV](data/data.csv) for the exercise.""")
self.assertTrue(validator._... | [
"def",
"test_non_html_link_finds_csv",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"Use [this CSV](data/data.csv) for the exercise.\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
".",
"_validate_links",
"(",
")",
")"
... | [
270,
4
] | [
276,
52
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_non_html_links_are_path_sensitive | (self) | Fails to find CSV file with wrong path. | Fails to find CSV file with wrong path. | def test_non_html_links_are_path_sensitive(self):
"""Fails to find CSV file with wrong path."""
validator = self._create_validator(
"""Use [this CSV](data.csv) for the exercise.""")
self.assertFalse(validator._validate_links()) | [
"def",
"test_non_html_links_are_path_sensitive",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"Use [this CSV](data.csv) for the exercise.\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_links",
"(",
")",
... | [
278,
4
] | [
282,
53
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_one_prereq_callout_passes | (self) | index.md should have one, and only one, prerequisites box | index.md should have one, and only one, prerequisites box | def test_one_prereq_callout_passes(self):
"""index.md should have one, and only one, prerequisites box"""
validator = self._create_validator("""> ## Prerequisites {.prereq}
>
> What learners need to know before tackling this lesson.
""")
self.assertTrue(validator._validate_callouts()) | [
"def",
"test_one_prereq_callout_passes",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Prerequisites {.prereq}\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",
... | [
285,
4
] | [
291,
55
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_two_prereq_callouts_fail | (self) | More than one prereq callout box is not allowed | More than one prereq callout box is not allowed | def test_two_prereq_callouts_fail(self):
"""More than one prereq callout box is not allowed"""
validator = self._create_validator("""> ## Prerequisites {.prereq}
>
> What learners need to know before tackling this lesson.
A spacer paragraph
> ## Prerequisites {.prereq}
>
> A second prerequisites box s... | [
"def",
"test_two_prereq_callouts_fail",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Prerequisites {.prereq}\n>\n> What learners need to know before tackling this lesson.\n\nA spacer paragraph\n\n> ## Prerequisites {.prereq}\n>\n> A second prere... | [
293,
4
] | [
305,
56
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_callout_without_style_fails | (self) | A callout box will fail if it is missing the required style | A callout box will fail if it is missing the required style | def test_callout_without_style_fails(self):
"""A callout box will fail if it is missing the required style"""
validator = self._create_validator("""> ## Prerequisites
>
> What learners need to know before tackling this lesson.
""")
self.assertFalse(validator._validate_callouts()) | [
"def",
"test_callout_without_style_fails",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Prerequisites\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
... | [
307,
4
] | [
313,
56
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_callout_with_wrong_title_fails | (self) | A callout box will fail if it has the wrong title | A callout box will fail if it has the wrong title | def test_callout_with_wrong_title_fails(self):
"""A callout box will fail if it has the wrong title"""
validator = self._create_validator("""> ## Wrong title {.prereq}
>
> What learners need to know before tackling this lesson.
""")
self.assertFalse(validator._validate_callouts()) | [
"def",
"test_callout_with_wrong_title_fails",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Wrong title {.prereq}\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator... | [
315,
4
] | [
321,
56
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_unknown_callout_style_fails | (self) | A callout whose style is unrecognized by template is invalid | A callout whose style is unrecognized by template is invalid | def test_unknown_callout_style_fails(self):
"""A callout whose style is unrecognized by template is invalid"""
validator = self._create_validator("""> ## Any title {.callout}
>
> What learners need to know before tackling this lesson.
""")
callout_node = validator.ast.get_callouts()[0]
s... | [
"def",
"test_unknown_callout_style_fails",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Any title {.callout}\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"callout_node",
"=",
"validator",
".",
"ast",
... | [
323,
4
] | [
330,
71
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_block_ignored_sans_heading | (self) |
Blockquotes only count as callouts if they have a heading
|
Blockquotes only count as callouts if they have a heading
| def test_block_ignored_sans_heading(self):
"""
Blockquotes only count as callouts if they have a heading
"""
validator = self._create_validator("""> Prerequisites {.prereq}
>
> What learners need to know before tackling this lesson.
""")
callout_nodes = validator.ast.get_callouts... | [
"def",
"test_block_ignored_sans_heading",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> Prerequisites {.prereq}\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"callout_nodes",
"=",
"validator",
".",
"ast",
... | [
332,
4
] | [
341,
47
] | python | en | ['en', 'error', 'th'] | False |
TestIndexPage.test_callout_heading_must_be_l2 | (self) | Callouts will fail validation if the heading is not level 2 | Callouts will fail validation if the heading is not level 2 | def test_callout_heading_must_be_l2(self):
"""Callouts will fail validation if the heading is not level 2"""
validator = self._create_validator("""> ### Prerequisites {.prereq}
>
> What learners need to know before tackling this lesson.
""")
self.assertFalse(validator._validate_callouts()) | [
"def",
"test_callout_heading_must_be_l2",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ### Prerequisites {.prereq}\n>\n> What learners need to know before tackling this lesson.\n\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator"... | [
343,
4
] | [
349,
56
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_fail_if_fixme_present_all_caps | (self) | Validation should fail if a line contains the word FIXME (exact) | Validation should fail if a line contains the word FIXME (exact) | def test_fail_if_fixme_present_all_caps(self):
"""Validation should fail if a line contains the word FIXME (exact)"""
validator = self._create_validator("""Incomplete sentence (FIXME).""")
self.assertFalse(validator._validate_no_fixme()) | [
"def",
"test_fail_if_fixme_present_all_caps",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"Incomplete sentence (FIXME).\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_no_fixme",
"(",
")",
")"
] | [
351,
4
] | [
354,
56
] | python | en | ['en', 'en', 'en'] | True |
TestIndexPage.test_fail_if_fixme_present_mixed_case | (self) | Validation should fail if a line contains the word FIXME
(in any capitalization) | Validation should fail if a line contains the word FIXME
(in any capitalization) | def test_fail_if_fixme_present_mixed_case(self):
"""Validation should fail if a line contains the word FIXME
(in any capitalization)"""
validator = self._create_validator("""Incomplete sentence (FiXmE).""")
self.assertFalse(validator._validate_no_fixme()) | [
"def",
"test_fail_if_fixme_present_mixed_case",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"Incomplete sentence (FiXmE).\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_no_fixme",
"(",
")",
")"
] | [
356,
4
] | [
360,
56
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_headers_fail_because_invalid_content | (self) | The value provided as YAML does not match the expected datatype | The value provided as YAML does not match the expected datatype | def test_headers_fail_because_invalid_content(self):
"""The value provided as YAML does not match the expected datatype"""
validator = self._create_validator("""---
layout: lesson
title: Lesson Title
subtitle: A page
minutes: not a number
---""")
self.assertFalse(validator._validate_doc_headers(... | [
"def",
"test_headers_fail_because_invalid_content",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"---\nlayout: lesson\ntitle: Lesson Title\nsubtitle: A page\nminutes: not a number\n---\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validat... | [
368,
4
] | [
376,
59
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_topic_page_should_have_no_headings | (self) | Requirement according to spec; may be relaxed in future | Requirement according to spec; may be relaxed in future | def test_topic_page_should_have_no_headings(self):
"""Requirement according to spec; may be relaxed in future"""
validator = self._create_validator("""
## Heading that should not be present
Some text""")
self.assertFalse(validator._validate_has_no_headings()) | [
"def",
"test_topic_page_should_have_no_headings",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\n## Heading that should not be present\n\nSome text\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"validator",
".",
"_validate_has_no_head... | [
378,
4
] | [
384,
63
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_should_not_check_text_of_links_in_topic | (self) | Never check that text of local-html links in topic
matches dest title | Never check that text of local-html links in topic
matches dest title | def test_should_not_check_text_of_links_in_topic(self):
"""Never check that text of local-html links in topic
matches dest title """
validator = self._create_validator("""
## [This link is in a heading](reference.html)
[Topic Title One](01-one.html#anchor)""")
links = validator.ast.find_... | [
"def",
"test_should_not_check_text_of_links_in_topic",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\n## [This link is in a heading](reference.html)\n[Topic Title One](01-one.html#anchor)\"\"\"",
")",
"links",
"=",
"validator",
".",
"ast"... | [
386,
4
] | [
396,
44
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_pass_when_optional_callouts_absent | (self) | Optional block titles should be optional | Optional block titles should be optional | def test_pass_when_optional_callouts_absent(self):
"""Optional block titles should be optional"""
validator = self._create_validator("""> ## Learning Objectives {.objectives}
>
> * All topic pages must have this callout""")
self.assertTrue(validator._validate_callouts()) | [
"def",
"test_pass_when_optional_callouts_absent",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Learning Objectives {.objectives}\n>\n> * All topic pages must have this callout\"\"\"",
")",
"self",
".",
"assertTrue",
"(",
"validator",... | [
398,
4
] | [
403,
55
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_callout_style_passes_regardless_of_title | (self) | Verify that certain kinds of callout box can be recognized solely
by style, regardless of the heading title | Verify that certain kinds of callout box can be recognized solely
by style, regardless of the heading title | def test_callout_style_passes_regardless_of_title(self):
"""Verify that certain kinds of callout box can be recognized solely
by style, regardless of the heading title"""
validator = self._create_validator("""> ## Learning Objectives {.objectives}
>
> * All topic pages must have this callout
> ... | [
"def",
"test_callout_style_passes_regardless_of_title",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Learning Objectives {.objectives}\n>\n> * All topic pages must have this callout\n\n> ## Some random title {.callout}\n>\n> Some informative tex... | [
406,
4
] | [
417,
55
] | python | en | ['en', 'en', 'en'] | True |
TestTopicPage.test_callout_style_allows_duplicates | (self) | Multiple blockquoted sections with style 'callout' are allowed | Multiple blockquoted sections with style 'callout' are allowed | def test_callout_style_allows_duplicates(self):
"""Multiple blockquoted sections with style 'callout' are allowed"""
validator = self._create_validator("""> ## Learning Objectives {.objectives}
>
> * All topic pages must have this callout
> ## Callout box one {.callout}
>
> Some informative text
Spac... | [
"def",
"test_callout_style_allows_duplicates",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Learning Objectives {.objectives}\n>\n> * All topic pages must have this callout\n\n> ## Callout box one {.callout}\n>\n> Some informative text\n\nSpace... | [
419,
4
] | [
434,
55
] | python | en | ['en', 'en', 'en'] | True |
TestReferencePage.test_callout_fails_when_none_specified | (self) | The presence of a callout box should cause validation to fail
when the template doesn't define any recognized callouts
(No "unknown" blockquote sections are allowed)
| The presence of a callout box should cause validation to fail
when the template doesn't define any recognized callouts | def test_callout_fails_when_none_specified(self):
"""The presence of a callout box should cause validation to fail
when the template doesn't define any recognized callouts
(No "unknown" blockquote sections are allowed)
"""
validator = self._create_validator("""> ## Lear... | [
"def",
"test_callout_fails_when_none_specified",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"> ## Learning Objectives {.objectives}\n>\n> * Learning objective 1\n> * Learning objective 2\"\"\"",
")",
"self",
".",
"assertFalse",
"(",
"val... | [
496,
4
] | [
507,
56
] | python | en | ['en', 'en', 'en'] | True |
TestInstructorPage.test_should_selectively_check_text_of_links_in_topic | (self) | Only verify that text of local-html links in topic
matches dest title if the link is in a heading | Only verify that text of local-html links in topic
matches dest title if the link is in a heading | def test_should_selectively_check_text_of_links_in_topic(self):
"""Only verify that text of local-html links in topic
matches dest title if the link is in a heading"""
validator = self._create_validator("""
## [Reference](reference.html)
[Topic Title One](01-one.html#anchor)""")
check_t... | [
"def",
"test_should_selectively_check_text_of_links_in_topic",
"(",
"self",
")",
":",
"validator",
"=",
"self",
".",
"_create_validator",
"(",
"\"\"\"\n## [Reference](reference.html)\n\n[Topic Title One](01-one.html#anchor)\"\"\"",
")",
"check_text",
",",
"dont_check_text",
"=",
... | [
520,
4
] | [
530,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_ddp | (rank, world_size) | Setup ddp enviroment | Setup ddp enviroment | def setup_ddp(rank, world_size):
""" Setup ddp enviroment """
os.environ["MASTER_ADDR"] = "localhost"
os.environ["MASTER_PORT"] = "8088"
if torch.distributed.is_available() and sys.platform not in ("win32", "cygwin"):
torch.distributed.init_process_group("gloo", rank=rank, world_size=world_size... | [
"def",
"setup_ddp",
"(",
"rank",
",",
"world_size",
")",
":",
"os",
".",
"environ",
"[",
"\"MASTER_ADDR\"",
"]",
"=",
"\"localhost\"",
"os",
".",
"environ",
"[",
"\"MASTER_PORT\"",
"]",
"=",
"\"8088\"",
"if",
"torch",
".",
"distributed",
".",
"is_available",... | [
26,
0
] | [
32,
86
] | python | en | ['en', 'hi-Latn', 'hi'] | False |
_assert_allclose | (pl_result, sk_result, atol: float = 1e-8) | Utility function for recursively asserting that two results are within
a certain tolerance
| Utility function for recursively asserting that two results are within
a certain tolerance
| def _assert_allclose(pl_result, sk_result, atol: float = 1e-8):
""" Utility function for recursively asserting that two results are within
a certain tolerance
"""
# single output compare
if isinstance(pl_result, torch.Tensor):
assert np.allclose(pl_result.numpy(), sk_result, atol=atol, e... | [
"def",
"_assert_allclose",
"(",
"pl_result",
",",
"sk_result",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
":",
"# single output compare",
"if",
"isinstance",
"(",
"pl_result",
",",
"torch",
".",
"Tensor",
")",
":",
"assert",
"np",
".",
"allclose",
"(",
"... | [
35,
0
] | [
47,
57
] | python | en | ['en', 'en', 'en'] | True |
_assert_tensor | (pl_result) | Utility function for recursively checking that some input only consist of
torch tensors
| Utility function for recursively checking that some input only consist of
torch tensors
| def _assert_tensor(pl_result):
""" Utility function for recursively checking that some input only consist of
torch tensors
"""
if isinstance(pl_result, (list, tuple)):
for plr in pl_result:
_assert_tensor(plr)
else:
assert isinstance(pl_result, torch.Tensor) | [
"def",
"_assert_tensor",
"(",
"pl_result",
")",
":",
"if",
"isinstance",
"(",
"pl_result",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"plr",
"in",
"pl_result",
":",
"_assert_tensor",
"(",
"plr",
")",
"else",
":",
"assert",
"isinstance",
"(",
... | [
50,
0
] | [
58,
50
] | python | en | ['en', 'en', 'en'] | True |
_class_test | (
rank: int,
worldsize: int,
preds: torch.Tensor,
target: torch.Tensor,
metric_class: Metric,
sk_metric: Callable,
dist_sync_on_step: bool,
metric_args: dict = {},
check_dist_sync_on_step: bool = True,
check_batch: bool = True,
atol: float = 1e-8,
) | Utility function doing the actual comparison between lightning class metric
and reference metric.
Args:
rank: rank of current process
worldsize: number of processes
preds: torch tensor with predictions
target: torch tensor with targets
metric_class: lightning metric clas... | Utility function doing the actual comparison between lightning class metric
and reference metric. | def _class_test(
rank: int,
worldsize: int,
preds: torch.Tensor,
target: torch.Tensor,
metric_class: Metric,
sk_metric: Callable,
dist_sync_on_step: bool,
metric_args: dict = {},
check_dist_sync_on_step: bool = True,
check_batch: bool = True,
atol: float = 1e-8,
):
"""Uti... | [
"def",
"_class_test",
"(",
"rank",
":",
"int",
",",
"worldsize",
":",
"int",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"metric_class",
":",
"Metric",
",",
"sk_metric",
":",
"Callable",
",",
"dist_sync_on_... | [
61,
0
] | [
125,
50
] | python | en | ['en', 'en', 'en'] | True |
_functional_test | (
preds: torch.Tensor,
target: torch.Tensor,
metric_functional: Callable,
sk_metric: Callable,
metric_args: dict = {},
atol: float = 1e-8,
) | Utility function doing the actual comparison between lightning functional metric
and reference metric.
Args:
preds: torch tensor with predictions
target: torch tensor with targets
metric_functional: lightning metric functional that should be tested
sk_metric: callable function t... | Utility function doing the actual comparison between lightning functional metric
and reference metric. | def _functional_test(
preds: torch.Tensor,
target: torch.Tensor,
metric_functional: Callable,
sk_metric: Callable,
metric_args: dict = {},
atol: float = 1e-8,
):
"""Utility function doing the actual comparison between lightning functional metric
and reference metric.
Args:
p... | [
"def",
"_functional_test",
"(",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"metric_functional",
":",
"Callable",
",",
"sk_metric",
":",
"Callable",
",",
"metric_args",
":",
"dict",
"=",
"{",
"}",
",",
"atol",
"... | [
128,
0
] | [
153,
64
] | python | en | ['en', 'en', 'en'] | True |
MetricTester.setup_class | (self) | Setup the metric class. This will spawn the pool of workers that are
used for metric testing and setup_ddp
| Setup the metric class. This will spawn the pool of workers that are
used for metric testing and setup_ddp
| def setup_class(self):
"""Setup the metric class. This will spawn the pool of workers that are
used for metric testing and setup_ddp
"""
self.poolSize = NUM_PROCESSES
self.pool = Pool(processes=self.poolSize)
self.pool.starmap(setup_ddp, [(rank, self.poolSize) for rank i... | [
"def",
"setup_class",
"(",
"self",
")",
":",
"self",
".",
"poolSize",
"=",
"NUM_PROCESSES",
"self",
".",
"pool",
"=",
"Pool",
"(",
"processes",
"=",
"self",
".",
"poolSize",
")",
"self",
".",
"pool",
".",
"starmap",
"(",
"setup_ddp",
",",
"[",
"(",
"... | [
168,
4
] | [
175,
94
] | python | en | ['en', 'en', 'en'] | True |
MetricTester.teardown_class | (self) | Close pool of workers | Close pool of workers | def teardown_class(self):
""" Close pool of workers """
self.pool.close()
self.pool.join() | [
"def",
"teardown_class",
"(",
"self",
")",
":",
"self",
".",
"pool",
".",
"close",
"(",
")",
"self",
".",
"pool",
".",
"join",
"(",
")"
] | [
177,
4
] | [
180,
24
] | python | en | ['en', 'en', 'en'] | True |
MetricTester.run_functional_metric_test | (
self,
preds: torch.Tensor,
target: torch.Tensor,
metric_functional: Callable,
sk_metric: Callable,
metric_args: dict = {},
) | Main method that should be used for testing functions. Call this inside
testing method
Args:
preds: torch tensor with predictions
target: torch tensor with targets
metric_functional: lightning metric class that should be tested
sk_metric: callable functio... | Main method that should be used for testing functions. Call this inside
testing method | def run_functional_metric_test(
self,
preds: torch.Tensor,
target: torch.Tensor,
metric_functional: Callable,
sk_metric: Callable,
metric_args: dict = {},
):
"""Main method that should be used for testing functions. Call this inside
testing method
... | [
"def",
"run_functional_metric_test",
"(",
"self",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"metric_functional",
":",
"Callable",
",",
"sk_metric",
":",
"Callable",
",",
"metric_args",
":",
"dict",
"=",
"{",
... | [
182,
4
] | [
207,
9
] | python | en | ['en', 'en', 'en'] | True |
MetricTester.run_class_metric_test | (
self,
ddp: bool,
preds: torch.Tensor,
target: torch.Tensor,
metric_class: Metric,
sk_metric: Callable,
dist_sync_on_step: bool,
metric_args: dict = {},
check_dist_sync_on_step: bool = True,
check_batch: bool = True,
) | Main method that should be used for testing class. Call this inside testing
methods.
Args:
ddp: bool, if running in ddp mode or not
preds: torch tensor with predictions
target: torch tensor with targets
metric_class: lightning metric class that should be ... | Main method that should be used for testing class. Call this inside testing
methods. | def run_class_metric_test(
self,
ddp: bool,
preds: torch.Tensor,
target: torch.Tensor,
metric_class: Metric,
sk_metric: Callable,
dist_sync_on_step: bool,
metric_args: dict = {},
check_dist_sync_on_step: bool = True,
check_batch: bool = Tru... | [
"def",
"run_class_metric_test",
"(",
"self",
",",
"ddp",
":",
"bool",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"metric_class",
":",
"Metric",
",",
"sk_metric",
":",
"Callable",
",",
"dist_sync_on_step",
":... | [
209,
4
] | [
270,
13
] | python | en | ['en', 'en', 'en'] | True |
poly2herm | (pol) |
poly2herm(pol)
Convert a polynomial to a Hermite 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 Hermite series, ordered
from lowest to highest de... |
poly2herm(pol) | def poly2herm(pol):
"""
poly2herm(pol)
Convert a polynomial to a Hermite 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 Hermite series, ordered
... | [
"def",
"poly2herm",
"(",
"pol",
")",
":",
"[",
"pol",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"pol",
"]",
")",
"deg",
"=",
"len",
"(",
"pol",
")",
"-",
"1",
"res",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"deg",
",",
"-",
"1",
",",
"... | [
81,
0
] | [
124,
14
] | python | en | ['en', 'error', 'th'] | False |
herm2poly | (c) |
Convert a Hermite series to a polynomial.
Convert an array representing the coefficients of a Hermite 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.
Parameter... |
Convert a Hermite series to a polynomial. | def herm2poly(c):
"""
Convert a Hermite series to a polynomial.
Convert an array representing the coefficients of a Hermite 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 highe... | [
"def",
"herm2poly",
"(",
"c",
")",
":",
"from",
".",
"polynomial",
"import",
"polyadd",
",",
"polysub",
",",
"polymulx",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"n",
"=",
"len",
"(",
"c",
")",
"if",
"n",
"==",
"1",
... | [
127,
0
] | [
182,
42
] | python | en | ['en', 'error', 'th'] | False |
hermline | (off, scl) |
Hermite 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 Hermite series for
``off + scl*x``.
See Also
--------
... |
Hermite series whose graph is a straight line. | def hermline(off, scl):
"""
Hermite 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 Hermite series for
``off + scl*x... | [
"def",
"hermline",
"(",
"off",
",",
"scl",
")",
":",
"if",
"scl",
"!=",
"0",
":",
"return",
"np",
".",
"array",
"(",
"[",
"off",
",",
"scl",
"/",
"2",
"]",
")",
"else",
":",
"return",
"np",
".",
"array",
"(",
"[",
"off",
"]",
")"
] | [
202,
0
] | [
235,
30
] | python | en | ['en', 'error', 'th'] | False |
hermfromroots | (roots) |
Generate a Hermite 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 Hermite form, where the `r_n` are the roots specified in `roots`.
If a zero has multiplicity n, then it must appear in `roots` n times.... |
Generate a Hermite series with given roots. | def hermfromroots(roots):
"""
Generate a Hermite 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 Hermite form, where the `r_n` are the roots specified in `roots`.
If a zero has multiplicity n, then i... | [
"def",
"hermfromroots",
"(",
"roots",
")",
":",
"return",
"pu",
".",
"_fromroots",
"(",
"hermline",
",",
"hermmul",
",",
"roots",
")"
] | [
238,
0
] | [
287,
50
] | python | en | ['en', 'error', 'th'] | False |
hermadd | (c1, c2) |
Add one Hermite series to another.
Returns the sum of two Hermite series `c1` + `c2`. The arguments
are sequences of coefficients ordered from lowest order term to
highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : array_like
1-D ... |
Add one Hermite series to another. | def hermadd(c1, c2):
"""
Add one Hermite series to another.
Returns the sum of two Hermite series `c1` + `c2`. The arguments
are sequences of coefficients ordered from lowest order term to
highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, ... | [
"def",
"hermadd",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_add",
"(",
"c1",
",",
"c2",
")"
] | [
290,
0
] | [
327,
26
] | python | en | ['en', 'error', 'th'] | False |
hermsub | (c1, c2) |
Subtract one Hermite series from another.
Returns the difference of two Hermite series `c1` - `c2`. The
sequences of coefficients are from lowest order term to highest, i.e.,
[1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : array_like
1-D arra... |
Subtract one Hermite series from another. | def hermsub(c1, c2):
"""
Subtract one Hermite series from another.
Returns the difference of two Hermite series `c1` - `c2`. The
sequences of coefficients are from lowest order term to highest, i.e.,
[1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 :... | [
"def",
"hermsub",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_sub",
"(",
"c1",
",",
"c2",
")"
] | [
330,
0
] | [
367,
26
] | python | en | ['en', 'error', 'th'] | False |
hermmulx | (c) | Multiply a Hermite series by x.
Multiply the Hermite series `c` by x, where x is the independent
variable.
Parameters
----------
c : array_like
1-D array of Hermite series coefficients ordered from low to
high.
Returns
-------
out : ndarray
Array representing ... | Multiply a Hermite series by x. | def hermmulx(c):
"""Multiply a Hermite series by x.
Multiply the Hermite series `c` by x, where x is the independent
variable.
Parameters
----------
c : array_like
1-D array of Hermite series coefficients ordered from low to
high.
Returns
-------
out : ndarray
... | [
"def",
"hermmulx",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"# The zero series needs special treatment",
"if",
"len",
"(",
"c",
")",
"==",
"1",
"and",
"c",
"[",
"0",
"]",
"==",
... | [
370,
0
] | [
420,
14
] | python | en | ['en', 'en', 'en'] | True |
hermmul | (c1, c2) |
Multiply one Hermite series by another.
Returns the product of two Hermite series `c1` * `c2`. The arguments
are sequences of coefficients, from lowest order "term" to highest,
e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : array_like
... |
Multiply one Hermite series by another. | def hermmul(c1, c2):
"""
Multiply one Hermite series by another.
Returns the product of two Hermite series `c1` * `c2`. The arguments
are sequences of coefficients, from lowest order "term" to highest,
e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
... | [
"def",
"hermmul",
"(",
"c1",
",",
"c2",
")",
":",
"# s1, s2 are trimmed copies",
"[",
"c1",
",",
"c2",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c1",
",",
"c2",
"]",
")",
"if",
"len",
"(",
"c1",
")",
">",
"len",
"(",
"c2",
")",
":",
"c",
"... | [
423,
0
] | [
486,
38
] | python | en | ['en', 'error', 'th'] | False |
hermdiv | (c1, c2) |
Divide one Hermite series by another.
Returns the quotient-with-remainder of two Hermite series
`c1` / `c2`. The arguments are sequences of coefficients from lowest
order "term" to highest, e.g., [1,2,3] represents the series
``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : ar... |
Divide one Hermite series by another. | def hermdiv(c1, c2):
"""
Divide one Hermite series by another.
Returns the quotient-with-remainder of two Hermite series
`c1` / `c2`. The arguments are sequences of coefficients from lowest
order "term" to highest, e.g., [1,2,3] represents the series
``P_0 + 2*P_1 + 3*P_2``.
Parameters
... | [
"def",
"hermdiv",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_div",
"(",
"hermmul",
",",
"c1",
",",
"c2",
")"
] | [
489,
0
] | [
534,
35
] | python | en | ['en', 'error', 'th'] | False |
hermpow | (c, pow, maxpower=16) | Raise a Hermite series to a power.
Returns the Hermite 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 ``P_0 + 2*P_1 + 3*P_2.``
Parameters
----------
c : array_like
1-D array of Hermite series c... | Raise a Hermite series to a power. | def hermpow(c, pow, maxpower=16):
"""Raise a Hermite series to a power.
Returns the Hermite 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 ``P_0 + 2*P_1 + 3*P_2.``
Parameters
----------
c : array_l... | [
"def",
"hermpow",
"(",
"c",
",",
"pow",
",",
"maxpower",
"=",
"16",
")",
":",
"return",
"pu",
".",
"_pow",
"(",
"hermmul",
",",
"c",
",",
"pow",
",",
"maxpower",
")"
] | [
537,
0
] | [
571,
45
] | python | en | ['en', 'gd', 'en'] | True |
hermder | (c, m=1, scl=1, axis=0) |
Differentiate a Hermite series.
Returns the Hermite 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 degr... |
Differentiate a Hermite series. | def hermder(c, m=1, scl=1, axis=0):
"""
Differentiate a Hermite series.
Returns the Hermite 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 ... | [
"def",
"hermder",
"(",
"c",
",",
"m",
"=",
"1",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"1",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in... | [
574,
0
] | [
654,
12
] | python | en | ['en', 'error', 'th'] | False |
hermint | (c, m=1, k=[], lbnd=0, scl=1, axis=0) |
Integrate a Hermite series.
Returns the Hermite 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. ("Buye... |
Integrate a Hermite series. | def hermint(c, m=1, k=[], lbnd=0, scl=1, axis=0):
"""
Integrate a Hermite series.
Returns the Hermite 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 ... | [
"def",
"hermint",
"(",
"c",
",",
"m",
"=",
"1",
",",
"k",
"=",
"[",
"]",
",",
"lbnd",
"=",
"0",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"... | [
657,
0
] | [
776,
12
] | python | en | ['en', 'error', 'th'] | False |
hermval | (x, c, tensor=True) |
Evaluate an Hermite series at points x.
If `c` is of length `n + 1`, this function returns the value:
.. math:: p(x) = c_0 * H_0(x) + c_1 * H_1(x) + ... + c_n * H_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 an Hermite series at points x. | def hermval(x, c, tensor=True):
"""
Evaluate an Hermite series at points x.
If `c` is of length `n + 1`, this function returns the value:
.. math:: p(x) = c_0 * H_0(x) + c_1 * H_1(x) + ... + c_n * H_n(x)
The parameter `x` is converted to an array only if it is a tuple or a
list, otherwise it ... | [
"def",
"hermval",
"(",
"x",
",",
"c",
",",
"tensor",
"=",
"True",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"0",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in",
"'?bBhHiIlLqQpP'",
":",
"c",
... | [
779,
0
] | [
872,
21
] | python | en | ['en', 'error', 'th'] | False |
hermval2d | (x, y, c) |
Evaluate a 2-D Hermite series at points (x, y).
This function returns the values:
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * H_i(x) * H_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 sam... |
Evaluate a 2-D Hermite series at points (x, y). | def hermval2d(x, y, c):
"""
Evaluate a 2-D Hermite series at points (x, y).
This function returns the values:
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * H_i(x) * H_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... | [
"def",
"hermval2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"hermval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
875,
0
] | [
921,
38
] | python | en | ['en', 'error', 'th'] | False |
hermgrid2d | (x, y, c) |
Evaluate a 2-D Hermite series on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * H_i(a) * H_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 Hermite series on the Cartesian product of x and y. | def hermgrid2d(x, y, c):
"""
Evaluate a 2-D Hermite series on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * H_i(a) * H_j(b)
where the points `(a, b)` consist of all pairs formed by taking
`a` from `x` and `b` from `y`. The resulti... | [
"def",
"hermgrid2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"hermval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
924,
0
] | [
974,
39
] | python | en | ['en', 'error', 'th'] | False |
hermval3d | (x, y, z, c) |
Evaluate a 3-D Hermite series at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * H_i(x) * H_j(y) * H_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 Hermite series at points (x, y, z). | def hermval3d(x, y, z, c):
"""
Evaluate a 3-D Hermite series at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * H_i(x) * H_j(y) * H_k(z)
The parameters `x`, `y`, and `z` are converted to arrays only if
they are tuples or a lists, otherwise th... | [
"def",
"hermval3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"hermval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
977,
0
] | [
1025,
41
] | python | en | ['en', 'error', 'th'] | False |
hermgrid3d | (x, y, z, c) |
Evaluate a 3-D Hermite 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} * H_i(a) * H_j(b) * H_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`. The ... |
Evaluate a 3-D Hermite series on the Cartesian product of x, y, and z. | def hermgrid3d(x, y, z, c):
"""
Evaluate a 3-D Hermite 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} * H_i(a) * H_j(b) * H_k(c)
where the points `(a, b, c)` consist of all triples formed by taking
`a` from `x`, `... | [
"def",
"hermgrid3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"hermval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
1028,
0
] | [
1081,
42
] | python | en | ['en', 'error', 'th'] | False |
hermvander | (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] = H_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 hermvander(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] = H_i(x),
where `0 <= i <= deg`. The leading indices of `V` index the elements of
... | [
"def",
"hermvander",
"(",
"x",
",",
"deg",
")",
":",
"ideg",
"=",
"pu",
".",
"_deprecate_as_int",
"(",
"deg",
",",
"\"deg\"",
")",
"if",
"ideg",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"deg must be non-negative\"",
")",
"x",
"=",
"np",
".",
"array... | [
1084,
0
] | [
1142,
32
] | python | ca | ['nl', 'ca', 'en'] | False |
hermvander2d | (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] = H_i(x) * H_j(y),
where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of
... | Pseudo-Vandermonde matrix of given degrees. | def hermvander2d(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] = H_i(x) * H_j(y),
where `0 <= i <= deg[0]` and `0 <= j <... | [
"def",
"hermvander2d",
"(",
"x",
",",
"y",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander2d",
"(",
"hermvander",
",",
"x",
",",
"y",
",",
"deg",
")"
] | [
1145,
0
] | [
1195,
46
] | python | ca | ['nl', 'ca', 'en'] | False |
hermvander3d | (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] = H_i(x)*H_j(y)*H_k(z),
wh... | Pseudo-Vandermonde matrix of given degrees. | def hermvander3d(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",
"hermvander3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander3d",
"(",
"hermvander",
",",
"x",
",",
"y",
",",
"z",
",",
"deg",
")"
] | [
1198,
0
] | [
1249,
49
] | python | ca | ['nl', 'ca', 'en'] | False |
hermfit | (x, y, deg, rcond=None, full=False, w=None) |
Least squares fit of Hermite series to data.
Return the coefficients of a Hermite 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 of ... |
Least squares fit of Hermite series to data. | def hermfit(x, y, deg, rcond=None, full=False, w=None):
"""
Least squares fit of Hermite series to data.
Return the coefficients of a Hermite 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... | [
"def",
"hermfit",
"(",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
"=",
"None",
",",
"full",
"=",
"False",
",",
"w",
"=",
"None",
")",
":",
"return",
"pu",
".",
"_fit",
"(",
"hermvander",
",",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
",",
"full"... | [
1252,
0
] | [
1376,
57
] | python | en | ['en', 'error', 'th'] | False |
hermcompanion | (c) | Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is
symmetric when `c` is an Hermite basis polynomial. This provides
better eigenvalue estimates than the unscaled case and for basis
polynomials the eigenvalues are guaranteed to be real if
`numpy... | Return the scaled companion matrix of c. | def hermcompanion(c):
"""Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is
symmetric when `c` is an Hermite basis polynomial. This provides
better eigenvalue estimates than the unscaled case and for basis
polynomials the eigenvalues are guaran... | [
"def",
"hermcompanion",
"(",
"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... | [
1379,
0
] | [
1421,
14
] | python | en | ['en', 'sm', 'en'] | True |
hermroots | (c) |
Compute the roots of a Hermite series.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * H_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 Hermite series. | def hermroots(c):
"""
Compute the roots of a Hermite series.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * H_i(x).
Parameters
----------
c : 1-D array_like
1-D array of coefficients.
Returns
-------
out : ndarray
Array of ... | [
"def",
"hermroots",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"if",
"len",
"(",
"c",
")",
"<=",
"1",
":",
"return",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
... | [
1424,
0
] | [
1481,
12
] | python | en | ['en', 'error', 'th'] | False |
_normed_hermite_n | (x, n) |
Evaluate a normalized Hermite polynomial.
Compute the value of the normalized Hermite polynomial of degree ``n``
at the points ``x``.
Parameters
----------
x : ndarray of double.
Points at which to evaluate the function
n : int
Degree of the normalized Hermite function to... |
Evaluate a normalized Hermite polynomial. | def _normed_hermite_n(x, n):
"""
Evaluate a normalized Hermite polynomial.
Compute the value of the normalized Hermite polynomial of degree ``n``
at the points ``x``.
Parameters
----------
x : ndarray of double.
Points at which to evaluate the function
n : int
Degree o... | [
"def",
"_normed_hermite_n",
"(",
"x",
",",
"n",
")",
":",
"if",
"n",
"==",
"0",
":",
"return",
"np",
".",
"full",
"(",
"x",
".",
"shape",
",",
"1",
"/",
"np",
".",
"sqrt",
"(",
"np",
".",
"sqrt",
"(",
"np",
".",
"pi",
")",
")",
")",
"c0",
... | [
1484,
0
] | [
1524,
31
] | python | en | ['en', 'error', 'th'] | False |
hermgauss | (deg) |
Gauss-Hermite quadrature.
Computes the sample points and weights for Gauss-Hermite quadrature.
These sample points and weights will correctly integrate polynomials of
degree :math:`2*deg - 1` or less over the interval :math:`[-\\inf, \\inf]`
with the weight function :math:`f(x) = \\exp(-x^2)`.
... |
Gauss-Hermite quadrature. | def hermgauss(deg):
"""
Gauss-Hermite quadrature.
Computes the sample points and weights for Gauss-Hermite quadrature.
These sample points and weights will correctly integrate polynomials of
degree :math:`2*deg - 1` or less over the interval :math:`[-\\inf, \\inf]`
with the weight function :mat... | [
"def",
"hermgauss",
"(",
"deg",
")",
":",
"ideg",
"=",
"pu",
".",
"_deprecate_as_int",
"(",
"deg",
",",
"\"deg\"",
")",
"if",
"ideg",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"deg must be a positive integer\"",
")",
"# first approximation of roots. We use the... | [
1527,
0
] | [
1591,
15
] | python | en | ['en', 'error', 'th'] | False |
hermweight | (x) |
Weight function of the Hermite polynomials.
The weight function is :math:`\\exp(-x^2)` and the interval of
integration is :math:`[-\\inf, \\inf]`. the Hermite polynomials are
orthogonal, but not normalized, with respect to this weight function.
Parameters
----------
x : array_like
... |
Weight function of the Hermite polynomials. | def hermweight(x):
"""
Weight function of the Hermite polynomials.
The weight function is :math:`\\exp(-x^2)` and the interval of
integration is :math:`[-\\inf, \\inf]`. the Hermite polynomials are
orthogonal, but not normalized, with respect to this weight function.
Parameters
----------
... | [
"def",
"hermweight",
"(",
"x",
")",
":",
"w",
"=",
"np",
".",
"exp",
"(",
"-",
"x",
"**",
"2",
")",
"return",
"w"
] | [
1594,
0
] | [
1619,
12
] | python | en | ['en', 'error', 'th'] | False |
test_grad_tracking_interval | (tmpdir, log_every_n_steps) | Test that gradient norms get tracked in the right interval and that everytime the same keys get logged. | Test that gradient norms get tracked in the right interval and that everytime the same keys get logged. | def test_grad_tracking_interval(tmpdir, log_every_n_steps):
""" Test that gradient norms get tracked in the right interval and that everytime the same keys get logged. """
trainer = Trainer(
default_root_dir=tmpdir,
track_grad_norm=2,
log_every_n_steps=log_every_n_steps,
max_step... | [
"def",
"test_grad_tracking_interval",
"(",
"tmpdir",
",",
"log_every_n_steps",
")",
":",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"track_grad_norm",
"=",
"2",
",",
"log_every_n_steps",
"=",
"log_every_n_steps",
",",
"max_steps",
"=",
... | [
94,
0
] | [
115,
82
] | python | en | ['en', 'en', 'en'] | True |
is_released | (config) | Return True if a released version of numpy is detected. | Return True if a released version of numpy is detected. | def is_released(config):
"""Return True if a released version of numpy is detected."""
from distutils.version import LooseVersion
v = config.get_version('../version.py')
if v is None:
raise ValueError("Could not get version")
pv = LooseVersion(vstring=v).version
if len(pv) > 3:
... | [
"def",
"is_released",
"(",
"config",
")",
":",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"v",
"=",
"config",
".",
"get_version",
"(",
"'../version.py'",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Could not get versio... | [
49,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
get_api_versions | (apiversion, codegen_dir) |
Return current C API checksum and the recorded checksum.
Return current C API checksum and the recorded checksum for the given
version of the C API version.
|
Return current C API checksum and the recorded checksum. | def get_api_versions(apiversion, codegen_dir):
"""
Return current C API checksum and the recorded checksum.
Return current C API checksum and the recorded checksum for the given
version of the C API version.
"""
# Compute the hash of the current API as defined in the .txt files in
# code_g... | [
"def",
"get_api_versions",
"(",
"apiversion",
",",
"codegen_dir",
")",
":",
"# Compute the hash of the current API as defined in the .txt files in",
"# code_generators",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"codegen_dir",
")",
"try",
":",
"m",
"=",
"__imp... | [
61,
0
] | [
80,
45
] | python | en | ['en', 'error', 'th'] | False |
check_api_version | (apiversion, codegen_dir) | Emits a MismatchCAPIWarning if the C API version needs updating. | Emits a MismatchCAPIWarning if the C API version needs updating. | def check_api_version(apiversion, codegen_dir):
"""Emits a MismatchCAPIWarning if the C API version needs updating."""
curapi_hash, api_hash = get_api_versions(apiversion, codegen_dir)
# If different hash, it means that the api .txt files in
# codegen_dir have been updated without the API version being... | [
"def",
"check_api_version",
"(",
"apiversion",
",",
"codegen_dir",
")",
":",
"curapi_hash",
",",
"api_hash",
"=",
"get_api_versions",
"(",
"apiversion",
",",
"codegen_dir",
")",
"# If different hash, it means that the api .txt files in",
"# codegen_dir have been updated without... | [
82,
0
] | [
101,
56
] | python | en | ['en', 'en', 'en'] | True |
pyod | (filename) | Python implementation of the od UNIX utility (od -b, more exactly).
Parameters
----------
filename : str
name of the file to get the dump from.
Returns
-------
out : seq
list of lines of od output
Note
----
We only implement enough to get the necessary information ... | Python implementation of the od UNIX utility (od -b, more exactly). | def pyod(filename):
"""Python implementation of the od UNIX utility (od -b, more exactly).
Parameters
----------
filename : str
name of the file to get the dump from.
Returns
-------
out : seq
list of lines of od output
Note
----
We only implement enough to get... | [
"def",
"pyod",
"(",
"filename",
")",
":",
"def",
"_pyod2",
"(",
")",
":",
"out",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fid",
":",
"yo",
"=",
"[",
"int",
"(",
"oct",
"(",
"int",
"(",
"binascii",
".",
"b2a_hex",... | [
296,
0
] | [
339,
23
] | python | en | ['en', 'en', 'en'] | True |
long_double_representation | (lines) | Given a binary dump as given by GNU od -b, look for long double
representation. | Given a binary dump as given by GNU od -b, look for long double
representation. | def long_double_representation(lines):
"""Given a binary dump as given by GNU od -b, look for long double
representation."""
# Read contains a list of 32 items, each item is a byte (in octal
# representation, as a string). We 'slide' over the output until read is of
# the form before_seq + content ... | [
"def",
"long_double_representation",
"(",
"lines",
")",
":",
"# Read contains a list of 32 items, each item is a byte (in octal",
"# representation, as a string). We 'slide' over the output until read is of",
"# the form before_seq + content + after_sequence, where content is the long double",
"# ... | [
361,
0
] | [
417,
63
] | python | en | ['en', 'en', 'en'] | True |
BoringModel.__init__ | (self) |
Testing PL Module
Use as follows:
- subclass
- modify the behavior for what you want
class TestModel(BaseTestModel):
def training_step(...):
# do your own thing
or:
model = BaseTestModel()
model.training_epoch_end = None
... |
Testing PL Module | def __init__(self):
"""
Testing PL Module
Use as follows:
- subclass
- modify the behavior for what you want
class TestModel(BaseTestModel):
def training_step(...):
# do your own thing
or:
model = BaseTestModel()
mod... | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"layer",
"=",
"torch",
".",
"nn",
".",
"Linear",
"(",
"32",
",",
"2",
")"
] | [
55,
4
] | [
74,
43
] | python | en | ['en', 'error', 'th'] | False |
test_cli_to_pass | (tmpdir, args=None) |
This test verify we can call function using test_cli name
|
This test verify we can call function using test_cli name
| def test_cli_to_pass(tmpdir, args=None):
"""
This test verify we can call function using test_cli name
"""
return '1' | [
"def",
"test_cli_to_pass",
"(",
"tmpdir",
",",
"args",
"=",
"None",
")",
":",
"return",
"'1'"
] | [
77,
0
] | [
81,
14
] | python | en | ['en', 'error', 'th'] | False |
test_torch_distributed_backend_env_variables | (tmpdir) |
This test set `undefined` as torch backend and should raise an `Backend.UNDEFINED` ValueError.
|
This test set `undefined` as torch backend and should raise an `Backend.UNDEFINED` ValueError.
| def test_torch_distributed_backend_env_variables(tmpdir):
"""
This test set `undefined` as torch backend and should raise an `Backend.UNDEFINED` ValueError.
"""
_environ = {"PL_TORCH_DISTRIBUTED_BACKEND": "undefined", "CUDA_VISIBLE_DEVICES": "0,1", "WORLD_SIZE": "2"}
with patch.dict(os.environ, _env... | [
"def",
"test_torch_distributed_backend_env_variables",
"(",
"tmpdir",
")",
":",
"_environ",
"=",
"{",
"\"PL_TORCH_DISTRIBUTED_BACKEND\"",
":",
"\"undefined\"",
",",
"\"CUDA_VISIBLE_DEVICES\"",
":",
"\"0,1\"",
",",
"\"WORLD_SIZE\"",
":",
"\"2\"",
"}",
"with",
"patch",
".... | [
86,
0
] | [
103,
30
] | python | en | ['en', 'error', 'th'] | False |
HandBaseDataset._get_mapping_id_name | (imgs) |
Args:
imgs (dict): dict of image info.
Returns:
tuple: Image name & id mapping dicts.
- id2name (dict): Mapping image id to name.
- name2id (dict): Mapping image name to id.
|
Args:
imgs (dict): dict of image info. | def _get_mapping_id_name(imgs):
"""
Args:
imgs (dict): dict of image info.
Returns:
tuple: Image name & id mapping dicts.
- id2name (dict): Mapping image id to name.
- name2id (dict): Mapping image name to id.
"""
id2name = {}
... | [
"def",
"_get_mapping_id_name",
"(",
"imgs",
")",
":",
"id2name",
"=",
"{",
"}",
"name2id",
"=",
"{",
"}",
"for",
"image_id",
",",
"image",
"in",
"imgs",
".",
"items",
"(",
")",
":",
"file_name",
"=",
"image",
"[",
"'file_name'",
"]",
"id2name",
"[",
... | [
65,
4
] | [
83,
31
] | python | en | ['en', 'error', 'th'] | False |
HandBaseDataset._xywh2cs | (self, x, y, w, h, padding=1.25) | This encodes bbox(x,y,w,w) into (center, scale)
Args:
x, y, w, h
Returns:
center (np.ndarray[float32](2,)): center of the bbox (x, y).
scale (np.ndarray[float32](2,)): scale of the bbox w & h.
| This encodes bbox(x,y,w,w) into (center, scale) | def _xywh2cs(self, x, y, w, h, padding=1.25):
"""This encodes bbox(x,y,w,w) into (center, scale)
Args:
x, y, w, h
Returns:
center (np.ndarray[float32](2,)): center of the bbox (x, y).
scale (np.ndarray[float32](2,)): scale of the bbox w & h.
"""
... | [
"def",
"_xywh2cs",
"(",
"self",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
",",
"padding",
"=",
"1.25",
")",
":",
"aspect_ratio",
"=",
"self",
".",
"ann_info",
"[",
"'image_size'",
"]",
"[",
"0",
"]",
"/",
"self",
".",
"ann_info",
"[",
"'image_size'",... | [
85,
4
] | [
112,
28
] | python | en | ['en', 'en', 'en'] | True |
HandBaseDataset._get_db | (self) | Load dataset. | Load dataset. | def _get_db(self):
"""Load dataset."""
raise NotImplementedError | [
"def",
"_get_db",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
115,
4
] | [
117,
33
] | python | da | ['es', 'da', 'it'] | False |
HandBaseDataset.evaluate | (self, cfg, preds, output_dir, *args, **kwargs) | Evaluate keypoint results. | Evaluate keypoint results. | def evaluate(self, cfg, preds, output_dir, *args, **kwargs):
"""Evaluate keypoint results."""
raise NotImplementedError | [
"def",
"evaluate",
"(",
"self",
",",
"cfg",
",",
"preds",
",",
"output_dir",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
120,
4
] | [
122,
33
] | python | en | ['en', 'en', 'en'] | True |
HandBaseDataset._write_keypoint_results | (keypoints, res_file) | Write results into a json file. | Write results into a json file. | def _write_keypoint_results(keypoints, res_file):
"""Write results into a json file."""
with open(res_file, 'w') as f:
json.dump(keypoints, f, sort_keys=True, indent=4) | [
"def",
"_write_keypoint_results",
"(",
"keypoints",
",",
"res_file",
")",
":",
"with",
"open",
"(",
"res_file",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"keypoints",
",",
"f",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
... | [
125,
4
] | [
129,
61
] | python | en | ['en', 'en', 'en'] | True |
HandBaseDataset._report_metric | (self,
res_file,
metrics,
pck_thr=0.2,
pckh_thr=0.7,
auc_nor=30) | Keypoint evaluation.
Args:
res_file (str): Json file stored prediction results.
metrics (str | list[str]): Metric to be performed.
Options: 'PCK', 'PCKh', 'AUC', 'EPE'.
pck_thr (float): PCK threshold, default as 0.2.
pckh_thr (float): PCKh thresho... | Keypoint evaluation. | def _report_metric(self,
res_file,
metrics,
pck_thr=0.2,
pckh_thr=0.7,
auc_nor=30):
"""Keypoint evaluation.
Args:
res_file (str): Json file stored prediction results.
... | [
"def",
"_report_metric",
"(",
"self",
",",
"res_file",
",",
"metrics",
",",
"pck_thr",
"=",
"0.2",
",",
"pckh_thr",
"=",
"0.7",
",",
"auc_nor",
"=",
"30",
")",
":",
"info_str",
"=",
"[",
"]",
"with",
"open",
"(",
"res_file",
",",
"'r'",
")",
"as",
... | [
131,
4
] | [
198,
23
] | python | en | ['fr', 'et', 'en'] | False |
HandBaseDataset.__len__ | (self) | Get the size of the dataset. | Get the size of the dataset. | def __len__(self):
"""Get the size of the dataset."""
return len(self.db) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"db",
")"
] | [
200,
4
] | [
202,
27
] | python | en | ['en', 'en', 'en'] | True |
HandBaseDataset.__getitem__ | (self, idx) | Get the sample given index. | Get the sample given index. | def __getitem__(self, idx):
"""Get the sample given index."""
results = copy.deepcopy(self.db[idx])
results['ann_info'] = self.ann_info
return self.pipeline(results) | [
"def",
"__getitem__",
"(",
"self",
",",
"idx",
")",
":",
"results",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"db",
"[",
"idx",
"]",
")",
"results",
"[",
"'ann_info'",
"]",
"=",
"self",
".",
"ann_info",
"return",
"self",
".",
"pipeline",
"(",
... | [
204,
4
] | [
208,
37
] | python | en | ['en', 'en', 'en'] | True |
_create_synth_kitti_dataset | (path_dir: str, image_dims: tuple = (1024, 512)) | Create synthetic dataset with random images, just to simulate that the dataset have been already downloaded. | Create synthetic dataset with random images, just to simulate that the dataset have been already downloaded. | def _create_synth_kitti_dataset(path_dir: str, image_dims: tuple = (1024, 512)):
"""Create synthetic dataset with random images, just to simulate that the dataset have been already downloaded."""
path_dir_images = os.path.join(path_dir, KITTI.IMAGE_PATH)
path_dir_masks = os.path.join(path_dir, KITTI.MASK_PA... | [
"def",
"_create_synth_kitti_dataset",
"(",
"path_dir",
":",
"str",
",",
"image_dims",
":",
"tuple",
"=",
"(",
"1024",
",",
"512",
")",
")",
":",
"path_dir_images",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path_dir",
",",
"KITTI",
".",
"IMAGE_PATH",
")"... | [
34,
0
] | [
44,
50
] | python | en | ['en', 'en', 'en'] | True |
KITTI.encode_segmap | (self, mask) |
Sets void classes to zero so they won't be considered for training
|
Sets void classes to zero so they won't be considered for training
| def encode_segmap(self, mask):
"""
Sets void classes to zero so they won't be considered for training
"""
for voidc in self.void_labels:
mask[mask == voidc] = self.ignore_index
for validc in self.valid_labels:
mask[mask == validc] = self.class_map[validc]
... | [
"def",
"encode_segmap",
"(",
"self",
",",
"mask",
")",
":",
"for",
"voidc",
"in",
"self",
".",
"void_labels",
":",
"mask",
"[",
"mask",
"==",
"voidc",
"]",
"=",
"self",
".",
"ignore_index",
"for",
"validc",
"in",
"self",
".",
"valid_labels",
":",
"mask... | [
128,
4
] | [
138,
19
] | python | en | ['en', 'error', 'th'] | False |
KITTI.get_filenames | (self, path) |
Returns a list of absolute paths to images inside given `path`
|
Returns a list of absolute paths to images inside given `path`
| def get_filenames(self, path):
"""
Returns a list of absolute paths to images inside given `path`
"""
files_list = list()
for filename in os.listdir(path):
files_list.append(os.path.join(path, filename))
return files_list | [
"def",
"get_filenames",
"(",
"self",
",",
"path",
")",
":",
"files_list",
"=",
"list",
"(",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"files_list",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",... | [
140,
4
] | [
147,
25
] | python | en | ['en', 'error', 'th'] | False |
test_state_decorator_nothing_passed | (tmpdir) | Test that state is not changed if nothing is passed to a decorator | Test that state is not changed if nothing is passed to a decorator | def test_state_decorator_nothing_passed(tmpdir):
""" Test that state is not changed if nothing is passed to a decorator"""
@trainer_state()
def test_method(self):
return self.state
trainer = Trainer(default_root_dir=tmpdir)
snapshot_state = test_method(trainer)
assert snapshot_state ... | [
"def",
"test_state_decorator_nothing_passed",
"(",
"tmpdir",
")",
":",
"@",
"trainer_state",
"(",
")",
"def",
"test_method",
"(",
"self",
")",
":",
"return",
"self",
".",
"state",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
")",
"snapsho... | [
38,
0
] | [
50,
53
] | python | en | ['en', 'en', 'en'] | True |
test_state_decorator_entering_only | (tmpdir) | Tests that state is set to entering inside a run function and restored to the previous value after. | Tests that state is set to entering inside a run function and restored to the previous value after. | def test_state_decorator_entering_only(tmpdir):
""" Tests that state is set to entering inside a run function and restored to the previous value after. """
@trainer_state(entering=TrainerState.RUNNING)
def test_method(self):
return self.state
trainer = Trainer(default_root_dir=tmpdir)
sna... | [
"def",
"test_state_decorator_entering_only",
"(",
"tmpdir",
")",
":",
"@",
"trainer_state",
"(",
"entering",
"=",
"TrainerState",
".",
"RUNNING",
")",
"def",
"test_method",
"(",
"self",
")",
":",
"return",
"self",
".",
"state",
"trainer",
"=",
"Trainer",
"(",
... | [
53,
0
] | [
65,
53
] | 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.