improved module loading

pull/202/head
ggrieco-tob 6 years ago
parent 06d70856bd
commit 7f39c77219
  1. 10
      utils/similarity/__init__.py
  2. 2
      utils/similarity/info.py
  3. 11
      utils/similarity/model.py
  4. 6
      utils/similarity/plot.py
  5. 6
      utils/similarity/test.py
  6. 2
      utils/similarity/train.py

@ -1,9 +1 @@
# from https://stackoverflow.com/questions/563022/whats-python-good-practice-for-importing-and-offering-optional-features from .model import load_model
import sys
try:
import fastText
except ImportError:
print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:")
print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n")
sys.exit(-1)

@ -3,7 +3,7 @@ import sys
import os.path import os.path
import traceback import traceback
from fastText import load_model from .model import load_model
from .encode import parse_target, encode_contract from .encode import parse_target, encode_contract
logging.basicConfig() logging.basicConfig()

@ -0,0 +1,11 @@
import sys
try:
from fastText import load_model
from fastText import train_unsupervised
except ImportError:
print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:")
print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n")
sys.exit(-1)

@ -5,15 +5,15 @@ import operator
import numpy as np import numpy as np
import random import random
from .model import load_model
from .encode import load_and_encode, parse_target
try: try:
from sklearn import decomposition from sklearn import decomposition
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
except ImportError: except ImportError:
decomposition = None decomposition = None
plt = None plt = None
from fastText import load_model
from .encode import load_and_encode, parse_target
logger = logging.getLogger("Slither-simil") logger = logging.getLogger("Slither-simil")

@ -5,9 +5,9 @@ import traceback
import operator import operator
import numpy as np import numpy as np
from fastText import load_model from .model import load_model
from .encode import encode_contract, load_and_encode, parse_target from .encode import encode_contract, load_and_encode, parse_target
from .cache import save_cache from .cache import save_cache
from .similarity import similarity from .similarity import similarity
logger = logging.getLogger("Slither-simil") logger = logging.getLogger("Slither-simil")

@ -5,7 +5,7 @@ import traceback
import operator import operator
import os import os
from fastText import train_unsupervised from .model import train_unsupervised
from .encode import encode_contract, load_contracts from .encode import encode_contract, load_contracts
from .cache import save_cache from .cache import save_cache

Loading…
Cancel
Save