_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38100 | decimate | train | def decimate(x, q=10, n=4, k=0.8, filterfun=ss.cheby1):
"""
scipy.signal.decimate like downsampling using filtfilt instead of lfilter,
and filter coeffs from butterworth or chebyshev type 1.
Parameters
----------
x : numpy.ndarray
Array to be downsampled along last axis.
q : int
... | python | {
"resource": ""
} |
q38101 | mean | train | def mean(data, units=False, time=False):
"""
Function to compute mean of data
Parameters
----------
data : numpy.ndarray
1st axis unit, 2nd axis time
units : bool
Average over units
time : bool
Average over time
Returns
-------
if units=False and tim... | python | {
"resource": ""
} |
q38102 | corrcoef | train | def corrcoef(time, crossf, integration_window=0.):
"""
Calculate the correlation coefficient for given auto- and crosscorrelation
functions. Standard settings yield the zero lag correlation coefficient.
Setting integration_window > 0 yields the correlation coefficient of
integrated auto- and crossco... | python | {
"resource": ""
} |
q38103 | coherence | train | def coherence(freq, power, cross):
"""
Calculate frequency resolved coherence for given power- and crossspectra.
Parameters
----------
freq : numpy.ndarray
Frequencies, 1 dim array.
power : numpy.ndarray
Power spectra, 1st axis units, 2nd axis frequencies.
cross : numpy.nda... | python | {
"resource": ""
} |
q38104 | add_sst_to_dot_display | train | def add_sst_to_dot_display(ax, sst, color= '0.',alpha= 1.):
'''
suitable for plotting fraction of neurons
'''
plt.sca(ax)
N = len(sst)
current_ymax = 0
counter = 0
while True:
if len(ax.get_lines()) !=0:
data = ax.get_lines()[-1-counter].get_data()[1]
if n... | python | {
"resource": ""
} |
q38105 | empty_bar_plot | train | def empty_bar_plot(ax):
''' Delete all axis ticks and labels '''
plt.sca(ax)
plt.setp(plt.gca(),xticks=[],xticklabels=[])
return ax | python | {
"resource": ""
} |
q38106 | add_to_bar_plot | train | def add_to_bar_plot(ax, x, number, name = '', color = '0.'):
''' This function takes an axes and adds one bar to it '''
plt.sca(ax)
plt.setp(ax,xticks=np.append(ax.get_xticks(),np.array([x]))\
,xticklabels=[item.get_text() for item in ax.get_xticklabels()] +[name])
plt.bar([x],number , colo... | python | {
"resource": ""
} |
q38107 | add_to_line_plot | train | def add_to_line_plot(ax, x, y, color = '0.' , label = ''):
''' This function takes an axes and adds one line to it '''
plt.sca(ax)
plt.plot(x,y, color = color, label = label)
return ax | python | {
"resource": ""
} |
q38108 | colorbar | train | def colorbar(fig, ax, im,
width=0.05,
height=1.0,
hoffset=0.01,
voffset=0.0,
orientation='vertical'):
'''
draw colorbar without resizing the axes object to make room
kwargs:
::
fig : matplotlib.figure.Figure
... | python | {
"resource": ""
} |
q38109 | frontiers_style | train | def frontiers_style():
'''
Figure styles for frontiers
'''
inchpercm = 2.54
frontierswidth=8.5
textsize = 5
titlesize = 7
plt.rcdefaults()
plt.rcParams.update({
'figure.figsize' : [frontierswidth/inchpercm, frontierswidth/inchpercm],
'figure.dpi' : 160,
... | python | {
"resource": ""
} |
q38110 | annotate_subplot | train | def annotate_subplot(ax, ncols=1, nrows=1, letter='a',
linear_offset=0.075, fontsize=8):
'''add a subplot annotation number'''
ax.text(-ncols*linear_offset, 1+nrows*linear_offset, letter,
horizontalalignment='center',
verticalalignment='center',
fontsize=fontsize, fo... | python | {
"resource": ""
} |
q38111 | get_colors | train | def get_colors(num=16, cmap=plt.cm.Set1):
'''return a list of color tuples to use in plots'''
colors = []
for i in xrange(num):
if analysis_params.bw:
colors.append('k' if i % 2 == 0 else 'gray')
else:
i *= 256.
if num > 1:
i /= num - 1.
... | python | {
"resource": ""
} |
q38112 | Compressor.compress | train | def compress(self, data, windowLength = None):
"""Compresses text data using the LZ77 algorithm."""
if windowLength == None:
windowLength = self.defaultWindowLength
compressed = ""
pos = 0
lastPos = len(data) - self.minStringLength
while pos < lastPos:
searchStart = max(pos - windowLength, 0);
... | python | {
"resource": ""
} |
q38113 | Compressor.decompress | train | def decompress(self, data):
"""Decompresses LZ77 compressed text data"""
decompressed = ""
pos = 0
while pos < len(data):
currentChar = data[pos]
if currentChar != self.referencePrefix:
decompressed += currentChar
pos += 1
else:
nextChar = data[pos + 1]
if nextChar != self.referencePre... | python | {
"resource": ""
} |
q38114 | main | train | def main():
"""
Main entry point for running baseconvert as a command.
Examples:
$ python -m baseconvert -n 0.5 -i 10 -o 20 -s True
0.A
$ echo 3.1415926 | python -m baseconvert -i 10 -o 16 -d 3 -s True
3.243
"""
# Parse arguments
parser = argparse.ArgumentParse... | python | {
"resource": ""
} |
q38115 | Counter.notify | train | def notify(self, value):
"""
Increment or decrement the value, according to the given value's sign
The value should be an integer, an attempt to cast it to integer will be made
"""
value = int(value)
with self.lock:
self.value += value | python | {
"resource": ""
} |
q38116 | ConfigStore.get_config | train | def get_config(self):
"""
Load user configuration or return default when not found.
:rtype: :class:`Configuration`
"""
if not self._config:
namespace = {}
if os.path.exists(self.config_path):
execfile(self.config_path, namespace)
... | python | {
"resource": ""
} |
q38117 | CommandShell.open | train | def open(self, input_streams=['stdin'], output_streams=['stderr', 'stdout']):
"""
Opens the remote shell
"""
shell = dict()
shell['rsp:InputStreams'] = " ".join(input_streams)
shell['rsp:OutputStreams'] = " ".join(output_streams)
shell['rsp:IdleTimeout'] = str(sel... | python | {
"resource": ""
} |
q38118 | OAuthSession.start_login_server | train | def start_login_server(self, ):
"""Start a server that will get a request from a user logging in.
This uses the Implicit Grant Flow of OAuth2. The user is asked
to login to twitch and grant PyTwitcher authorization.
Once the user agrees, he is redirected to an url.
This server w... | python | {
"resource": ""
} |
q38119 | OAuthSession.shutdown_login_server | train | def shutdown_login_server(self, ):
"""Shutdown the login server and thread
:returns: None
:rtype: None
:raises: None
"""
log.debug('Shutting down the login server thread.')
self.login_server.shutdown()
self.login_server.server_close()
self.login_t... | python | {
"resource": ""
} |
q38120 | TwitchSession.token | train | def token(self, token):
"""Set the oauth token and the current_user
:param token: the oauth token
:type token: :class:`dict`
:returns: None
:rtype: None
:raises: None
"""
self._token = token
if token:
self.current_user = self.query_log... | python | {
"resource": ""
} |
q38121 | TwitchSession.kraken_request | train | def kraken_request(self, method, endpoint, **kwargs):
"""Make a request to one of the kraken api endpoints.
Headers are automatically set to accept :data:`TWITCH_HEADER_ACCEPT`.
Also the client id from :data:`CLIENT_ID` will be set.
The url will be constructed of :data:`TWITCH_KRAKENURL... | python | {
"resource": ""
} |
q38122 | TwitchSession.usher_request | train | def usher_request(self, method, endpoint, **kwargs):
"""Make a request to one of the usher api endpoints.
The url will be constructed of :data:`TWITCH_USHERURL` and
the given endpoint.
:param method: the request method
:type method: :class:`str`
:param endpoint: the end... | python | {
"resource": ""
} |
q38123 | TwitchSession.oldapi_request | train | def oldapi_request(self, method, endpoint, **kwargs):
"""Make a request to one of the old api endpoints.
The url will be constructed of :data:`TWITCH_APIURL` and
the given endpoint.
:param method: the request method
:type method: :class:`str`
:param endpoint: the endpoi... | python | {
"resource": ""
} |
q38124 | TwitchSession.fetch_viewers | train | def fetch_viewers(self, game):
"""Query the viewers and channels of the given game and
set them on the object
:returns: the given game
:rtype: :class:`models.Game`
:raises: None
"""
r = self.kraken_request('GET', 'streams/summary',
... | python | {
"resource": ""
} |
q38125 | TwitchSession.search_games | train | def search_games(self, query, live=True):
"""Search for games that are similar to the query
:param query: the query string
:type query: :class:`str`
:param live: If true, only returns games that are live on at least one
channel
:type live: :class:`bool`
... | python | {
"resource": ""
} |
q38126 | TwitchSession.top_games | train | def top_games(self, limit=10, offset=0):
"""Return the current top games
:param limit: the maximum amount of top games to query
:type limit: :class:`int`
:param offset: the offset in the top games
:type offset: :class:`int`
:returns: a list of top games
:rtype: :... | python | {
"resource": ""
} |
q38127 | TwitchSession.get_game | train | def get_game(self, name):
"""Get the game instance for a game name
:param name: the name of the game
:type name: :class:`str`
:returns: the game instance
:rtype: :class:`models.Game` | None
:raises: None
"""
games = self.search_games(query=name, live=Fals... | python | {
"resource": ""
} |
q38128 | TwitchSession.get_channel | train | def get_channel(self, name):
"""Return the channel for the given name
:param name: the channel name
:type name: :class:`str`
:returns: the model instance
:rtype: :class:`models.Channel`
:raises: None
"""
r = self.kraken_request('GET', 'channels/' + name)
... | python | {
"resource": ""
} |
q38129 | TwitchSession.search_channels | train | def search_channels(self, query, limit=25, offset=0):
"""Search for channels and return them
:param query: the query string
:type query: :class:`str`
:param limit: maximum number of results
:type limit: :class:`int`
:param offset: offset for pagination
:type offs... | python | {
"resource": ""
} |
q38130 | TwitchSession.get_stream | train | def get_stream(self, channel):
"""Return the stream of the given channel
:param channel: the channel that is broadcasting.
Either name or models.Channel instance
:type channel: :class:`str` | :class:`models.Channel`
:returns: the stream or None, if the channel is... | python | {
"resource": ""
} |
q38131 | TwitchSession.get_streams | train | def get_streams(self, game=None, channels=None, limit=25, offset=0):
"""Return a list of streams queried by a number of parameters
sorted by number of viewers descending
:param game: the game or name of the game
:type game: :class:`str` | :class:`models.Game`
:param channels: li... | python | {
"resource": ""
} |
q38132 | TwitchSession.search_streams | train | def search_streams(self, query, hls=False, limit=25, offset=0):
"""Search for streams and return them
:param query: the query string
:type query: :class:`str`
:param hls: If true, only return streams that have hls stream
:type hls: :class:`bool`
:param limit: maximum num... | python | {
"resource": ""
} |
q38133 | TwitchSession.followed_streams | train | def followed_streams(self, limit=25, offset=0):
"""Return the streams the current user follows.
Needs authorization ``user_read``.
:param limit: maximum number of results
:type limit: :class:`int`
:param offset: offset for pagination
:type offset: :class:`int`
:... | python | {
"resource": ""
} |
q38134 | TwitchSession.get_user | train | def get_user(self, name):
"""Get the user for the given name
:param name: The username
:type name: :class:`str`
:returns: the user instance
:rtype: :class:`models.User`
:raises: None
"""
r = self.kraken_request('GET', 'user/' + name)
return models... | python | {
"resource": ""
} |
q38135 | TwitchSession.get_playlist | train | def get_playlist(self, channel):
"""Return the playlist for the given channel
:param channel: the channel
:type channel: :class:`models.Channel` | :class:`str`
:returns: the playlist
:rtype: :class:`m3u8.M3U8`
:raises: :class:`requests.HTTPError` if channel is offline.
... | python | {
"resource": ""
} |
q38136 | TwitchSession.get_quality_options | train | def get_quality_options(self, channel):
"""Get the available quality options for streams of the given channel
Possible values in the list:
* source
* high
* medium
* low
* mobile
* audio
:param channel: the channel or channel name
... | python | {
"resource": ""
} |
q38137 | TwitchSession.get_channel_access_token | train | def get_channel_access_token(self, channel):
"""Return the token and sig for the given channel
:param channel: the channel or channel name to get the access token for
:type channel: :class:`channel` | :class:`str`
:returns: The token and sig for the given channel
:rtype: (:class... | python | {
"resource": ""
} |
q38138 | TwitchSession.get_chat_server | train | def get_chat_server(self, channel):
"""Get an appropriate chat server for the given channel
Usually the server is irc.twitch.tv. But because of the delicate
twitch chat, they use a lot of servers. Big events are on special
event servers. This method tries to find a good one.
:p... | python | {
"resource": ""
} |
q38139 | TwitchSession._find_best_chat_server | train | def _find_best_chat_server(servers, stats):
"""Find the best from servers by comparing with the stats
:param servers: a list if server adresses, e.g. ['0.0.0.0:80']
:type servers: :class:`list` of :class:`str`
:param stats: list of server statuses
:type stats: :class:`list` of :... | python | {
"resource": ""
} |
q38140 | TwitchSession.get_emote_picture | train | def get_emote_picture(self, emote, size=1.0):
"""Return the picture for the given emote
:param emote: the emote object
:type emote: :class:`pytwitcherapi.chat.message.Emote`
:param size: the size of the picture.
Choices are: 1.0, 2.0, 3.0
:type size: :class:... | python | {
"resource": ""
} |
q38141 | strip_glob | train | def strip_glob(string, split_str=' '):
"""
Strip glob portion in `string`.
>>> strip_glob('*glob*like')
'glob like'
>>> strip_glob('glob?')
'glo'
>>> strip_glob('glob[seq]')
'glob'
>>> strip_glob('glob[!seq]')
'glob'
:type string: str
:rtype: str
"""
string = _... | python | {
"resource": ""
} |
q38142 | daterange | train | def daterange(start, end, delta=timedelta(days=1), lower=Interval.CLOSED, upper=Interval.OPEN):
"""Returns a generator which creates the next value in the range on demand"""
date_interval = Interval(lower=lower, lower_value=start, upper_value=end, upper=upper)
current = start if start in date_interval else ... | python | {
"resource": ""
} |
q38143 | new_metric | train | def new_metric(name, class_, *args, **kwargs):
"""Create a new metric of the given class.
Raise DuplicateMetricError if the given name has been already registered before
Internal function - use "new_<type> instead"
"""
with LOCK:
try:
item = REGISTRY[name]
except KeyEr... | python | {
"resource": ""
} |
q38144 | delete_metric | train | def delete_metric(name):
"""Remove the named metric"""
with LOCK:
old_metric = REGISTRY.pop(name, None)
# look for the metric name in the tags and remove it
for _, tags in py3comp.iteritems(TAGS):
if name in tags:
tags.remove(name)
return old_metric | python | {
"resource": ""
} |
q38145 | new_histogram | train | def new_histogram(name, reservoir=None):
"""
Build a new histogram metric with a given reservoir object
If the reservoir is not provided, a uniform reservoir with the default size is used
"""
if reservoir is None:
reservoir = histogram.UniformReservoir(histogram.DEFAULT_UNIFORM_RESERVOIR_SI... | python | {
"resource": ""
} |
q38146 | new_histogram_with_implicit_reservoir | train | def new_histogram_with_implicit_reservoir(name, reservoir_type='uniform', *reservoir_args, **reservoir_kwargs):
"""
Build a new histogram metric and a reservoir from the given parameters
"""
reservoir = new_reservoir(reservoir_type, *reservoir_args, **reservoir_kwargs)
return new_histogram(name, re... | python | {
"resource": ""
} |
q38147 | new_reservoir | train | def new_reservoir(reservoir_type='uniform', *reservoir_args, **reservoir_kwargs):
"""
Build a new reservoir
"""
try:
reservoir_cls = RESERVOIR_TYPES[reservoir_type]
except KeyError:
raise InvalidMetricError("Unknown reservoir type: {}".format(reservoir_type))
return reservoir_c... | python | {
"resource": ""
} |
q38148 | get_or_create_histogram | train | def get_or_create_histogram(name, reservoir_type, *reservoir_args, **reservoir_kwargs):
"""
Will return a histogram matching the given parameters or raise
DuplicateMetricError if it can't be created due to a name collision
with another histogram with different parameters.
"""
reservoir = new_res... | python | {
"resource": ""
} |
q38149 | tag | train | def tag(name, tag_name):
"""
Tag the named metric with the given tag.
"""
with LOCK:
# just to check if <name> exists
metric(name)
TAGS.setdefault(tag_name, set()).add(name) | python | {
"resource": ""
} |
q38150 | untag | train | def untag(name, tag_name):
"""
Remove the given tag from the given metric.
Return True if the metric was tagged, False otherwise
"""
with LOCK:
by_tag = TAGS.get(tag_name, None)
if not by_tag:
return False
try:
by_tag.remove(name)
# remov... | python | {
"resource": ""
} |
q38151 | quantity_yXL | train | def quantity_yXL(fig, left, bottom, top, quantity=params.L_yXL, label=r'$\mathcal{L}_{yXL}$'):
'''make a bunch of image plots, each showing the spatial normalized
connectivity of synapses'''
layers = ['L1', 'L2/3', 'L4', 'L5', 'L6']
ncols = len(params.y) / 4
... | python | {
"resource": ""
} |
q38152 | Connection.get | train | def get(self, url, proto='http'):
"""
Load an url using the GET method.
Keyword arguments:
url -- the Universal Resource Location
proto -- the protocol (default 'http')
"""
self.last_response = self.session.get(proto + self.base_uri + url,
... | python | {
"resource": ""
} |
q38153 | Connection.post | train | def post(self, url, data, proto='http', form_name=None):
"""
Load an url using the POST method.
Keyword arguments:
url -- the Universal Resource Location
data -- the form to be sent
proto -- the protocol (default 'http')
form_name -- the form name to search the d... | python | {
"resource": ""
} |
q38154 | watch_record | train | def watch_record(indexer, use_polling=False):
"""
Start watching `cfstore.record_path`.
:type indexer: rash.indexer.Indexer
"""
if use_polling:
from watchdog.observers.polling import PollingObserver as Observer
Observer # fool pyflakes
else:
from watchdog.observers imp... | python | {
"resource": ""
} |
q38155 | run_sim | train | def run_sim(morphology='patdemo/cells/j4a.hoc',
cell_rotation=dict(x=4.99, y=-4.33, z=3.14),
closest_idx=dict(x=-200., y=0., z=800.)):
'''set up simple cell simulation with LFPs in the plane'''
# Create cell
cell = LFPy.Cell(morphology=morphology, **cell_parameters)
# Align cell... | python | {
"resource": ""
} |
q38156 | multicompartment_params._synDelayParams | train | def _synDelayParams(self):
'''
set up the detailed synaptic delay parameters,
loc is mean delay,
scale is std with low bound cutoff,
assumes numpy.random.normal is used later
'''
delays = {}
#mean delays
loc = np.zeros((len(self.y), len(self.X)))
... | python | {
"resource": ""
} |
q38157 | multicompartment_params._calcDepths | train | def _calcDepths(self):
'''
return the cortical depth of each subpopulation
'''
depths = self.layerBoundaries.mean(axis=1)[1:]
depth_y = []
for y in self.y:
if y in ['p23', 'b23', 'nb23']:
depth_y = np.r_[depth_y, depths[0]]
elif y ... | python | {
"resource": ""
} |
q38158 | multicompartment_params._yCellParams | train | def _yCellParams(self):
'''
Return dict with parameters for each population.
The main operation is filling in cell type specific morphology
'''
#cell type specific parameters going into LFPy.Cell
yCellParams = {}
for layer, morpho, _, _ in self.y_zip_list:... | python | {
"resource": ""
} |
q38159 | PopulationSuper.run | train | def run(self):
"""
Distribute individual cell simulations across ranks.
This method takes no keyword arguments.
Parameters
----------
None
Returns
-------
None
"""
for cellindex in self.RANK_CELLINDICES:
self.cells... | python | {
"resource": ""
} |
q38160 | PopulationSuper.calc_min_cell_interdist | train | def calc_min_cell_interdist(self, x, y, z):
"""
Calculate cell interdistance from input coordinates.
Parameters
----------
x, y, z : numpy.ndarray
xyz-coordinates of each cell-body.
Returns
-------
min_cell_interdist : np.nparray
... | python | {
"resource": ""
} |
q38161 | PopulationSuper.calc_signal_sum | train | def calc_signal_sum(self, measure='LFP'):
"""
Superimpose each cell's contribution to the compound population signal,
i.e., the population CSD or LFP
Parameters
----------
measure : str
{'LFP', 'CSD'}: Either 'LFP' or 'CSD'.
Returns
-------... | python | {
"resource": ""
} |
q38162 | PopulationSuper.collect_data | train | def collect_data(self):
"""
Collect LFPs, CSDs and soma traces from each simulated population,
and save to file.
Parameters
----------
None
Returns
-------
None
"""
#collect some measurements resolved per file and save to file
... | python | {
"resource": ""
} |
q38163 | Population.get_all_synIdx | train | def get_all_synIdx(self):
"""
Auxilliary function to set up class attributes containing
synapse locations given as LFPy.Cell compartment indices
This function takes no inputs.
Parameters
----------
None
Returns
-------
synIdx : dict
... | python | {
"resource": ""
} |
q38164 | Population.get_all_SpCells | train | def get_all_SpCells(self):
"""
For each postsynaptic cell existing on this RANK, load or compute
the presynaptic cell index for each synaptic connection
This function takes no kwargs.
Parameters
----------
None
Returns
-------
SpCells ... | python | {
"resource": ""
} |
q38165 | Population.get_all_synDelays | train | def get_all_synDelays(self):
"""
Create and load arrays of connection delays per connection on this rank
Get random normally distributed synaptic delays,
returns dict of nested list of same shape as SpCells.
Delays are rounded to dt.
This function takes no kwargs.
... | python | {
"resource": ""
} |
q38166 | Population.get_synidx | train | def get_synidx(self, cellindex):
"""
Local function, draw and return synapse locations corresponding
to a single cell, using a random seed set as
`POPULATIONSEED` + `cellindex`.
Parameters
----------
cellindex : int
Index of cell object.
Re... | python | {
"resource": ""
} |
q38167 | Population.fetchSynIdxCell | train | def fetchSynIdxCell(self, cell, nidx, synParams):
"""
Find possible synaptic placements for each cell
As synapses are placed within layers with bounds determined by
self.layerBoundaries, it will check this matrix accordingly, and
use the probabilities from `self.connProbLayer to ... | python | {
"resource": ""
} |
q38168 | Population.cellsim | train | def cellsim(self, cellindex, return_just_cell = False):
"""
Do the actual simulations of LFP, using synaptic spike times from
network simulation.
Parameters
----------
cellindex : int
cell index between 0 and population size-1.
return_just_cell : boo... | python | {
"resource": ""
} |
q38169 | Population.insert_all_synapses | train | def insert_all_synapses(self, cellindex, cell):
"""
Insert all synaptic events from all presynaptic layers on
cell object with index `cellindex`.
Parameters
----------
cellindex : int
cell index in the population.
cell : `LFPy.Cell` instance
... | python | {
"resource": ""
} |
q38170 | Population.insert_synapses | train | def insert_synapses(self, cell, cellindex, synParams, idx = np.array([]),
X='EX', SpCell = np.array([]),
synDelays = None):
"""
Insert synapse with `parameters`=`synparams` on cell=cell, with
segment indexes given by `idx`. `SpCell` and `SpTimes` p... | python | {
"resource": ""
} |
q38171 | run | train | def run(func, keys, max_procs=None, show_proc=False, affinity=None, **kwargs):
"""
Provide interface for multiprocessing
Args:
func: callable functions
keys: keys in kwargs that want to use process
max_procs: max number of processes
show_proc: whether to show process
... | python | {
"resource": ""
} |
q38172 | saturate_kwargs | train | def saturate_kwargs(keys, **kwargs):
"""
Saturate all combinations of kwargs
Args:
keys: keys in kwargs that want to use process
**kwargs: kwargs for func
"""
# Validate if keys are in kwargs and if they are iterable
if isinstance(keys, str): keys = [keys]
keys = [k for k in... | python | {
"resource": ""
} |
q38173 | quick_idw | train | def quick_idw(input_geojson_points, variable_name, power, nb_class,
nb_pts=10000, resolution=None, disc_func=None,
mask=None, user_defined_breaks=None,
variable_name2=None, output='GeoJSON', **kwargs):
"""
Function acting as a one-shot wrapper around SmoothIdw object.
... | python | {
"resource": ""
} |
q38174 | quick_stewart | train | def quick_stewart(input_geojson_points, variable_name, span,
beta=2, typefct='exponential',nb_class=None,
nb_pts=10000, resolution=None, mask=None,
user_defined_breaks=None, variable_name2=None,
output="GeoJSON", **kwargs):
"""
Function act... | python | {
"resource": ""
} |
q38175 | make_regular_points | train | def make_regular_points(bounds, resolution, longlat=True):
"""
Return a regular grid of points within `bounds` with the specified
resolution.
Parameters
----------
bounds : 4-floats tuple
The bbox of the grid, as xmin, ymin, xmax, ymax.
resolution : int
The resolution to use... | python | {
"resource": ""
} |
q38176 | identify | train | def identify(s):
"""Identify what kind of Chinese characters a string contains.
*s* is a string to examine. The string's Chinese characters are tested to
see if they are compatible with the Traditional or Simplified characters
systems, compatible with both, or contain a mixture of Traditional and
S... | python | {
"resource": ""
} |
q38177 | is_traditional | train | def is_traditional(s):
"""Check if a string's Chinese characters are Traditional.
This is equivalent to:
>>> identify('foo') in (TRADITIONAL, BOTH)
"""
chinese = _get_hanzi(s)
if not chinese:
return False
elif chinese.issubset(_SHARED_CHARACTERS):
return True
elif c... | python | {
"resource": ""
} |
q38178 | is_simplified | train | def is_simplified(s):
"""Check if a string's Chinese characters are Simplified.
This is equivalent to:
>>> identify('foo') in (SIMPLIFIED, BOTH)
"""
chinese = _get_hanzi(s)
if not chinese:
return False
elif chinese.issubset(_SHARED_CHARACTERS):
return True
elif chin... | python | {
"resource": ""
} |
q38179 | params.set_default_fig_style | train | def set_default_fig_style(self):
'''default figure size'''
plt.rcParams.update({
'figure.figsize' : [self.frontierswidth/self.inchpercm, self.frontierswidth/self.inchpercm],
}) | python | {
"resource": ""
} |
q38180 | params.set_large_fig_style | train | def set_large_fig_style(self):
'''twice width figure size'''
plt.rcParams.update({
'figure.figsize' : [self.frontierswidth/self.inchpercm*2, self.frontierswidth/self.inchpercm],
}) | python | {
"resource": ""
} |
q38181 | params.set_broad_fig_style | train | def set_broad_fig_style(self):
'''4 times width, 1.5 times height'''
plt.rcParams.update({
'figure.figsize' : [self.frontierswidth/self.inchpercm*4, self.frontierswidth/self.inchpercm*1.5],
}) | python | {
"resource": ""
} |
q38182 | params.set_enormous_fig_style | train | def set_enormous_fig_style(self):
'''2 times width, 2 times height'''
plt.rcParams.update({
'figure.figsize' : [self.frontierswidth/self.inchpercm*2, self.frontierswidth/self.inchpercm*2],
}) | python | {
"resource": ""
} |
q38183 | params.set_PLOS_1column_fig_style | train | def set_PLOS_1column_fig_style(self, ratio=1):
'''figure size corresponding to Plos 1 column'''
plt.rcParams.update({
'figure.figsize' : [self.PLOSwidth1Col,self.PLOSwidth1Col*ratio],
}) | python | {
"resource": ""
} |
q38184 | params.set_PLOS_2column_fig_style | train | def set_PLOS_2column_fig_style(self, ratio=1):
'''figure size corresponding to Plos 2 columns'''
plt.rcParams.update({
'figure.figsize' : [self.PLOSwidth2Col, self.PLOSwidth2Col*ratio],
}) | python | {
"resource": ""
} |
q38185 | PostProcess.run | train | def run(self):
""" Perform the postprocessing steps, computing compound signals from
cell-specific output files.
"""
if RANK == 0:
if 'LFP' in self.savelist:
#get the per population LFPs and total LFP from all populations:
self.LFPdict, self.LF... | python | {
"resource": ""
} |
q38186 | PostProcess.calc_lfp | train | def calc_lfp(self):
""" Sum all the LFP contributions from every cell type.
"""
LFParray = np.array([])
LFPdict = {}
i = 0
for y in self.y:
fil = os.path.join(self.populations_path,
self.output_file.format(y, 'LFP.h5'))
... | python | {
"resource": ""
} |
q38187 | PostProcess.calc_csd | train | def calc_csd(self):
""" Sum all the CSD contributions from every layer.
"""
CSDarray = np.array([])
CSDdict = {}
i = 0
for y in self.y:
fil = os.path.join(self.populations_path,
self.output_file.format(y, 'CSD.h5'))
... | python | {
"resource": ""
} |
q38188 | PostProcess.create_tar_archive | train | def create_tar_archive(self):
""" Create a tar archive of the main simulation outputs.
"""
#file filter
EXCLUDE_FILES = glob.glob(os.path.join(self.savefolder, 'cells'))
EXCLUDE_FILES += glob.glob(os.path.join(self.savefolder,
'popu... | python | {
"resource": ""
} |
q38189 | sort_queryset | train | def sort_queryset(queryset, request, context=None):
""" Returns a sorted queryset
The context argument is only used in the template tag
"""
sort_by = request.GET.get('sort_by')
if sort_by:
if sort_by in [el.name for el in queryset.model._meta.fields]:
queryset = queryset.order_by... | python | {
"resource": ""
} |
q38190 | include_before | train | def include_before(predicate, num, iterative):
"""
Return elements in `iterative` including `num`-before elements.
>>> list(include_before(lambda x: x == 'd', 2, 'abcded'))
['b', 'c', 'd', 'e', 'd']
"""
(it0, it1) = itertools.tee(iterative)
ps = _backward_shifted_predicate(predicate, num, ... | python | {
"resource": ""
} |
q38191 | include_after | train | def include_after(predicate, num, iterative):
"""
Return elements in `iterative` including `num`-after elements.
>>> list(include_after(lambda x: x == 'b', 2, 'abcbcde'))
['b', 'c', 'b', 'c', 'd']
"""
(it0, it1) = itertools.tee(iterative)
ps = _forward_shifted_predicate(predicate, num, it1... | python | {
"resource": ""
} |
q38192 | include_context | train | def include_context(predicate, num, iterative):
"""
Return elements in `iterative` including `num` before and after elements.
>>> ''.join(include_context(lambda x: x == '!', 2, 'bb!aa__bb!aa'))
'bb!aabb!aa'
"""
(it0, it1, it2) = itertools.tee(iterative, 3)
psf = _forward_shifted_predicate(... | python | {
"resource": ""
} |
q38193 | calc_variances | train | def calc_variances(params):
'''
This function calculates the variance of the sum signal and all population-resolved signals
'''
depth = params.electrodeParams['z']
############################
### CSD ###
############################
for i, data_type in enumerate(['C... | python | {
"resource": ""
} |
q38194 | MyIRCClient.on_join | train | def on_join(self, connection, event):
"""Handles the join event and greets everone
:param connection: the connection with the event
:type connection: :class:`irc.client.ServerConnection`
:param event: the event to handle
:type event: :class:`irc.client.Event`
:returns: N... | python | {
"resource": ""
} |
q38195 | daemon_run | train | def daemon_run(no_error, restart, record_path, keep_json, check_duplicate,
use_polling, log_level):
"""
Run RASH index daemon.
This daemon watches the directory ``~/.config/rash/data/record``
and translate the JSON files dumped by ``record`` command into
sqlite3 DB at ``~/.config/ras... | python | {
"resource": ""
} |
q38196 | show_run | train | def show_run(command_history_id):
"""
Show detailed command history by its ID.
"""
from pprint import pprint
from .config import ConfigStore
from .database import DataBase
db = DataBase(ConfigStore().db_path)
with db.connection():
for ch_id in command_history_id:
crec... | python | {
"resource": ""
} |
q38197 | BlobDBClient.insert | train | def insert(self, database, key, value, callback=None):
"""
Insert an item into the given database.
:param database: The database into which to insert the value.
:type database: .BlobDatabaseID
:param key: The key to insert.
:type key: uuid.UUID
:param value: The ... | python | {
"resource": ""
} |
q38198 | BlobDBClient.delete | train | def delete(self, database, key, callback=None):
"""
Delete an item from the given database.
:param database: The database from which to delete the value.
:type database: .BlobDatabaseID
:param key: The key to delete.
:type key: uuid.UUID
:param callback: A callba... | python | {
"resource": ""
} |
q38199 | Service.invoke | train | def invoke(self, headers, body):
"""
Invokes the soap service
"""
xml = Service._create_request(headers, body)
try:
response = self.session.post(self.endpoint, verify=False, data=xml)
logging.debug(response.content)
except Exception as e:
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.