Faster co-occurence vectorization

The goal of this notebook is to write a faster way to implement the co-ocurence matrix vectorizer. To begin, let's write a toy tokenizer.


In [1]:
tokenizer = lambda txt: txt.split(' ')

tokenizer("Say hello to faster vectorisation !")


Out[1]:
['Say', 'hello', 'to', 'faster', 'vectorisation', '!']

Now we will import a larger text...


In [2]:
from urllib.request import urlopen

# Uses only demonstration, the text is not cleaned (with a copyright message...).
test_tokens = tokenizer(str(urlopen('http://www.gutenberg.org/cache/epub/1777/pg1777.txt').read()))

Let's run the new vectorizer into a CProfiler.


In [3]:
import cProfile

cProfile.run("""
from scipy import sparse as S
import numpy as np

vocabulary = sorted(set(test_tokens))
len_vocabulary = len(vocabulary)

voc_indices = [vocabulary.index(word) for word in test_tokens]
len_document = len(test_tokens)
cooc_matrix = S.lil_matrix((len_vocabulary, len_vocabulary))

window_size = 5

for word_pos, row_index in enumerate(voc_indices):
    window = voc_indices[max(0, word_pos - window_size) : word_pos] +\
             voc_indices[word_pos+1 : min(len_document+1, word_pos+1+window_size)]
    
    for col_index in window:
        cooc_matrix[row_index, col_index] += 1    
""")


         6458352 function calls (6456243 primitive calls) in 6.546 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        8    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:1043(__import__)
      372    0.001    0.000    0.001    0.000 <frozen importlib._bootstrap>:119(release)
      168    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:159(__init__)
      168    0.000    0.000    0.003    0.000 <frozen importlib._bootstrap>:163(__enter__)
      168    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap>:170(__exit__)
      372    0.001    0.000    0.002    0.000 <frozen importlib._bootstrap>:176(_get_module_lock)
      171    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:190(cb)
      204    0.001    0.000    0.002    0.000 <frozen importlib._bootstrap>:195(_lock_unlock_module)
    204/2    0.000    0.000    0.135    0.068 <frozen importlib._bootstrap>:214(_call_with_frames_removed)
      131    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:225(_verbose_message)
      131    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:310(__init__)
      131    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:314(__enter__)
      131    0.002    0.000    0.003    0.000 <frozen importlib._bootstrap>:321(__exit__)
      524    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:324(<genexpr>)
      117    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:35(_new_module)
      150    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:372(__init__)
      248    0.000    0.000    0.003    0.000 <frozen importlib._bootstrap>:406(cached)
      131    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:419(parent)
      131    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:427(has_location)
      131    0.001    0.000    0.005    0.000 <frozen importlib._bootstrap>:510(_init_module_attrs)
  131/129    0.001    0.000    0.033    0.000 <frozen importlib._bootstrap>:570(module_from_spec)
    131/2    0.001    0.000    0.136    0.068 <frozen importlib._bootstrap>:659(_load_unlocked)
      150    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:716(find_spec)
      171    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap>:74(__init__)
      150    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:789(find_spec)
      507    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:852(__enter__)
      507    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:856(__exit__)
       57    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:870(_find_spec_legacy)
      150    0.002    0.000    0.020    0.000 <frozen importlib._bootstrap>:879(_find_spec)
       16    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:919(_sanity_check)
    168/2    0.001    0.000    0.137    0.068 <frozen importlib._bootstrap>:939(_find_and_load_unlocked)
      372    0.001    0.000    0.001    0.000 <frozen importlib._bootstrap>:94(acquire)
    168/2    0.002    0.000    0.137    0.068 <frozen importlib._bootstrap>:966(_find_and_load)
       16    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap>:972(_gcd_import)
   807/45    0.001    0.000    0.128    0.003 <frozen importlib._bootstrap>:996(_handle_fromlist)
       17    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:1047(_path_hooks)
      164    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:1064(_path_importer_cache)
      150    0.001    0.000    0.016    0.000 <frozen importlib._bootstrap_external>:1101(_get_spec)
      150    0.000    0.000    0.016    0.000 <frozen importlib._bootstrap_external>:1133(find_spec)
       17    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:1178(__init__)
      136    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:1184(<genexpr>)
      131    0.000    0.000    0.002    0.000 <frozen importlib._bootstrap_external>:1210(_get_spec)
      161    0.003    0.000    0.014    0.000 <frozen importlib._bootstrap_external>:1215(find_spec)
       17    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:1260(_fill_cache)
       17    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:1301(path_hook_for_FileFinder)
      234    0.001    0.000    0.003    0.000 <frozen importlib._bootstrap_external>:246(cache_from_source)
      161    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:34(_relax_case)
      131    0.000    0.000    0.002    0.000 <frozen importlib._bootstrap_external>:342(_get_cached)
      826    0.001    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:366(_verbose_message)
      117    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:382(_check_name_wrapper)
      117    0.002    0.000    0.003    0.000 <frozen importlib._bootstrap_external>:419(_validate_bytecode_header)
      234    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:45(_r_long)
      117    0.002    0.000    0.022    0.000 <frozen importlib._bootstrap_external>:474(_compile_bytecode)
      883    0.002    0.000    0.004    0.000 <frozen importlib._bootstrap_external>:50(_path_join)
      131    0.001    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:513(spec_from_file_location)
      883    0.001    0.000    0.002    0.000 <frozen importlib._bootstrap_external>:52(<listcomp>)
      234    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:56(_path_split)
      117    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:656(create_module)
    117/2    0.001    0.000    0.136    0.068 <frozen importlib._bootstrap_external>:659(exec_module)
      477    0.000    0.000    0.005    0.000 <frozen importlib._bootstrap_external>:68(_path_stat)
      117    0.002    0.000    0.034    0.000 <frozen importlib._bootstrap_external>:729(get_code)
      199    0.000    0.000    0.002    0.000 <frozen importlib._bootstrap_external>:78(_path_is_mode_type)
      117    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:786(__init__)
      117    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:811(get_filename)
      117    0.003    0.000    0.005    0.000 <frozen importlib._bootstrap_external>:816(get_data)
      117    0.000    0.000    0.001    0.000 <frozen importlib._bootstrap_external>:826(path_stats)
      182    0.000    0.000    0.002    0.000 <frozen importlib._bootstrap_external>:87(_path_isfile)
       14    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:892(__init__)
    14/13    0.000    0.000    0.027    0.002 <frozen importlib._bootstrap_external>:903(create_module)
       14    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:911(exec_module)
       17    0.000    0.000    0.000    0.000 <frozen importlib._bootstrap_external>:92(_path_isdir)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.699    0.699    6.545    6.545 <string>:2(<module>)
        1    0.000    0.000    0.000    0.000 <string>:5(ArgSpec)
        1    0.000    0.000    0.000    0.000 <string>:5(Mismatch)
        1    0.000    0.000    0.000    0.000 <string>:5(_LoggingWatcher)
        1    0.013    0.013    2.004    2.004 <string>:8(<listcomp>)
        2    0.000    0.000    0.000    0.000 __config__.py:3(<module>)
        4    0.001    0.000    0.119    0.030 __init__.py:1(<module>)
        1    0.000    0.000    0.001    0.001 __init__.py:10(<module>)
        1    0.000    0.000    0.101    0.101 __init__.py:106(<module>)
        1    0.000    0.000    0.000    0.000 __init__.py:11(<module>)
        1    0.000    0.000    0.007    0.007 __init__.py:134(<module>)
        1    0.000    0.000    0.006    0.006 __init__.py:15(<module>)
        1    0.000    0.000    0.028    0.028 __init__.py:220(<module>)
       19    0.000    0.000    0.000    0.000 __init__.py:23(find_module)
        1    0.000    0.000    0.000    0.000 __init__.py:245(<listcomp>)
        1    0.000    0.000    0.001    0.001 __init__.py:3(<module>)
        3    0.000    0.000    0.003    0.001 __init__.py:356(namedtuple)
        1    0.000    0.000    0.007    0.007 __init__.py:41(<module>)
       12    0.000    0.000    0.000    0.000 __init__.py:419(<genexpr>)
       12    0.000    0.000    0.000    0.000 __init__.py:421(<genexpr>)
        2    0.000    0.000    0.012    0.006 __init__.py:45(<module>)
        4    0.000    0.000    0.000    0.000 __init__.py:483(cast)
        1    0.000    0.000    0.107    0.107 __init__.py:56(<module>)
        1    0.000    0.000    0.015    0.015 __init__.py:7(<module>)
        5    0.000    0.000    0.000    0.000 __init__.py:73(CFUNCTYPE)
        1    0.000    0.000    0.003    0.003 __init__.py:88(<module>)
        5    0.000    0.000    0.000    0.000 __init__.py:99(CFunctionType)
        1    0.000    0.000    0.001    0.001 _ccallback.py:1(<module>)
        1    0.000    0.000    0.000    0.000 _ccallback.py:26(LowLevelCallable)
        1    0.000    0.000    0.000    0.000 _ccallback.py:9(CData)
        1    0.000    0.000    0.000    0.000 _collections_abc.py:592(get)
        2    0.000    0.000    0.000    0.000 _collections_abc.py:599(__contains__)
        1    0.000    0.000    0.000    0.000 _components.py:1(<module>)
        1    0.000    0.000    0.000    0.000 _datasource.py:136(_FileOpeners)
        1    0.000    0.000    0.000    0.000 _datasource.py:160(__init__)
        1    0.000    0.000    0.000    0.000 _datasource.py:263(DataSource)
        1    0.000    0.000    0.000    0.000 _datasource.py:35(<module>)
        1    0.000    0.000    0.000    0.000 _datasource.py:619(Repository)
        1    0.000    0.000    0.000    0.000 _distributor_init.py:10(<module>)
        1    0.000    0.000    0.000    0.000 _globals.py:17(<module>)
        1    0.000    0.000    0.000    0.000 _globals.py:33(ModuleDeprecationWarning)
        1    0.000    0.000    0.000    0.000 _globals.py:45(VisibleDeprecationWarning)
        1    0.000    0.000    0.000    0.000 _globals.py:56(_NoValue)
        1    0.000    0.000    0.000    0.000 _import_tools.py:1(<module>)
        1    0.000    0.000    0.000    0.000 _import_tools.py:339(PackageLoaderDebug)
        1    0.000    0.000    0.000    0.000 _import_tools.py:9(PackageLoader)
       98    0.000    0.000    0.000    0.000 _inspect.py:133(strseq)
       38    0.000    0.000    0.000    0.000 _inspect.py:142(formatargspec)
        7    0.000    0.000    0.000    0.000 _inspect.py:144(<lambda>)
        5    0.000    0.000    0.000    0.000 _inspect.py:145(<lambda>)
       60    0.000    0.000    0.000    0.000 _inspect.py:146(<lambda>)
       43    0.000    0.000    0.000    0.000 _inspect.py:15(ismethod)
       43    0.000    0.000    0.000    0.000 _inspect.py:28(isfunction)
       38    0.000    0.000    0.000    0.000 _inspect.py:43(iscode)
       38    0.000    0.000    0.000    0.000 _inspect.py:67(getargs)
        1    0.000    0.000    0.000    0.000 _inspect.py:7(<module>)
       43    0.000    0.000    0.000    0.000 _inspect.py:98(getargspec)
        1    0.000    0.000    0.000    0.000 _internal.py:204(dummy_ctype)
        1    0.000    0.000    0.000    0.000 _internal.py:216(_getintp_ctype)
        1    0.000    0.000    0.000    0.000 _internal.py:239(_missing_ctypes)
        1    0.000    0.000    0.000    0.000 _internal.py:246(_ctypes)
        1    0.000    0.000    0.006    0.006 _internal.py:6(<module>)
        1    0.000    0.000    0.000    0.000 _internal.py:683(TooHardError)
        1    0.000    0.000    0.000    0.000 _internal.py:686(AxisError)
       51    0.000    0.000    0.000    0.000 _internal.py:715(_ufunc_doc_signature_formatter)
       78    0.000    0.000    0.000    0.000 _internal.py:726(<genexpr>)
        1    0.000    0.000    0.000    0.000 _iotools.py:170(LineSplitter)
        1    0.000    0.000    0.000    0.000 _iotools.py:266(NameValidator)
        1    0.000    0.000    0.000    0.000 _iotools.py:3(<module>)
        1    0.000    0.000    0.000    0.000 _iotools.py:460(ConverterError)
        1    0.000    0.000    0.000    0.000 _iotools.py:468(ConverterLockError)
        1    0.000    0.000    0.000    0.000 _iotools.py:476(ConversionWarning)
        1    0.000    0.000    0.000    0.000 _iotools.py:489(StringConverter)
        1    0.000    0.000    0.000    0.000 _laplacian.py:3(<module>)
        1    0.000    0.000    0.000    0.000 _matrix_io.py:1(<module>)
        1    0.000    0.000    0.000    0.000 _methods.py:5(<module>)
        1    0.000    0.000    0.000    0.000 _polybase.py:19(ABCPolyBase)
        1    0.000    0.000    0.000    0.000 _polybase.py:8(<module>)
        1    0.000    0.000    0.001    0.001 _util.py:1(<module>)
        1    0.000    0.000    0.000    0.000 _util.py:138(DeprecatedImport)
        1    0.000    0.000    0.001    0.001 _validation.py:1(<module>)
        2    0.000    0.000    0.000    0.000 _version.py:114(_compare)
        1    0.000    0.000    0.000    0.000 _version.py:136(__lt__)
        1    0.000    0.000    0.000    0.000 _version.py:151(__ge__)
        1    0.000    0.000    0.000    0.000 _version.py:17(NumpyVersion)
        1    0.000    0.000    0.000    0.000 _version.py:18(NumpyVersion)
        4    0.000    0.000    0.001    0.000 _version.py:55(__init__)
        4    0.000    0.000    0.000    0.000 _version.py:62(<listcomp>)
        2    0.000    0.000    0.001    0.000 _version.py:7(<module>)
        2    0.000    0.000    0.000    0.000 _version.py:78(_compare_version)
       13    0.000    0.000    0.000    0.000 _weakrefset.py:16(__init__)
       13    0.000    0.000    0.000    0.000 _weakrefset.py:20(__enter__)
       13    0.000    0.000    0.000    0.000 _weakrefset.py:26(__exit__)
       12    0.000    0.000    0.000    0.000 _weakrefset.py:36(__init__)
       13    0.000    0.000    0.000    0.000 _weakrefset.py:52(_commit_removals)
       28    0.000    0.000    0.000    0.000 _weakrefset.py:58(__iter__)
       14    0.000    0.000    0.000    0.000 _weakrefset.py:70(__contains__)
       17    0.000    0.000    0.000    0.000 _weakrefset.py:81(add)
        4    0.000    0.000    0.000    0.000 abc.py:151(register)
     13/4    0.000    0.000    0.000    0.000 abc.py:194(__subclasscheck__)
       12    0.000    0.000    0.000    0.000 abc.py:9(abstractmethod)
        1    0.000    0.000    0.075    0.075 add_newdocs.py:10(<module>)
        1    0.000    0.000    0.000    0.000 arraypad.py:5(<module>)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1068(IntegerFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1081(BoolFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1091(ComplexFloatingFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1120(ComplexFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1127(LongComplexFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1135(_TimelikeFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1161(DatetimeFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1193(TimedeltaFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1198(SubArrayFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1208(StructuredVoidFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:1245(StructureFormat)
        2    0.000    0.000    0.000    0.000 arrayprint.py:1465(set_string_function)
        2    0.000    0.000    0.000    0.000 arrayprint.py:406(_recursive_guard)
        2    0.000    0.000    0.000    0.000 arrayprint.py:416(decorating_function)
        1    0.000    0.000    0.001    0.001 arrayprint.py:5(<module>)
        1    0.000    0.000    0.000    0.000 arrayprint.py:771(FloatingFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:914(FloatFormat)
        1    0.000    0.000    0.000    0.000 arrayprint.py:921(LongFloatFormat)
        1    0.000    0.000    0.000    0.000 arraysetops.py:27(<module>)
        1    0.000    0.000    0.000    0.000 arrayterator.py:20(Arrayterator)
        1    0.000    0.000    0.000    0.000 arrayterator.py:9(<module>)
        1    0.000    0.000    0.002    0.002 base.py:1(<module>)
  1575440    0.221    0.000    0.221    0.000 base.py:100(get_shape)
        1    0.000    0.000    0.000    0.000 base.py:1111(isspmatrix)
        1    0.000    0.000    0.000    0.000 base.py:16(SparseWarning)
        1    0.000    0.000    0.000    0.000 base.py:20(SparseFormatWarning)
        1    0.000    0.000    0.000    0.000 base.py:24(SparseEfficiencyWarning)
        1    0.000    0.000    0.000    0.000 base.py:62(spmatrix)
        1    0.000    0.000    0.000    0.000 base.py:70(__init__)
        1    0.000    0.000    0.000    0.000 bsr.py:1(<module>)
        1    0.000    0.000    0.000    0.000 bsr.py:22(bsr_matrix)
        1    0.000    0.000    0.002    0.002 case.py:1(<module>)
        1    0.000    0.000    0.000    0.000 case.py:127(_BaseTestCaseContext)
       10    0.000    0.000    0.000    0.000 case.py:1306(_deprecate)
        1    0.000    0.000    0.000    0.000 case.py:1328(FunctionTestCase)
        1    0.000    0.000    0.000    0.000 case.py:136(_AssertRaisesBaseContext)
        1    0.000    0.000    0.000    0.000 case.py:1386(_SubTest)
        1    0.000    0.000    0.000    0.000 case.py:179(_AssertRaisesContext)
        1    0.000    0.000    0.000    0.000 case.py:216(_AssertWarnsContext)
        1    0.000    0.000    0.000    0.000 case.py:24(SkipTest)
        1    0.000    0.000    0.000    0.000 case.py:273(_CapturingHandler)
        1    0.000    0.000    0.000    0.000 case.py:292(_AssertLogsContext)
        1    0.000    0.000    0.000    0.000 case.py:32(_ShouldStop)
        1    0.000    0.000    0.000    0.000 case.py:336(TestCase)
        1    0.000    0.000    0.000    0.000 case.py:37(_UnexpectedSuccess)
        1    0.000    0.000    0.000    0.000 case.py:43(_Outcome)
        1    0.000    0.000    0.000    0.000 chebyshev.py:2109(Chebyshev)
        1    0.000    0.000    0.000    0.000 chebyshev.py:88(<module>)
        1    0.000    0.000    0.002    0.002 compressed.py:1(<module>)
        1    0.000    0.000    0.000    0.000 compressed.py:22(_cs_matrix)
        1    0.000    0.000    0.000    0.000 construct.py:2(<module>)
        6    0.000    0.000    0.000    0.000 contextlib.py:103(contextmanager)
        1    0.000    0.000    0.000    0.000 coo.py:1(<module>)
        1    0.000    0.000    0.000    0.000 coo.py:21(coo_matrix)
        1    0.000    0.000    0.000    0.000 copyreg.py:12(pickle)
        1    0.000    0.000    0.000    0.000 copyreg.py:22(constructor)
        1    0.000    0.000    0.000    0.000 core.py:1122(_DomainedBinaryOperation)
        6    0.000    0.000    0.000    0.000 core.py:1143(__init__)
        4    0.000    0.000    0.000    0.000 core.py:125(doc_note)
        3    0.000    0.000    0.000    0.000 core.py:1360(getmask)
       43    0.000    0.000    0.001    0.000 core.py:150(get_object_signature)
        1    0.000    0.000    0.000    0.000 core.py:167(MAError)
        1    0.000    0.000    0.000    0.000 core.py:175(MaskError)
        1    0.000    0.000    0.000    0.000 core.py:207(<listcomp>)
        1    0.000    0.000    0.000    0.000 core.py:209(<listcomp>)
        1    0.001    0.001    0.003    0.003 core.py:21(<module>)
        1    0.000    0.000    0.000    0.000 core.py:2374(_MaskedPrintOption)
        1    0.000    0.000    0.000    0.000 core.py:2380(__init__)
        8    0.000    0.000    0.000    0.000 core.py:2547(_arraymethod)
        1    0.000    0.000    0.000    0.000 core.py:2592(MaskedIterator)
        1    0.000    0.000    0.000    0.000 core.py:2706(MaskedArray)
        1    0.000    0.000    0.000    0.000 core.py:2771(__new__)
        2    0.000    0.000    0.000    0.000 core.py:2908(_update_from)
        2    0.000    0.000    0.000    0.000 core.py:2934(__array_finalize__)
        1    0.000    0.000    0.000    0.000 core.py:3064(view)
        7    0.000    0.000    0.000    0.000 core.py:3372(__setattr__)
        1    0.000    0.000    0.000    0.000 core.py:6058(mvoid)
        1    0.000    0.000    0.000    0.000 core.py:6254(MaskedConstant)
        2    0.000    0.000    0.000    0.000 core.py:6258(__has_singleton)
        1    0.000    0.000    0.000    0.000 core.py:6264(__new__)
        1    0.000    0.000    0.000    0.000 core.py:6282(__array_finalize__)
        1    0.000    0.000    0.000    0.000 core.py:6420(_extrema_operation)
        2    0.000    0.000    0.000    0.000 core.py:6429(__init__)
        1    0.000    0.000    0.000    0.000 core.py:6539(_frommethod)
       26    0.000    0.000    0.001    0.000 core.py:6550(__init__)
       26    0.000    0.000    0.001    0.000 core.py:6555(getdoc)
        1    0.000    0.000    0.000    0.000 core.py:794(_DomainCheckInterval)
        1    0.000    0.000    0.000    0.000 core.py:8015(_convert2ma)
        8    0.000    0.000    0.000    0.000 core.py:8028(__init__)
        3    0.000    0.000    0.000    0.000 core.py:803(__init__)
        8    0.000    0.000    0.000    0.000 core.py:8033(getdoc)
        1    0.000    0.000    0.000    0.000 core.py:819(_DomainTan)
        1    0.000    0.000    0.000    0.000 core.py:827(__init__)
        1    0.000    0.000    0.000    0.000 core.py:837(_DomainSafeDivide)
        6    0.000    0.000    0.000    0.000 core.py:843(__init__)
        1    0.000    0.000    0.000    0.000 core.py:858(_DomainGreater)
        3    0.000    0.000    0.000    0.000 core.py:864(__init__)
        1    0.000    0.000    0.000    0.000 core.py:874(_DomainGreaterEqual)
        2    0.000    0.000    0.000    0.000 core.py:880(__init__)
        1    0.000    0.000    0.000    0.000 core.py:890(_MaskedUFunc)
       53    0.000    0.000    0.001    0.000 core.py:891(__init__)
        1    0.000    0.000    0.000    0.000 core.py:900(_MaskedUnaryOperation)
       27    0.000    0.000    0.000    0.000 core.py:918(__init__)
        1    0.000    0.000    0.000    0.000 core.py:94(MaskedArrayFutureWarning)
        1    0.000    0.000    0.000    0.000 core.py:974(_MaskedBinaryOperation)
       18    0.000    0.000    0.000    0.000 core.py:994(__init__)
        1    0.000    0.000    0.000    0.000 csc.py:1(<module>)
        1    0.000    0.000    0.000    0.000 csc.py:20(csc_matrix)
        1    0.000    0.000    0.009    0.009 csr.py:1(<module>)
        1    0.000    0.000    0.000    0.000 csr.py:23(csr_matrix)
        1    0.000    0.000    0.000    0.000 ctypeslib.py:177(_ndptr)
       12    0.000    0.000    0.000    0.000 ctypeslib.py:331(prep_simple)
        1    0.000    0.000    0.000    0.000 ctypeslib.py:51(<module>)
       18    0.000    0.000    0.000    0.000 data.py:117(_create_method)
        1    0.000    0.000    0.000    0.000 data.py:144(_minmax_mixin)
        1    0.000    0.000    0.000    0.000 data.py:21(_data_matrix)
        1    0.000    0.000    0.000    0.000 data.py:7(<module>)
        1    0.000    0.000    0.003    0.003 decorators.py:15(<module>)
        1    0.000    0.000    0.004    0.004 decorators.py:5(<module>)
        1    0.000    0.000    0.000    0.000 defchararray.py:1669(chararray)
        1    0.000    0.000    0.000    0.000 defchararray.py:17(<module>)
        1    0.000    0.000    0.000    0.000 defmatrix.py:1(<module>)
        1    0.000    0.000    0.000    0.000 defmatrix.py:174(matrix)
        1    0.000    0.000    0.000    0.000 dia.py:1(<module>)
        1    0.000    0.000    0.000    0.000 dia.py:18(dia_matrix)
        1    0.000    0.000    0.000    0.000 dok.py:1(<module>)
        1    0.000    0.000    0.000    0.000 dok.py:28(dok_matrix)
        1    0.000    0.000    0.000    0.000 einsumfunc.py:4(<module>)
        1    0.000    0.000    0.000    0.000 extract.py:2(<module>)
        1    0.000    0.000    0.001    0.001 extras.py:10(<module>)
        1    0.000    0.000    0.000    0.000 extras.py:1453(MAxisConcatenator)
        1    0.000    0.000    0.000    0.000 extras.py:1478(mr_class)
        1    0.000    0.000    0.000    0.000 extras.py:1494(__init__)
        1    0.000    0.000    0.000    0.000 extras.py:218(_fromnxfunction)
        9    0.000    0.000    0.000    0.000 extras.py:238(__init__)
        9    0.000    0.000    0.000    0.000 extras.py:242(getdoc)
        1    0.000    0.000    0.000    0.000 extras.py:273(_fromnxfunction_single)
        1    0.000    0.000    0.000    0.000 extras.py:291(_fromnxfunction_seq)
        1    0.000    0.000    0.000    0.000 extras.py:304(_fromnxfunction_args)
        1    0.000    0.000    0.000    0.000 extras.py:329(_fromnxfunction_allargs)
        1    0.000    0.000    0.001    0.001 fftpack.py:32(<module>)
        1    0.000    0.000    0.000    0.000 financial.py:12(<module>)
        1    0.000    0.000    0.000    0.000 format.py:149(<module>)
        2    0.000    0.000    0.000    0.000 fromnumeric.py:2632(ndim)
        1    0.000    0.000    0.001    0.001 fromnumeric.py:3(<module>)
        2    0.000    0.000    0.004    0.002 function_base.py:1(<module>)
        1    0.000    0.000    0.000    0.000 function_base.py:2543(vectorize)
      278    0.001    0.000    0.003    0.000 function_base.py:4533(add_newdoc)
       14    0.000    0.000    0.000    0.000 functools.py:43(update_wrapper)
       14    0.000    0.000    0.000    0.000 functools.py:73(wraps)
       30    0.000    0.000    0.000    0.000 getlimits.py:26(_fr1)
        1    0.000    0.000    0.001    0.001 getlimits.py:3(<module>)
        1    0.000    0.000    0.000    0.000 getlimits.py:305(finfo)
        1    0.000    0.000    0.000    0.000 getlimits.py:455(iinfo)
        5    0.000    0.000    0.000    0.000 getlimits.py:507(__init__)
        2    0.000    0.000    0.000    0.000 getlimits.py:532(max)
        1    0.000    0.000    0.000    0.000 getlimits.py:62(MachArLike)
        6    0.000    0.000    0.000    0.000 getlimits.py:65(__init__)
       36    0.000    0.000    0.000    0.000 getlimits.py:69(<lambda>)
       30    0.000    0.000    0.000    0.000 getlimits.py:70(<lambda>)
        1    0.000    0.000    0.000    0.000 helper.py:230(_FFTCache)
        2    0.000    0.000    0.000    0.000 helper.py:251(__init__)
        1    0.000    0.000    0.000    0.000 helper.py:4(<module>)
        1    0.000    0.000    0.000    0.000 hermite.py:1814(Hermite)
        1    0.000    0.000    0.000    0.000 hermite.py:59(<module>)
        1    0.000    0.000    0.000    0.000 hermite_e.py:1811(HermiteE)
        1    0.000    0.000    0.000    0.000 hermite_e.py:59(<module>)
        1    0.000    0.000    0.008    0.008 index_tricks.py:1(<module>)
        2    0.000    0.000    0.000    0.000 index_tricks.py:159(__init__)
        1    0.000    0.000    0.000    0.000 index_tricks.py:231(AxisConcatenator)
        3    0.000    0.000    0.000    0.000 index_tricks.py:241(__init__)
        1    0.000    0.000    0.000    0.000 index_tricks.py:356(RClass)
        1    0.000    0.000    0.000    0.000 index_tricks.py:451(__init__)
        1    0.000    0.000    0.000    0.000 index_tricks.py:456(CClass)
        1    0.000    0.000    0.000    0.000 index_tricks.py:481(__init__)
        1    0.000    0.000    0.000    0.000 index_tricks.py:486(ndenumerate)
        1    0.000    0.000    0.000    0.000 index_tricks.py:536(ndindex)
        1    0.000    0.000    0.000    0.000 index_tricks.py:614(IndexExpression)
        2    0.000    0.000    0.000    0.000 index_tricks.py:658(__init__)
        1    0.000    0.000    0.000    0.000 index_tricks.py:98(nd_grid)
        1    0.000    0.000    0.000    0.000 info.py:156(<module>)
        1    0.000    0.000    0.000    0.000 info.py:184(<module>)
        1    0.000    0.000    0.000    0.000 info.py:34(<module>)
        1    0.000    0.000    0.000    0.000 info.py:83(<module>)
        1    0.000    0.000    0.000    0.000 info.py:86(<module>)
        1    0.000    0.000    0.000    0.000 laguerre.py:1764(Laguerre)
        1    0.000    0.000    0.000    0.000 laguerre.py:59(<module>)
        1    0.000    0.000    0.000    0.000 legendre.py:1794(Legendre)
        1    0.000    0.000    0.000    0.000 legendre.py:83(<module>)
        1    0.000    0.000    0.000    0.000 lil.py:130(set_shape)
        1    0.000    0.000    0.000    0.000 lil.py:19(lil_matrix)
        1    0.000    0.000    0.002    0.002 lil.py:2(<module>)
   393860    0.918    0.000    1.743    0.000 lil.py:240(__getitem__)
   393860    0.942    0.000    1.927    0.000 lil.py:333(__setitem__)
        1    0.005    0.005    0.005    0.005 lil.py:84(__init__)
        1    0.000    0.000    0.002    0.002 linalg.py:10(<module>)
        1    0.000    0.000    0.000    0.000 linalg.py:44(LinAlgError)
        1    0.000    0.000    0.000    0.000 linalg.py:74(_determine_error_states)
        1    0.000    0.000    0.001    0.001 loader.py:1(<module>)
        1    0.000    0.000    0.000    0.000 loader.py:23(_FailedTest)
        1    0.000    0.000    0.000    0.000 loader.py:66(TestLoader)
        1    0.000    0.000    0.000    0.000 loader.py:76(__init__)
        1    0.000    0.000    0.000    0.000 machar.py:17(MachAr)
        1    0.000    0.000    0.000    0.000 machar.py:7(<module>)
        1    0.000    0.000    0.001    0.001 main.py:1(<module>)
        1    0.000    0.000    0.000    0.000 main.py:48(TestProgram)
        1    0.000    0.000    0.000    0.000 memmap.py:1(<module>)
        1    0.000    0.000    0.000    0.000 memmap.py:20(memmap)
        1    0.000    0.000    0.000    0.000 mixins.py:1(<module>)
       19    0.000    0.000    0.000    0.000 mixins.py:20(_binary_method)
       13    0.000    0.000    0.000    0.000 mixins.py:30(_reflected_binary_method)
       12    0.000    0.000    0.000    0.000 mixins.py:40(_inplace_binary_method)
       12    0.000    0.000    0.000    0.000 mixins.py:48(_numeric_methods)
        4    0.000    0.000    0.000    0.000 mixins.py:55(_unary_method)
        1    0.000    0.000    0.000    0.000 mixins.py:63(NDArrayOperatorsMixin)
        1    0.000    0.000    0.000    0.000 nanfunctions.py:21(<module>)
        1    0.000    0.000    0.000    0.000 nosetester.py:115(NoseTester)
       23    0.000    0.000    0.000    0.000 nosetester.py:157(__init__)
        1    0.000    0.000    0.001    0.001 nosetester.py:5(<module>)
       19    0.000    0.000    0.000    0.000 nosetester.py:554(_numpy_tester)
        1    0.000    0.000    0.000    0.000 nosetester.py:6(<module>)
        1    0.000    0.000    0.002    0.002 npyio.py:1(<module>)
        1    0.000    0.000    0.000    0.000 npyio.py:106(NpzFile)
        1    0.000    0.000    0.000    0.000 npyio.py:42(BagObj)
        1    0.000    0.000    0.004    0.004 numeric.py:1(<module>)
        2    0.000    0.000    0.000    0.000 numeric.py:1917(isscalar)
        6    0.000    0.000    0.000    0.000 numeric.py:2460(seterr)
        6    0.000    0.000    0.000    0.000 numeric.py:2560(geterr)
        1    0.000    0.000    0.000    0.000 numeric.py:2785(_unspecified)
        1    0.000    0.000    0.000    0.000 numeric.py:2790(errstate)
        3    0.000    0.000    0.000    0.000 numeric.py:2853(__init__)
        3    0.000    0.000    0.000    0.000 numeric.py:2857(__enter__)
        3    0.000    0.000    0.000    0.000 numeric.py:2862(__exit__)
        1    0.000    0.000    0.000    0.000 numeric.py:2868(_setdef)
        4    0.000    0.000    0.000    0.000 numeric.py:2882(extend_all)
        1    0.000    0.000    0.000    0.000 numeric.py:2889(<listcomp>)
        2    0.000    0.000    0.000    0.000 numeric.py:424(asarray)
        1    0.000    0.000    0.000    0.000 numeric.py:72(ComplexWarning)
        1    0.000    0.000    0.000    0.000 numerictypes.py:121(<listcomp>)
       72    0.000    0.000    0.000    0.000 numerictypes.py:128(english_lower)
       40    0.000    0.000    0.000    0.000 numerictypes.py:155(english_upper)
       14    0.000    0.000    0.000    0.000 numerictypes.py:182(english_capitalize)
       23    0.000    0.000    0.000    0.000 numerictypes.py:217(_evalname)
       26    0.000    0.000    0.000    0.000 numerictypes.py:230(bitname)
        1    0.000    0.000    0.000    0.000 numerictypes.py:286(_add_types)
        1    0.000    0.000    0.000    0.000 numerictypes.py:302(_add_aliases)
        1    0.000    0.000    0.000    0.000 numerictypes.py:339(_add_integer_aliases)
        1    0.000    0.000    0.000    0.000 numerictypes.py:380(_set_up_aliases)
        1    0.000    0.000    0.000    0.000 numerictypes.py:429(_construct_char_code_lookup)
       30    0.000    0.000    0.000    0.000 numerictypes.py:444(_add_array_type)
        1    0.000    0.000    0.000    0.000 numerictypes.py:452(_set_array_types)
        1    0.000    0.000    0.000    0.000 numerictypes.py:762(_typedict)
        1    0.000    0.000    0.000    0.000 numerictypes.py:778(_construct_lookups)
        1    0.001    0.001    0.002    0.002 numerictypes.py:82(<module>)
        1    0.000    0.000    0.000    0.000 numerictypes.py:954(_register_types)
        3    0.000    0.000    0.000    0.000 os.py:720(__getitem__)
        2    0.000    0.000    0.000    0.000 os.py:728(__setitem__)
        2    0.000    0.000    0.000    0.000 os.py:734(__delitem__)
        9    0.000    0.000    0.000    0.000 os.py:796(encode)
        1    0.000    0.000    0.000    0.000 polynomial.py:1606(Polynomial)
        1    0.000    0.000    0.000    0.000 polynomial.py:22(RankWarning)
        1    0.000    0.000    0.004    0.004 polynomial.py:4(<module>)
        1    0.000    0.000    0.002    0.002 polynomial.py:56(<module>)
        1    0.000    0.000    0.000    0.000 polynomial.py:939(poly1d)
        1    0.000    0.000    0.000    0.000 polyutils.py:45(<module>)
        1    0.000    0.000    0.000    0.000 polyutils.py:58(RankWarning)
        1    0.000    0.000    0.000    0.000 polyutils.py:62(PolyError)
        1    0.000    0.000    0.000    0.000 polyutils.py:66(PolyDomainError)
        1    0.000    0.000    0.000    0.000 polyutils.py:79(PolyBase)
       24    0.000    0.000    0.000    0.000 posixpath.py:145(dirname)
       25    0.000    0.000    0.000    0.000 posixpath.py:39(_get_sep)
        1    0.000    0.000    0.000    0.000 posixpath.py:71(join)
        1    0.000    0.000    0.000    0.000 py3k.py:4(<module>)
        4    0.000    0.000    0.000    0.000 re.py:160(match)
        4    0.000    0.000    0.000    0.000 re.py:170(search)
        4    0.000    0.000    0.000    0.000 re.py:175(sub)
       14    0.000    0.000    0.005    0.000 re.py:222(compile)
       26    0.000    0.000    0.005    0.000 re.py:278(_compile)
        1    0.000    0.000    0.000    0.000 records.py:217(record)
        1    0.000    0.000    0.000    0.000 records.py:304(recarray)
        1    0.000    0.000    0.000    0.000 records.py:36(<module>)
        1    0.000    0.000    0.000    0.000 records.py:85(format_parser)
        1    0.000    0.000    0.002    0.002 result.py:1(<module>)
        3    0.000    0.000    0.000    0.000 result.py:12(failfast)
        1    0.000    0.000    0.000    0.000 result.py:24(TestResult)
        1    0.000    0.000    0.001    0.001 runner.py:1(<module>)
        1    0.000    0.000    0.000    0.000 runner.py:120(TextTestRunner)
        1    0.000    0.000    0.000    0.000 runner.py:13(_WritelnDecorator)
        1    0.000    0.000    0.000    0.000 runner.py:29(TextTestResult)
        1    0.000    0.000    0.000    0.000 scimath.py:17(<module>)
        2    0.000    0.000    0.000    0.000 shape_base.py:1(<module>)
        1    0.000    0.000    0.000    0.000 signals.py:1(<module>)
        1    0.000    0.000    0.000    0.000 signals.py:9(_InterruptHandler)
        1    0.000    0.000    0.000    0.000 six.py:1(<module>)
       38    0.000    0.000    0.000    0.000 six.py:184(find_module)
        4    0.000    0.000    0.000    0.000 six.py:67(_add_doc)
        1    0.000    0.000    0.000    0.000 sputils.py:15(<listcomp>)
        2    0.000    0.000    0.000    0.000 sputils.py:183(isscalarlike)
        2    0.000    0.000    0.000    0.000 sputils.py:188(isintlike)
        1    0.000    0.000    0.000    0.000 sputils.py:2(<module>)
        1    0.000    0.000    0.000    0.000 sputils.py:200(isshape)
        1    0.000    0.000    0.000    0.000 sputils.py:254(IndexMixin)
        1    0.000    0.000    0.000    0.000 sputils.py:95(getdtype)
       84    0.000    0.000    0.000    0.000 sre_compile.py:101(fixup)
       17    0.000    0.000    0.001    0.000 sre_compile.py:221(_compile_charset)
       17    0.001    0.000    0.001    0.000 sre_compile.py:248(_optimize_charset)
        5    0.000    0.000    0.000    0.000 sre_compile.py:374(_mk_bitmap)
        5    0.000    0.000    0.000    0.000 sre_compile.py:376(<listcomp>)
        2    0.000    0.000    0.000    0.000 sre_compile.py:379(_bytes_to_codes)
       20    0.000    0.000    0.000    0.000 sre_compile.py:386(_simple)
        1    0.000    0.000    0.000    0.000 sre_compile.py:391(_generate_overlap_table)
       11    0.000    0.000    0.000    0.000 sre_compile.py:412(_compile_info)
       22    0.000    0.000    0.000    0.000 sre_compile.py:513(isstring)
       11    0.000    0.000    0.002    0.000 sre_compile.py:516(_code)
       11    0.000    0.000    0.005    0.000 sre_compile.py:531(compile)
    37/11    0.000    0.000    0.002    0.000 sre_compile.py:64(_compile)
       37    0.000    0.000    0.000    0.000 sre_parse.py:105(__init__)
       61    0.000    0.000    0.000    0.000 sre_parse.py:153(__len__)
      139    0.000    0.000    0.000    0.000 sre_parse.py:157(__getitem__)
       20    0.000    0.000    0.000    0.000 sre_parse.py:161(__setitem__)
      120    0.000    0.000    0.000    0.000 sre_parse.py:165(append)
    62/36    0.000    0.000    0.000    0.000 sre_parse.py:167(getwidth)
       11    0.000    0.000    0.000    0.000 sre_parse.py:217(__init__)
      272    0.000    0.000    0.000    0.000 sre_parse.py:226(__next)
      104    0.000    0.000    0.000    0.000 sre_parse.py:242(match)
      207    0.000    0.000    0.000    0.000 sre_parse.py:247(get)
        4    0.000    0.000    0.000    0.000 sre_parse.py:260(getuntil)
       58    0.000    0.000    0.000    0.000 sre_parse.py:276(tell)
       12    0.000    0.000    0.000    0.000 sre_parse.py:362(_escape)
    17/11    0.000    0.000    0.002    0.000 sre_parse.py:429(_parse_sub)
    17/11    0.001    0.000    0.002    0.000 sre_parse.py:491(_parse)
       11    0.000    0.000    0.000    0.000 sre_parse.py:70(__init__)
       32    0.000    0.000    0.000    0.000 sre_parse.py:75(groups)
        5    0.000    0.000    0.000    0.000 sre_parse.py:78(opengroup)
       11    0.000    0.000    0.000    0.000 sre_parse.py:797(fix_flags)
       11    0.000    0.000    0.002    0.000 sre_parse.py:819(parse)
        5    0.000    0.000    0.000    0.000 sre_parse.py:90(closegroup)
        1    0.000    0.000    0.000    0.000 stride_tricks.py:15(DummyArray)
        1    0.000    0.000    0.000    0.000 stride_tricks.py:7(<module>)
        1    0.000    0.000    0.000    0.000 suite.py:1(<module>)
        1    0.000    0.000    0.000    0.000 suite.py:16(BaseTestSuite)
        1    0.000    0.000    0.000    0.000 suite.py:270(_ErrorHolder)
        1    0.000    0.000    0.000    0.000 suite.py:317(_DebugResult)
        1    0.000    0.000    0.000    0.000 suite.py:92(TestSuite)
        4    0.000    0.000    0.000    0.000 textwrap.py:415(dedent)
        1    0.003    0.003    0.003    0.003 twodim_base.py:3(<module>)
        1    0.000    0.000    0.047    0.047 type_check.py:3(<module>)
        3    0.000    0.000    0.000    0.000 ufunclike.py:14(_deprecate_out_named_y)
        1    0.000    0.000    0.000    0.000 ufunclike.py:5(<module>)
        1    0.000    0.000    0.001    0.001 util.py:1(<module>)
        1    0.000    0.000    0.001    0.001 utils.py:1(<module>)
        6    0.000    0.000    0.000    0.000 utils.py:118(deprecate)
        1    0.000    0.000    0.000    0.000 utils.py:1590(WarningMessage)
        1    0.000    0.000    0.000    0.000 utils.py:1623(WarningManager)
        1    0.000    0.000    0.000    0.000 utils.py:1850(IgnoreException)
        1    0.000    0.000    0.000    0.000 utils.py:1891(clear_and_catch_warnings)
        1    0.000    0.000    0.000    0.000 utils.py:1956(suppress_warnings)
        1    0.000    0.000    0.002    0.002 utils.py:4(<module>)
        1    0.000    0.000    0.000    0.000 utils.py:42(KnownFailureException)
        1    0.000    0.000    0.000    0.000 utils.py:5(<module>)
        6    0.000    0.000    0.000    0.000 utils.py:52(_set_function_name)
        1    0.000    0.000    0.000    0.000 utils.py:57(_Deprecate)
        6    0.000    0.000    0.000    0.000 utils.py:69(__init__)
        6    0.000    0.000    0.000    0.000 utils.py:74(__call__)
        1    0.000    0.000    0.000    0.000 utils.py:997(SafeEval)
        1    0.000    0.000    0.000    0.000 version.py:3(<module>)
        1    0.000    0.000    0.000    0.000 version.py:5(<module>)
        1    0.000    0.000    0.000    0.000 warnings.py:350(__init__)
        1    0.000    0.000    0.000    0.000 warnings.py:371(__enter__)
        4    0.000    0.000    0.001    0.000 warnings.py:38(filterwarnings)
        1    0.000    0.000    0.000    0.000 warnings.py:388(__exit__)
        1    0.000    0.000    0.000    0.000 warnings.py:62(simplefilter)
        5    0.000    0.000    0.000    0.000 warnings.py:78(_add_filter)
        1    0.000    0.000    0.000    0.000 weakref.py:325(__init__)
       12    0.000    0.000    0.000    0.000 {built-in method _ctypes.sizeof}
      117    0.000    0.000    0.000    0.000 {built-in method _imp._fix_co_filename}
      523    0.000    0.000    0.000    0.000 {built-in method _imp.acquire_lock}
    14/13    0.022    0.002    0.027    0.002 {built-in method _imp.create_dynamic}
       14    0.000    0.000    0.000    0.000 {built-in method _imp.exec_dynamic}
        3    0.000    0.000    0.000    0.000 {built-in method _imp.is_builtin}
      150    0.000    0.000    0.000    0.000 {built-in method _imp.is_frozen}
      879    0.000    0.000    0.000    0.000 {built-in method _imp.release_lock}
       11    0.000    0.000    0.000    0.000 {built-in method _sre.compile}
      160    0.000    0.000    0.000    0.000 {built-in method _sre.getlower}
      344    0.000    0.000    0.000    0.000 {built-in method _thread.allocate_lock}
      744    0.000    0.000    0.000    0.000 {built-in method _thread.get_ident}
        7    0.000    0.000    0.000    0.000 {built-in method _warnings._filters_mutated}
      165    0.006    0.000    0.007    0.000 {built-in method builtins.__build_class__}
   337/10    0.001    0.000    0.128    0.013 {built-in method builtins.__import__}
      131    0.000    0.000    0.000    0.000 {built-in method builtins.any}
        2    0.000    0.000    0.000    0.000 {built-in method builtins.callable}
      256    0.000    0.000    0.000    0.000 {built-in method builtins.chr}
        1    0.000    0.000    0.000    0.000 {built-in method builtins.dir}
    121/1    0.003    0.000    6.546    6.546 {built-in method builtins.exec}
     1501    0.001    0.000    0.001    0.000 {built-in method builtins.getattr}
      348    0.000    0.000    0.000    0.000 {built-in method builtins.globals}
     2812    0.002    0.000    0.002    0.000 {built-in method builtins.hasattr}
  2364479    0.189    0.000    0.189    0.000 {built-in method builtins.isinstance}
    63/39    0.000    0.000    0.000    0.000 {built-in method builtins.issubclass}
788726/788705    0.059    0.000    0.059    0.000 {built-in method builtins.len}
    39389    0.013    0.000    0.013    0.000 {built-in method builtins.max}
    39473    0.010    0.000    0.010    0.000 {built-in method builtins.min}
      131    0.000    0.000    0.000    0.000 {built-in method builtins.ord}
       63    0.000    0.000    0.000    0.000 {built-in method builtins.repr}
      215    0.000    0.000    0.000    0.000 {built-in method builtins.setattr}
        1    0.007    0.007    0.007    0.007 {built-in method builtins.sorted}
      234    0.000    0.000    0.000    0.000 {built-in method from_bytes}
      117    0.020    0.000    0.020    0.000 {built-in method marshal.loads}
      273    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.add_docstring}
       78    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.array}
       23    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.empty}
        2    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.set_string_function}
        1    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.set_typeDict}
       14    0.000    0.000    0.000    0.000 {built-in method numpy.core.umath.geterrobj}
        7    0.000    0.000    0.000    0.000 {built-in method numpy.core.umath.seterrobj}
        3    0.000    0.000    0.000    0.000 {built-in method posix.getcwd}
        2    0.000    0.000    0.000    0.000 {built-in method posix.getpid}
       17    0.001    0.000    0.001    0.000 {built-in method posix.listdir}
        2    0.000    0.000    0.000    0.000 {built-in method posix.putenv}
      477    0.004    0.000    0.004    0.000 {built-in method posix.stat}
        2    0.000    0.000    0.000    0.000 {built-in method posix.unsetenv}
   393860    0.590    0.000    0.590    0.000 {built-in method scipy.sparse._csparsetools.lil_get1}
   393860    0.752    0.000    0.752    0.000 {built-in method scipy.sparse._csparsetools.lil_insert}
       26    0.000    0.000    0.000    0.000 {built-in method sys._getframe}
       12    0.000    0.000    0.000    0.000 {method '__contains__' of 'frozenset' objects}
       13    0.000    0.000    0.000    0.000 {method '__subclasses__' of 'type' objects}
       13    0.000    0.000    0.000    0.000 {method '__subclasshook__' of 'object' objects}
       39    0.000    0.000    0.000    0.000 {method 'add' of 'set' objects}
     1163    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
        2    0.000    0.000    0.000    0.000 {method 'cast' of 'memoryview' objects}
       30    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
        9    0.000    0.000    0.000    0.000 {method 'encode' of 'str' objects}
        4    0.000    0.000    0.000    0.000 {method 'end' of '_sre.SRE_Match' objects}
      146    0.000    0.000    0.000    0.000 {method 'endswith' of 'str' objects}
       75    0.000    0.000    0.000    0.000 {method 'extend' of 'list' objects}
       51    0.000    0.000    0.000    0.000 {method 'find' of 'bytearray' objects}
        1    0.000    0.000    0.000    0.000 {method 'find' of 'str' objects}
        4    0.000    0.000    0.000    0.000 {method 'findall' of '_sre.SRE_Pattern' objects}
      804    0.001    0.000    0.001    0.000 {method 'format' of 'str' objects}
       71    0.000    0.000    0.000    0.000 {method 'get' of 'dict' objects}
        4    0.000    0.000    0.000    0.000 {method 'group' of '_sre.SRE_Match' objects}
    39389    1.992    0.000    1.992    0.000 {method 'index' of 'list' objects}
        5    0.000    0.000    0.000    0.000 {method 'insert' of 'list' objects}
       16    0.000    0.000    0.000    0.000 {method 'isidentifier' of 'str' objects}
       13    0.000    0.000    0.000    0.000 {method 'items' of 'dict' objects}
     1206    0.001    0.000    0.001    0.000 {method 'join' of 'str' objects}
       17    0.000    0.000    0.000    0.000 {method 'keys' of 'dict' objects}
        4    0.000    0.000    0.000    0.000 {method 'match' of '_sre.SRE_Pattern' objects}
       27    0.000    0.000    0.000    0.000 {method 'partition' of 'str' objects}
       43    0.000    0.000    0.000    0.000 {method 'pop' of 'dict' objects}
      117    0.002    0.000    0.002    0.000 {method 'read' of '_io.FileIO' objects}
       12    0.000    0.000    0.000    0.000 {method 'remove' of 'list' objects}
       13    0.000    0.000    0.000    0.000 {method 'remove' of 'set' objects}
        4    0.000    0.000    0.000    0.000 {method 'replace' of 'str' objects}
       24    0.000    0.000    0.000    0.000 {method 'rfind' of 'str' objects}
     1039    0.001    0.000    0.001    0.000 {method 'rpartition' of 'str' objects}
     2025    0.001    0.000    0.001    0.000 {method 'rstrip' of 'str' objects}
        4    0.000    0.000    0.000    0.000 {method 'search' of '_sre.SRE_Pattern' objects}
        1    0.000    0.000    0.000    0.000 {method 'setter' of 'property' objects}
        5    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
      251    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}
      273    0.000    0.000    0.000    0.000 {method 'strip' of 'str' objects}
        8    0.000    0.000    0.000    0.000 {method 'sub' of '_sre.SRE_Pattern' objects}
        2    0.000    0.000    0.000    0.000 {method 'tolist' of 'memoryview' objects}
        5    0.000    0.000    0.000    0.000 {method 'translate' of 'bytearray' objects}
      112    0.000    0.000    0.000    0.000 {method 'translate' of 'str' objects}
       39    0.000    0.000    0.000    0.000 {method 'update' of 'dict' objects}
        1    0.000    0.000    0.000    0.000 {method 'view' of 'numpy.ndarray' objects}


This is 96% faster than the implementation in the actual Kadot ! Indeed, we have a very low weight in ram so we can run on a large corpus without breaking the computer ! To be totally great, we should implement a new VectorDict on Kadot that internally store vectors as a scipy LIL matrix.


In [4]:
cooc_matrix.shape


Out[4]:
(7768, 7768)

In [ ]: