Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
64abd3e0
Commit
64abd3e0
authored
Jan 14, 2020
by
Lysandre
Committed by
Lysandre Debut
Jan 23, 2020
Browse files
Multi-line examples can be tested + ALBERT patch for CircleCI
All tests should now work fine.
parent
83757725
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
src/transformers/configuration_albert.py
src/transformers/configuration_albert.py
+2
-1
tests/test_examples.py
tests/test_examples.py
+3
-4
No files found.
src/transformers/configuration_albert.py
View file @
64abd3e0
...
@@ -79,6 +79,7 @@ class AlbertConfig(PretrainedConfig):
...
@@ -79,6 +79,7 @@ class AlbertConfig(PretrainedConfig):
Example::
Example::
from transformers import AlbertConfig, AlbertModel
# Initializing an ALBERT-xxlarge style configuration
# Initializing an ALBERT-xxlarge style configuration
albert_xxlarge_configuration = AlbertConfig()
albert_xxlarge_configuration = AlbertConfig()
...
@@ -90,7 +91,7 @@ class AlbertConfig(PretrainedConfig):
...
@@ -90,7 +91,7 @@ class AlbertConfig(PretrainedConfig):
)
)
# Initializing a model from the ALBERT-base style configuration
# Initializing a model from the ALBERT-base style configuration
model = AlbertModel(bert_
bas
e_configuration)
model = AlbertModel(
al
bert_
xxlarg
e_configuration)
# Accessing the model configuration
# Accessing the model configuration
configuration = model.config
configuration = model.config
...
...
tests/test_examples.py
View file @
64abd3e0
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
unittest
import
os
import
os
import
unittest
def
get_examples_from_file
(
file
):
def
get_examples_from_file
(
file
):
...
@@ -37,7 +37,7 @@ def get_examples_from_file(file):
...
@@ -37,7 +37,7 @@ def get_examples_from_file(file):
example_mode
=
True
example_mode
=
True
example_indentation
=
line
.
lower
().
find
(
"example::"
)
example_indentation
=
line
.
lower
().
find
(
"example::"
)
return
examples
return
[
'
\n
'
.
join
(
example
)
for
example
in
examples
]
class
TestCodeExamples
(
unittest
.
TestCase
):
class
TestCodeExamples
(
unittest
.
TestCase
):
...
@@ -51,8 +51,7 @@ class TestCodeExamples(unittest.TestCase):
...
@@ -51,8 +51,7 @@ class TestCodeExamples(unittest.TestCase):
print
(
"Testing"
,
configuration_file
,
str
(
len
(
examples
))
+
"/"
+
str
(
len
(
examples
)))
print
(
"Testing"
,
configuration_file
,
str
(
len
(
examples
))
+
"/"
+
str
(
len
(
examples
)))
def
execute_example
(
code_example
):
def
execute_example
(
code_example
):
for
line
in
code_example
:
exec
(
code_example
)
exec
(
line
)
with
self
.
subTest
(
msg
=
configuration_file
):
with
self
.
subTest
(
msg
=
configuration_file
):
[
execute_example
(
code_example
)
for
code_example
in
examples
]
[
execute_example
(
code_example
)
for
code_example
in
examples
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment