_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q233300 | smoothing_worker | train | def smoothing_worker(method=None, N=100, seed=None, fk=None, fk_info=None,
add_func=None, log_gamma=None):
"""Generic worker for off-line smoothing algorithms.
This worker may be used in conjunction with utils.multiplexer in order to
run in parallel (and eventually compare) off-line s... | python | {
"resource": ""
} |
q233301 | ParticleHistory.save | train | def save(self, X=None, w=None, A=None):
"""Save one "page" of history at a given time.
.. note::
This method is used internally by `SMC` to store the state of the
particle system at each time t. In most cases, users should not
have to call this method directly.
... | python | {
"resource": ""
} |
q233302 | ParticleHistory.extract_one_trajectory | train | def extract_one_trajectory(self):
"""Extract a single trajectory from the particle history.
The final state is chosen randomly, then the corresponding trajectory
is constructed backwards, until time t=0.
"""
traj = []
for t in reversed(range(self.T)):
if t ... | python | {
"resource": ""
} |
q233303 | ParticleHistory.compute_trajectories | train | def compute_trajectories(self):
"""Compute the N trajectories that constitute the current genealogy.
Compute and add attribute ``B`` to ``self`` where ``B`` is an array
such that ``B[t,n]`` is the index of ancestor at time t of particle X_T^n,
where T is the current length of history.
... | python | {
"resource": ""
} |
q233304 | ParticleHistory.twofilter_smoothing | train | def twofilter_smoothing(self, t, info, phi, loggamma, linear_cost=False,
return_ess=False, modif_forward=None,
modif_info=None):
"""Two-filter smoothing.
Parameters
----------
t: time, in range 0 <= t < T-1
info: SMC object... | python | {
"resource": ""
} |
q233305 | multiSMC | train | def multiSMC(nruns=10, nprocs=0, out_func=None, **args):
"""Run SMC algorithms in parallel, for different combinations of parameters.
`multiSMC` relies on the `multiplexer` utility, and obeys the same logic.
A basic usage is::
results = multiSMC(fk=my_fk_model, N=100, nruns=20, nprocs=0)
T... | python | {
"resource": ""
} |
q233306 | SMC.reset_weights | train | def reset_weights(self):
"""Reset weights after a resampling step.
"""
if self.fk.isAPF:
lw = (rs.log_mean_exp(self.logetat, W=self.W)
- self.logetat[self.A])
self.wgts = rs.Weights(lw=lw)
else:
self.wgts = rs.Weights() | python | {
"resource": ""
} |
q233307 | log_sum_exp | train | def log_sum_exp(v):
"""Log of the sum of the exp of the arguments.
Parameters
----------
v: ndarray
Returns
-------
l: float
l = log(sum(exp(v)))
Note
----
use the log_sum_exp trick to avoid overflow: i.e. we remove the max of v
before exponentiating, then we add... | python | {
"resource": ""
} |
q233308 | log_sum_exp_ab | train | def log_sum_exp_ab(a, b):
"""log_sum_exp for two scalars.
Parameters
----------
a, b: float
Returns
-------
c: float
c = log(e^a + e^b)
"""
if a > b:
return a + np.log(1. + np.exp(b - a))
else:
return b + np.log(1. + np.exp(a - b)) | python | {
"resource": ""
} |
q233309 | wmean_and_var | train | def wmean_and_var(W, x):
"""Component-wise weighted mean and variance.
Parameters
----------
W: (N,) ndarray
normalised weights (must be >=0 and sum to one).
x: ndarray (such that shape[0]==N)
data
Returns
-------
dictionary
{'mean':weighted_means, 'var':weig... | python | {
"resource": ""
} |
q233310 | wmean_and_var_str_array | train | def wmean_and_var_str_array(W, x):
"""Weighted mean and variance of each component of a structured array.
Parameters
----------
W: (N,) ndarray
normalised weights (must be >=0 and sum to one).
x: (N,) structured array
data
Returns
-------
dictionary
{'mean':... | python | {
"resource": ""
} |
q233311 | wquantiles | train | def wquantiles(W, x, alphas=(0.25, 0.50, 0.75)):
"""Quantiles for weighted data.
Parameters
----------
W: (N,) ndarray
normalised weights (weights are >=0 and sum to one)
x: (N,) or (N,d) ndarray
data
alphas: list-like of size k (default: (0.25, 0.50, 0.75))
probabilitie... | python | {
"resource": ""
} |
q233312 | wquantiles_str_array | train | def wquantiles_str_array(W, x, alphas=(0.25, 0.50, 0,75)):
"""quantiles for weighted data stored in a structured array.
Parameters
----------
W: (N,) ndarray
normalised weights (weights are >=0 and sum to one)
x: (N,) structured array
data
alphas: list-like of size k (default: ... | python | {
"resource": ""
} |
q233313 | resampling_scheme | train | def resampling_scheme(func):
"""Decorator for resampling schemes."""
@functools.wraps(func)
def modif_func(W, M=None):
M = W.shape[0] if M is None else M
return func(W, M)
rs_funcs[func.__name__] = modif_func
modif_func.__doc__ = rs_doc % func.__name__.capitalize()
return modif... | python | {
"resource": ""
} |
q233314 | inverse_cdf | train | def inverse_cdf(su, W):
"""Inverse CDF algorithm for a finite distribution.
Parameters
----------
su: (M,) ndarray
M sorted uniform variates (i.e. M ordered points in [0,1]).
W: (N,) ndarray
a vector of N normalized weights (>=0 and sum to one)
Re... | python | {
"resource": ""
} |
q233315 | hilbert_array | train | def hilbert_array(xint):
"""Compute Hilbert indices.
Parameters
----------
xint: (N, d) int numpy.ndarray
Returns
-------
h: (N,) int numpy.ndarray
Hilbert indices
"""
N, d = xint.shape
h = np.zeros(N, int64)
for n in range(N):
h[n] = Hilbert_to_int(xint[n... | python | {
"resource": ""
} |
q233316 | MCMC.mean_sq_jump_dist | train | def mean_sq_jump_dist(self, discard_frac=0.1):
"""Mean squared jumping distance estimated from chain.
Parameters
----------
discard_frac: float
fraction of iterations to discard at the beginning (as a burn-in)
Returns
-------
float
"""
... | python | {
"resource": ""
} |
q233317 | VanishCovTracker.update | train | def update(self, v):
"""Adds point v"""
self.t += 1
g = self.gamma()
self.mu = (1. - g) * self.mu + g * v
mv = v - self.mu
self.Sigma = ((1. - g) * self.Sigma
+ g * np.dot(mv[:, np.newaxis], mv[np.newaxis, :]))
try:
self.L = chole... | python | {
"resource": ""
} |
q233318 | cartesian_lists | train | def cartesian_lists(d):
"""
turns a dict of lists into a list of dicts that represents
the cartesian product of the initial lists
Example
-------
cartesian_lists({'a':[0, 2], 'b':[3, 4, 5]}
returns
[ {'a':0, 'b':3}, {'a':0, 'b':4}, ... {'a':2, 'b':5} ]
"""
return [{k: v for k, ... | python | {
"resource": ""
} |
q233319 | cartesian_args | train | def cartesian_args(args, listargs, dictargs):
""" Compute a list of inputs and outputs for a function
with kw arguments.
args: dict
fixed arguments, e.g. {'x': 3}, then x=3 for all inputs
listargs: dict
arguments specified as a list; then the inputs
should be the Cartesian product... | python | {
"resource": ""
} |
q233320 | worker | train | def worker(qin, qout, f):
"""Worker for muliprocessing.
A worker repeatedly picks a dict of arguments in the queue and computes
f for this set of arguments, until the input queue is empty.
"""
while not qin.empty():
i, args = qin.get()
qout.put((i, f(**args))) | python | {
"resource": ""
} |
q233321 | distinct_seeds | train | def distinct_seeds(k):
""" returns k distinct seeds for random number generation
"""
seeds = []
for _ in range(k):
while True:
s = random.randint(2**32 - 1)
if s not in seeds:
break
seeds.append(s)
return seeds | python | {
"resource": ""
} |
q233322 | multiplexer | train | def multiplexer(f=None, nruns=1, nprocs=1, seeding=None, **args):
"""Evaluate a function for different parameters, optionally in parallel.
Parameters
----------
f: function
function f to evaluate, must take only kw arguments as inputs
nruns: int
number of evaluations of f for each... | python | {
"resource": ""
} |
q233323 | StateSpaceModel.simulate | train | def simulate(self, T):
"""Simulate state and observation processes.
Parameters
----------
T: int
processes are simulated from time 0 to time T-1
Returns
-------
x, y: lists
lists of length T
"""
x = []
for t in ra... | python | {
"resource": ""
} |
q233324 | interpoled_resampling | train | def interpoled_resampling(W, x):
"""Resampling based on an interpolated CDF, as described in Malik and Pitt.
Parameters
----------
W: (N,) array
weights
x: (N,) array
particles
Returns
-------
xrs: (N,) array
the resampled particles
"""
N = W.shape[... | python | {
"resource": ""
} |
q233325 | sort_items | train | def sort_items(self,items,args=False):
"""
Sort the `self`'s contents, as contained in the list `items` as
specified in `self`'s meta-data.
"""
if self.settings['sort'].lower() == 'src': return
def alpha(i):
return i.name
def permission(i):
if args:
if i.intent ==... | python | {
"resource": ""
} |
q233326 | FortranBase.contents_size | train | def contents_size(self):
'''
Returns the number of different categories to be shown in the
contents side-bar in the HTML documentation.
'''
count = 0
if hasattr(self,'variables'): count += 1
if hasattr(self,'types'): count += 1
if hasattr(self,'modules'): ... | python | {
"resource": ""
} |
q233327 | FortranBase.sort | train | def sort(self):
'''
Sorts components of the object.
'''
if hasattr(self,'variables'):
sort_items(self,self.variables)
if hasattr(self,'modules'):
sort_items(self,self.modules)
if hasattr(self,'submodules'):
sort_items(self,self.submodul... | python | {
"resource": ""
} |
q233328 | FortranBase.make_links | train | def make_links(self, project):
"""
Process intra-site links to documentation of other parts of the program.
"""
self.doc = ford.utils.sub_links(self.doc,project)
if 'summary' in self.meta:
self.meta['summary'] = ford.utils.sub_links(self.meta['summary'],project)
... | python | {
"resource": ""
} |
q233329 | FortranBase.iterator | train | def iterator(self, *argv):
""" Iterator returning any list of elements via attribute lookup in `self`
This iterator retains the order of the arguments """
for arg in argv:
if hasattr(self, arg):
for item in getattr(self, arg):
yield item | python | {
"resource": ""
} |
q233330 | FortranModule.get_used_entities | train | def get_used_entities(self,use_specs):
"""
Returns the entities which are imported by a use statement. These
are contained in dicts.
"""
if len(use_specs.strip()) == 0:
return (self.pub_procs, self.pub_absints, self.pub_types, self.pub_vars)
only = bool(self.O... | python | {
"resource": ""
} |
q233331 | NameSelector.get_name | train | def get_name(self,item):
"""
Return the name for this item registered with this NameSelector.
If no name has previously been registered, then generate a new
one.
"""
if not isinstance(item,ford.sourceform.FortranBase):
raise Exception('{} is not of a type deri... | python | {
"resource": ""
} |
q233332 | main | train | def main(proj_data,proj_docs,md):
"""
Main driver of FORD.
"""
if proj_data['relative']: proj_data['project_url'] = '.'
# Parse the files in your project
project = ford.fortran_project.Project(proj_data)
if len(project.files) < 1:
print("Error: No source files with appropriate extens... | python | {
"resource": ""
} |
q233333 | convertToFree | train | def convertToFree(stream, length_limit=True):
"""Convert stream from fixed source form to free source form."""
linestack = []
for line in stream:
convline = FortranLine(line, length_limit)
if convline.is_regular:
if convline.isContinuation and linestack:
... | python | {
"resource": ""
} |
q233334 | FortranLine.continueLine | train | def continueLine(self):
"""Insert line continuation symbol at end of line."""
if not (self.isLong and self.is_regular):
self.line_conv = self.line_conv.rstrip() + " &\n"
else:
temp = self.line_conv[:72].rstrip() + " &"
self.line_conv = temp.ljust(72) + self.e... | python | {
"resource": ""
} |
q233335 | id_mods | train | def id_mods(obj,modlist,intrinsic_mods={},submodlist=[]):
"""
Match USE statements up with the right modules
"""
for i in range(len(obj.uses)):
for candidate in modlist:
if obj.uses[i][0].lower() == candidate.name.lower():
obj.uses[i] = [candidate, obj.uses[i][1]]
... | python | {
"resource": ""
} |
q233336 | Project.allfiles | train | def allfiles(self):
""" Instead of duplicating files, it is much more efficient to create the itterator on the fly """
for f in self.files:
yield f
for f in self.extra_files:
yield f | python | {
"resource": ""
} |
q233337 | Project.make_links | train | def make_links(self,base_url='..'):
"""
Substitute intrasite links to documentation for other parts of
the program.
"""
ford.sourceform.set_base_url(base_url)
for src in self.allfiles:
src.make_links(self) | python | {
"resource": ""
} |
q233338 | sub_notes | train | def sub_notes(docs):
"""
Substitutes the special controls for notes, warnings, todos, and bugs with
the corresponding div.
"""
def substitute(match):
ret = "</p><div class=\"alert alert-{}\" role=\"alert\"><h4>{}</h4>" \
"<p>{}</p></div>".format(NOTE_TYPE[match.group(1).lower()... | python | {
"resource": ""
} |
q233339 | paren_split | train | def paren_split(sep,string):
"""
Splits the string into pieces divided by sep, when sep is outside of parentheses.
"""
if len(sep) != 1: raise Exception("Separation string must be one character long")
retlist = []
level = 0
blevel = 0
left = 0
for i in range(len(string)):
if ... | python | {
"resource": ""
} |
q233340 | quote_split | train | def quote_split(sep,string):
"""
Splits the strings into pieces divided by sep, when sep in not inside quotes.
"""
if len(sep) != 1: raise Exception("Separation string must be one character long")
retlist = []
squote = False
dquote = False
left = 0
i = 0
while i < len(string):
... | python | {
"resource": ""
} |
q233341 | split_path | train | def split_path(path):
'''
Splits the argument into its constituent directories and returns them as
a list.
'''
def recurse_path(path,retlist):
if len(retlist) > 100:
fullpath = os.path.join(*([ path, ] + retlist))
print("Directory '{}' contains too many levels".format... | python | {
"resource": ""
} |
q233342 | sub_macros | train | def sub_macros(string,base_url):
'''
Replaces macros in documentation with their appropriate values. These macros
are used for things like providing URLs.
'''
macros = { '|url|': base_url,
'|media|': os.path.join(base_url,'media'),
'|page|': os.path.join(base_url,'page'... | python | {
"resource": ""
} |
q233343 | copytree | train | def copytree(src, dst):
"""Replaces shutil.copytree to avoid problems on certain file systems.
shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems
to fail when called for directories on at least one NFS file system.
The current routine is a simple replacement, which should be good... | python | {
"resource": ""
} |
q233344 | Utility.findArgs | train | def findArgs(args, prefixes):
"""
Extracts the list of arguments that start with any of the specified prefix values
"""
return list([
arg for arg in args
if len([p for p in prefixes if arg.lower().startswith(p.lower())]) > 0
]) | python | {
"resource": ""
} |
q233345 | Utility.stripArgs | train | def stripArgs(args, blacklist):
"""
Removes any arguments in the supplied list that are contained in the specified blacklist
"""
blacklist = [b.lower() for b in blacklist]
return list([arg for arg in args if arg.lower() not in blacklist]) | python | {
"resource": ""
} |
q233346 | Utility.capture | train | def capture(command, input=None, cwd=None, shell=False, raiseOnError=False):
"""
Executes a child process and captures its output
"""
# Attempt to execute the child process
proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, shell=shell, universa... | python | {
"resource": ""
} |
q233347 | Utility.run | train | def run(command, cwd=None, shell=False, raiseOnError=False):
"""
Executes a child process and waits for it to complete
"""
returncode = subprocess.call(command, cwd=cwd, shell=shell)
if raiseOnError == True and returncode != 0:
raise Exception('child process ' + str(command) + ' failed with exit code ' + s... | python | {
"resource": ""
} |
q233348 | UnrealManagerBase.setEngineRootOverride | train | def setEngineRootOverride(self, rootDir):
"""
Sets a user-specified directory as the root engine directory, overriding any auto-detection
"""
# Set the new root directory
ConfigurationManager.setConfigKey('rootDirOverride', os.path.abspath(rootDir))
# Check that the specified directory is valid and ... | python | {
"resource": ""
} |
q233349 | UnrealManagerBase.getEngineRoot | train | def getEngineRoot(self):
"""
Returns the root directory location of the latest installed version of UE4
"""
if not hasattr(self, '_engineRoot'):
self._engineRoot = self._getEngineRoot()
return self._engineRoot | python | {
"resource": ""
} |
q233350 | UnrealManagerBase.getEngineVersion | train | def getEngineVersion(self, outputFormat = 'full'):
"""
Returns the version number of the latest installed version of UE4
"""
version = self._getEngineVersionDetails()
formats = {
'major': version['MajorVersion'],
'minor': version['MinorVersion'],
'patch': version['PatchVersion'],
'full': '{}.{}.{}... | python | {
"resource": ""
} |
q233351 | UnrealManagerBase.getEngineChangelist | train | def getEngineChangelist(self):
"""
Returns the compatible Perforce changelist identifier for the latest installed version of UE4
"""
# Newer versions of the engine use the key "CompatibleChangelist", older ones use "Changelist"
version = self._getEngineVersionDetails()
if 'CompatibleChangelist' in versio... | python | {
"resource": ""
} |
q233352 | UnrealManagerBase.isInstalledBuild | train | def isInstalledBuild(self):
"""
Determines if the Engine is an Installed Build
"""
sentinelFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'InstalledBuild.txt')
return os.path.exists(sentinelFile) | python | {
"resource": ""
} |
q233353 | UnrealManagerBase.getEditorBinary | train | def getEditorBinary(self, cmdVersion=False):
"""
Determines the location of the UE4Editor binary
"""
return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion)) | python | {
"resource": ""
} |
q233354 | UnrealManagerBase.getProjectDescriptor | train | def getProjectDescriptor(self, dir):
"""
Detects the .uproject descriptor file for the Unreal project in the specified directory
"""
for project in glob.glob(os.path.join(dir, '*.uproject')):
return os.path.realpath(project)
# No project detected
raise UnrealManagerException('could not detect an Unrea... | python | {
"resource": ""
} |
q233355 | UnrealManagerBase.getPluginDescriptor | train | def getPluginDescriptor(self, dir):
"""
Detects the .uplugin descriptor file for the Unreal plugin in the specified directory
"""
for plugin in glob.glob(os.path.join(dir, '*.uplugin')):
return os.path.realpath(plugin)
# No plugin detected
raise UnrealManagerException('could not detect an Unreal plugi... | python | {
"resource": ""
} |
q233356 | UnrealManagerBase.getDescriptor | train | def getDescriptor(self, dir):
"""
Detects the descriptor file for either an Unreal project or an Unreal plugin in the specified directory
"""
try:
return self.getProjectDescriptor(dir)
except:
try:
return self.getPluginDescriptor(dir)
except:
raise UnrealManagerException('could not detect an ... | python | {
"resource": ""
} |
q233357 | UnrealManagerBase.listThirdPartyLibs | train | def listThirdPartyLibs(self, configuration = 'Development'):
"""
Lists the supported Unreal-bundled third-party libraries
"""
interrogator = self._getUE4BuildInterrogator()
return interrogator.list(self.getPlatformIdentifier(), configuration, self._getLibraryOverrides()) | python | {
"resource": ""
} |
q233358 | UnrealManagerBase.getThirdpartyLibs | train | def getThirdpartyLibs(self, libs, configuration = 'Development', includePlatformDefaults = True):
"""
Retrieves the ThirdPartyLibraryDetails instance for Unreal-bundled versions of the specified third-party libraries
"""
if includePlatformDefaults == True:
libs = self._defaultThirdpartyLibs() + libs
interr... | python | {
"resource": ""
} |
q233359 | UnrealManagerBase.getThirdPartyLibCompilerFlags | train | def getThirdPartyLibCompilerFlags(self, libs):
"""
Retrieves the compiler flags for building against the Unreal-bundled versions of the specified third-party libraries
"""
fmt = PrintingFormat.singleLine()
if libs[0] == '--multiline':
fmt = PrintingFormat.multiLine()
libs = libs[1:]
platformDefault... | python | {
"resource": ""
} |
q233360 | UnrealManagerBase.getThirdPartyLibLinkerFlags | train | def getThirdPartyLibLinkerFlags(self, libs):
"""
Retrieves the linker flags for building against the Unreal-bundled versions of the specified third-party libraries
"""
fmt = PrintingFormat.singleLine()
if libs[0] == '--multiline':
fmt = PrintingFormat.multiLine()
libs = libs[1:]
includeLibs = True
... | python | {
"resource": ""
} |
q233361 | UnrealManagerBase.getThirdPartyLibCmakeFlags | train | def getThirdPartyLibCmakeFlags(self, libs):
"""
Retrieves the CMake invocation flags for building against the Unreal-bundled versions of the specified third-party libraries
"""
fmt = PrintingFormat.singleLine()
if libs[0] == '--multiline':
fmt = PrintingFormat.multiLine()
libs = libs[1:]
platformDe... | python | {
"resource": ""
} |
q233362 | UnrealManagerBase.getThirdPartyLibIncludeDirs | train | def getThirdPartyLibIncludeDirs(self, libs):
"""
Retrieves the list of include directories for building against the Unreal-bundled versions of the specified third-party libraries
"""
platformDefaults = True
if libs[0] == '--nodefaults':
platformDefaults = False
libs = libs[1:]
details = self.getThi... | python | {
"resource": ""
} |
q233363 | UnrealManagerBase.getThirdPartyLibFiles | train | def getThirdPartyLibFiles(self, libs):
"""
Retrieves the list of library files for building against the Unreal-bundled versions of the specified third-party libraries
"""
platformDefaults = True
if libs[0] == '--nodefaults':
platformDefaults = False
libs = libs[1:]
details = self.getThirdpartyLibs(... | python | {
"resource": ""
} |
q233364 | UnrealManagerBase.getThirdPartyLibDefinitions | train | def getThirdPartyLibDefinitions(self, libs):
"""
Retrieves the list of preprocessor definitions for building against the Unreal-bundled versions of the specified third-party libraries
"""
platformDefaults = True
if libs[0] == '--nodefaults':
platformDefaults = False
libs = libs[1:]
details = self.g... | python | {
"resource": ""
} |
q233365 | UnrealManagerBase.generateProjectFiles | train | def generateProjectFiles(self, dir=os.getcwd(), args=[]):
"""
Generates IDE project files for the Unreal project in the specified directory
"""
# If the project is a pure Blueprint project, then we cannot generate project files
if os.path.exists(os.path.join(dir, 'Source')) == False:
Utility.printStderr... | python | {
"resource": ""
} |
q233366 | UnrealManagerBase.cleanDescriptor | train | def cleanDescriptor(self, dir=os.getcwd()):
"""
Cleans the build artifacts for the Unreal project or plugin in the specified directory
"""
# Verify that an Unreal project or plugin exists in the specified directory
descriptor = self.getDescriptor(dir)
# Because performing a clean will also delete the ... | python | {
"resource": ""
} |
q233367 | UnrealManagerBase.buildDescriptor | train | def buildDescriptor(self, dir=os.getcwd(), configuration='Development', args=[], suppressOutput=False):
"""
Builds the editor modules for the Unreal project or plugin in the specified directory, using the specified build configuration
"""
# Verify that an Unreal project or plugin exists in the specified dire... | python | {
"resource": ""
} |
q233368 | UnrealManagerBase.runUAT | train | def runUAT(self, args):
"""
Runs the Unreal Automation Tool with the supplied arguments
"""
Utility.run([self.getRunUATScript()] + args, cwd=self.getEngineRoot(), raiseOnError=True) | python | {
"resource": ""
} |
q233369 | UnrealManagerBase.packageProject | train | def packageProject(self, dir=os.getcwd(), configuration='Shipping', extraArgs=[]):
"""
Packages a build of the Unreal project in the specified directory, using common packaging options
"""
# Verify that the specified build configuration is valid
if configuration not in self.validBuildConfigurations():
r... | python | {
"resource": ""
} |
q233370 | UnrealManagerBase.packagePlugin | train | def packagePlugin(self, dir=os.getcwd(), extraArgs=[]):
"""
Packages a build of the Unreal plugin in the specified directory, suitable for use as a prebuilt Engine module
"""
# Invoke UAT to package the build
distDir = os.path.join(os.path.abspath(dir), 'dist')
self.runUAT([
'BuildPlugin',
'-Plugin... | python | {
"resource": ""
} |
q233371 | UnrealManagerBase.packageDescriptor | train | def packageDescriptor(self, dir=os.getcwd(), args=[]):
"""
Packages a build of the Unreal project or plugin in the specified directory
"""
# Verify that an Unreal project or plugin exists in the specified directory
descriptor = self.getDescriptor(dir)
# Perform the packaging step
if self.isProject(d... | python | {
"resource": ""
} |
q233372 | UnrealManagerBase.runAutomationCommands | train | def runAutomationCommands(self, projectFile, commands, capture=False):
'''
Invokes the Automation Test commandlet for the specified project with the supplied automation test commands
'''
# IMPORTANT IMPLEMENTATION NOTE:
# We need to format the command as a string and execute it using a shell in order to
... | python | {
"resource": ""
} |
q233373 | UnrealManagerBase._getEngineVersionDetails | train | def _getEngineVersionDetails(self):
"""
Parses the JSON version details for the latest installed version of UE4
"""
versionFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'Build.version')
return json.loads(Utility.readFile(versionFile)) | python | {
"resource": ""
} |
q233374 | UnrealManagerBase._getEngineVersionHash | train | def _getEngineVersionHash(self):
"""
Computes the SHA-256 hash of the JSON version details for the latest installed version of UE4
"""
versionDetails = self._getEngineVersionDetails()
hash = hashlib.sha256()
hash.update(json.dumps(versionDetails, sort_keys=True, indent=0).encode('utf-8'))
return hash.hexd... | python | {
"resource": ""
} |
q233375 | UnrealManagerBase._runUnrealBuildTool | train | def _runUnrealBuildTool(self, target, platform, configuration, args, capture=False):
"""
Invokes UnrealBuildTool with the specified parameters
"""
platform = self._transformBuildToolPlatform(platform)
arguments = [self.getBuildScript(), target, platform, configuration] + args
if capture == True:
return U... | python | {
"resource": ""
} |
q233376 | UnrealManagerBase._getUE4BuildInterrogator | train | def _getUE4BuildInterrogator(self):
"""
Uses UE4BuildInterrogator to interrogate UnrealBuildTool about third-party library details
"""
ubtLambda = lambda target, platform, config, args: self._runUnrealBuildTool(target, platform, config, args, True)
interrogator = UE4BuildInterrogator(self.getEngineRoot(), sel... | python | {
"resource": ""
} |
q233377 | JsonDataManager.getKey | train | def getKey(self, key):
"""
Retrieves the value for the specified dictionary key
"""
data = self.getDictionary()
if key in data:
return data[key]
else:
return None | python | {
"resource": ""
} |
q233378 | JsonDataManager.getDictionary | train | def getDictionary(self):
"""
Retrieves the entire data dictionary
"""
if os.path.exists(self.jsonFile):
return json.loads(Utility.readFile(self.jsonFile))
else:
return {} | python | {
"resource": ""
} |
q233379 | JsonDataManager.setKey | train | def setKey(self, key, value):
"""
Sets the value for the specified dictionary key
"""
data = self.getDictionary()
data[key] = value
self.setDictionary(data) | python | {
"resource": ""
} |
q233380 | JsonDataManager.setDictionary | train | def setDictionary(self, data):
"""
Overwrites the entire dictionary
"""
# Create the directory containing the JSON file if it doesn't already exist
jsonDir = os.path.dirname(self.jsonFile)
if os.path.exists(jsonDir) == False:
os.makedirs(jsonDir)
# Store the dictionary
Utility.writeFile(self.js... | python | {
"resource": ""
} |
q233381 | UE4BuildInterrogator.list | train | def list(self, platformIdentifier, configuration, libOverrides = {}):
"""
Returns the list of supported UE4-bundled third-party libraries
"""
modules = self._getThirdPartyLibs(platformIdentifier, configuration)
return sorted([m['Name'] for m in modules] + [key for key in libOverrides]) | python | {
"resource": ""
} |
q233382 | UE4BuildInterrogator.interrogate | train | def interrogate(self, platformIdentifier, configuration, libraries, libOverrides = {}):
"""
Interrogates UnrealBuildTool about the build flags for the specified third-party libraries
"""
# Determine which libraries need their modules parsed by UBT, and which are override-only
libModules = list([lib for lib... | python | {
"resource": ""
} |
q233383 | UE4BuildInterrogator._flatten | train | def _flatten(self, field, items, transform = None):
"""
Extracts the entry `field` from each item in the supplied iterable, flattening any nested lists
"""
# Retrieve the value for each item in the iterable
values = [item[field] for item in items]
# Flatten any nested lists
flattened = []
for valu... | python | {
"resource": ""
} |
q233384 | UE4BuildInterrogator._getThirdPartyLibs | train | def _getThirdPartyLibs(self, platformIdentifier, configuration):
"""
Runs UnrealBuildTool in JSON export mode and extracts the list of third-party libraries
"""
# If we have previously cached the library list for the current engine version, use the cached data
cachedList = CachedDataManager.getCachedDataKe... | python | {
"resource": ""
} |
q233385 | CMakeCustomFlags.processLibraryDetails | train | def processLibraryDetails(details):
"""
Processes the supplied ThirdPartyLibraryDetails instance and sets any custom CMake flags
"""
# If the header include directories list contains any directories we have flags for, add them
for includeDir in details.includeDirs:
# If the directory path matches an... | python | {
"resource": ""
} |
q233386 | PluginManager.getPlugins | train | def getPlugins():
"""
Returns the list of valid ue4cli plugins
"""
# Retrieve the list of detected entry points in the ue4cli.plugins group
plugins = {
entry_point.name: entry_point.load()
for entry_point
in pkg_resources.iter_entry_points('ue4cli.plugins')
}
# Filter out any invalid plugin... | python | {
"resource": ""
} |
q233387 | ThirdPartyLibraryDetails.getCompilerFlags | train | def getCompilerFlags(self, engineRoot, fmt):
"""
Constructs the compiler flags string for building against this library
"""
return Utility.join(
fmt.delim,
self.prefixedStrings(self.definitionPrefix, self.definitions, engineRoot) +
self.prefixedStrings(self.includeDirPrefix, self.includeDirs, engine... | python | {
"resource": ""
} |
q233388 | ThirdPartyLibraryDetails.getLinkerFlags | train | def getLinkerFlags(self, engineRoot, fmt, includeLibs=True):
"""
Constructs the linker flags string for building against this library
"""
components = self.resolveRoot(self.ldFlags, engineRoot)
if includeLibs == True:
components.extend(self.prefixedStrings(self.linkerDirPrefix, self.linkDirs, engineRoot))
... | python | {
"resource": ""
} |
q233389 | ThirdPartyLibraryDetails.getPrefixDirectories | train | def getPrefixDirectories(self, engineRoot, delimiter=' '):
"""
Returns the list of prefix directories for this library, joined using the specified delimiter
"""
return delimiter.join(self.resolveRoot(self.prefixDirs, engineRoot)) | python | {
"resource": ""
} |
q233390 | ThirdPartyLibraryDetails.getIncludeDirectories | train | def getIncludeDirectories(self, engineRoot, delimiter=' '):
"""
Returns the list of include directories for this library, joined using the specified delimiter
"""
return delimiter.join(self.resolveRoot(self.includeDirs, engineRoot)) | python | {
"resource": ""
} |
q233391 | ThirdPartyLibraryDetails.getLinkerDirectories | train | def getLinkerDirectories(self, engineRoot, delimiter=' '):
"""
Returns the list of linker directories for this library, joined using the specified delimiter
"""
return delimiter.join(self.resolveRoot(self.linkDirs, engineRoot)) | python | {
"resource": ""
} |
q233392 | ThirdPartyLibraryDetails.getLibraryFiles | train | def getLibraryFiles(self, engineRoot, delimiter=' '):
"""
Returns the list of library files for this library, joined using the specified delimiter
"""
return delimiter.join(self.resolveRoot(self.libs, engineRoot)) | python | {
"resource": ""
} |
q233393 | ThirdPartyLibraryDetails.getPreprocessorDefinitions | train | def getPreprocessorDefinitions(self, engineRoot, delimiter=' '):
"""
Returns the list of preprocessor definitions for this library, joined using the specified delimiter
"""
return delimiter.join(self.resolveRoot(self.definitions, engineRoot)) | python | {
"resource": ""
} |
q233394 | ThirdPartyLibraryDetails.getCMakeFlags | train | def getCMakeFlags(self, engineRoot, fmt):
"""
Constructs the CMake invocation flags string for building against this library
"""
return Utility.join(
fmt.delim,
[
'-DCMAKE_PREFIX_PATH=' + self.getPrefixDirectories(engineRoot, ';'),
'-DCMAKE_INCLUDE_PATH=' + self.getIncludeDirectories(engineRoot, '... | python | {
"resource": ""
} |
q233395 | is_changed | train | def is_changed():
""" Checks if current project has any noncommited changes. """
executed, changed_lines = execute_git('status --porcelain', output=False)
merge_not_finished = mod_path.exists('.git/MERGE_HEAD')
return changed_lines.strip() or merge_not_finished | python | {
"resource": ""
} |
q233396 | user_agent | train | def user_agent():
"""
Return a User-Agent that identifies this client.
Example:
python-requests/2.9.1 edx-rest-api-client/1.7.2 ecommerce
The last item in the list will be the application name, taken from the
OS environment variable EDX_REST_API_CLIENT_NAME. If that environment
variabl... | python | {
"resource": ""
} |
q233397 | get_oauth_access_token | train | def get_oauth_access_token(url, client_id, client_secret, token_type='jwt', grant_type='client_credentials',
refresh_token=None):
""" Retrieves OAuth 2.0 access token using the given grant type.
Args:
url (str): Oauth2 access token endpoint
client_id (str): client ID
... | python | {
"resource": ""
} |
q233398 | OAuthAPIClient.request | train | def request(self, method, url, **kwargs): # pylint: disable=arguments-differ
"""
Overrides Session.request to ensure that the session is authenticated
"""
self._check_auth()
return super(OAuthAPIClient, self).request(method, url, **kwargs) | python | {
"resource": ""
} |
q233399 | OSPDaemonSimpleSSH.run_command | train | def run_command(self, scan_id, host, cmd):
"""
Run a single command via SSH and return the content of stdout or
None in case of an Error. A scan error is issued in the latter
case.
For logging into 'host', the scan options 'port', 'username',
'password' and 'ssh_timeout'... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.