Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #224: Refactor the test file #234

Merged
merged 4 commits into from
Jun 27, 2019
Merged

Issue #224: Refactor the test file #234

merged 4 commits into from
Jun 27, 2019

Conversation

lalital
Copy link
Contributor

@lalital lalital commented Jun 23, 2019

According to issue #224, test cases were separated by package name. For example, all test cases belong to pythainlp.tokenize package will be grouped into one file, tests/test_tokenize.py.

As pythainlp has 11 packages, there are 11 test file (prefix: test_) including

  1. test_summarize.py
  2. test_transliterate.py
  3. test_corpus.py
  4. test_tag.py
  5. test_ulmfit.py (empty)
  6. test_soundex.py
  7. test_tokenize.py
  8. test_util.py
  9. test_spell.py
  10. test_tools.py (empty)
  11. test_word_vector.py

For the tests/__init__.py

# -*- coding: utf-8 -*-
"""
Unit test
"""
import sys
import unittest

sys.path.append('../pythainlp') # This line is to let all test files in 'tests/' access to pythainlp module

loader = unittest.TestLoader()  # Initiate a test loader
# Use discover feature to load files with prefix 'test_' in thte directory named tests
testSuite = loader.discover('tests') 
testRunner = unittest.TextTestRunner(verbosity=2)
testRunner.run(testSuite)

Command to run the unit test.

python -m unittest tests

Log result when running python -m unittest tests:

Using TensorFlow backend.
WARNING: Logging before flag parsing goes to stderr.
W0623 21:24:28.024565 4508587456 smart_open_lib.py:378] this function is deprecated, use smart_open.open instead
test_conceptnet (test_corpus.TestCorpusPackage) ... ok
test_corpus (test_corpus.TestCorpusPackage) ... Download: test
test 0.1
test.txt: 1.02kB [00:00, 5.25kB/s]                                                        
ok
test_tnc (test_corpus.TestCorpusPackage) ... ok
test_ttc (test_corpus.TestCorpusPackage) ... ok
test_wordnet (test_corpus.TestCorpusPackage) ... ok
test_soundex (test_soundex.TestSoundexPackage) ... ok
test_spell (test_spell.TestSpellPackage) ... ok
test_summarize (test_summarize.TestSummarizePackage) ... ok
test_ner (test_tag.TestTagPackage) ... ok
test_ner_locations (test_tag.TestTagPackage) ... ok
test_pos_tag (test_tag.TestTagPackage) ... ok
test_Tokenizer (test_tokenize.TestTokenizePackage) ... ok
test_dict_word_tokenize (test_tokenize.TestTokenizePackage) ... ok
test_etcc (test_tokenize.TestTokenizePackage) ... ok
test_sent_tokenize (test_tokenize.TestTokenizePackage) ... ok
test_subword_tokenize (test_tokenize.TestTokenizePackage) ... ok
test_syllable_tokenize (test_tokenize.TestTokenizePackage) ... ok
test_tcc (test_tokenize.TestTokenizePackage) ... ok
test_word_tokenize (test_tokenize.TestTokenizePackage) ... W0623 21:24:34.943847 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:74: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

W0623 21:24:34.981488 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0623 21:24:34.994447 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:4138: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.

W0623 21:24:35.023588 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:133: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.

W0623 21:24:35.032032 4508587456 deprecation.py:506] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
W0623 21:24:35.823905 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/optimizers.py:790: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

W0623 21:24:35.827678 4508587456 deprecation_wrapper.py:119] From /miniconda3/envs/haise/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3376: The name tf.log is deprecated. Please use tf.math.log instead.

W0623 21:24:35.831070 4508587456 deprecation.py:323] From /miniconda3/envs/haise/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py:180: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
2019-06-23 21:24:36.015942: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
ok
test_word_tokenize_deepcut (test_tokenize.TestTokenizePackage) ... ok
test_word_tokenize_icu (test_tokenize.TestTokenizePackage) ... ok
test_word_tokenize_longest (test_tokenize.TestTokenizePackage) ... ok
test_word_tokenize_mm (test_tokenize.TestTokenizePackage) ... ok
test_word_tokenize_newmm (test_tokenize.TestTokenizePackage) ... ok
test_romanize (test_transliterate.TestTransliteratePackage) ... ok
test_transliterate (test_transliterate.TestTransliteratePackage) ... ok
test_collate (test_util.TestUtilPackage) ... ok
test_countthai (test_util.TestUtilPackage) ... ok
test_date (test_util.TestUtilPackage) ... ok
test_deletetone (test_util.TestUtilPackage) ... ok
test_is_thaicheck (test_util.TestUtilPackage) ... ok
test_isthai (test_util.TestUtilPackage) ... ok
test_isthaichar (test_util.TestUtilPackage) ... ok
test_keyboard (test_util.TestUtilPackage) ... ok
test_keywords (test_util.TestUtilPackage) ... ok
test_normalize (test_util.TestUtilPackage) ... ok
test_number (test_util.TestUtilPackage) ... ok
test_rank (test_util.TestUtilPackage) ... ok
test_thai_strftime (test_util.TestUtilPackage) ... ok
test_thai2vec (test_word_vector.TestWordVectorPackage) ... /Users/arta/project/pythainlp/pythainlp/word_vector/__init__.py:103: RuntimeWarning: invalid value encountered in true_divide
  vec /= len(words)
/miniconda3/envs/haise/lib/python3.6/site-packages/gensim/models/keyedvectors.py:858: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
  vectors = vstack(self.word_vec(word, use_norm=True) for word in used_words).astype(REAL)
ok

----------------------------------------------------------------------
Ran 40 tests in 16.480s

OK

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

@pep8speaks
Copy link

Hello @artificiala! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 86:80: E501 line too long (83 > 79 characters)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.632% when pulling 15fafd4 on issue224_refactor_tests into a1899ef on dev.

@wannaphong wannaphong merged commit eb594f9 into dev Jun 27, 2019
@bact bact deleted the issue224_refactor_tests branch September 7, 2019 22:05
@bact bact added the refactoring a technical improvement which does not add any new features or change existing features. label Oct 29, 2019
@bact bact added this to Done in PyThaiNLP Oct 29, 2019
@bact bact added this to the 2.1 milestone Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring a technical improvement which does not add any new features or change existing features.
Projects
PyThaiNLP
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants