Best Python code snippet using avocado_python
setup.py
Source:setup.py
1# Copyright (c) Facebook, Inc. and its affiliates.2# This source code is licensed under the MIT license found in the3# LICENSE file in the root directory of this source tree.4import os.path5import platform6import sys7import os8from pkg_resources import (9 normalize_path,10 working_set,11 add_activation_listener,12 require,13)14from setuptools import setup, find_packages15from setuptools.command.build_py import build_py16from setuptools.command.develop import develop17from setuptools.command.test import test as test_command18from typing import List19PLATFORM = 'unix'20if platform.platform().startswith('Win'):21 PLATFORM = 'win'22MODEL_DIR = os.path.join('stan', PLATFORM)23MODEL_TARGET_DIR = os.path.join('fbprophet', 'stan_model')24def get_backends_from_env() -> List[str]:25 from fbprophet.models import StanBackendEnum26 return os.environ.get("STAN_BACKEND", StanBackendEnum.PYSTAN.name).split(",")27def build_models(target_dir):28 from fbprophet.models import StanBackendEnum29 for backend in get_backends_from_env():30 StanBackendEnum.get_backend_class(backend).build_model(target_dir, MODEL_DIR)31class BuildPyCommand(build_py):32 """Custom build command to pre-compile Stan models."""33 def run(self):34 if not self.dry_run:35 target_dir = os.path.join(self.build_lib, MODEL_TARGET_DIR)36 self.mkpath(target_dir)37 build_models(target_dir)38 build_py.run(self)39class DevelopCommand(develop):40 """Custom develop command to pre-compile Stan models in-place."""41 def run(self):42 if not self.dry_run:43 target_dir = os.path.join(self.setup_path, MODEL_TARGET_DIR)44 self.mkpath(target_dir)45 build_models(target_dir)46 develop.run(self)47class TestCommand(test_command):48 user_options = [49 ('test-module=', 'm', "Run 'test_suite' in specified module"),50 ('test-suite=', 's',51 "Run single test, case or suite (e.g. 'module.test_suite')"),52 ('test-runner=', 'r', "Test runner to use"),53 ('test-slow', 'w', "Test slow suites (default off)"),54 ]55 test_slow = None56 def initialize_options(self):57 super(TestCommand, self).initialize_options()58 self.test_slow = False59 def finalize_options(self):60 super(TestCommand, self).finalize_options()61 if self.test_slow is None:62 self.test_slow = getattr(self.distribution, 'test_slow', False)63 """We must run tests on the build directory, not source."""64 def with_project_on_sys_path(self, func):65 # Ensure metadata is up-to-date66 self.reinitialize_command('build_py', inplace=0)67 self.run_command('build_py')68 bpy_cmd = self.get_finalized_command("build_py")69 build_path = normalize_path(bpy_cmd.build_lib)70 # Build extensions71 self.reinitialize_command('egg_info', egg_base=build_path)72 self.run_command('egg_info')73 self.reinitialize_command('build_ext', inplace=0)74 self.run_command('build_ext')75 ei_cmd = self.get_finalized_command("egg_info")76 old_path = sys.path[:]77 old_modules = sys.modules.copy()78 try:79 sys.path.insert(0, normalize_path(ei_cmd.egg_base))80 working_set.__init__()81 add_activation_listener(lambda dist: dist.activate())82 require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))83 func()84 finally:85 sys.path[:] = old_path86 sys.modules.clear()87 sys.modules.update(old_modules)88 working_set.__init__()89with open('README.md', 'r', encoding='utf-8') as f:90 long_description = f.read()91with open('requirements.txt', 'r') as f:92 install_requires = f.read().splitlines()93setup(94 name='fbprophet',95 version='1.0',96 description='Automatic Forecasting Procedure',97 url='https://facebook.github.io/prophet/',98 author='Sean J. Taylor <sjtz@pm.me>, Ben Letham <bletham@fb.com>',99 author_email='sjtz@pm.me',100 license='MIT',101 packages=find_packages(),102 setup_requires=[103 ],104 install_requires=install_requires,105 python_requires='>=3',106 zip_safe=False,107 include_package_data=True,108 cmdclass={109 'build_py': BuildPyCommand,110 'develop': DevelopCommand,111 'test': TestCommand,112 },113 test_suite='fbprophet.tests',114 classifiers=[115 'Programming Language :: Python',116 'Programming Language :: Python :: 3',117 'Programming Language :: Python :: 3.7',118 ],119 long_description=long_description,120 long_description_content_type='text/markdown',...
slow.py
Source:slow.py
...5# LICENSE file in the root directory of this source tree.6# this is a slow computation to test whether ctrl-C handling works7import faiss8import numpy as np9def test_slow():10 d = 25611 index = faiss.index_cpu_to_gpu(faiss.StandardGpuResources(),12 0, faiss.IndexFlatL2(d))13 x = np.random.rand(10 ** 6, d).astype('float32')14 print('add')15 index.add(x)16 print('search')17 index.search(x, 10)18 print('done')19if __name__ == '__main__':...
attrib_example.py
Source:attrib_example.py
...9 pass10 test_faster.fast = 111 test_faster.layer = 112 test_faster.flags = ["red", "green"]13 def test_slow(self):14 pass15 test_slow.fast = 016 test_slow.slow = 117 test_slow.layer = 218 def test_slower(self):19 pass20 test_slower.slow = 121 test_slower.layer = 3...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!