示例#1
0
 def empty(cls, key_type, value_type):
     """Create a new empty Dict with *key_type* and *value_type*
     as the types for the keys and values of the dictionary respectively.
     """
     if config.DISABLE_JIT:
         return dict()
     else:
         return cls(dcttype=DictType(key_type, value_type))
示例#2
0
 def empty(cls, key_type, value_type):
     """Create a new empty Dict with *key_type* and *value_type*
     as the types for the keys and values of the dictionary respectively.
     """
     return cls(dcttype=DictType(key_type, value_type))
示例#3
0
duration = 1000  # milliseconds
freq = 300  # Hz
sys.path[0] = os.getcwd()
import BaseFDTD11
import Environment_Setup as envDef
from Tests.Validation_Physics import VideoMaker

import TransformHandler as transH
import Solver_Engine as SE
#import JuliaHandler as JH
"""
Below, specify typings of jclass members, as numba 
doesn't use dynamic typing like base python.

"""
specR = [('dict1', DictType(string, string))]


@jclass(specR)
class Reporter(object):
    def __init__(self):
        self.dict1 = {"": ""}

    def printer(self, item="", name="", show=False):
        self.dict1[name] = item

        # write this to file in organised manner, module for this?
        if show == True:
            print(item)

        #take in some string from a print to console and save to output file with
    (pterm_list_list_type, pterm_list_list_type, i8[:, :]))
distr_dnf_type = ListType(distr_ab_conjunct_type)

conditions_fields_dict = {
    ### Fields that are filled on in instantiation ###

    # The variables used by the condition
    'vars': ListType(GenericVarType),

    # The Disjunctive Normal Form of the condition but organized
    #  so that every conjunct has a seperate lists for alpha and
    #  beta terms.
    'dnf': dnf_type,

    # A mapping from Var pointers to their associated index
    'var_map': DictType(i8, i8),

    # Wether or not the conditions object has been initialized
    'is_initialized': u1,

    # Wether or not the conditions object has been linked to a knowledge base
    'is_linked': u1,

    ### Fields that are filled in after initialization ###
    "distr_dnf": distr_dnf_type

    # # The alpha parts of '.dnf' organized by which Var in 'vars' they use
    # 'alpha_dnfs': ListType(dnf_type),

    # # The beta parts of '.dnf' organized by which left Var in 'vars' they use
    # 'beta_dnfs': ListType(dnf_type),
示例#5
0
from numba.types import string, ListType, DictType
from numba.typed import List as numba_list
from numba.typed import Dict as numba_dict
from tqdm import tqdm
import numpy as np


def simple_cost_function(size: float,
                         frequency: float,
                         num_files: float,
                         exp: float = 2.0):
    return size / (frequency / num_files)**exp


spec = [
    ('_cache', DictType(string, float32)),
    ('_hit', int32),
    ('_miss', int32),
    ('size_history', ListType(float32)),
    ('hit_rate_history', ListType(float32)),
    ('_max_size', float32),
    ('_counters_list', ListType(int32)),
    ('_counters', DictType(int32, string)),
    ('_rev_counters', DictType(string, int32)),
    ('__counter', int32),
]


@jitclass(spec)
class LRUCache(object):
    def __init__(self, max_size: float):
示例#6
0
                return apply_and_concat_func(param_list[0].shape[0],
                                             select_params_func, apply_func,
                                             ts_list, param_list, *args,
                                             *more_args, **kwargs)

        return cls.from_custom_func(custom_func,
                                    output_names=output_names,
                                    pass_lists=True,
                                    **kwargs)


# ############# MA ############# #


@njit(DictType(UniTuple(i8, 2), f8[:, :])(f8[:, :], i8[:], b1[:]), cache=True)
def ma_caching_nb(ts, windows, ewms):
    cache_dict = dict()
    for i in range(windows.shape[0]):
        if (windows[i], int(ewms[i])) not in cache_dict:
            if ewms[i]:
                ma = ewm_mean_nb(ts, windows[i])
            else:
                ma = rolling_mean_nb(ts, windows[i])
            cache_dict[(windows[i], int(ewms[i]))] = ma
    return cache_dict


@njit(f8[:, :](f8[:, :], i8, b1, DictType(UniTuple(i8, 2), f8[:, :])),
      cache=True)
def ma_apply_func_nb(ts, window, ewm, cache_dict):