function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def execute_sql(self, *a, **kw): try: return super(SQLInsertCompiler, self).execute_sql(*a, **kw) except InvalidGaeKey: raise DatabaseError("Ivalid value for a key filter on GAE.")
potatolondon/djangoappengine-1-4
[ 3, 2, 3, 1, 1358943676 ]
def insert(self, data_list, return_id=False): opts = self.query.get_meta() unindexed_fields = get_model_indexes(self.query.model)['unindexed'] unindexed_cols = [opts.get_field(name).column for name in unindexed_fields] entity_list = [] ancestor_keys = [...
potatolondon/djangoappengine-1-4
[ 3, 2, 3, 1, 1358943676 ]
def execute_sql(self, result_type=MULTI): # Modify query to fetch pks only and then execute the query # to get all pks. pk_field = self.query.model._meta.pk self.query.add_immediate_loading([pk_field.name]) pks = [row for row in self.results_iter()] self.update_entities(p...
potatolondon/djangoappengine-1-4
[ 3, 2, 3, 1, 1358943676 ]
def update_entity(self, pk, pk_field): gae_query = self.build_query() entity = Get(self.ops.value_for_db(pk, pk_field)) if not gae_query.matches_filters(entity): return for field, _, value in self.query.values: if hasattr(value, 'prepare_database_save'): ...
potatolondon/djangoappengine-1-4
[ 3, 2, 3, 1, 1358943676 ]
def _af_rmul(a, b): """ Return the product b*a; input and output are array forms. The ith value is a[b[i]]. Examples ======== >>> Permutation.print_cyclic = False >>> a, b = [1, 0, 2], [0, 2, 1] >>> _af_rmul(a, b) [1, 2, 0] >>> [a[b[i]] for i in range(3)] [1, 2, 0] Th...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def _af_parity(pi): """ Computes the parity of a permutation in array form. The parity of a permutation reflects the parity of the number of inversions in the permutation, i.e., the number of pairs of x and y such that x > y but p[x] < p[y]. Examples ======== >>> _af_parity([0, 1, 2, ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def _af_pow(a, n): """ Routine for finding powers of a permutation. Examples ======== >>> Permutation.print_cyclic = False >>> p = Permutation([2, 0, 3, 1]) >>> p.order() 4 >>> _af_pow(p._array_form, 4) [0, 1, 2, 3] """ if n == 0: return list(range(len(a))) ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __missing__(self, arg): """Enter arg into dictionary and return arg.""" arg = as_int(arg) self[arg] = arg return arg
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __call__(self, *other): """Return product of cycles processed from R to L. Examples ======== >>> Cycle(1, 2)(2, 3) Cycle(1, 3, 2) An instance of a Cycle will automatically parse list-like objects and Permutations that are on the right. It is more fl...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __repr__(self): """We want it to print as a Cycle, not as a dict. Examples ======== >>> Cycle(1, 2) Cycle(1, 2) >>> print(_) Cycle(1, 2) >>> list(Cycle(1, 2).items()) [(1, 2), (2, 1)] """ if not self: return 'Cycl...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def size(self): if not self: return 0 return max(self.keys()) + 1
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __new__(cls, *args, **kwargs): """ Constructor for the Permutation object from a list or a list of lists in which all elements of the permutation may appear only once. Examples ======== >>> Permutation.print_cyclic = False Permutations entered in ar...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def _af_new(perm): """A method to produce a Permutation object from a list; the list is bound to the _array_form attribute, so it must not be modified; this method is meant for internal use only; the list ``a`` is supposed to be generated as a temporary value in a method, so p = ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def array_form(self): """ Return a copy of the attribute _array_form Examples ======== >>> Permutation.print_cyclic = False >>> p = Permutation([[2, 0], [3, 1]]) >>> p.array_form [2, 3, 0, 1] >>> Permutation([[2, 0, 3, 1]]).array_form [3, ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def cyclic_form(self): """ This is used to convert to the cyclic notation from the canonical notation. Singletons are omitted. Examples ======== >>> Permutation.print_cyclic = False >>> p = Permutation([0, 3, 1, 2]) >>> p.cyclic_form [[1, 3, 2]] ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def full_cyclic_form(self): """Return permutation in cyclic form including singletons. Examples ======== >>> Permutation([0, 2, 1]).full_cyclic_form [[0], [1, 2]] """ need = set(range(self.size)) - set(flatten(self.cyclic_form)) rv = self.cyclic_form ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def size(self): """ Returns the number of elements in the permutation. Examples ======== >>> Permutation([[3, 2], [0, 1]]).size 4 See Also ======== cardinality, length, order, rank """ return self._size
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __add__(self, other): """Return permutation that is other higher in rank than self. The rank is the lexicographical rank, with the identity permutation having rank of 0. Examples ======== >>> Permutation.print_cyclic = False >>> I = Permutation([0, 1, 2, 3]...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def rmul(*args): """ Return product of Permutations [a, b, c, ...] as the Permutation whose ith value is a(b(c(i))). a, b, c, ... can be Permutation objects or tuples. Examples ======== >>> Permutation.print_cyclic = False >>> a, b = [1, 0, 2], [0, 2, ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def rmul_with_af(*args): """ Same as rmul, but the elements of args are Permutation objects which have _array_form. """ a = [x._array_form for x in args] rv = _af_new(_af_rmuln(*a)) return rv
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __rmul__(self, other): """This is needed to coerse other to Permutation in rmul.""" return Perm(other)*self
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def commutes_with(self, other): """ Checks if the elements are commuting. Examples ======== >>> a = Permutation([1, 4, 3, 0, 2, 5]) >>> b = Permutation([0, 1, 2, 3, 4, 5]) >>> a.commutes_with(b) True >>> b = Permutation([2, 3, 5, 4, 1, 0]) ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __rxor__(self, i): """Return self(i) when ``i`` is an int. Examples ======== >>> p = Permutation(1, 2, 9) >>> 2 ^ p == p(2) == 9 True """ if int(i) == i: return self(i) else: raise NotImplementedError( ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def transpositions(self): """ Return the permutation decomposed into a list of transpositions. It is always possible to express a permutation as the product of transpositions, see [1] Examples ======== >>> p = Permutation([[1, 2, 3], [0, 4, 5, 6, 7]]) >...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def from_sequence(cls, i, key=None): """Return the permutation needed to obtain ``i`` from the sorted elements of ``i``. If custom sorting is desired, a key can be given. Examples ======== >>> Permutation.print_cyclic = True >>> Permutation.from_sequence('SymPy') ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __iter__(self): """Yield elements from array form. Examples ======== >>> list(Permutation(range(3))) [0, 1, 2] """ for i in self.array_form: yield i
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def atoms(self): """ Returns all the elements of a permutation Examples ======== >>> Permutation([0, 1, 2, 3, 4, 5]).atoms() {0, 1, 2, 3, 4, 5} >>> Permutation([[0, 1], [2, 3], [4, 5]]).atoms() {0, 1, 2, 3, 4, 5} """ return set(self.arra...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def unrank_nonlex(cls, n, r): """ This is a linear time unranking algorithm that does not respect lexicographic order [3]. Examples ======== >>> Permutation.print_cyclic = False >>> Permutation.unrank_nonlex(4, 5) Permutation([2, 0, 3, 1]) >>> Pe...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def _rank1(n, perm, inv_perm): if n == 1: return 0 s = perm[n - 1] t = inv_perm[n - 1] perm[n - 1], perm[t] = perm[t], s inv_perm[n - 1], inv_perm[s] = inv_perm[s], t return s + n*_rank1(n - 1, perm, inv_perm)
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def next_nonlex(self): """ Returns the next permutation in nonlex order [3]. If self is the last permutation in this order it returns None. Examples ======== >>> Permutation.print_cyclic = False >>> p = Permutation([2, 0, 3, 1]) >>> p.rank_nonlex() ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def cardinality(self): """ Returns the number of all possible permutations. Examples ======== >>> p = Permutation([0, 1, 2, 3]) >>> p.cardinality 24 See Also ======== length, order, rank, size """ return int(ifac(self.s...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def is_even(self): """ Checks if a permutation is even. Examples ======== >>> p = Permutation([0, 1, 2, 3]) >>> p.is_even True >>> p = Permutation([3, 2, 1, 0]) >>> p.is_even True See Also ======== is_odd ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def is_odd(self): """ Checks if a permutation is odd. Examples ======== >>> p = Permutation([0, 1, 2, 3]) >>> p.is_odd False >>> p = Permutation([3, 2, 0, 1]) >>> p.is_odd True See Also ======== is_even ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def is_Singleton(self): """ Checks to see if the permutation contains only one number and is thus the only possible permutation of this set of numbers Examples ======== >>> Permutation([0]).is_Singleton True >>> Permutation([0, 1]).is_Singleton F...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def is_Empty(self): """ Checks to see if the permutation is a set with zero elements Examples ======== >>> Permutation([]).is_Empty True >>> Permutation([0]).is_Empty False See Also ======== is_Singleton """ ret...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def is_Identity(self): """ Returns True if the Permutation is an identity permutation. Examples ======== >>> p = Permutation([]) >>> p.is_Identity True >>> p = Permutation([[0], [1], [2]]) >>> p.is_Identity True >>> p = Permutatio...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def descents(self): """ Returns the positions of descents in a permutation, ie, the location where p[i] > p[i+1] Examples ======== >>> p = Permutation([4, 0, 1, 3, 2]) >>> p.descents() [0, 3] See Also ======== ascents, inversion...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def min(self): """ The minimum element moved by the permutation. Examples ======== >>> p = Permutation([0, 1, 4, 3, 2]) >>> p.min() 2 See Also ======== max, descents, ascents, inversions """ a = self.array_form ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def commutator(self, x): """Return the commutator of self and x: ``~x*~self*x*self`` If f and g are part of a group, G, then the commutator of f and g is the group identity iff f and g commute, i.e. fg == gf. Examples ======== >>> Permutation.print_cyclic = False ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def order(self): """ Computes the order of a permutation. When the permutation is raised to the power of its order it equals the identity permutation. Examples ======== >>> Permutation.print_cyclic = False >>> p = Permutation([3, 1, 5, 2, 4, 0]) ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def cycle_structure(self): """Return the cycle structure of the permutation as a dictionary indicating the multiplicity of each cycle length. Examples ======== >>> Permutation.print_cyclic = True >>> Permutation(3).cycle_structure {1: 4} >>> Permutation(...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def cycles(self): """ Returns the number of cycles contained in the permutation (including singletons). Examples ======== >>> Permutation([0, 1, 2]).cycles 3 >>> Permutation([0, 1, 2]).full_cyclic_form [[0], [1], [2]] >>> Permutation(0, 1...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def runs(self): """ Returns the runs of a permutation. An ascending sequence in a permutation is called a run [5]. Examples ======== >>> p = Permutation([2, 5, 7, 3, 6, 0, 1, 4, 8]) >>> p.runs() [[2, 5, 7], [3, 6], [0, 1, 4, 8]] >>> q = Permuta...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def rank_trotterjohnson(self): """ Returns the Trotter Johnson rank, which we get from the minimal change algorithm. See [4] section 2.4. Examples ======== >>> p = Permutation([0, 1, 2, 3]) >>> p.rank_trotterjohnson() 0 >>> p = Permutation([0, 2,...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def unrank_trotterjohnson(cls, size, rank): """ Trotter Johnson permutation unranking. See [4] section 2.4. Examples ======== >>> Permutation.unrank_trotterjohnson(5, 10) Permutation([0, 3, 1, 2, 4]) See Also ======== rank_trotterjohnson, next_...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def get_precedence_matrix(self): """ Gets the precedence matrix. This is used for computing the distance between two permutations. Examples ======== >>> p = Permutation.josephus(3, 6, 1) >>> Permutation.print_cyclic = False >>> p Permutation([2, ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def get_adjacency_matrix(self): """ Computes the adjacency matrix of a permutation. If job i is adjacent to job j in a permutation p then we set m[i, j] = 1 where m is the adjacency matrix of p. Examples ======== >>> p = Permutation.josephus(3, 6, 1) ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def get_positional_distance(self, other): """ Computes the positional distance between two permutations. Examples ======== >>> p = Permutation([0, 3, 1, 2, 4]) >>> q = Permutation.josephus(4, 5, 2) >>> r = Permutation([3, 1, 4, 0, 2]) >>> p.get_positiona...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def josephus(cls, m, n, s=1): """Return as a permutation the shuffling of range(n) using the Josephus scheme in which every m-th item is selected until all have been chosen. The returned permutation has elements listed by the order in which they were selected. The parameter ``s`...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def from_inversion_vector(cls, inversion): """ Calculates the permutation from the inversion vector. Examples ======== >>> Permutation.print_cyclic = False >>> Permutation.from_inversion_vector([3, 2, 1, 0, 0]) Permutation([3, 2, 1, 0, 4, 5]) """ ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def random(cls, n): """ Generates a random permutation of length ``n``. Uses the underlying Python pseudo-random number generator. Examples ======== >>> Permutation.random(2) in (Permutation([1, 0]), Permutation([0, 1])) True """ perm_array = l...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def unrank_lex(cls, size, rank): """ Lexicographic permutation unranking. Examples ======== >>> Permutation.print_cyclic = False >>> a = Permutation.unrank_lex(5, 10) >>> a.rank() 10 >>> a Permutation([0, 2, 4, 1, 3]) See Also ...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def _merge(arr, temp, left, mid, right): """ Merges two sorted arrays and calculates the inversion count. Helper function for calculating inversions. This method is for internal use only. """ i = k = left j = mid inv_count = 0 while i < mid and j <= right: if arr[i] < arr[j...
diofant/diofant
[ 61, 16, 61, 107, 1424619203 ]
def __init__(self, filename, problem, arg): self.filename = filename self.problem = problem self.arg = arg
DecisionSystemsGroup/DSGos
[ 2, 1, 2, 1, 1427035979 ]
def pacman_conf_enumerator(path): filestack = [] current_section = None filestack.append(open(path)) while len(filestack) > 0: f = filestack[-1] line = f.readline() if len(line) == 0: # end of file f.close() filestack.pop() continue...
DecisionSystemsGroup/DSGos
[ 2, 1, 2, 1, 1427035979 ]
def __init__(self, conf=None, options=None): super(PacmanConfig, self).__init__() self['options'] = collections.OrderedDict() self.options = self['options'] self.repos = collections.OrderedDict() self.options["RootDir"] = "/" self.options["DBPath"] = "/var/lib/pacman" ...
DecisionSystemsGroup/DSGos
[ 2, 1, 2, 1, 1427035979 ]
def load_from_options(self, options): global _logmask if options.root is not None: self.options["RootDir"] = options.root if options.dbpath is not None: self.options["DBPath"] = options.dbpath if options.gpgdir is not None: self.options["GPGDir"] = opt...
DecisionSystemsGroup/DSGos
[ 2, 1, 2, 1, 1427035979 ]
def create(kernel): result = Tangible() result.template = "object/tangible/gambling/table/shared_table_base.iff" result.attribute_template_id = -1 result.stfName("item_n","gambling_table")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Creature() result.template = "object/mobile/shared_mynock.iff" result.attribute_template_id = 9 result.stfName("monster_name","mynock")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Tangible() result.template = "object/tangible/ship/components/armor/shared_arm_mandal_enhanced_heavy_composite.iff" result.attribute_template_id = 8 result.stfName("space/space_item","arm_mandal_enhanced_heavy_composite_n")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def __init__(self, **kwargs): """Initialize module.""" super(RProcess, self).__init__(**kwargs) self._wants_dense = True barnes_v = np.asarray([0.1, 0.2, 0.3]) barnes_M = np.asarray([1.e-3, 5.e-3, 1.e-2, 5.e-2]) barnes_a = np.asarray([[2.01, 4.52, 8.16], [0.81, 1.9, 3.2],...
guillochon/FriendlyFit
[ 33, 47, 33, 38, 1473435475 ]
def create(kernel): result = Creature() result.template = "object/mobile/shared_tanc_mite_hue.iff" result.attribute_template_id = 9 result.stfName("monster_name","tanc_mite")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Creature() result.template = "object/mobile/shared_dressed_deathstar_debris_cultist_hum_m_02.iff" result.attribute_template_id = 9 result.stfName("obj_n","unknown_creature")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def my_append(self, a): self.append(a)
chrivers/pyjaco
[ 142, 18, 142, 42, 1298974725 ]
def resolve(url): try: try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0] except: referer=url
azumimuo/family-xbmc-addon
[ 1, 3, 1, 2, 1456692116 ]
def __init__(self, a): self.args = a self.configfile = self.args['config'] self.fullscreen = self.args['fullscreen'] self.resolution = self.args['resolution'] self.theme = self.args['theme'] self.config = self.load_config(self.configfile) # Lysdestic - Allow su...
fofix/fofix
[ 379, 88, 379, 66, 1341600969 ]
def load_config(configPath): ''' Load the configuration file. ''' if configPath is not None: if configPath.lower() == "reset": # Get os specific location of config file, and remove it. fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNI...
fofix/fofix
[ 379, 88, 379, 66, 1341600969 ]
def __init__(self, name, bases, nmspc): super(RegisterClasses, self).__init__(name, bases, nmspc) if not hasattr(self, 'registry'): self.registry = set() self.registry.add(self) self.registry -= set(bases)
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def start(cls, addr, iface=None): raise NotImplementedError("do it")
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def stop(cls, daemon): daemon.close()
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def start(cls): raise NotImplementedError("do it")
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def stop(cls, ihandler): ihandler.stop()
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def __init__(self, interval: float, function: Callable, delay: Optional[float] = None, repeat=False, args: Optional[list] = None, kwargs: Optional[dict] = None): Thread.__init__(self) self.interval = interval self.function = function self.delay = delay if self.de...
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def run(self) -> None: self.finished.wait(self.delay) if not self.finished.is_set(): self.function(*self.args, **self.kwargs) while self.repeat and not self.finished.wait(self.interval): if not self.finished.is_set(): self.function(*self.args, **self.kwarg...
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def __init__(self, interval: float, function: Callable, delay: Optional[float] = None, repeat=False, args: Optional[list] = None, kwargs: Optional[dict] = None): self.interval = interval self.function = function self.delay = delay if self.delay is None: self....
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def cancel(self) -> None: """Cancel the Timer""" if self._timer: self._timer.cancel()
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def load_submodules(base_pkg=None): if base_pkg is None: import dionaea as base_pkg prefix = base_pkg.__name__ + "." for importer, modname, ispkg in pkgutil.iter_modules(base_pkg.__path__, prefix): if modname in loaded_submodules: continue logger.info("Import module %s"...
DinoTools/dionaea
[ 628, 172, 628, 57, 1450728831 ]
def to_xmlrpc(cls, query={}): """ Convert the query set for XMLRPC """ s = XMLRPCSerializer(queryset=cls.objects.filter(**query).order_by("pk")) return s.serialize_queryset()
Nitrate/Nitrate
[ 222, 99, 222, 60, 1413958586 ]
def log(self): log = TCMSLog(model=self) return log.list()
Nitrate/Nitrate
[ 222, 99, 222, 60, 1413958586 ]
def connect(self,host,port): raise NotImplementedError("Not implemented by subclass")
gromacs/copernicus
[ 14, 4, 14, 4, 1421754399 ]
def prepareHeaders(self,request): """ Creates and adds necessary headers for this connection type inputs: request:ServerRequest returns: ServerRequest """ raise NotImplementedError("not implemented by subclass")
gromacs/copernicus
[ 14, 4, 14, 4, 1421754399 ]
def check_output_config(config): """ Check that the configuration is valid""" ok = True if config['output']['sort_column'] not in config['output']['columns']: print("Sort column not in output columns list") ok = False return ok
BjerknesClimateDataCentre/QuinCe
[ 5, 6, 5, 484, 1428402948 ]
def __init__(self, local_error = 0.001, dz = 1e-5, disable_Raman = False, disable_self_steepening = False, suppress_iteration = True, USE_SIMPLE_RAMAN = False, f_R = 0.18, f_R0 = 0.18, tau_1 = 0.0122, tau_2 = 0.0320): """ This initialization function s...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def load_fiber_parameters(self, pulse_in, fiber, output_power, z=0): """ This funciton loads the fiber parameters into class variables. """ self.betas[:] = fiber.get_betas(pulse_in, z=z) # self.alpha[:] = -fiber.get_gain(pulse_in, output_power) # currently alpha cannot change ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def setup_fftw(self, pulse_in, fiber, output_power, raman_plots = False): ''' Call immediately before starting Propagate. This function does two things:\n 1) it sets up byte aligned arrays for fftw\n 2) it fftshifts betas, omegas, and the Raman response so that no further\n s...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def CalculateRamanResponseFT(self, pulse): """ Calculate Raman response in frequency domain. Two versions are available: the first is the LaserFOAM one, which directly calculates R[w]. The second is Dudley-style, which calculates R[t] and then FFTs. Note that the use of fftshifts...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def integrate_over_dz(self,delta_z, direction=1):
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def Advance(self,A,dz,direction): if self.method == SSFM.METHOD_SSFM: if direction==1: A[:] = self.LinearStep(A,dz,direction) return np.exp(dz*direction*self.NonlinearOperator(A))*A else: A[:] = np.exp(dz*direction*self.NonlinearOperator(A)...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def Deriv(self,Aw): """Calculate the temporal derivative using FFT. \n\n MODIFIED from LaserFOAM original code, now input is in frequency space, output is temporal derivative. This should save a few FFTs per iteration.""" return self.IFFT_t(-1.0j*self.omegas * Aw)
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def RK4IP(self,A,h,direction): """Fourth-order Runge-Kutta in the interaction picture. J. Hult, J. Lightwave Tech. 25, 3770 (2007).""" self.A_I[:] = self.LinearStep(A,h,direction) #Side effect: Rely on LinearStep to recalculate self.exp_D for h/2 and direction dir ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def propagate(self, pulse_in, fiber, n_steps, output_power=None, reload_fiber_each_step=False): """ This is the main user-facing function that allows a pulse to be propagated along a fiber (or other nonlinear medium).
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def calculate_coherence(self, pulse_in, fiber, num_trials=5, random_seed=None, noise_type='one_photon_freq', n_steps=50, output_power=None, reload_fiber_each_step=False): """ This function runs :func:`pynlo.interactions.FourWaveMixing.SSFM.propaga...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def propagate_to_gain_goal(self, pulse_in, fiber, n_steps, power_goal = 1, scalefactor_guess = None, powertol = 0.05): """ Integrate over length of gain fiber such that the average output power is power_goal [W]. For this to work, fiber must have spectroscopic ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def FFT_t(self, A): if PYFFTW_AVAILABLE: if global_variables.PRE_FFTSHIFT: self.fft_input[:] = A return self.fft() else: self.fft_input[:] = fftshift(A) return ifftshift(self.fft()) else: ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def FFT_t_shift(self, A): if PYFFTW_AVAILABLE: self.fft_input[:] = fftshift(A) return ifftshift(self.fft()) else: return ifftshift(scipy.fftpack.ifft(fftshift(A)))
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def FFT_t_2(self, A): if PYFFTW_AVAILABLE: if global_variables.PRE_FFTSHIFT: self.fft_input_2[:] = A return self.fft_2() else: self.fft_input_2[:] = fftshift(A) return ifftshift(self.fft_2()) else: ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def IFFT_t_3(self, A): if PYFFTW_AVAILABLE: if global_variables.PRE_FFTSHIFT: self.ifft_input_3[:] = A return self.ifft_3() else: self.ifft_input_3[:] = fftshift(A) return ifftshift(self.ifft_3()) ...
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def CalculateLocalError(self): denom = np.linalg.norm(self.Af) if denom != 0.0: return np.linalg.norm(self.Af-self.Ac)/np.linalg.norm(self.Af) else: return np.linalg.norm(self.Af-self.Ac)
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def conditional_fftshift(self, x): if global_variables.PRE_FFTSHIFT: x[:] = fftshift(x) return x else: return x
pyNLO/PyNLO
[ 72, 43, 72, 14, 1451323162 ]
def stubo_path(): # Find folder that this module is contained in module = sys.modules[__name__] return os.path.dirname(os.path.abspath(module.__file__))
rusenask/mirage
[ 1, 9, 1, 1, 1442829462 ]