repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
RacingTadpole/cmsplugin-rt
cmsplugin_rt/twitter_button/models.py
from cms.models import CMSPlugin from django.db import models from django.utils.translation import ugettext_lazy as _ class TwitterButtonPluginModel(CMSPlugin): tweet_text = models.CharField(_("Tweet text"), default=None, blank=True, max_length=60, help_text=_("Leave blank to use page title")) hash_tag = mode...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/google_font/models.py
from cms.models import CMSPlugin from cms.models.pagemodel import Page from django.db import models from django.utils.translation import ugettext_lazy as _ class GoogleFontPluginModel(CMSPlugin): font_family_pluses = models.CharField(_("font family name"), default='Eagle+Lake', max_length=100, help_text=_("You mu...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/text_minimal_markup/models.py
# Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from os.path import basename from django.db import models class TextMinimalMarkupPluginModel(CMSPlugin): title = mo...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/hbar/cms_plugins.py
from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import ugettext_lazy as _ from django.conf import settings from models import * bootstrap_module_name = _("Widgets") layout_module_name = _("Layout elements") ge...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/google_analytics/cms_plugins.py
<reponame>RacingTadpole/cmsplugin-rt<filename>cmsplugin_rt/google_analytics/cms_plugins.py from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.utils.translation import ugettext_lazy as _ from models import * bootstrap_module_name = _("Widgets") layout_module_name = _("Layout ...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/resizeable_picture/models.py
# Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from os.path import basename from django.db import models class ResizeablePicturePluginModel(CMSPlugin): """ A ...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/facebook_button/cms_plugins.py
<filename>cmsplugin_rt/facebook_button/cms_plugins.py from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.utils.translation import ugettext_lazy as _ from models import * class BasePlugin(CMSPluginBase): name = None module = _("Social Networking") def render(self,...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/rt_carousel/migrations/0001_initial.py
<filename>cmsplugin_rt/rt_carousel/migrations/0001_initial.py # -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'RTCarouselPluginModel' db.crea...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/navbar/models.py
# Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.db import models class NavbarPluginModel(CMSPlugin): DISPLAY_CHOICES =(("", _("default")), ("navbar-fixed-top", _("fixed to top...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/button/templatetags/allow_special.py
from django import template register = template.Library() from django.utils.html import conditional_escape from django.utils.safestring import mark_safe import re @register.filter(needs_autoescape=True) def allow_special(text, autoescape=None): """This filter turns any http(s)://www.* or www.* into a link, ...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/style_modifier/models.py
<filename>cmsplugin_rt/style_modifier/models.py # Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from os.path import basename from django.db import models from django.co...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/google_analytics/models.py
<filename>cmsplugin_rt/google_analytics/models.py<gh_stars>1-10 from cms.models import CMSPlugin from cms.models.pagemodel import Page from django.db import models from django.utils.translation import ugettext_lazy as _ class GoogleAnalyticsPluginModel(CMSPlugin): account_code = models.CharField(_("Account code")...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/rt_carousel/cms_plugins.py
from django.db import models from django.utils.translation import ugettext_lazy as _ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from models import RTCarouselPluginModel bootstrap_module_name = _("Widgets") layout_module_name = _("Lay...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/button_appstore/models.py
<gh_stars>1-10 # Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.db import models from django.conf import settings class ButtonAppstorePluginModel(CMSPlugin): button_link = models.URLField(_("Dire...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/open_graph/models.py
<gh_stars>1-10 # Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from os.path import basename from django.db import models class OpenGraphPluginModel(CMSPlugin): og_...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/google_font/cms_plugins.py
from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.utils.translation import ugettext_lazy as _ from models import * bootstrap_module_name = _("Widgets") layout_module_name = _("Layout elements") generic_module_name = _("Generic") meta_module_name = _("Meta elements") class ...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/mailchimp_form/models.py
from cms.models import CMSPlugin from django.db import models from django.utils.translation import ugettext_lazy as _ class MailChimpPluginModel(CMSPlugin): CLASS_CHOICES =(("", _("default")), ("btn-primary", _("primary")), ("btn-info", _("info")), ("btn-...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/facebook_button/migrations/0001_initial.py
<reponame>RacingTadpole/cmsplugin-rt<gh_stars>1-10 # -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'FacebookButtonPluginModel' db.create_tabl...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/meta_icons/models.py
<gh_stars>1-10 # Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from os.path import basename from django.db import models class MetaIconsPluginModel(CMSPlugin): fav...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/self_calc_pagination/cms_plugins.py
from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import ugettext_lazy as _ from django.conf import settings from models import * bootstrap_module_name = _("Widgets") layout_module_name = _("Layout elements") ge...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/button/cms_plugins.py
<reponame>RacingTadpole/cmsplugin-rt from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import ugettext_lazy as _ from django.conf import settings from .models import ButtonPluginModel from .forms import ButtonFor...
RacingTadpole/cmsplugin-rt
setup.py
import os from setuptools import setup, find_packages README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name = 'cmsplugin-rt', version = '0.5.1', packag...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/rt_carousel/models.py
# Plugin models from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.utils.translation import ugettext_lazy as _ from django.conf import settings from cms.models.pluginmodel import CMSPlugin CAROUSEL_DISPLAY_CHOICES = ( ...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/navbar/cms_plugins.py
<gh_stars>1-10 from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import ugettext_lazy as _ from django.conf import settings from models import * bootstrap_module_name = _("Widgets") layout_module_name = _("Layou...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/meta_icons/cms_plugins.py
<reponame>RacingTadpole/cmsplugin-rt from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import ugettext_lazy as _ from django.conf import settings from models import * bootstrap_module_name = _("Widgets") layout_...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/button/models.py
<reponame>RacingTadpole/cmsplugin-rt<filename>cmsplugin_rt/button/models.py # Plugin models from cms.models.pluginmodel import CMSPlugin from cms.models.pagemodel import Page from django.utils.translation import ugettext_lazy as _ from django.db import models from django.conf import settings class ButtonPluginModel(C...
RacingTadpole/cmsplugin-rt
cmsplugin_rt/facebook_button/models.py
<filename>cmsplugin_rt/facebook_button/models.py from cms.models import CMSPlugin from cms.models.pagemodel import Page from django.db import models from django.utils.translation import ugettext_lazy as _ LAYOUT_CHOICES = [ ('standard', _('Standard')), ('button_count', _('Button count')), ('box_count', _(...
RacingTadpole/cmsplugin-rt
tests/runtests.py
import os, sys from django.conf import settings DIRNAME = os.path.dirname(__file__) settings.configure(DEBUG=True, DATABASES={ 'default': { 'ENGINE': 'django.db.backends.sqlite3', } }, #ROOT_URLCONF='myapp.url...
christine-berlin/Capstone_WindPowerPredictions
modeling/features.py
<gh_stars>0 import pandas as pd def get_feature_combinations(): """Returns a dictionary with different feature combinations of the dataframe. Returns: (dict): Dictionary with different feature combinations. """ data = pd.read_csv('../data/GEFCom2014Data/Wind/clean_data.csv', parse_dates=['T...
christine-berlin/Capstone_WindPowerPredictions
modeling/functions.py
<reponame>christine-berlin/Capstone_WindPowerPredictions """Functions for: - logging with MLflow, - modelling, - hyperparameter tuning, - finding best feature combinations, """ import warnings import numpy as np import pandas as pd from sklearn.metrics import mean_squared_error from sklearn.model_selection import Grid...
Minyan910/libcint
testsuite/test_cint4c1e.py
<reponame>Minyan910/libcint #!/usr/bin/env python # $Id$ # -*- coding: utf-8 ''' test libcint ''' __author__ = "<NAME> <<EMAIL>>" import sys import os import ctypes import numpy _cint = numpy.ctypeslib.load_library('libcint', '.') PTR_LIGHT_SPEED = 0 PTR_COMMON_ORIG = 1 PTR_SHIELDING_ORIG = 4 PTR_RINV_ORIG ...
Minyan910/libcint
testsuite/test_3c2e.py
#!/usr/bin/env python # $Id$ # -*- coding: utf-8 from __future__ import print_function ''' test libcint ''' __author__ = "<NAME> <<EMAIL>>" import sys import os import ctypes import numpy _cint = numpy.ctypeslib.load_library('libcint', '.') PTR_LIGHT_SPEED = 0 PTR_COMMON_ORIG = 1 PTR_SHIELDING_ORIG = 4 PTR_...
Minyan910/libcint
examples/python_call.py
from math import * import numpy import ctypes # general contracted DZ basis [3s1p/2s1p] for H2 # exponents contract-coeff # S 6.0 0.7 0.4 # 2.0 0.6 0.3 # 0.8 0.5 0.2 # P 0.9 1. def gto_norm(n, a): # normalization fact...
WyattSP/MSc-Future-Work
RandomEvolutionModel.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 2 19:07:01 2021 @author: wyattpetryshen """ # Code templates for Ornstein-Uhlenbeck process and Brownian motion are from IPython Interactive Computing and Visualization Cookbook, Second Edition (2018), by <NAME>. import numpy as np import matplot...
pyrkamarcin/epiphany
cli/src/helpers/naming_helpers.py
<filename>cli/src/helpers/naming_helpers.py def to_role_name(feature_name): return feature_name.replace("-", "_") def to_feature_name(role_name): return role_name.replace("_", "-") def resource_name(prefix, cluster_name, resource_type, component=None): name = '' if (not prefix) or (prefix == 'defaul...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/src/error.py
import logging class DownloadRequirementsError(Exception): """ Base class for all non standard errors raised during a script run. """ def __init__(self, msg: str): super().__init__() logging.error(msg) class CriticalError(DownloadRequirementsError): """ Raised when there was ...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py
<filename>ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py from typing import Dict, List from src.command.command import Command from src.error import CriticalError class Dnf(Command): """ Interface for `dnf` """ def __init__(self, retries: int): super().__in...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf_config_manager.py
<filename>ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf_config_manager.py<gh_stars>1-10 from src.command.command import Command class DnfConfigManager(Command): """ Interface for `dnf config-manager` """ def __init__(self, retries: int): super().__init__('dnf'...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf_repoquery.py
from typing import Callable, List from src.command.command import Command from src.error import CriticalError, PackageNotfound class DnfRepoquery(Command): """ Interface for `dnf repoquery` """ def __init__(self, retries: int): super().__init__('dnf', retries) # repoquery would require yum-...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/src/config/os_type.py
<reponame>pyrkamarcin/epiphany from enum import Enum from typing import Dict, List class OSArch(Enum): """ Supported architecture types """ X86_64 = 'x86_64' ARM64 = 'arm64' class OSFamily(Enum): """ Supported distro type families """ Debian = 'debian' RedHat = 'redhat' class OSConfig: ...
pyrkamarcin/epiphany
ansible/playbooks/roles/repository/files/download-requirements/tests/command/test_dnf_repoquery.py
from tests.mocks.command_run_mock import CommandRunMock from src.command.dnf_repoquery import DnfRepoquery def test_interface_query(mocker): ''' Check argument construction for `dnf repoquery` - generic query ''' with CommandRunMock(mocker, DnfRepoquery(1).query, {'packages': ['tar', 'vim'], ...
microsoft/lightgbm-benchmark
tests/common/test_distributed.py
"""Tests src/common/io.py""" import os import pytest from unittest.mock import call, Mock, patch import time import json from common.distributed import MultiNodeScript, MPIHandler, mpi_config_class from test_component import ( assert_runnable_script_properties, assert_runnable_script_metrics ) class FakeMulti...
microsoft/lightgbm-benchmark
src/common/math.py
""" Helper math functions """ import os import argparse import logging import numpy as np def bootstrap_ci(data, iterations=1000, operators={'mean':np.mean}, confidence_level=0.95, seed=None): """ Args: data (np.array) : input data iterations (int) : how many bootstrapped samples to generate ...
microsoft/lightgbm-benchmark
tests/common/test_data.py
<reponame>microsoft/lightgbm-benchmark """Tests src/common/data.py""" import os import pytest from unittest.mock import call, Mock, patch from common.data import RegressionDataGenerator def test_regression_data_generator(): """Tests format of outputs of RegressionDataGenerator""" generator = RegressionDataGen...
microsoft/lightgbm-benchmark
tests/pipelines/test_lightgbm_training.py
""" Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile import pytest from unittest.mock import patch from pipelines.azureml.lightgbm_training import main def test_lightgbm_training_cpu(aml_config, config_directory): # create test arguments...
microsoft/lightgbm-benchmark
tests/scripts/test_sample_sample.py
<reponame>microsoft/lightgbm-benchmark<filename>tests/scripts/test_sample_sample.py<gh_stars>10-100 """ Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.sample import sample # IMPORT...
microsoft/lightgbm-benchmark
tests/common/test_pipelines.py
<reponame>microsoft/lightgbm-benchmark """Tests src/common/pipelines.py""" import os import sys import pytest from unittest.mock import call, Mock, patch import time from dataclasses import dataclass from omegaconf import DictConfig from common.pipelines import ( parse_pipeline_config, azureml_connect, pi...
microsoft/lightgbm-benchmark
src/scripts/data_processing/generate_data/generate.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Generate synthetic data for LightGBM training/inferencing """ import os import sys import argparse import logging from distutils.util import strtobool import numpy import sklearn from sklearn.datasets im...
microsoft/lightgbm-benchmark
src/pipelines/azureml/lightgbm_training.py
<gh_stars>10-100 """ Runs LightGBM using distributed (mpi) training. to execute: > python src/pipelines/azureml/lightgbm_training.py --exp-config conf/experiments/lightgbm_training/cpu.yaml """ # pylint: disable=no-member # NOTE: because it raises 'dict' has no 'outputs' member in dsl.pipeline construction import os i...
microsoft/lightgbm-benchmark
tests/common/test_sweep.py
<filename>tests/common/test_sweep.py<gh_stars>10-100 """Tests src/common/metrics.py""" import os from azureml.train.hyperdrive import ( choice, quniform, qloguniform, qnormal, qlognormal, uniform, loguniform, normal, lognormal ) from common.sweep import SweepParameterParser ### UNI...
microsoft/lightgbm-benchmark
src/common/components.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ This script contains a class to structure and standardize all scripts in the lightgbm-benchmark repository. This class factors duplicate code to achieve usual routines of every script: logging init, MLFlow init, system properties logging, etc...
microsoft/lightgbm-benchmark
tests/scripts/test_partition_data.py
<gh_stars>10-100 """ test src/scripts/partition_data/partition.py """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.data_processing.partition_data import partition # IMPORTANT: see conftest.py for fixtures def verify_partitioned_files(partitioned_data_dir, expected_f...
microsoft/lightgbm-benchmark
src/common/distributed.py
<gh_stars>10-100 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ LightGBM/Python training script """ import os import logging import traceback from .components import RunnableScript from dataclasses import dataclass from .perf import PerformanceMetricsCollector, PerfReportPlotter @datacl...
microsoft/lightgbm-benchmark
src/scripts/model_transformation/treelite_compile/compile_treelite.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ TreeLite/Python inferencing script """ import os import sys import argparse import logging import numpy from distutils.util import strtobool import pandas as pd import treelite, treelite_runtime # Add the right path to PYTHONPATH # so that y...
microsoft/lightgbm-benchmark
src/scripts/training/lightgbm_python/train.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ LightGBM/Python training script """ import os import sys import argparse import logging import traceback import json from distutils.util import strtobool import lightgbm from collections import namedtupl...
microsoft/lightgbm-benchmark
tests/scripts/test_treelite_python.py
<filename>tests/scripts/test_treelite_python.py<gh_stars>10-100 """ Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile from unittest.mock import patch from scripts.model_transformation.treelite_compile import compile_treelite from scripts.infer...
microsoft/lightgbm-benchmark
tests/aml/test_components.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ PyTest suite for testing if each run.py is aligned with module specification: > Status: this code relates to the _recipe_ and is a _proposition_ """ import pytest import os from shrike.pipeline.testing...
microsoft/lightgbm-benchmark
src/common/tasks.py
<reponame>microsoft/lightgbm-benchmark from dataclasses import dataclass from omegaconf import MISSING from typing import Any, Optional @dataclass class data_input_spec: # NOTE: Union is not supported in Hydra/OmegaConf # specify either by dataset name and version name: Optional[str] = None version: Op...
microsoft/lightgbm-benchmark
src/pipelines/azureml/lightgbm_inferencing.py
""" Compares 3 versions of LightGBM Inferencing A - vanilla B - custom build C - treelite to execute: > python src/pipelines/azureml/lightgbm_inferencing.py --exp-config conf/experiments/lightgbm-inferencing.yaml """ # pylint: disable=no-member # NOTE: because it raises 'dict' has no 'outputs' member in dsl.pipeline ...
microsoft/lightgbm-benchmark
tests/conftest.py
<reponame>microsoft/lightgbm-benchmark """ Add src/ to path """ import os import sys import logging import pytest import tempfile LIGHTGBM_BENCHMARK_ROOT = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "src") ) if LIGHTGBM_BENCHMARK_ROOT not in sys.path: logging.info(f"Adding {LIGHTGBM_BENCHM...
microsoft/lightgbm-benchmark
src/common/io.py
<filename>src/common/io.py<gh_stars>10-100 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ This contains helper functions to handle inputs and outputs arguments in the benchmark scripts. It also provides some automation routine to handle data. """ import os import argparse import logging ...
microsoft/lightgbm-benchmark
tests/scripts/test_lightgbm_python.py
<filename>tests/scripts/test_lightgbm_python.py """ Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.training.lightgbm_python import train from scripts.inferencing.lightgbm_python imp...
microsoft/lightgbm-benchmark
tests/scripts/test_lightgbm_inferencing_ray.py
""" Test LightGBM Inferencing using Ray """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.inferencing.lightgbm_ray import score # IMPORTANT: see conftest.py for fixtures def test_lightgbm_ray_score(temporary_dir, regression_model_sample, regression_inference_sample):...
microsoft/lightgbm-benchmark
src/common/sweep.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Parses Sweep parameters from text arguments (cli or yaml) """ import re import argparse import logging from azureml.core import Workspace, Datastore, Dataset from azureml.train.hyperdrive import ( ch...
microsoft/lightgbm-benchmark
src/common/data.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Helper code to handle/process data """ import numpy as np # derived from https://github.com/scikit-learn/scikit-learn/blob/7e1e6d09bcc2eaeba98f7e737aac2ac782f0e5f1/sklearn/datasets/_samples_generator.py#L506 # for generating data in batches...
microsoft/lightgbm-benchmark
src/scripts/analysis/analyze.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ TreeLite/Python inferencing script """ import os import sys import re import json import argparse import logging from distutils.util import strtobool from jinja2 import Template import mlflow import pandas as pd import numpy as np # Add the...
microsoft/lightgbm-benchmark
tests/common/test_lightgbm_utils.py
"""Tests src/common/io.py""" import os import pytest from unittest.mock import call, Mock, patch from common.lightgbm_utils import LightGBMCallbackHandler from lightgbm.callback import CallbackEnv def test_lightgbm_callback_handler(): metrics_logger = Mock() callback_handler = LightGBMCallbackHandler( ...
microsoft/lightgbm-benchmark
tests/scripts/test_generate_data.py
<filename>tests/scripts/test_generate_data.py """ Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.data_processing.generate_data import generate def test_generate_regression_data(te...
microsoft/lightgbm-benchmark
src/scripts/data_processing/lightgbm_data2bin/data2bin.py
<filename>src/scripts/data_processing/lightgbm_data2bin/data2bin.py # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ LightGBM/Python dataset saving to binary """ import os import sys import argparse import logging import traceback import json from distutils.util import strtobool import ligh...
microsoft/lightgbm-benchmark
src/pipelines/azureml/data_generation.py
<filename>src/pipelines/azureml/data_generation.py """ Generates synthetic data with multiple parameters. See config file /conf/experiments/data-generation.yaml to execute: > python src/pipelines/azureml/data_generation.py --exp-config conf/experiments/data-generation.yaml """ # pylint: disable=no-member # NOTE: beca...
microsoft/lightgbm-benchmark
tests/common/test_metrics.py
"""Tests src/common/metrics.py""" import os import pytest from unittest.mock import call, Mock, patch import time import platform import psutil from common.metrics import MetricsLogger @patch('mlflow.end_run') @patch('mlflow.start_run') def test_unique_mlflow_parallel_initialization(mlflow_start_run_mock, mlflow_end_...
microsoft/lightgbm-benchmark
tests/common/test_math.py
"""Tests src/common/math.py""" import os import pytest import numpy as np from common.math import bootstrap_ci def test_bootstrap_ci_fixed_seed(): """Testing the bootstrap_ci method, but we can't have a non-deterministic test here. """ sample_data = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 5.0]) opera...
microsoft/lightgbm-benchmark
tests/scripts/test_lightgbm_data2bin.py
<filename>tests/scripts/test_lightgbm_data2bin.py """ test src/scripts/partition_data/partition.py """ import os import sys import tempfile import pytest from unittest.mock import patch from scripts.data_processing.lightgbm_data2bin import data2bin # IMPORTANT: see conftest.py for fixtures def test_lightgbm_data2bin...
microsoft/lightgbm-benchmark
src/scripts/inferencing/treelite_python/score.py
<gh_stars>10-100 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ TreeLite/Python inferencing script """ import os import sys import argparse import logging import numpy from distutils.util import strtobool import pandas as pd import treelite, treelite_runtime # Add the right path to PYTHO...
microsoft/lightgbm-benchmark
tests/common/test_component.py
"""Tests src/common/io.py""" import os import pytest from unittest.mock import call, Mock, patch import time import json from common.components import SingleNodeScript from common.metrics import MetricsLogger def assert_runnable_script_properties(script_instance: SingleNodeScript, benchmark_name: str, mlflow_set_tag...
microsoft/lightgbm-benchmark
src/scripts/inferencing/custom_win_cli/score.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Custom Binaries inferencing script """ import os import sys import argparse import logging from distutils.util import strtobool from subprocess import PIPE from subprocess import run as subprocess_run from subprocess import TimeoutExpired # ...
microsoft/lightgbm-benchmark
src/scripts/data_processing/partition_data/partition.py
""" Partitions input data (text/lines) into chunks for parallel processing. NOTE: current script assumes all records are independent. """ import os import sys import argparse import logging from distutils.util import strtobool # Add the right path to PYTHONPATH # so that you can import from common.* COMMON_ROOT = os....
microsoft/lightgbm-benchmark
src/scripts/sample/sample.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ This script is a tutorial sample script to explain how all the benchmark scripts are structured and standardized using the `RunnableScript` helper class. We've numbered the steps you need to modify and adapt this sample script to your own ne...
microsoft/lightgbm-benchmark
tests/scripts/test_lightgbm_inferencing_c_api.py
<filename>tests/scripts/test_lightgbm_inferencing_c_api.py<gh_stars>10-100 """ Executes the series of scripts end-to-end to test LightGBM (python) manual benchmark """ import os import sys import tempfile import pytest from unittest.mock import patch, Mock, call from scripts.inferencing.lightgbm_c_api import score # ...
microsoft/lightgbm-benchmark
tests/common/test_perf.py
"""Tests src/common/metrics.py""" import os import pytest from unittest.mock import call, Mock, patch import time from common.perf import PerformanceReportingThread, PerformanceMetricsCollector def verify_all_perf_report_keys(perf_report): """Helper test function, tests all keys in perf report""" assert isins...
microsoft/lightgbm-benchmark
src/common/lightgbm_utils.py
<gh_stars>10-100 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ This classes provide help to integrate lightgbm """ import lightgbm import logging class LightGBMCallbackHandler(): """ This class handles LightGBM callbacks for recording metrics. """ def __init__(self, metrics_logg...
microsoft/lightgbm-benchmark
src/common/metrics.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ These classes provide some tools to automate wall time compute and logging. """ import os import time import re from functools import wraps import mlflow import platform import psutil import json import traceback import logging class Metric...
microsoft/lightgbm-benchmark
src/scripts/inferencing/lightgbm_python/score.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ LightGBM/Python inferencing script """ import os import sys import argparse import logging import time import numpy as np from distutils.util import strtobool import lightgbm # Add the right path to PYTHONPATH # so that you can import from c...
microsoft/lightgbm-benchmark
src/common/perf.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Helps with reporting performance metrics (cpu/mem utilization). Needs to be implemented in the rest of the code. """ import logging import threading import time import psutil class PerformanceReportingThread(threading.Thread): """Thread...
microsoft/lightgbm-benchmark
src/common/paths.py
<filename>src/common/paths.py import os LIGHTGBM_REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) SCRIPTS_SOURCES_ROOT = os.path.join(LIGHTGBM_REPO_ROOT, 'src') COMPONENTS_ROOT = os.path.join(LIGHTGBM_REPO_ROOT, 'src', 'scripts') CONFIG_PATH = os.path.join(LIGHTGBM_REPO_ROOT, 'conf')
microsoft/lightgbm-benchmark
src/common/aml.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ This script contains methods to handle connection to AzureML, such as registering Datasets or obtaining a Dataset handler from a given workspace. """ import logging from azureml.core import Datastore, Da...
microsoft/lightgbm-benchmark
src/scripts/inferencing/lightgbm_c_api/score.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ LightGBM inferencing script using an executable lightgbm_predict to run C API predictions. """ import os import sys import argparse import logging import re import lightgbm import numpy as np import matplotlib.pyplot as plt from distutils.uti...
microsoft/lightgbm-benchmark
src/common/ray.py
<reponame>microsoft/lightgbm-benchmark # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Helper code to run Ray distributed scripts [EXPERIMENTAL] """ import os import logging import traceback from .components import RunnableScript from dataclasses import dataclass from distutils.util impor...
microsoft/lightgbm-benchmark
src/common/pipelines.py
""" Replacement-code for Shrike """ # pylint: disable=no-member # NOTE: because it raises 'dict' has no 'outputs' member in dsl.pipeline construction import os import sys import json import logging import argparse # config management from dataclasses import dataclass from omegaconf import MISSING from typing import An...
Bill-Park/rpi-iot-gcamp
serial_communication/serial_read.py
<reponame>Bill-Park/rpi-iot-gcamp import serial ser = serial.Serial('/dev/ttyACM0', 9600) while True : r = ser.read() print(r) ser.close()
Bill-Park/rpi-iot-gcamp
api_series/dust_2.py
<reponame>Bill-Park/rpi-iot-gcamp import requests import json serviceKey = "<KEY>2F6kdqe2%2F<KEY>yQjLlQH%2B0ZD%2Fg%3D%3D" sido = "서울" url = "http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getCtprvnMesureSidoLIst?sidoName={sido}&searchCondition=DAILY&pageNo=1&numOfRows=10&ServiceKey={key}&_ret...
Bill-Park/rpi-iot-gcamp
snowboy/example/Python3/sample1.py
import snowboydecoder import sys import signal import make_sound_file import os from naver_api import stt, tts import weather_api import serial interrupted = False ser = serial.Serial("/dev/ttyACM0", 9600) led_on_str = "[led on\r\n" led_off_str = "[led off\r\n" def test() : print("hi") snowboydecoder.play_au...
Bill-Park/rpi-iot-gcamp
snowboy/example/Python3/make_sound_file.py
<reponame>Bill-Park/rpi-iot-gcamp import pyaudio import wave import audioop import math import os CHUNK = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 2 RATE = 44100 RECORD_SECONDS = 5 WAVE_OUTPUT_FILENAME = "output.mp3" def main(file_name = "output.mp3") : p = pyaudio.PyAudio() stream = p.open(format=FORMAT, ...
Bill-Park/rpi-iot-gcamp
api_series/dust_1.py
<reponame>Bill-Park/rpi-iot-gcamp<gh_stars>0 import requests from xml.etree import ElementTree serviceKey = "Z9vuWBX1vbycgKOhb8zaQ%2FFAdiYe1IiQTxPL04nRhLPoLakrbl%2F6kdqe2%2F1EpeK1qPlQkdBu2yQjLlQH%2B0ZD%2Fg%3D%3D" sido = "서울" url = "http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getCtprvnMesur...
Bill-Park/rpi-iot-gcamp
snowboy/example/Python3/naver_api/stt.py
<gh_stars>0 import sys import requests import json client_id = "Client ID" client_secret = "Client Secret" lang = "Kor" # 언어 코드 ( Kor, Jpn, Eng, Chn ) url = "https://naveropenapi.apigw.ntruss.com/recog/v1/stt?lang=" + lang def main(file_name) : data = open(file_name, 'rb') headers = { "X-NCP-APIGW-AP...
Bill-Park/rpi-iot-gcamp
snowboy/example/Python3/naver_api/tts.py
import os import sys import requests import json client_id = "Client ID" client_secret = "Client Secret" url = "https://naveropenapi.apigw.ntruss.com/voice/v1/tts" def main(tts_text, file_name = "input.mp3") : datas = { "speaker" : "mijin", "speed" : "0", "text" : tts_text } hea...
Bill-Park/rpi-iot-gcamp
serial_communication/serial_send.py
import serial import time ser = serial.Serial("/dev/ttyACM0", 9600) sample_str = "[led on\r\n" time.sleep(3) ser.write(sample_str.encode()) ser.close()
Bill-Park/rpi-iot-gcamp
api_series/weather_api.py
import requests import json api_key = "dd40631e0b2c53fdc84e1dffd1da95f6" url = "http://api.openweathermap.org/data/2.5/weather?q=Seoul&appid={key}".format(key=api_key) def main() : res = requests.get(url) res_json = json.loads(res.text) temperature = round(res_json["main"]["temp"] - 273, 1) humidity = ...
justinzzy-code/FlappyBird_AI
ai_creation.py
<filename>ai_creation.py from setup import * COLUMNWIDTH,OPENING_SIZE = 50, 300 import random from random import randint as rng import numpy as np from collections import deque from keras.models import Sequential from keras.layers import Dense from tensorflow.keras.optimizers import Adam import os import ...
justinzzy-code/FlappyBird_AI
setup_load.py
<reponame>justinzzy-code/FlappyBird_AI<filename>setup_load.py import random import math import time import copy from random import randint as rng, shuffle # GLOBALS BIRD_X = 300 BIRD_Y = 100 BIRD_WIDTH = 15 BIRD_HEIGHT = 15 GRAVITY = 1.2 JUMP_HEIGHT = 12 BIRD_MAX_VEL = 20 COLUMNWIDTH,OPENING_SIZE = 50,...