repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
andy-z/ged4py
ged4py/model.py
Individual.father
def father(self): """Parent of this individual""" if self._father == []: self._father = self.sub_tag("FAMC/HUSB") return self._father
python
def father(self): """Parent of this individual""" if self._father == []: self._father = self.sub_tag("FAMC/HUSB") return self._father
[ "def", "father", "(", "self", ")", ":", "if", "self", ".", "_father", "==", "[", "]", ":", "self", ".", "_father", "=", "self", ".", "sub_tag", "(", "\"FAMC/HUSB\"", ")", "return", "self", ".", "_father" ]
Parent of this individual
[ "Parent", "of", "this", "individual" ]
d0e0cceaadf0a84cbf052705e3c27303b12e1757
https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/model.py#L400-L404
train
Return the parent of this individual
frasertweedale/ledgertools
ltlib/rule.py
Rule.match
def match(self, xn): """Processes a transaction against this rule If all conditions are satisfied, a list of outcomes is returned. If any condition is unsatisifed, None is returned. """ if all(map(lambda x: x.match(xn), self.conditions)): return self.outcomes ...
python
def match(self, xn): """Processes a transaction against this rule If all conditions are satisfied, a list of outcomes is returned. If any condition is unsatisifed, None is returned. """ if all(map(lambda x: x.match(xn), self.conditions)): return self.outcomes ...
[ "def", "match", "(", "self", ",", "xn", ")", ":", "if", "all", "(", "map", "(", "lambda", "x", ":", "x", ".", "match", "(", "xn", ")", ",", "self", ".", "conditions", ")", ")", ":", "return", "self", ".", "outcomes", "return", "None" ]
Processes a transaction against this rule If all conditions are satisfied, a list of outcomes is returned. If any condition is unsatisifed, None is returned.
[ "Processes", "a", "transaction", "against", "this", "rule" ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/rule.py#L152-L160
train
Processes a transaction against this rule
geophysics-ubonn/reda
lib/reda/importers/sip04.py
import_sip04_data
def import_sip04_data(data_filename): """Import RELEVANT data from the result files. Refer to the function :func:`reda.importers.sip04.import_sip04_data_all` for an importer that imports ALL data. Exported parameters: ================== ======================================================== ...
python
def import_sip04_data(data_filename): """Import RELEVANT data from the result files. Refer to the function :func:`reda.importers.sip04.import_sip04_data_all` for an importer that imports ALL data. Exported parameters: ================== ======================================================== ...
[ "def", "import_sip04_data", "(", "data_filename", ")", ":", "df_all", "=", "import_sip04_data_all", "(", "data_filename", ")", "columns_to_keep", "=", "[", "'a'", ",", "'b'", ",", "'m'", ",", "'n'", ",", "'frequency'", ",", "'Temp_1'", ",", "'Temp_2'", ",", ...
Import RELEVANT data from the result files. Refer to the function :func:`reda.importers.sip04.import_sip04_data_all` for an importer that imports ALL data. Exported parameters: ================== ======================================================== key description ==========...
[ "Import", "RELEVANT", "data", "from", "the", "result", "files", ".", "Refer", "to", "the", "function", ":", "func", ":", "reda", ".", "importers", ".", "sip04", ".", "import_sip04_data_all", "for", "an", "importer", "that", "imports", "ALL", "data", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/sip04.py#L30-L91
train
Imports RELEVANT data from the. mat or. csv file containing SIP -04 measurement results.
geophysics-ubonn/reda
lib/reda/importers/sip04.py
import_sip04_data_all
def import_sip04_data_all(data_filename): """Import ALL data from the result files Parameters ---------- data_filename : string Path to .mat or .csv file containing SIP-04 measurement results. Note that the .csv file does not contain all data contained in the .mat file! Ret...
python
def import_sip04_data_all(data_filename): """Import ALL data from the result files Parameters ---------- data_filename : string Path to .mat or .csv file containing SIP-04 measurement results. Note that the .csv file does not contain all data contained in the .mat file! Ret...
[ "def", "import_sip04_data_all", "(", "data_filename", ")", ":", "filename", ",", "fformat", "=", "os", ".", "path", ".", "splitext", "(", "data_filename", ")", "if", "fformat", "==", "'.csv'", ":", "print", "(", "'Import SIP04 data from .csv file'", ")", "df_all...
Import ALL data from the result files Parameters ---------- data_filename : string Path to .mat or .csv file containing SIP-04 measurement results. Note that the .csv file does not contain all data contained in the .mat file! Returns ------- df_all : :py:class:`pandas.D...
[ "Import", "ALL", "data", "from", "the", "result", "files" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/sip04.py#L94-L121
train
Import ALL data from the result files containing SIP -04 measurement results.
geophysics-ubonn/reda
lib/reda/main/units.py
get_label
def get_label(key): """Convenience function: return the label (latex version) of a given key, if available. Otherwise, return the key itself. """ if key in rel: if mpl.rcParams['text.usetex']: return rel[key]['label_latex'] else: return rel[key]['label_mpl'] e...
python
def get_label(key): """Convenience function: return the label (latex version) of a given key, if available. Otherwise, return the key itself. """ if key in rel: if mpl.rcParams['text.usetex']: return rel[key]['label_latex'] else: return rel[key]['label_mpl'] e...
[ "def", "get_label", "(", "key", ")", ":", "if", "key", "in", "rel", ":", "if", "mpl", ".", "rcParams", "[", "'text.usetex'", "]", ":", "return", "rel", "[", "key", "]", "[", "'label_latex'", "]", "else", ":", "return", "rel", "[", "key", "]", "[", ...
Convenience function: return the label (latex version) of a given key, if available. Otherwise, return the key itself.
[ "Convenience", "function", ":", "return", "the", "label", "(", "latex", "version", ")", "of", "a", "given", "key", "if", "available", ".", "Otherwise", "return", "the", "key", "itself", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/main/units.py#L68-L78
train
Convenience function to get the label of a given key.
YosaiProject/yosai_alchemystore
yosai_alchemystore/meta/meta.py
init_session
def init_session(db_url=None, echo=False, engine=None, settings=None): """ A SQLAlchemy Session requires that an engine be initialized if one isn't provided. """ if engine is None: engine = init_engine(db_url=db_url, echo=echo, settings=settings) return sessionmaker(bind=engine)
python
def init_session(db_url=None, echo=False, engine=None, settings=None): """ A SQLAlchemy Session requires that an engine be initialized if one isn't provided. """ if engine is None: engine = init_engine(db_url=db_url, echo=echo, settings=settings) return sessionmaker(bind=engine)
[ "def", "init_session", "(", "db_url", "=", "None", ",", "echo", "=", "False", ",", "engine", "=", "None", ",", "settings", "=", "None", ")", ":", "if", "engine", "is", "None", ":", "engine", "=", "init_engine", "(", "db_url", "=", "db_url", ",", "ech...
A SQLAlchemy Session requires that an engine be initialized if one isn't provided.
[ "A", "SQLAlchemy", "Session", "requires", "that", "an", "engine", "be", "initialized", "if", "one", "isn", "t", "provided", "." ]
6479c159ab2ac357e6b70cdd71a2d673279e86bb
https://github.com/YosaiProject/yosai_alchemystore/blob/6479c159ab2ac357e6b70cdd71a2d673279e86bb/yosai_alchemystore/meta/meta.py#L58-L65
train
A SQLAlchemy Session requires that an engine be initialized if one isn t provided.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
importers.import_crtomo
def import_crtomo(self, directory, frequency_file='frequencies.dat', data_prefix='volt_', **kwargs): """CRTomo importer""" # we get not electrode positions (dummy1) and no topography data # (dummy2) df, dummy1, dumm2 = reda_crtomo_exporter.load_seit_data( ...
python
def import_crtomo(self, directory, frequency_file='frequencies.dat', data_prefix='volt_', **kwargs): """CRTomo importer""" # we get not electrode positions (dummy1) and no topography data # (dummy2) df, dummy1, dumm2 = reda_crtomo_exporter.load_seit_data( ...
[ "def", "import_crtomo", "(", "self", ",", "directory", ",", "frequency_file", "=", "'frequencies.dat'", ",", "data_prefix", "=", "'volt_'", ",", "*", "*", "kwargs", ")", ":", "# we get not electrode positions (dummy1) and no topography data", "# (dummy2)", "df", ",", ...
CRTomo importer
[ "CRTomo", "importer" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L59-L70
train
Import CRTomo data from seit. dat into the current container.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
importers.import_sip256c
def import_sip256c(self, filename, settings=None, reciprocal=None, **kwargs): """Radic SIP256c data import""" if settings is None: settings = {} # we get not electrode positions (dummy1) and no topography data # (dummy2) df, dummy1, dummy2 = red...
python
def import_sip256c(self, filename, settings=None, reciprocal=None, **kwargs): """Radic SIP256c data import""" if settings is None: settings = {} # we get not electrode positions (dummy1) and no topography data # (dummy2) df, dummy1, dummy2 = red...
[ "def", "import_sip256c", "(", "self", ",", "filename", ",", "settings", "=", "None", ",", "reciprocal", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "settings", "is", "None", ":", "settings", "=", "{", "}", "# we get not electrode positions (dummy1)...
Radic SIP256c data import
[ "Radic", "SIP256c", "data", "import" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L72-L84
train
Radic SIP256c data import
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
importers.import_eit_fzj
def import_eit_fzj(self, filename, configfile, correction_file=None, timestep=None, **kwargs): """EIT data import for FZJ Medusa systems""" # we get not electrode positions (dummy1) and no topography data # (dummy2) df_emd, dummy1, dummy2 = eit_fzj.read_3p_data( ...
python
def import_eit_fzj(self, filename, configfile, correction_file=None, timestep=None, **kwargs): """EIT data import for FZJ Medusa systems""" # we get not electrode positions (dummy1) and no topography data # (dummy2) df_emd, dummy1, dummy2 = eit_fzj.read_3p_data( ...
[ "def", "import_eit_fzj", "(", "self", ",", "filename", ",", "configfile", ",", "correction_file", "=", "None", ",", "timestep", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# we get not electrode positions (dummy1) and no topography data", "# (dummy2)", "df_emd", ...
EIT data import for FZJ Medusa systems
[ "EIT", "data", "import", "for", "FZJ", "Medusa", "systems" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L86-L105
train
Import EIT data from 3P file
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.check_dataframe
def check_dataframe(self, dataframe): """Check the given dataframe for the required columns """ required_columns = ( 'a', 'b', 'm', 'n', 'r', ) for column in required_columns: if column not in dataframe: ...
python
def check_dataframe(self, dataframe): """Check the given dataframe for the required columns """ required_columns = ( 'a', 'b', 'm', 'n', 'r', ) for column in required_columns: if column not in dataframe: ...
[ "def", "check_dataframe", "(", "self", ",", "dataframe", ")", ":", "required_columns", "=", "(", "'a'", ",", "'b'", ",", "'m'", ",", "'n'", ",", "'r'", ",", ")", "for", "column", "in", "required_columns", ":", "if", "column", "not", "in", "dataframe", ...
Check the given dataframe for the required columns
[ "Check", "the", "given", "dataframe", "for", "the", "required", "columns" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L118-L132
train
Check the given dataframe for the required columns
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.query
def query(self, query, inplace=True): """State what you want to keep """ # TODO: add to queue result = self.data.query(query, inplace=inplace) return result
python
def query(self, query, inplace=True): """State what you want to keep """ # TODO: add to queue result = self.data.query(query, inplace=inplace) return result
[ "def", "query", "(", "self", ",", "query", ",", "inplace", "=", "True", ")", ":", "# TODO: add to queue", "result", "=", "self", ".", "data", ".", "query", "(", "query", ",", "inplace", "=", "inplace", ")", "return", "result" ]
State what you want to keep
[ "State", "what", "you", "want", "to", "keep" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L163-L169
train
Query the data for the given query.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.remove_frequencies
def remove_frequencies(self, fmin, fmax): """Remove frequencies from the dataset """ self.data.query( 'frequency > {0} and frequency < {1}'.format(fmin, fmax), inplace=True ) g = self.data.groupby('frequency') print('Remaining frequencies:') ...
python
def remove_frequencies(self, fmin, fmax): """Remove frequencies from the dataset """ self.data.query( 'frequency > {0} and frequency < {1}'.format(fmin, fmax), inplace=True ) g = self.data.groupby('frequency') print('Remaining frequencies:') ...
[ "def", "remove_frequencies", "(", "self", ",", "fmin", ",", "fmax", ")", ":", "self", ".", "data", ".", "query", "(", "'frequency > {0} and frequency < {1}'", ".", "format", "(", "fmin", ",", "fmax", ")", ",", "inplace", "=", "True", ")", "g", "=", "self...
Remove frequencies from the dataset
[ "Remove", "frequencies", "from", "the", "dataset" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L196-L205
train
Remove frequencies from the dataset
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.compute_K_analytical
def compute_K_analytical(self, spacing): """Assuming an equal electrode spacing, compute the K-factor over a homogeneous half-space. For more complex grids, please refer to the module: reda.utils.geometric_factors Parameters ---------- spacing: float ...
python
def compute_K_analytical(self, spacing): """Assuming an equal electrode spacing, compute the K-factor over a homogeneous half-space. For more complex grids, please refer to the module: reda.utils.geometric_factors Parameters ---------- spacing: float ...
[ "def", "compute_K_analytical", "(", "self", ",", "spacing", ")", ":", "assert", "isinstance", "(", "spacing", ",", "Number", ")", "K", "=", "geometric_factors", ".", "compute_K_analytical", "(", "self", ".", "data", ",", "spacing", ")", "self", ".", "data", ...
Assuming an equal electrode spacing, compute the K-factor over a homogeneous half-space. For more complex grids, please refer to the module: reda.utils.geometric_factors Parameters ---------- spacing: float Electrode spacing
[ "Assuming", "an", "equal", "electrode", "spacing", "compute", "the", "K", "-", "factor", "over", "a", "homogeneous", "half", "-", "space", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L207-L223
train
Compute the K - factor over the homogeneous half - space of the data.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.scatter_norrec
def scatter_norrec(self, filename=None, individual=False): """Create a scatter plot for all diff pairs Parameters ---------- filename : string, optional if given, save plot to file individual : bool, optional if set to True, return one figure for each ro...
python
def scatter_norrec(self, filename=None, individual=False): """Create a scatter plot for all diff pairs Parameters ---------- filename : string, optional if given, save plot to file individual : bool, optional if set to True, return one figure for each ro...
[ "def", "scatter_norrec", "(", "self", ",", "filename", "=", "None", ",", "individual", "=", "False", ")", ":", "# if not otherwise specified, use these column pairs:", "std_diff_labels", "=", "{", "'r'", ":", "'rdiff'", ",", "'rpha'", ":", "'rphadiff'", ",", "}", ...
Create a scatter plot for all diff pairs Parameters ---------- filename : string, optional if given, save plot to file individual : bool, optional if set to True, return one figure for each row Returns ------- fig : matplotlib.Figure or ...
[ "Create", "a", "scatter", "plot", "for", "all", "diff", "pairs" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L230-L305
train
Create a scatter plot for all diff pairs of the current object.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.filter_incomplete_spectra
def filter_incomplete_spectra(self, flimit=1000, percAccept=85): """Remove all data points that belong to spectra that did not retain at least **percAccept** percent of the number of data points. ..warning:: This function does not honor additional dimensions (e.g., time...
python
def filter_incomplete_spectra(self, flimit=1000, percAccept=85): """Remove all data points that belong to spectra that did not retain at least **percAccept** percent of the number of data points. ..warning:: This function does not honor additional dimensions (e.g., time...
[ "def", "filter_incomplete_spectra", "(", "self", ",", "flimit", "=", "1000", ",", "percAccept", "=", "85", ")", ":", "assert", "percAccept", ">", "0", "and", "percAccept", "<", "100", "def", "_retain_only_complete_spectra", "(", "item", ",", "fmax", ",", "ac...
Remove all data points that belong to spectra that did not retain at least **percAccept** percent of the number of data points. ..warning:: This function does not honor additional dimensions (e.g., timesteps) yet!
[ "Remove", "all", "data", "points", "that", "belong", "to", "spectra", "that", "did", "not", "retain", "at", "least", "**", "percAccept", "**", "percent", "of", "the", "number", "of", "data", "points", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L307-L355
train
Filter incomplete data points in the current set.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.get_spectrum
def get_spectrum(self, nr_id=None, abmn=None, plot_filename=None): """Return a spectrum and its reciprocal counter part, if present in the dataset. Optimally, refer to the spectrum by its normal-reciprocal id. Returns ------- spectrum_nor : :py:class:`reda.eis.plots.sip_response...
python
def get_spectrum(self, nr_id=None, abmn=None, plot_filename=None): """Return a spectrum and its reciprocal counter part, if present in the dataset. Optimally, refer to the spectrum by its normal-reciprocal id. Returns ------- spectrum_nor : :py:class:`reda.eis.plots.sip_response...
[ "def", "get_spectrum", "(", "self", ",", "nr_id", "=", "None", ",", "abmn", "=", "None", ",", "plot_filename", "=", "None", ")", ":", "assert", "nr_id", "is", "None", "or", "abmn", "is", "None", "# determine nr_id for given abmn tuple", "if", "abmn", "is", ...
Return a spectrum and its reciprocal counter part, if present in the dataset. Optimally, refer to the spectrum by its normal-reciprocal id. Returns ------- spectrum_nor : :py:class:`reda.eis.plots.sip_response` Normal spectrum. None if no normal spectrum is available ...
[ "Return", "a", "spectrum", "and", "its", "reciprocal", "counter", "part", "if", "present", "in", "the", "dataset", ".", "Optimally", "refer", "to", "the", "spectrum", "by", "its", "normal", "-", "reciprocal", "id", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L357-L419
train
Return a spectrum and its reciprocal counter part if present in the available set of reciprocals.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.plot_all_spectra
def plot_all_spectra(self, outdir): """This is a convenience function to plot ALL spectra currently stored in the container. It is useful to asses whether data filters do perform correctly. Note that the function just iterates over all ids and plots the corresponding spectra, th...
python
def plot_all_spectra(self, outdir): """This is a convenience function to plot ALL spectra currently stored in the container. It is useful to asses whether data filters do perform correctly. Note that the function just iterates over all ids and plots the corresponding spectra, th...
[ "def", "plot_all_spectra", "(", "self", ",", "outdir", ")", ":", "os", ".", "makedirs", "(", "outdir", ",", "exist_ok", "=", "True", ")", "g", "=", "self", ".", "data", ".", "groupby", "(", "'id'", ")", "for", "nr", ",", "(", "name", ",", "item", ...
This is a convenience function to plot ALL spectra currently stored in the container. It is useful to asses whether data filters do perform correctly. Note that the function just iterates over all ids and plots the corresponding spectra, thus it is slow. Spectra a named using t...
[ "This", "is", "a", "convenience", "function", "to", "plot", "ALL", "spectra", "currently", "stored", "in", "the", "container", ".", "It", "is", "useful", "to", "asses", "whether", "data", "filters", "do", "perform", "correctly", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L421-L453
train
This function plots all the spectra currently stored in the container. It will iterate over all ids and plot the spectrum for each.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.plot_pseudosections
def plot_pseudosections(self, column, filename=None, return_fig=False): """Create a multi-plot with one pseudosection for each frequency. Parameters ---------- column : string which column to plot filename : None|string output filename. If set to None, do...
python
def plot_pseudosections(self, column, filename=None, return_fig=False): """Create a multi-plot with one pseudosection for each frequency. Parameters ---------- column : string which column to plot filename : None|string output filename. If set to None, do...
[ "def", "plot_pseudosections", "(", "self", ",", "column", ",", "filename", "=", "None", ",", "return_fig", "=", "False", ")", ":", "assert", "column", "in", "self", ".", "data", ".", "columns", "g", "=", "self", ".", "data", ".", "groupby", "(", "'freq...
Create a multi-plot with one pseudosection for each frequency. Parameters ---------- column : string which column to plot filename : None|string output filename. If set to None, do not write to file. Default: None return_fig : bool ...
[ "Create", "a", "multi", "-", "plot", "with", "one", "pseudosection", "for", "each", "frequency", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L455-L493
train
Create a multi - plot with one pseudosection for each frequency.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.export_to_directory_crtomo
def export_to_directory_crtomo(self, directory, norrec='norrec'): """Export the sEIT data into data files that can be read by CRTomo. Parameters ---------- directory : string output directory. will be created if required norrec : string (nor|rec|norrec) W...
python
def export_to_directory_crtomo(self, directory, norrec='norrec'): """Export the sEIT data into data files that can be read by CRTomo. Parameters ---------- directory : string output directory. will be created if required norrec : string (nor|rec|norrec) W...
[ "def", "export_to_directory_crtomo", "(", "self", ",", "directory", ",", "norrec", "=", "'norrec'", ")", ":", "exporter_crtomo", ".", "write_files_to_directory", "(", "self", ".", "data", ",", "directory", ",", "norrec", "=", "norrec", ")" ]
Export the sEIT data into data files that can be read by CRTomo. Parameters ---------- directory : string output directory. will be created if required norrec : string (nor|rec|norrec) Which data to export. Default: norrec
[ "Export", "the", "sEIT", "data", "into", "data", "files", "that", "can", "be", "read", "by", "CRTomo", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L495-L508
train
Export the sEIT data into a directory.
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
sEIT.export_to_crtomo_seit_manager
def export_to_crtomo_seit_manager(self, grid): """Return a ready-initialized seit-manager object from the CRTomo tools. This function only works if the crtomo_tools are installed. """ import crtomo g = self.data.groupby('frequency') seit_data = {} for name, item i...
python
def export_to_crtomo_seit_manager(self, grid): """Return a ready-initialized seit-manager object from the CRTomo tools. This function only works if the crtomo_tools are installed. """ import crtomo g = self.data.groupby('frequency') seit_data = {} for name, item i...
[ "def", "export_to_crtomo_seit_manager", "(", "self", ",", "grid", ")", ":", "import", "crtomo", "g", "=", "self", ".", "data", ".", "groupby", "(", "'frequency'", ")", "seit_data", "=", "{", "}", "for", "name", ",", "item", "in", "g", ":", "print", "("...
Return a ready-initialized seit-manager object from the CRTomo tools. This function only works if the crtomo_tools are installed.
[ "Return", "a", "ready", "-", "initialized", "seit", "-", "manager", "object", "from", "the", "CRTomo", "tools", ".", "This", "function", "only", "works", "if", "the", "crtomo_tools", "are", "installed", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L510-L524
train
Export the data to a ready - initialized seit - manager object.
evolbioinfo/pastml
pastml/models/hky.py
get_hky_pij
def get_hky_pij(t, frequencies, kappa): """ Calculates the probability matrix of substitutions i->j over time t, with HKY model [Hasegawa, Kishino and Yano 1985], given state frequencies and kappa. :param t: time :type t: float :param kappa: kappa parameter for HKY model :type kappa: float...
python
def get_hky_pij(t, frequencies, kappa): """ Calculates the probability matrix of substitutions i->j over time t, with HKY model [Hasegawa, Kishino and Yano 1985], given state frequencies and kappa. :param t: time :type t: float :param kappa: kappa parameter for HKY model :type kappa: float...
[ "def", "get_hky_pij", "(", "t", ",", "frequencies", ",", "kappa", ")", ":", "pi_a", ",", "pi_c", ",", "pi_g", ",", "pi_t", "=", "frequencies", "pi_ag", "=", "pi_a", "+", "pi_g", "pi_ct", "=", "pi_c", "+", "pi_t", "beta", "=", ".5", "/", "(", "pi_ag...
Calculates the probability matrix of substitutions i->j over time t, with HKY model [Hasegawa, Kishino and Yano 1985], given state frequencies and kappa. :param t: time :type t: float :param kappa: kappa parameter for HKY model :type kappa: float :param frequencies: array of state frequencies ...
[ "Calculates", "the", "probability", "matrix", "of", "substitutions", "i", "-", ">", "j", "over", "time", "t", "with", "HKY", "model", "[", "Hasegawa", "Kishino", "and", "Yano", "1985", "]", "given", "state", "frequencies", "and", "kappa", "." ]
df8a375841525738383e59548eed3441b07dbd3e
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/models/hky.py#L11-L51
train
Calculates the probability matrix of substitutions i - > j over time t with HKY model.
joelbm24/brainy
lib/bfinter.py
Brainy.get_tape
def get_tape(self, start=0, end=10): '''Pretty prints the tape values''' self.tape_start = start self.tape_end = end self.tape_length = end - start tmp = '\n'+"|"+str(start)+"| " for i in xrange(len(self.tape[start:end])): if i == self.cur_cell: ...
python
def get_tape(self, start=0, end=10): '''Pretty prints the tape values''' self.tape_start = start self.tape_end = end self.tape_length = end - start tmp = '\n'+"|"+str(start)+"| " for i in xrange(len(self.tape[start:end])): if i == self.cur_cell: ...
[ "def", "get_tape", "(", "self", ",", "start", "=", "0", ",", "end", "=", "10", ")", ":", "self", ".", "tape_start", "=", "start", "self", ".", "tape_end", "=", "end", "self", ".", "tape_length", "=", "end", "-", "start", "tmp", "=", "'\\n'", "+", ...
Pretty prints the tape values
[ "Pretty", "prints", "the", "tape", "values" ]
bc3e1d6e020f1bb884a9bbbda834dac3a7a7fdb4
https://github.com/joelbm24/brainy/blob/bc3e1d6e020f1bb884a9bbbda834dac3a7a7fdb4/lib/bfinter.py#L79-L90
train
Pretty prints the tape values
geophysics-ubonn/reda
lib/reda/containers/SIP.py
importers.import_sip04
def import_sip04(self, filename, timestep=None): """SIP04 data import Parameters ---------- filename: string Path to .mat or .csv file containing SIP-04 measurement results Examples -------- :: import tempfile import reda ...
python
def import_sip04(self, filename, timestep=None): """SIP04 data import Parameters ---------- filename: string Path to .mat or .csv file containing SIP-04 measurement results Examples -------- :: import tempfile import reda ...
[ "def", "import_sip04", "(", "self", ",", "filename", ",", "timestep", "=", "None", ")", ":", "df", "=", "reda_sip04", ".", "import_sip04_data", "(", "filename", ")", "if", "timestep", "is", "not", "None", ":", "print", "(", "'adding timestep'", ")", "df", ...
SIP04 data import Parameters ---------- filename: string Path to .mat or .csv file containing SIP-04 measurement results Examples -------- :: import tempfile import reda with tempfile.TemporaryDirectory() as fid: ...
[ "SIP04", "data", "import" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/SIP.py#L26-L54
train
Import SIP -04 measurement data from. mat or. csv file containing SIP -04 measurement results
geophysics-ubonn/reda
lib/reda/containers/SIP.py
SIP.check_dataframe
def check_dataframe(self, dataframe): """Check the given dataframe for the required type and columns """ if dataframe is None: return None # is this a DataFrame if not isinstance(dataframe, pd.DataFrame): raise Exception( 'The provided dat...
python
def check_dataframe(self, dataframe): """Check the given dataframe for the required type and columns """ if dataframe is None: return None # is this a DataFrame if not isinstance(dataframe, pd.DataFrame): raise Exception( 'The provided dat...
[ "def", "check_dataframe", "(", "self", ",", "dataframe", ")", ":", "if", "dataframe", "is", "None", ":", "return", "None", "# is this a DataFrame", "if", "not", "isinstance", "(", "dataframe", ",", "pd", ".", "DataFrame", ")", ":", "raise", "Exception", "(",...
Check the given dataframe for the required type and columns
[ "Check", "the", "given", "dataframe", "for", "the", "required", "type", "and", "columns" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/SIP.py#L73-L90
train
Check the given dataframe for the required type and columns
geophysics-ubonn/reda
lib/reda/containers/SIP.py
SIP.reduce_duplicate_frequencies
def reduce_duplicate_frequencies(self): """In case multiple frequencies were measured, average them and compute std, min, max values for zt. In case timesteps were added (i.e., multiple separate measurements), group over those and average for each timestep. Examples ---...
python
def reduce_duplicate_frequencies(self): """In case multiple frequencies were measured, average them and compute std, min, max values for zt. In case timesteps were added (i.e., multiple separate measurements), group over those and average for each timestep. Examples ---...
[ "def", "reduce_duplicate_frequencies", "(", "self", ")", ":", "group_keys", "=", "[", "'frequency'", ",", "]", "if", "'timestep'", "in", "self", ".", "data", ".", "columns", ":", "group_keys", "=", "group_keys", "+", "[", "'timestep'", ",", "]", "g", "=", ...
In case multiple frequencies were measured, average them and compute std, min, max values for zt. In case timesteps were added (i.e., multiple separate measurements), group over those and average for each timestep. Examples -------- :: import tempfile ...
[ "In", "case", "multiple", "frequencies", "were", "measured", "average", "them", "and", "compute", "std", "min", "max", "values", "for", "zt", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/SIP.py#L92-L153
train
Reduces the duplicate frequencies of the current record.
cloudbase/python-hnvclient
hnv/config/factory.py
_load_class
def _load_class(class_path): """Load the module and return the required class.""" parts = class_path.rsplit('.', 1) module = __import__(parts[0], fromlist=parts[1]) return getattr(module, parts[1])
python
def _load_class(class_path): """Load the module and return the required class.""" parts = class_path.rsplit('.', 1) module = __import__(parts[0], fromlist=parts[1]) return getattr(module, parts[1])
[ "def", "_load_class", "(", "class_path", ")", ":", "parts", "=", "class_path", ".", "rsplit", "(", "'.'", ",", "1", ")", "module", "=", "__import__", "(", "parts", "[", "0", "]", ",", "fromlist", "=", "parts", "[", "1", "]", ")", "return", "getattr",...
Load the module and return the required class.
[ "Load", "the", "module", "and", "return", "the", "required", "class", "." ]
b019452af01db22629809b8930357a2ebf6494be
https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/config/factory.py#L22-L26
train
Load the module and return the required class.
evolbioinfo/pastml
pastml/visualisation/tree_compressor.py
collapse_vertically
def collapse_vertically(tree, columns): """ Collapses a child node into its parent if they are in the same state. :param columns: a list of characters :param tree: ete3.Tree :return: void, modifies the input tree """ def _same_states(node1, node2, columns): for column in columns: ...
python
def collapse_vertically(tree, columns): """ Collapses a child node into its parent if they are in the same state. :param columns: a list of characters :param tree: ete3.Tree :return: void, modifies the input tree """ def _same_states(node1, node2, columns): for column in columns: ...
[ "def", "collapse_vertically", "(", "tree", ",", "columns", ")", ":", "def", "_same_states", "(", "node1", ",", "node2", ",", "columns", ")", ":", "for", "column", "in", "columns", ":", "if", "getattr", "(", "node1", ",", "column", ",", "set", "(", ")",...
Collapses a child node into its parent if they are in the same state. :param columns: a list of characters :param tree: ete3.Tree :return: void, modifies the input tree
[ "Collapses", "a", "child", "node", "into", "its", "parent", "if", "they", "are", "in", "the", "same", "state", ".", ":", "param", "columns", ":", "a", "list", "of", "characters", ":", "param", "tree", ":", "ete3", ".", "Tree", ":", "return", ":", "vo...
df8a375841525738383e59548eed3441b07dbd3e
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/visualisation/tree_compressor.py#L141-L174
train
Collapse a child node into its parent if they are in the same state.
evolbioinfo/pastml
pastml/visualisation/tree_compressor.py
remove_mediators
def remove_mediators(tree, columns): """ Removes intermediate nodes that are just mediators between their parent and child states. :param columns: list of characters :param tree: ete3.Tree :return: void, modifies the input tree """ num_removed = 0 for n in tree.traverse('postorder'): ...
python
def remove_mediators(tree, columns): """ Removes intermediate nodes that are just mediators between their parent and child states. :param columns: list of characters :param tree: ete3.Tree :return: void, modifies the input tree """ num_removed = 0 for n in tree.traverse('postorder'): ...
[ "def", "remove_mediators", "(", "tree", ",", "columns", ")", ":", "num_removed", "=", "0", "for", "n", "in", "tree", ".", "traverse", "(", "'postorder'", ")", ":", "if", "getattr", "(", "n", ",", "METACHILD", ",", "False", ")", "or", "n", ".", "is_le...
Removes intermediate nodes that are just mediators between their parent and child states. :param columns: list of characters :param tree: ete3.Tree :return: void, modifies the input tree
[ "Removes", "intermediate", "nodes", "that", "are", "just", "mediators", "between", "their", "parent", "and", "child", "states", ".", ":", "param", "columns", ":", "list", "of", "characters", ":", "param", "tree", ":", "ete3", ".", "Tree", ":", "return", ":...
df8a375841525738383e59548eed3441b07dbd3e
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/visualisation/tree_compressor.py#L177-L210
train
Removes intermediate nodes that are just mediators between their parent and child states.
RobersonLab/motif_scraper
motif_scraper/__init__.py
rev_comp
def rev_comp( seq, molecule='dna' ): """ DNA|RNA seq -> reverse complement """ if molecule == 'dna': nuc_dict = { "A":"T", "B":"V", "C":"G", "D":"H", "G":"C", "H":"D", "K":"M", "M":"K", "N":"N", "R":"Y", "S":"S", "T":"A", "V":"B", "W":"W", "Y":"R" } elif molecule == 'rna': nuc_dict = { "A":"U", "B":"V", "C":"...
python
def rev_comp( seq, molecule='dna' ): """ DNA|RNA seq -> reverse complement """ if molecule == 'dna': nuc_dict = { "A":"T", "B":"V", "C":"G", "D":"H", "G":"C", "H":"D", "K":"M", "M":"K", "N":"N", "R":"Y", "S":"S", "T":"A", "V":"B", "W":"W", "Y":"R" } elif molecule == 'rna': nuc_dict = { "A":"U", "B":"V", "C":"...
[ "def", "rev_comp", "(", "seq", ",", "molecule", "=", "'dna'", ")", ":", "if", "molecule", "==", "'dna'", ":", "nuc_dict", "=", "{", "\"A\"", ":", "\"T\"", ",", "\"B\"", ":", "\"V\"", ",", "\"C\"", ":", "\"G\"", ",", "\"D\"", ":", "\"H\"", ",", "\"G...
DNA|RNA seq -> reverse complement
[ "DNA|RNA", "seq", "-", ">", "reverse", "complement" ]
382dcb5932d9750282906c356ca35e802bd68bd0
https://github.com/RobersonLab/motif_scraper/blob/382dcb5932d9750282906c356ca35e802bd68bd0/motif_scraper/__init__.py#L28-L42
train
Reverse complement a sequence.
RobersonLab/motif_scraper
motif_scraper/__init__.py
make_degenerate_regex
def make_degenerate_regex( motif_seq, molecule='dna' ): """ Degenerate sequence -> regex Example: NNYCGAARN -> [ACGT]{2}[CT]CGA{2}[AG][ACGT] """ if not isinstance( motif_seq, six.string_types ): raise TypeError( "motif_seq must be a string!" ) if molecule == 'dna': degenerate_code = { "A":"A", "B":"[CGT]"...
python
def make_degenerate_regex( motif_seq, molecule='dna' ): """ Degenerate sequence -> regex Example: NNYCGAARN -> [ACGT]{2}[CT]CGA{2}[AG][ACGT] """ if not isinstance( motif_seq, six.string_types ): raise TypeError( "motif_seq must be a string!" ) if molecule == 'dna': degenerate_code = { "A":"A", "B":"[CGT]"...
[ "def", "make_degenerate_regex", "(", "motif_seq", ",", "molecule", "=", "'dna'", ")", ":", "if", "not", "isinstance", "(", "motif_seq", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "\"motif_seq must be a string!\"", ")", "if", "molecule"...
Degenerate sequence -> regex Example: NNYCGAARN -> [ACGT]{2}[CT]CGA{2}[AG][ACGT]
[ "Degenerate", "sequence", "-", ">", "regex", "Example", ":", "NNYCGAARN", "-", ">", "[", "ACGT", "]", "{", "2", "}", "[", "CT", "]", "CGA", "{", "2", "}", "[", "AG", "]", "[", "ACGT", "]" ]
382dcb5932d9750282906c356ca35e802bd68bd0
https://github.com/RobersonLab/motif_scraper/blob/382dcb5932d9750282906c356ca35e802bd68bd0/motif_scraper/__init__.py#L44-L84
train
This function returns a regex that matches the given motif sequence.
RobersonLab/motif_scraper
motif_scraper/__init__.py
fasta_motif_scan
def fasta_motif_scan( fasta_fname, input_tuples, regex_ready=False, allow_overlaps=True, file_buffer=False, molecule='dna' ): """ fasta_fname = string path to FASTA file input_tuples = tuple containing (1) motif sequence, (2) contig name, (3) start position*, (4) end position, (5) strand to search *start is expec...
python
def fasta_motif_scan( fasta_fname, input_tuples, regex_ready=False, allow_overlaps=True, file_buffer=False, molecule='dna' ): """ fasta_fname = string path to FASTA file input_tuples = tuple containing (1) motif sequence, (2) contig name, (3) start position*, (4) end position, (5) strand to search *start is expec...
[ "def", "fasta_motif_scan", "(", "fasta_fname", ",", "input_tuples", ",", "regex_ready", "=", "False", ",", "allow_overlaps", "=", "True", ",", "file_buffer", "=", "False", ",", "molecule", "=", "'dna'", ")", ":", "###################", "# validity checks #", "####...
fasta_fname = string path to FASTA file input_tuples = tuple containing (1) motif sequence, (2) contig name, (3) start position*, (4) end position, (5) strand to search *start is expected to be 0-base, end is expected to be 1-base
[ "fasta_fname", "=", "string", "path", "to", "FASTA", "file", "input_tuples", "=", "tuple", "containing", "(", "1", ")", "motif", "sequence", "(", "2", ")", "contig", "name", "(", "3", ")", "start", "position", "*", "(", "4", ")", "end", "position", "("...
382dcb5932d9750282906c356ca35e802bd68bd0
https://github.com/RobersonLab/motif_scraper/blob/382dcb5932d9750282906c356ca35e802bd68bd0/motif_scraper/__init__.py#L147-L219
train
This function will scan a motif sequence using the motif_seq function.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_doc_parser.py
ShexDocParser.visitBaseDecl
def visitBaseDecl(self, ctx: ShExDocParser.BaseDeclContext): """ baseDecl: KW_BASE IRIREF """ self.context.base = None self.context.base = self.context.iriref_to_shexj_iriref(ctx.IRIREF())
python
def visitBaseDecl(self, ctx: ShExDocParser.BaseDeclContext): """ baseDecl: KW_BASE IRIREF """ self.context.base = None self.context.base = self.context.iriref_to_shexj_iriref(ctx.IRIREF())
[ "def", "visitBaseDecl", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "BaseDeclContext", ")", ":", "self", ".", "context", ".", "base", "=", "None", "self", ".", "context", ".", "base", "=", "self", ".", "context", ".", "iriref_to_shexj_iriref", "(",...
baseDecl: KW_BASE IRIREF
[ "baseDecl", ":", "KW_BASE", "IRIREF" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_doc_parser.py#L50-L53
train
baseDecl is a base decl
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_doc_parser.py
ShexDocParser.visitPrefixDecl
def visitPrefixDecl(self, ctx: ShExDocParser.PrefixDeclContext): """ prefixDecl: KW_PREFIX PNAME_NS IRIREF """ iri = self.context.iriref_to_shexj_iriref(ctx.IRIREF()) prefix = ctx.PNAME_NS().getText() if iri not in self.context.ld_prefixes: self.context.prefixes.setdefault(pr...
python
def visitPrefixDecl(self, ctx: ShExDocParser.PrefixDeclContext): """ prefixDecl: KW_PREFIX PNAME_NS IRIREF """ iri = self.context.iriref_to_shexj_iriref(ctx.IRIREF()) prefix = ctx.PNAME_NS().getText() if iri not in self.context.ld_prefixes: self.context.prefixes.setdefault(pr...
[ "def", "visitPrefixDecl", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "PrefixDeclContext", ")", ":", "iri", "=", "self", ".", "context", ".", "iriref_to_shexj_iriref", "(", "ctx", ".", "IRIREF", "(", ")", ")", "prefix", "=", "ctx", ".", "PNAME_NS",...
prefixDecl: KW_PREFIX PNAME_NS IRIREF
[ "prefixDecl", ":", "KW_PREFIX", "PNAME_NS", "IRIREF" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_doc_parser.py#L55-L60
train
visitPrefixDecl : Add prefix to the context if it is not already there.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_doc_parser.py
ShexDocParser.visitStart
def visitStart(self, ctx: ShExDocParser.StartContext): """ start: KW_START '=' shapeExpression """ shexpr = ShexShapeExpressionParser(self.context, None) shexpr.visit(ctx.shapeExpression()) self.context.schema.start = shexpr.expr
python
def visitStart(self, ctx: ShExDocParser.StartContext): """ start: KW_START '=' shapeExpression """ shexpr = ShexShapeExpressionParser(self.context, None) shexpr.visit(ctx.shapeExpression()) self.context.schema.start = shexpr.expr
[ "def", "visitStart", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "StartContext", ")", ":", "shexpr", "=", "ShexShapeExpressionParser", "(", "self", ".", "context", ",", "None", ")", "shexpr", ".", "visit", "(", "ctx", ".", "shapeExpression", "(", "...
start: KW_START '=' shapeExpression
[ "start", ":", "KW_START", "=", "shapeExpression" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_doc_parser.py#L62-L66
train
visit a START context and set the schema. start attribute
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_doc_parser.py
ShexDocParser.visitShapeExprDecl
def visitShapeExprDecl(self, ctx: ShExDocParser.ShapeExprDeclContext): """ shapeExprDecl: shapeExprLabel (shapeExpression | KW_EXTERNAL) """ label = self.context.shapeexprlabel_to_IRI(ctx.shapeExprLabel()) if self.context.schema.shapes is None: self.context.schema.shapes = [] ...
python
def visitShapeExprDecl(self, ctx: ShExDocParser.ShapeExprDeclContext): """ shapeExprDecl: shapeExprLabel (shapeExpression | KW_EXTERNAL) """ label = self.context.shapeexprlabel_to_IRI(ctx.shapeExprLabel()) if self.context.schema.shapes is None: self.context.schema.shapes = [] ...
[ "def", "visitShapeExprDecl", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "ShapeExprDeclContext", ")", ":", "label", "=", "self", ".", "context", ".", "shapeexprlabel_to_IRI", "(", "ctx", ".", "shapeExprLabel", "(", ")", ")", "if", "self", ".", "conte...
shapeExprDecl: shapeExprLabel (shapeExpression | KW_EXTERNAL)
[ "shapeExprDecl", ":", "shapeExprLabel", "(", "shapeExpression", "|", "KW_EXTERNAL", ")" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_doc_parser.py#L68-L79
train
ShapeExprDecl is a wrapper for ShexShapeExpressionParser. shapeExpr
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_doc_parser.py
ShexDocParser.visitStartActions
def visitStartActions(self, ctx: ShExDocParser.StartActionsContext): """ startActions: codeDecl+ """ self.context.schema.startActs = [] for cd in ctx.codeDecl(): cdparser = ShexAnnotationAndSemactsParser(self.context) cdparser.visit(cd) self.context.schema.sta...
python
def visitStartActions(self, ctx: ShExDocParser.StartActionsContext): """ startActions: codeDecl+ """ self.context.schema.startActs = [] for cd in ctx.codeDecl(): cdparser = ShexAnnotationAndSemactsParser(self.context) cdparser.visit(cd) self.context.schema.sta...
[ "def", "visitStartActions", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "StartActionsContext", ")", ":", "self", ".", "context", ".", "schema", ".", "startActs", "=", "[", "]", "for", "cd", "in", "ctx", ".", "codeDecl", "(", ")", ":", "cdparser",...
startActions: codeDecl+
[ "startActions", ":", "codeDecl", "+" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_doc_parser.py#L81-L87
train
visit StartActions
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.from_json
def from_json(cls, key, scopes, subject=None): """Alternate constructor intended for using JSON format of private key. Args: key (dict) - Parsed JSON with service account credentials. scopes (Union[str, collections.Iterable[str]]) - List of permissions that the a...
python
def from_json(cls, key, scopes, subject=None): """Alternate constructor intended for using JSON format of private key. Args: key (dict) - Parsed JSON with service account credentials. scopes (Union[str, collections.Iterable[str]]) - List of permissions that the a...
[ "def", "from_json", "(", "cls", ",", "key", ",", "scopes", ",", "subject", "=", "None", ")", ":", "credentials_type", "=", "key", "[", "'type'", "]", "if", "credentials_type", "!=", "'service_account'", ":", "raise", "ValueError", "(", "'key: expected type ser...
Alternate constructor intended for using JSON format of private key. Args: key (dict) - Parsed JSON with service account credentials. scopes (Union[str, collections.Iterable[str]]) - List of permissions that the application requests. subject (str) - The email...
[ "Alternate", "constructor", "intended", "for", "using", "JSON", "format", "of", "private", "key", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L75-L96
train
Alternate constructor intended for using JSON format of private key.
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.from_pkcs12
def from_pkcs12(cls, key, email, scopes, subject=None, passphrase=PKCS12_PASSPHRASE): """Alternate constructor intended for using .p12 files. Args: key (dict) - Parsed JSON with service account credentials. email (str) - Service account email. sco...
python
def from_pkcs12(cls, key, email, scopes, subject=None, passphrase=PKCS12_PASSPHRASE): """Alternate constructor intended for using .p12 files. Args: key (dict) - Parsed JSON with service account credentials. email (str) - Service account email. sco...
[ "def", "from_pkcs12", "(", "cls", ",", "key", ",", "email", ",", "scopes", ",", "subject", "=", "None", ",", "passphrase", "=", "PKCS12_PASSPHRASE", ")", ":", "key", "=", "OpenSSL", ".", "crypto", ".", "load_pkcs12", "(", "key", ",", "passphrase", ")", ...
Alternate constructor intended for using .p12 files. Args: key (dict) - Parsed JSON with service account credentials. email (str) - Service account email. scopes (Union[str, collections.Iterable[str]]) - List of permissions that the application requests. ...
[ "Alternate", "constructor", "intended", "for", "using", ".", "p12", "files", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L99-L119
train
Alternate constructor intended for using PKCS12 files.
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.issued_at
def issued_at(self): """Time when access token was requested, as seconds since epoch. Note: Accessing this property when there wasn't any request attempts will return current time. Returns: int """ issued_at = self._issued_at if issue...
python
def issued_at(self): """Time when access token was requested, as seconds since epoch. Note: Accessing this property when there wasn't any request attempts will return current time. Returns: int """ issued_at = self._issued_at if issue...
[ "def", "issued_at", "(", "self", ")", ":", "issued_at", "=", "self", ".", "_issued_at", "if", "issued_at", "is", "None", ":", "self", ".", "_issued_at", "=", "int", "(", "time", ".", "time", "(", ")", ")", "return", "self", ".", "_issued_at" ]
Time when access token was requested, as seconds since epoch. Note: Accessing this property when there wasn't any request attempts will return current time. Returns: int
[ "Time", "when", "access", "token", "was", "requested", "as", "seconds", "since", "epoch", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L181-L194
train
Return the time when the access token was requested.
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.access_token
def access_token(self): """Stores always valid OAuth2 access token. Note: Accessing this property may result in HTTP request. Returns: str """ if (self._access_token is None or self.expiration_time <= int(time.time())): resp =...
python
def access_token(self): """Stores always valid OAuth2 access token. Note: Accessing this property may result in HTTP request. Returns: str """ if (self._access_token is None or self.expiration_time <= int(time.time())): resp =...
[ "def", "access_token", "(", "self", ")", ":", "if", "(", "self", ".", "_access_token", "is", "None", "or", "self", ".", "expiration_time", "<=", "int", "(", "time", ".", "time", "(", ")", ")", ")", ":", "resp", "=", "self", ".", "make_access_request", ...
Stores always valid OAuth2 access token. Note: Accessing this property may result in HTTP request. Returns: str
[ "Stores", "always", "valid", "OAuth2", "access", "token", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L214-L228
train
Stores always valid OAuth2 access token.
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.make_access_request
def make_access_request(self): """Makes an OAuth2 access token request with crafted JWT and signature. The core of this module. Based on arguments it creates proper JWT for you and signs it with supplied private key. Regardless of present valid token, it always clears ``issued_a...
python
def make_access_request(self): """Makes an OAuth2 access token request with crafted JWT and signature. The core of this module. Based on arguments it creates proper JWT for you and signs it with supplied private key. Regardless of present valid token, it always clears ``issued_a...
[ "def", "make_access_request", "(", "self", ")", ":", "del", "self", ".", "issued_at", "assertion", "=", "b'.'", ".", "join", "(", "(", "self", ".", "header", "(", ")", ",", "self", ".", "claims", "(", ")", ",", "self", ".", "signature", "(", ")", "...
Makes an OAuth2 access token request with crafted JWT and signature. The core of this module. Based on arguments it creates proper JWT for you and signs it with supplied private key. Regardless of present valid token, it always clears ``issued_at`` property, which in turn results in req...
[ "Makes", "an", "OAuth2", "access", "token", "request", "with", "crafted", "JWT", "and", "signature", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L259-L290
train
Makes an OAuth2 access token request with crafted JWT and signature.
miedzinski/google-oauth
google_oauth/service.py
ServiceAccount.authorized_request
def authorized_request(self, method, url, **kwargs): """Shortcut for requests.request with proper Authorization header. Note: If you put auth keyword argument or Authorization in headers keyword argument, this will raise an exception. Decide what you want to do! ...
python
def authorized_request(self, method, url, **kwargs): """Shortcut for requests.request with proper Authorization header. Note: If you put auth keyword argument or Authorization in headers keyword argument, this will raise an exception. Decide what you want to do! ...
[ "def", "authorized_request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "kwargs", ".", "pop", "(", "'headers'", ",", "{", "}", ")", "if", "headers", ".", "get", "(", "'Authorization'", ")", "or", "kwarg...
Shortcut for requests.request with proper Authorization header. Note: If you put auth keyword argument or Authorization in headers keyword argument, this will raise an exception. Decide what you want to do! Args: method (str) - HTTP method of this reques...
[ "Shortcut", "for", "requests", ".", "request", "with", "proper", "Authorization", "header", "." ]
aef2e19d87281b1d8e42d6b158111e14e80128db
https://github.com/miedzinski/google-oauth/blob/aef2e19d87281b1d8e42d6b158111e14e80128db/google_oauth/service.py#L292-L321
train
Shortcut for requests. request with proper Authorization header.
geophysics-ubonn/reda
lib/reda/importers/iris_syscal_pro.py
_convert_coords_to_abmn_X
def _convert_coords_to_abmn_X(data, **kwargs): """The syscal only stores positions for the electrodes. Yet, we need to infer electrode numbers for (a,b,m,n) by means of some heuristics. This heuristic uses the x-coordinates to infer an electrode spacing (y/z coordinates are ignored). We also assume a co...
python
def _convert_coords_to_abmn_X(data, **kwargs): """The syscal only stores positions for the electrodes. Yet, we need to infer electrode numbers for (a,b,m,n) by means of some heuristics. This heuristic uses the x-coordinates to infer an electrode spacing (y/z coordinates are ignored). We also assume a co...
[ "def", "_convert_coords_to_abmn_X", "(", "data", ",", "*", "*", "kwargs", ")", ":", "assert", "data", ".", "shape", "[", "1", "]", "==", "4", ",", "'data variable must only contain four columns'", "x0", "=", "kwargs", ".", "get", "(", "'x0'", ",", "data", ...
The syscal only stores positions for the electrodes. Yet, we need to infer electrode numbers for (a,b,m,n) by means of some heuristics. This heuristic uses the x-coordinates to infer an electrode spacing (y/z coordinates are ignored). We also assume a constant spacing of electrodes (i.e., a gap in elect...
[ "The", "syscal", "only", "stores", "positions", "for", "the", "electrodes", ".", "Yet", "we", "need", "to", "infer", "electrode", "numbers", "for", "(", "a", "b", "m", "n", ")", "by", "means", "of", "some", "heuristics", ".", "This", "heuristic", "uses",...
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/iris_syscal_pro.py#L17-L76
train
Convert the x - coordinates of a syscal system into a single systemcal system that can be used in the abmn - X system.
geophysics-ubonn/reda
lib/reda/importers/iris_syscal_pro.py
import_txt
def import_txt(filename, **kwargs): """Import Syscal measurements from a text file, exported as 'Spreadsheet'. Parameters ---------- filename: string input filename x0: float, optional position of first electrode. If not given, then use the smallest x-position in the data as...
python
def import_txt(filename, **kwargs): """Import Syscal measurements from a text file, exported as 'Spreadsheet'. Parameters ---------- filename: string input filename x0: float, optional position of first electrode. If not given, then use the smallest x-position in the data as...
[ "def", "import_txt", "(", "filename", ",", "*", "*", "kwargs", ")", ":", "# read in text file into a buffer", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fid", ":", "text", "=", "fid", ".", "read", "(", ")", "strings_to_replace", "=", "{", "...
Import Syscal measurements from a text file, exported as 'Spreadsheet'. Parameters ---------- filename: string input filename x0: float, optional position of first electrode. If not given, then use the smallest x-position in the data as the first electrode. spacing: float ...
[ "Import", "Syscal", "measurements", "from", "a", "text", "file", "exported", "as", "Spreadsheet", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/iris_syscal_pro.py#L80-L156
train
Import Syscal measurements from a text file exported as Spreadsheet.
geophysics-ubonn/reda
lib/reda/importers/iris_syscal_pro.py
import_bin
def import_bin(filename, **kwargs): """Read a .bin file generated by the IRIS Instruments Syscal Pro System and return a curated dataframe for further processing. This dataframe contains only information currently deemed important. Use the function reda.importers.iris_syscal_pro_binary._import_bin to ex...
python
def import_bin(filename, **kwargs): """Read a .bin file generated by the IRIS Instruments Syscal Pro System and return a curated dataframe for further processing. This dataframe contains only information currently deemed important. Use the function reda.importers.iris_syscal_pro_binary._import_bin to ex...
[ "def", "import_bin", "(", "filename", ",", "*", "*", "kwargs", ")", ":", "metadata", ",", "data_raw", "=", "_import_bin", "(", "filename", ")", "skip_rows", "=", "kwargs", ".", "get", "(", "'skip_rows'", ",", "0", ")", "if", "skip_rows", ">", "0", ":",...
Read a .bin file generated by the IRIS Instruments Syscal Pro System and return a curated dataframe for further processing. This dataframe contains only information currently deemed important. Use the function reda.importers.iris_syscal_pro_binary._import_bin to extract ALL information from a given .bin...
[ "Read", "a", ".", "bin", "file", "generated", "by", "the", "IRIS", "Instruments", "Syscal", "Pro", "System", "and", "return", "a", "curated", "dataframe", "for", "further", "processing", ".", "This", "dataframe", "contains", "only", "information", "currently", ...
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/iris_syscal_pro.py#L160-L266
train
Read a. bin file generated by the IRIS Instruments Syscal Pro System and return a curated dataframe for further processing.
geophysics-ubonn/reda
lib/reda/importers/iris_syscal_pro.py
_import_bin
def _import_bin(filename): """Read a .bin file generated by the IRIS Instruments Syscal Pro System Parameters ---------- filename : string Path to input filename Returns ------- metadata : dict General information on the measurement df : :py:class:`pandas.DataFrame` ...
python
def _import_bin(filename): """Read a .bin file generated by the IRIS Instruments Syscal Pro System Parameters ---------- filename : string Path to input filename Returns ------- metadata : dict General information on the measurement df : :py:class:`pandas.DataFrame` ...
[ "def", "_import_bin", "(", "filename", ")", ":", "fid", "=", "open", "(", "filename", ",", "'rb'", ")", "def", "fget", "(", "fid", ",", "fmt", ",", "tsize", ")", ":", "buffer", "=", "fid", ".", "read", "(", "tsize", ")", "result_raw", "=", "struct"...
Read a .bin file generated by the IRIS Instruments Syscal Pro System Parameters ---------- filename : string Path to input filename Returns ------- metadata : dict General information on the measurement df : :py:class:`pandas.DataFrame` dataframe containing all meas...
[ "Read", "a", ".", "bin", "file", "generated", "by", "the", "IRIS", "Instruments", "Syscal", "Pro", "System" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/iris_syscal_pro.py#L269-L475
train
Read a. bin file generated by the IRIS Instruments Syscal Pro System and return a dataframe containing all measurement data
lambdalisue/notify
src/notify/notifier.py
call_and_notificate
def call_and_notificate(args, opts): """ Execute specified arguments and send notification email Parameters ---------- args : list A execution command/arguments list opts : object A option instance """ # store starttime stctime = time.clock() stttime = time.time(...
python
def call_and_notificate(args, opts): """ Execute specified arguments and send notification email Parameters ---------- args : list A execution command/arguments list opts : object A option instance """ # store starttime stctime = time.clock() stttime = time.time(...
[ "def", "call_and_notificate", "(", "args", ",", "opts", ")", ":", "# store starttime", "stctime", "=", "time", ".", "clock", "(", ")", "stttime", "=", "time", ".", "time", "(", ")", "stdtime", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "# ...
Execute specified arguments and send notification email Parameters ---------- args : list A execution command/arguments list opts : object A option instance
[ "Execute", "specified", "arguments", "and", "send", "notification", "email" ]
1b6d7d1faa2cea13bfaa1f35130f279a0115e686
https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/notifier.py#L28-L78
train
Execute specified arguments and send notification email to the user
evolbioinfo/pastml
pastml/visualisation/colour_generator.py
get_enough_colours
def get_enough_colours(num_unique_values): """ Generates and returns an array of `num_unique_values` HEX colours. :param num_unique_values: int, number of colours to be generated. :return: array of str, containing colours in HEX format. """ if num_unique_values in NUM2COLOURS: return NUM...
python
def get_enough_colours(num_unique_values): """ Generates and returns an array of `num_unique_values` HEX colours. :param num_unique_values: int, number of colours to be generated. :return: array of str, containing colours in HEX format. """ if num_unique_values in NUM2COLOURS: return NUM...
[ "def", "get_enough_colours", "(", "num_unique_values", ")", ":", "if", "num_unique_values", "in", "NUM2COLOURS", ":", "return", "NUM2COLOURS", "[", "num_unique_values", "]", "vs", "=", "[", "'#%02x%02x%02x'", "%", "tuple", "(", "rgb", ")", "for", "rgb", "in", ...
Generates and returns an array of `num_unique_values` HEX colours. :param num_unique_values: int, number of colours to be generated. :return: array of str, containing colours in HEX format.
[ "Generates", "and", "returns", "an", "array", "of", "num_unique_values", "HEX", "colours", ".", ":", "param", "num_unique_values", ":", "int", "number", "of", "colours", "to", "be", "generated", ".", ":", "return", ":", "array", "of", "str", "containing", "c...
df8a375841525738383e59548eed3441b07dbd3e
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/visualisation/colour_generator.py#L25-L39
train
Generates and returns an array of num_unique_values HEX colours.
gtaylor/django-athumb
athumb/fields.py
ImageWithThumbsFieldFile.get_thumbnail_format
def get_thumbnail_format(self): """ Determines the target thumbnail type either by looking for a format override specified at the model level, or by using the format the user uploaded. """ if self.field.thumbnail_format: # Over-ride was given, use that instead...
python
def get_thumbnail_format(self): """ Determines the target thumbnail type either by looking for a format override specified at the model level, or by using the format the user uploaded. """ if self.field.thumbnail_format: # Over-ride was given, use that instead...
[ "def", "get_thumbnail_format", "(", "self", ")", ":", "if", "self", ".", "field", ".", "thumbnail_format", ":", "# Over-ride was given, use that instead.", "return", "self", ".", "field", ".", "thumbnail_format", ".", "lower", "(", ")", "else", ":", "# Use the exi...
Determines the target thumbnail type either by looking for a format override specified at the model level, or by using the format the user uploaded.
[ "Determines", "the", "target", "thumbnail", "type", "either", "by", "looking", "for", "a", "format", "override", "specified", "at", "the", "model", "level", "or", "by", "using", "the", "format", "the", "user", "uploaded", "." ]
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/fields.py#L94-L106
train
Determines the thumbnail format of the file.
gtaylor/django-athumb
athumb/fields.py
ImageWithThumbsFieldFile.save
def save(self, name, content, save=True): """ Handles some extra logic to generate the thumbnails when the original file is uploaded. """ super(ImageWithThumbsFieldFile, self).save(name, content, save) try: self.generate_thumbs(name, content) except IO...
python
def save(self, name, content, save=True): """ Handles some extra logic to generate the thumbnails when the original file is uploaded. """ super(ImageWithThumbsFieldFile, self).save(name, content, save) try: self.generate_thumbs(name, content) except IO...
[ "def", "save", "(", "self", ",", "name", ",", "content", ",", "save", "=", "True", ")", ":", "super", "(", "ImageWithThumbsFieldFile", ",", "self", ")", ".", "save", "(", "name", ",", "content", ",", "save", ")", "try", ":", "self", ".", "generate_th...
Handles some extra logic to generate the thumbnails when the original file is uploaded.
[ "Handles", "some", "extra", "logic", "to", "generate", "the", "thumbnails", "when", "the", "original", "file", "is", "uploaded", "." ]
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/fields.py#L108-L124
train
Save the image with thumbnails.
gtaylor/django-athumb
athumb/fields.py
ImageWithThumbsFieldFile._calc_thumb_filename
def _calc_thumb_filename(self, thumb_name): """ Calculates the correct filename for a would-be (or potentially existing) thumbnail of the given size. NOTE: This includes the path leading up to the thumbnail. IE: uploads/cbid_images/photo.png size: (tuple...
python
def _calc_thumb_filename(self, thumb_name): """ Calculates the correct filename for a would-be (or potentially existing) thumbnail of the given size. NOTE: This includes the path leading up to the thumbnail. IE: uploads/cbid_images/photo.png size: (tuple...
[ "def", "_calc_thumb_filename", "(", "self", ",", "thumb_name", ")", ":", "filename_split", "=", "self", ".", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "file_name", "=", "filename_split", "[", "0", "]", "file_extension", "=", "self", ".", "get_thumb...
Calculates the correct filename for a would-be (or potentially existing) thumbnail of the given size. NOTE: This includes the path leading up to the thumbnail. IE: uploads/cbid_images/photo.png size: (tuple) In the format of (width, height) Returns a st...
[ "Calculates", "the", "correct", "filename", "for", "a", "would", "-", "be", "(", "or", "potentially", "existing", ")", "thumbnail", "of", "the", "given", "size", ".", "NOTE", ":", "This", "includes", "the", "path", "leading", "up", "to", "the", "thumbnail"...
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/fields.py#L140-L156
train
Calculates the correct filename for a would - be thumbnail of the given size.
gtaylor/django-athumb
athumb/fields.py
ImageWithThumbsFieldFile.create_and_store_thumb
def create_and_store_thumb(self, image, thumb_name, thumb_options): """ Given that 'image' is a PIL Image object, create a thumbnail for the given size tuple and store it via the storage backend. image: (Image) PIL Image object. size: (tuple) Tuple in form of (width, hei...
python
def create_and_store_thumb(self, image, thumb_name, thumb_options): """ Given that 'image' is a PIL Image object, create a thumbnail for the given size tuple and store it via the storage backend. image: (Image) PIL Image object. size: (tuple) Tuple in form of (width, hei...
[ "def", "create_and_store_thumb", "(", "self", ",", "image", ",", "thumb_name", ",", "thumb_options", ")", ":", "size", "=", "thumb_options", "[", "'size'", "]", "upscale", "=", "thumb_options", ".", "get", "(", "'upscale'", ",", "True", ")", "crop", "=", "...
Given that 'image' is a PIL Image object, create a thumbnail for the given size tuple and store it via the storage backend. image: (Image) PIL Image object. size: (tuple) Tuple in form of (width, height). Image will be thumbnailed to this size.
[ "Given", "that", "image", "is", "a", "PIL", "Image", "object", "create", "a", "thumbnail", "for", "the", "given", "size", "tuple", "and", "store", "it", "via", "the", "storage", "backend", ".", "image", ":", "(", "Image", ")", "PIL", "Image", "object", ...
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/fields.py#L158-L195
train
Create a thumbnail for the given image and store it in the storage backend.
gtaylor/django-athumb
athumb/fields.py
ImageWithThumbsFieldFile.delete
def delete(self, save=True): """ Deletes the original, plus any thumbnails. Fails silently if there are errors deleting the thumbnails. """ for thumb in self.field.thumbs: thumb_name, thumb_options = thumb thumb_filename = self._calc_thumb_filename(thumb_n...
python
def delete(self, save=True): """ Deletes the original, plus any thumbnails. Fails silently if there are errors deleting the thumbnails. """ for thumb in self.field.thumbs: thumb_name, thumb_options = thumb thumb_filename = self._calc_thumb_filename(thumb_n...
[ "def", "delete", "(", "self", ",", "save", "=", "True", ")", ":", "for", "thumb", "in", "self", ".", "field", ".", "thumbs", ":", "thumb_name", ",", "thumb_options", "=", "thumb", "thumb_filename", "=", "self", ".", "_calc_thumb_filename", "(", "thumb_name...
Deletes the original, plus any thumbnails. Fails silently if there are errors deleting the thumbnails.
[ "Deletes", "the", "original", "plus", "any", "thumbnails", ".", "Fails", "silently", "if", "there", "are", "errors", "deleting", "the", "thumbnails", "." ]
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/fields.py#L197-L207
train
Deletes the original plus any thumbnails.
tony-landis/datomic-py
datomic/datomic.py
dump_edn_val
def dump_edn_val(v): " edn simple value dump" if isinstance(v, (str, unicode)): return json.dumps(v) elif isinstance(v, E): return unicode(v) else: return dumps(v)
python
def dump_edn_val(v): " edn simple value dump" if isinstance(v, (str, unicode)): return json.dumps(v) elif isinstance(v, E): return unicode(v) else: return dumps(v)
[ "def", "dump_edn_val", "(", "v", ")", ":", "if", "isinstance", "(", "v", ",", "(", "str", ",", "unicode", ")", ")", ":", "return", "json", ".", "dumps", "(", "v", ")", "elif", "isinstance", "(", "v", ",", "E", ")", ":", "return", "unicode", "(", ...
edn simple value dump
[ "edn", "simple", "value", "dump" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L644-L651
train
edn simple value dump
tony-landis/datomic-py
datomic/datomic.py
DB.create
def create(self): """ Creates the database >>> db.create() True """ data = data={"db-name":self.db} self.rest('POST', self.uri_str, status_codes=(200,201), data=data) return True
python
def create(self): """ Creates the database >>> db.create() True """ data = data={"db-name":self.db} self.rest('POST', self.uri_str, status_codes=(200,201), data=data) return True
[ "def", "create", "(", "self", ")", ":", "data", "=", "data", "=", "{", "\"db-name\"", ":", "self", ".", "db", "}", "self", ".", "rest", "(", "'POST'", ",", "self", ".", "uri_str", ",", "status_codes", "=", "(", "200", ",", "201", ")", ",", "data"...
Creates the database >>> db.create() True
[ "Creates", "the", "database", ">>>", "db", ".", "create", "()", "True" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L51-L58
train
Creates the database
tony-landis/datomic-py
datomic/datomic.py
DB.tx_schema
def tx_schema(self, **kwargs): """ Builds the data structure edn, and puts it in the db """ for s in self.schema.schema: tx = self.tx(s, **kwargs)
python
def tx_schema(self, **kwargs): """ Builds the data structure edn, and puts it in the db """ for s in self.schema.schema: tx = self.tx(s, **kwargs)
[ "def", "tx_schema", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "s", "in", "self", ".", "schema", ".", "schema", ":", "tx", "=", "self", ".", "tx", "(", "s", ",", "*", "*", "kwargs", ")" ]
Builds the data structure edn, and puts it in the db
[ "Builds", "the", "data", "structure", "edn", "and", "puts", "it", "in", "the", "db" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L67-L71
train
Builds the data structure edn and puts it in the db
tony-landis/datomic-py
datomic/datomic.py
DB.tx
def tx(self, *args, **kwargs): """ Executes a raw tx string, or get a new TX object to work with. Passing a raw string or list of strings will immedately transact and return the API response as a dict. >>> resp = tx('{:db/id #db/id[:db.part/user] :person/name "Bob"}') {db-before: db-after: tempids...
python
def tx(self, *args, **kwargs): """ Executes a raw tx string, or get a new TX object to work with. Passing a raw string or list of strings will immedately transact and return the API response as a dict. >>> resp = tx('{:db/id #db/id[:db.part/user] :person/name "Bob"}') {db-before: db-after: tempids...
[ "def", "tx", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "0", "==", "len", "(", "args", ")", ":", "return", "TX", "(", "self", ")", "ops", "=", "[", "]", "for", "op", "in", "args", ":", "if", "isinstance", "(", "...
Executes a raw tx string, or get a new TX object to work with. Passing a raw string or list of strings will immedately transact and return the API response as a dict. >>> resp = tx('{:db/id #db/id[:db.part/user] :person/name "Bob"}') {db-before: db-after: tempids: } This gets a fresh `TX()` to pr...
[ "Executes", "a", "raw", "tx", "string", "or", "get", "a", "new", "TX", "object", "to", "work", "with", "." ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L73-L118
train
Executes a raw TX string or get a new TX object to work with. Returns a dict of the response.
tony-landis/datomic-py
datomic/datomic.py
DB.e
def e(self, eid): """Get an Entity """ ta = datetime.datetime.now() rs = self.rest('GET', self.uri_db + '-/entity', data={'e':int(eid)}, parse=True) tb = datetime.datetime.now() - ta print cl('<<< fetched entity %s in %sms' % (eid, tb.microseconds/1000.0), 'cyan') return rs
python
def e(self, eid): """Get an Entity """ ta = datetime.datetime.now() rs = self.rest('GET', self.uri_db + '-/entity', data={'e':int(eid)}, parse=True) tb = datetime.datetime.now() - ta print cl('<<< fetched entity %s in %sms' % (eid, tb.microseconds/1000.0), 'cyan') return rs
[ "def", "e", "(", "self", ",", "eid", ")", ":", "ta", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "rs", "=", "self", ".", "rest", "(", "'GET'", ",", "self", ".", "uri_db", "+", "'-/entity'", ",", "data", "=", "{", "'e'", ":", "int", ...
Get an Entity
[ "Get", "an", "Entity" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L120-L127
train
Get an Entity
tony-landis/datomic-py
datomic/datomic.py
DB.retract
def retract(self, e, a, v): """ redact the value of an attribute """ ta = datetime.datetime.now() ret = u"[:db/retract %i :%s %s]" % (e, a, dump_edn_val(v)) rs = self.tx(ret) tb = datetime.datetime.now() - ta print cl('<<< retracted %s,%s,%s in %sms' % (e,a,v, tb.microseconds/1000.0), 'cyan'...
python
def retract(self, e, a, v): """ redact the value of an attribute """ ta = datetime.datetime.now() ret = u"[:db/retract %i :%s %s]" % (e, a, dump_edn_val(v)) rs = self.tx(ret) tb = datetime.datetime.now() - ta print cl('<<< retracted %s,%s,%s in %sms' % (e,a,v, tb.microseconds/1000.0), 'cyan'...
[ "def", "retract", "(", "self", ",", "e", ",", "a", ",", "v", ")", ":", "ta", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "ret", "=", "u\"[:db/retract %i :%s %s]\"", "%", "(", "e", ",", "a", ",", "dump_edn_val", "(", "v", ")", ")", "rs...
redact the value of an attribute
[ "redact", "the", "value", "of", "an", "attribute" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L129-L137
train
redact the value of an attribute
tony-landis/datomic-py
datomic/datomic.py
DB.datoms
def datoms(self, index='aevt', e='', a='', v='', limit=0, offset=0, chunk=100, start='', end='', since='', as_of='', history='', **kwargs): """ Returns a lazy generator that will only fetch groups of datoms at the chunk size specified. http://docs.datomic.com/clo...
python
def datoms(self, index='aevt', e='', a='', v='', limit=0, offset=0, chunk=100, start='', end='', since='', as_of='', history='', **kwargs): """ Returns a lazy generator that will only fetch groups of datoms at the chunk size specified. http://docs.datomic.com/clo...
[ "def", "datoms", "(", "self", ",", "index", "=", "'aevt'", ",", "e", "=", "''", ",", "a", "=", "''", ",", "v", "=", "''", ",", "limit", "=", "0", ",", "offset", "=", "0", ",", "chunk", "=", "100", ",", "start", "=", "''", ",", "end", "=", ...
Returns a lazy generator that will only fetch groups of datoms at the chunk size specified. http://docs.datomic.com/clojure/index.html#datomic.api/datoms
[ "Returns", "a", "lazy", "generator", "that", "will", "only", "fetch", "groups", "of", "datoms", "at", "the", "chunk", "size", "specified", "." ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L140-L172
train
Returns a generator that returns datoms in a specified chunk size.
tony-landis/datomic-py
datomic/datomic.py
DB.rest
def rest(self, method, uri, data=None, status_codes=None, parse=True, **kwargs): """ Rest helpers """ r = self.pool.request_encode_body(method, uri, fields=data, encode_multipart=False) if not r.status in (status_codes if status_codes else (200,201)): print cl('\n---------\nURI / REQUEST TYPE : %s...
python
def rest(self, method, uri, data=None, status_codes=None, parse=True, **kwargs): """ Rest helpers """ r = self.pool.request_encode_body(method, uri, fields=data, encode_multipart=False) if not r.status in (status_codes if status_codes else (200,201)): print cl('\n---------\nURI / REQUEST TYPE : %s...
[ "def", "rest", "(", "self", ",", "method", ",", "uri", ",", "data", "=", "None", ",", "status_codes", "=", "None", ",", "parse", "=", "True", ",", "*", "*", "kwargs", ")", ":", "r", "=", "self", ".", "pool", ".", "request_encode_body", "(", "method...
Rest helpers
[ "Rest", "helpers" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L174-L191
train
Rest helper function
tony-landis/datomic-py
datomic/datomic.py
DB.debug
def debug(self, defn, args, kwargs, fmt=None, color='green'): """ debug timing, colored terminal output """ ta = datetime.datetime.now() rs = defn(*args, **kwargs) tb = datetime.datetime.now() - ta fmt = fmt or "processed {defn} in {ms}ms" logmsg = fmt.format(ms=tb.microseconds/1000.0, def...
python
def debug(self, defn, args, kwargs, fmt=None, color='green'): """ debug timing, colored terminal output """ ta = datetime.datetime.now() rs = defn(*args, **kwargs) tb = datetime.datetime.now() - ta fmt = fmt or "processed {defn} in {ms}ms" logmsg = fmt.format(ms=tb.microseconds/1000.0, def...
[ "def", "debug", "(", "self", ",", "defn", ",", "args", ",", "kwargs", ",", "fmt", "=", "None", ",", "color", "=", "'green'", ")", ":", "ta", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "rs", "=", "defn", "(", "*", "args", ",", "*", ...
debug timing, colored terminal output
[ "debug", "timing", "colored", "terminal", "output" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L193-L205
train
debug timing terminal output
tony-landis/datomic-py
datomic/datomic.py
DB.q
def q(self, q, inputs=None, limit='', offset='', history=False): """ query """ if not q.strip().startswith("["): q = "[ {0} ]".format(q) args = u'[ {:db/alias "%(store)s/%(db)s" %(hist)s} %(inputs)s ]' % dict( store = self.store, db = self.db, hist = ':history true' if histo...
python
def q(self, q, inputs=None, limit='', offset='', history=False): """ query """ if not q.strip().startswith("["): q = "[ {0} ]".format(q) args = u'[ {:db/alias "%(store)s/%(db)s" %(hist)s} %(inputs)s ]' % dict( store = self.store, db = self.db, hist = ':history true' if histo...
[ "def", "q", "(", "self", ",", "q", ",", "inputs", "=", "None", ",", "limit", "=", "''", ",", "offset", "=", "''", ",", "history", "=", "False", ")", ":", "if", "not", "q", ".", "strip", "(", ")", ".", "startswith", "(", "\"[\"", ")", ":", "q"...
query
[ "query" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L207-L221
train
Query the national von von.
tony-landis/datomic-py
datomic/datomic.py
DB.find
def find(self, *args, **kwargs): " new query builder on current db" return Query(*args, db=self, schema=self.schema)
python
def find(self, *args, **kwargs): " new query builder on current db" return Query(*args, db=self, schema=self.schema)
[ "def", "find", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Query", "(", "*", "args", ",", "db", "=", "self", ",", "schema", "=", "self", ".", "schema", ")" ]
new query builder on current db
[ "new", "query", "builder", "on", "current", "db" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L223-L225
train
new query builder on current db
tony-landis/datomic-py
datomic/datomic.py
Query.find
def find(self, *args, **kwargs): " :find " if args[0] is all: pass # finds all else: [(self._find.append(x)) for x in args] return self
python
def find(self, *args, **kwargs): " :find " if args[0] is all: pass # finds all else: [(self._find.append(x)) for x in args] return self
[ "def", "find", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", "[", "0", "]", "is", "all", ":", "pass", "# finds all", "else", ":", "[", "(", "self", ".", "_find", ".", "append", "(", "x", ")", ")", "for", "x",...
:find
[ ":", "find" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L254-L260
train
find "
tony-landis/datomic-py
datomic/datomic.py
Query.where
def where(self, *args, **kwargs): " :where " [(self._where.append(x)) for x in args] return self
python
def where(self, *args, **kwargs): " :where " [(self._where.append(x)) for x in args] return self
[ "def", "where", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "[", "(", "self", ".", "_where", ".", "append", "(", "x", ")", ")", "for", "x", "in", "args", "]", "return", "self" ]
:where
[ ":", "where" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L262-L265
train
where " : where
tony-landis/datomic-py
datomic/datomic.py
Query.param
def param(self, *args, **kwargs): " :in " for first, second in pairwise(args): if isinstance(second, list): if not isinstance(second[0], list): " add a logical _or_ " self._input.append(( u"[{0} ...]".format(first), second)) else: " relations, ...
python
def param(self, *args, **kwargs): " :in " for first, second in pairwise(args): if isinstance(second, list): if not isinstance(second[0], list): " add a logical _or_ " self._input.append(( u"[{0} ...]".format(first), second)) else: " relations, ...
[ "def", "param", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "first", ",", "second", "in", "pairwise", "(", "args", ")", ":", "if", "isinstance", "(", "second", ",", "list", ")", ":", "if", "not", "isinstance", "(", "s...
:in
[ ":", "in" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L271-L290
train
add a logical or list of list
tony-landis/datomic-py
datomic/datomic.py
Query.hashone
def hashone(self): "execute query, get back" rs = self.one() if not rs: return {} else: finds = " ".join(self._find).split(' ') return dict(zip((x.replace('?','') for x in finds), rs))
python
def hashone(self): "execute query, get back" rs = self.one() if not rs: return {} else: finds = " ".join(self._find).split(' ') return dict(zip((x.replace('?','') for x in finds), rs))
[ "def", "hashone", "(", "self", ")", ":", "rs", "=", "self", ".", "one", "(", ")", "if", "not", "rs", ":", "return", "{", "}", "else", ":", "finds", "=", "\" \"", ".", "join", "(", "self", ".", "_find", ")", ".", "split", "(", "' '", ")", "ret...
execute query, get back
[ "execute", "query", "get", "back" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L302-L309
train
execute query get back
tony-landis/datomic-py
datomic/datomic.py
Query.all
def all(self): " execute query, get all list of lists" query,inputs = self._toedn() return self.db.q(query, inputs = inputs, limit = self._limit, offset = self._offset, history = self._history)
python
def all(self): " execute query, get all list of lists" query,inputs = self._toedn() return self.db.q(query, inputs = inputs, limit = self._limit, offset = self._offset, history = self._history)
[ "def", "all", "(", "self", ")", ":", "query", ",", "inputs", "=", "self", ".", "_toedn", "(", ")", "return", "self", ".", "db", ".", "q", "(", "query", ",", "inputs", "=", "inputs", ",", "limit", "=", "self", ".", "_limit", ",", "offset", "=", ...
execute query, get all list of lists
[ "execute", "query", "get", "all", "list", "of", "lists" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L320-L327
train
execute query get all list of lists
tony-landis/datomic-py
datomic/datomic.py
Query._toedn
def _toedn(self): """ prepare the query for the rest api """ finds = u"" inputs = u"" wheres = u"" args = [] ": in and args" for a,b in self._input: inputs += " {0}".format(a) args.append(dump_edn_val(b)) if inputs: inputs = u":in ${0}".format(inputs) " :wher...
python
def _toedn(self): """ prepare the query for the rest api """ finds = u"" inputs = u"" wheres = u"" args = [] ": in and args" for a,b in self._input: inputs += " {0}".format(a) args.append(dump_edn_val(b)) if inputs: inputs = u":in ${0}".format(inputs) " :wher...
[ "def", "_toedn", "(", "self", ")", ":", "finds", "=", "u\"\"", "inputs", "=", "u\"\"", "wheres", "=", "u\"\"", "args", "=", "[", "]", "\": in and args\"", "for", "a", ",", "b", "in", "self", ".", "_input", ":", "inputs", "+=", "\" {0}\"", ".", "forma...
prepare the query for the rest api
[ "prepare", "the", "query", "for", "the", "rest", "api" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L329-L359
train
prepare the query for the rest api
tony-landis/datomic-py
datomic/datomic.py
TX.add
def add(self, *args, **kwargs): """ Accumulate datums for the transaction Start a transaction on an existing db connection >>> tx = TX(db) Get get an entity object with a tempid >>> ref = add() >>> ref = add(0) >>> ref = add(None) >>> ref = add(False) Entity id passed as first arg...
python
def add(self, *args, **kwargs): """ Accumulate datums for the transaction Start a transaction on an existing db connection >>> tx = TX(db) Get get an entity object with a tempid >>> ref = add() >>> ref = add(0) >>> ref = add(None) >>> ref = add(False) Entity id passed as first arg...
[ "def", "add", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "resp", "is", "None", ",", "\"Transaction already committed\"", "entity", ",", "av_pairs", ",", "args", "=", "None", ",", "[", "]", ",", "list", "(...
Accumulate datums for the transaction Start a transaction on an existing db connection >>> tx = TX(db) Get get an entity object with a tempid >>> ref = add() >>> ref = add(0) >>> ref = add(None) >>> ref = add(False) Entity id passed as first argument (int|long) >>> tx.add(1, 'thin...
[ "Accumulate", "datums", "for", "the", "transaction" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L515-L594
train
Add a new object to the list of objects in the order they appear in the list.
tony-landis/datomic-py
datomic/datomic.py
TX.execute
def execute(self, **kwargs): """ commit the current statements from add() """ assert self.resp is None, "Transaction already committed" try: self.resp = self.db.tx(list(self.edn_iter), **kwargs) except Exception: self.resp = False raise else: self.resolve() self.add...
python
def execute(self, **kwargs): """ commit the current statements from add() """ assert self.resp is None, "Transaction already committed" try: self.resp = self.db.tx(list(self.edn_iter), **kwargs) except Exception: self.resp = False raise else: self.resolve() self.add...
[ "def", "execute", "(", "self", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "resp", "is", "None", ",", "\"Transaction already committed\"", "try", ":", "self", ".", "resp", "=", "self", ".", "db", ".", "tx", "(", "list", "(", "self", "."...
commit the current statements from add()
[ "commit", "the", "current", "statements", "from", "add", "()" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L596-L609
train
Commit the current statements from add
tony-landis/datomic-py
datomic/datomic.py
TX.resolve
def resolve(self): """ Resolve one or more tempids. Automatically takes place after transaction is executed. """ assert isinstance(self.resp, dict), "Transaction in uncommitted or failed state" rids = [(v) for k,v in self.resp['tempids'].items()] self.txid = self.resp['tx-data'][0]['tx'] ri...
python
def resolve(self): """ Resolve one or more tempids. Automatically takes place after transaction is executed. """ assert isinstance(self.resp, dict), "Transaction in uncommitted or failed state" rids = [(v) for k,v in self.resp['tempids'].items()] self.txid = self.resp['tx-data'][0]['tx'] ri...
[ "def", "resolve", "(", "self", ")", ":", "assert", "isinstance", "(", "self", ".", "resp", ",", "dict", ")", ",", "\"Transaction in uncommitted or failed state\"", "rids", "=", "[", "(", "v", ")", "for", "k", ",", "v", "in", "self", ".", "resp", "[", "...
Resolve one or more tempids. Automatically takes place after transaction is executed.
[ "Resolve", "one", "or", "more", "tempids", ".", "Automatically", "takes", "place", "after", "transaction", "is", "executed", "." ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L611-L623
train
Resolve one or more tempids. Automatically takes place after transaction is executed.
tony-landis/datomic-py
datomic/datomic.py
TX.edn_iter
def edn_iter(self): """ yields edns """ for e,a,v in self.adds: yield u"{%(a)s %(v)s :db/id #db/id[:db.part/user %(e)s ]}" % \ dict(a=a, v=dump_edn_val(v), e=int(e))
python
def edn_iter(self): """ yields edns """ for e,a,v in self.adds: yield u"{%(a)s %(v)s :db/id #db/id[:db.part/user %(e)s ]}" % \ dict(a=a, v=dump_edn_val(v), e=int(e))
[ "def", "edn_iter", "(", "self", ")", ":", "for", "e", ",", "a", ",", "v", "in", "self", ".", "adds", ":", "yield", "u\"{%(a)s %(v)s :db/id #db/id[:db.part/user %(e)s ]}\"", "%", "dict", "(", "a", "=", "a", ",", "v", "=", "dump_edn_val", "(", "v", ")", ...
yields edns
[ "yields", "edns" ]
54f713d29ad85ba86d53d5115c9b312ff14b7846
https://github.com/tony-landis/datomic-py/blob/54f713d29ad85ba86d53d5115c9b312ff14b7846/datomic/datomic.py#L634-L639
train
Iterate over the user - specified additions.
pennlabs/penn-sdk-python
penn/fitness.py
Fitness.get_usage
def get_usage(self): """Get fitness locations and their current usage.""" resp = requests.get(FITNESS_URL, timeout=30) resp.raise_for_status() soup = BeautifulSoup(resp.text, "html5lib") eastern = pytz.timezone('US/Eastern') output = [] for item in soup.findAll(...
python
def get_usage(self): """Get fitness locations and their current usage.""" resp = requests.get(FITNESS_URL, timeout=30) resp.raise_for_status() soup = BeautifulSoup(resp.text, "html5lib") eastern = pytz.timezone('US/Eastern') output = [] for item in soup.findAll(...
[ "def", "get_usage", "(", "self", ")", ":", "resp", "=", "requests", ".", "get", "(", "FITNESS_URL", ",", "timeout", "=", "30", ")", "resp", ".", "raise_for_status", "(", ")", "soup", "=", "BeautifulSoup", "(", "resp", ".", "text", ",", "\"html5lib\"", ...
Get fitness locations and their current usage.
[ "Get", "fitness", "locations", "and", "their", "current", "usage", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/fitness.py#L49-L69
train
Get fitness locations and their current usage.
pennlabs/penn-sdk-python
penn/map.py
Map.search
def search(self, keyword): """Return all buildings related to the provided query. :param keyword: The keyword for your map search >>> results = n.search('Harrison') """ params = { "source": "map", "description": keyword } data...
python
def search(self, keyword): """Return all buildings related to the provided query. :param keyword: The keyword for your map search >>> results = n.search('Harrison') """ params = { "source": "map", "description": keyword } data...
[ "def", "search", "(", "self", ",", "keyword", ")", ":", "params", "=", "{", "\"source\"", ":", "\"map\"", ",", "\"description\"", ":", "keyword", "}", "data", "=", "self", ".", "_request", "(", "ENDPOINTS", "[", "'SEARCH'", "]", ",", "params", ")", "da...
Return all buildings related to the provided query. :param keyword: The keyword for your map search >>> results = n.search('Harrison')
[ "Return", "all", "buildings", "related", "to", "the", "provided", "query", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/map.py#L21-L35
train
Search for buildings related to the provided keyword.
geophysics-ubonn/reda
lib/reda/utils/geometric_factors.py
apply_K
def apply_K(df, k): """Apply the geometric factors to the dataset and compute (apparent) resistivities/conductivities """ if 'k' not in df.columns: df['k'] = k if 'rho_a' not in df.columns: df['rho_a'] = df['r'] * df['k'] if 'sigma_a' not in df.columns: df['sigma_a'] = ...
python
def apply_K(df, k): """Apply the geometric factors to the dataset and compute (apparent) resistivities/conductivities """ if 'k' not in df.columns: df['k'] = k if 'rho_a' not in df.columns: df['rho_a'] = df['r'] * df['k'] if 'sigma_a' not in df.columns: df['sigma_a'] = ...
[ "def", "apply_K", "(", "df", ",", "k", ")", ":", "if", "'k'", "not", "in", "df", ".", "columns", ":", "df", "[", "'k'", "]", "=", "k", "if", "'rho_a'", "not", "in", "df", ".", "columns", ":", "df", "[", "'rho_a'", "]", "=", "df", "[", "'r'", ...
Apply the geometric factors to the dataset and compute (apparent) resistivities/conductivities
[ "Apply", "the", "geometric", "factors", "to", "the", "dataset", "and", "compute", "(", "apparent", ")", "resistivities", "/", "conductivities" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/geometric_factors.py#L11-L26
train
Apply the geometric factors to the dataset and compute the parent s resistivities and conductivities
geophysics-ubonn/reda
lib/reda/utils/geometric_factors.py
compute_K_numerical
def compute_K_numerical(dataframe, settings=None, keep_dir=None): """Use a finite-element modeling code to infer geometric factors for meshes with topography or irregular electrode spacings. Parameters ---------- dataframe : pandas.DataFrame the data frame that contains the data setting...
python
def compute_K_numerical(dataframe, settings=None, keep_dir=None): """Use a finite-element modeling code to infer geometric factors for meshes with topography or irregular electrode spacings. Parameters ---------- dataframe : pandas.DataFrame the data frame that contains the data setting...
[ "def", "compute_K_numerical", "(", "dataframe", ",", "settings", "=", "None", ",", "keep_dir", "=", "None", ")", ":", "inversion_code", "=", "reda", ".", "rcParams", ".", "get", "(", "'geom_factor.inversion_code'", ",", "'crtomo'", ")", "if", "inversion_code", ...
Use a finite-element modeling code to infer geometric factors for meshes with topography or irregular electrode spacings. Parameters ---------- dataframe : pandas.DataFrame the data frame that contains the data settings : dict The settings required to compute the geometric factors. ...
[ "Use", "a", "finite", "-", "element", "modeling", "code", "to", "infer", "geometric", "factors", "for", "meshes", "with", "topography", "or", "irregular", "electrode", "spacings", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/geometric_factors.py#L29-L74
train
Use a finite - element modeling code to infer geometric factors for a single object in the current directory.
geophysics-ubonn/reda
lib/reda/utils/geometric_factors.py
compute_K_analytical
def compute_K_analytical(dataframe, spacing): """Given an electrode spacing, compute geometrical factors using the equation for the homogeneous half-space (Neumann-equation) If a dataframe is given, use the column (a, b, m, n). Otherwise, expect an Nx4 arrray. Parameters ---------- datafra...
python
def compute_K_analytical(dataframe, spacing): """Given an electrode spacing, compute geometrical factors using the equation for the homogeneous half-space (Neumann-equation) If a dataframe is given, use the column (a, b, m, n). Otherwise, expect an Nx4 arrray. Parameters ---------- datafra...
[ "def", "compute_K_analytical", "(", "dataframe", ",", "spacing", ")", ":", "if", "isinstance", "(", "dataframe", ",", "pd", ".", "DataFrame", ")", ":", "configs", "=", "dataframe", "[", "[", "'a'", ",", "'b'", ",", "'m'", ",", "'n'", "]", "]", ".", "...
Given an electrode spacing, compute geometrical factors using the equation for the homogeneous half-space (Neumann-equation) If a dataframe is given, use the column (a, b, m, n). Otherwise, expect an Nx4 arrray. Parameters ---------- dataframe : pandas.DataFrame or numpy.ndarray Config...
[ "Given", "an", "electrode", "spacing", "compute", "geometrical", "factors", "using", "the", "equation", "for", "the", "homogeneous", "half", "-", "space", "(", "Neumann", "-", "equation", ")" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/geometric_factors.py#L77-L107
train
Compute geometrical factors for homogeneous half - space electrodes.
fuzeman/PyUPnP
pyupnp/lict.py
Lict._get_object_key
def _get_object_key(self, p_object): """Get key from object""" matched_key = None matched_index = None if hasattr(p_object, self._searchNames[0]): return getattr(p_object, self._searchNames[0]) for x in xrange(len(self._searchNames)): key = self._searchN...
python
def _get_object_key(self, p_object): """Get key from object""" matched_key = None matched_index = None if hasattr(p_object, self._searchNames[0]): return getattr(p_object, self._searchNames[0]) for x in xrange(len(self._searchNames)): key = self._searchN...
[ "def", "_get_object_key", "(", "self", ",", "p_object", ")", ":", "matched_key", "=", "None", "matched_index", "=", "None", "if", "hasattr", "(", "p_object", ",", "self", ".", "_searchNames", "[", "0", "]", ")", ":", "return", "getattr", "(", "p_object", ...
Get key from object
[ "Get", "key", "from", "object" ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L52-L72
train
Get key from object
fuzeman/PyUPnP
pyupnp/lict.py
Lict.extend
def extend(self, collection): """ L.extend(iterable) -- extend list by appending elements from the iterable """ if type(collection) is list: if self._col_dict is None and self._col_list is None: self._col_list = collection else: self._col_list += c...
python
def extend(self, collection): """ L.extend(iterable) -- extend list by appending elements from the iterable """ if type(collection) is list: if self._col_dict is None and self._col_list is None: self._col_list = collection else: self._col_list += c...
[ "def", "extend", "(", "self", ",", "collection", ")", ":", "if", "type", "(", "collection", ")", "is", "list", ":", "if", "self", ".", "_col_dict", "is", "None", "and", "self", ".", "_col_list", "is", "None", ":", "self", ".", "_col_list", "=", "coll...
L.extend(iterable) -- extend list by appending elements from the iterable
[ "L", ".", "extend", "(", "iterable", ")", "--", "extend", "list", "by", "appending", "elements", "from", "the", "iterable" ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L199-L215
train
extend the list by appending elements from the iterable
fuzeman/PyUPnP
pyupnp/lict.py
Lict.index
def index(self, value, start=None, stop=None): """ L.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present. """ if start is None: start = 0 if stop is None: stop = len(self._col_list)...
python
def index(self, value, start=None, stop=None): """ L.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present. """ if start is None: start = 0 if stop is None: stop = len(self._col_list)...
[ "def", "index", "(", "self", ",", "value", ",", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "if", "start", "is", "None", ":", "start", "=", "0", "if", "stop", "is", "None", ":", "stop", "=", "len", "(", "self", ".", "_col_list", "...
L.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present.
[ "L", ".", "index", "(", "value", "[", "start", "[", "stop", "]]", ")", "-", ">", "integer", "--", "return", "first", "index", "of", "value", ".", "Raises", "ValueError", "if", "the", "value", "is", "not", "present", "." ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L217-L226
train
L. index returns the index of value in the column in the log.
fuzeman/PyUPnP
pyupnp/lict.py
Lict.insert
def insert(self, index, p_object): """ L.insert(index, object) -- insert object before index """ key = self._get_object_key(p_object) if key in self._col_dict: raise KeyError() self._col_list.insert(index, p_object) self._col_dict[key] = p_object
python
def insert(self, index, p_object): """ L.insert(index, object) -- insert object before index """ key = self._get_object_key(p_object) if key in self._col_dict: raise KeyError() self._col_list.insert(index, p_object) self._col_dict[key] = p_object
[ "def", "insert", "(", "self", ",", "index", ",", "p_object", ")", ":", "key", "=", "self", ".", "_get_object_key", "(", "p_object", ")", "if", "key", "in", "self", ".", "_col_dict", ":", "raise", "KeyError", "(", ")", "self", ".", "_col_list", ".", "...
L.insert(index, object) -- insert object before index
[ "L", ".", "insert", "(", "index", "object", ")", "--", "insert", "object", "before", "index" ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L228-L234
train
L. insert object before index
fuzeman/PyUPnP
pyupnp/lict.py
Lict.pop
def pop(self, index=None): """ L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or index is out of range. """ if index is None: index = len(self._col_list) - 1 key = self._get_object_key(self._col_li...
python
def pop(self, index=None): """ L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or index is out of range. """ if index is None: index = len(self._col_list) - 1 key = self._get_object_key(self._col_li...
[ "def", "pop", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "len", "(", "self", ".", "_col_list", ")", "-", "1", "key", "=", "self", ".", "_get_object_key", "(", "self", ".", "_col_list", "[", "...
L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or index is out of range.
[ "L", ".", "pop", "(", "[", "index", "]", ")", "-", ">", "item", "--", "remove", "and", "return", "item", "at", "index", "(", "default", "last", ")", ".", "Raises", "IndexError", "if", "list", "is", "empty", "or", "index", "is", "out", "of", "range"...
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L236-L247
train
L. pop returns the item at the specified index. Raises IndexError if the list is empty.
fuzeman/PyUPnP
pyupnp/lict.py
Lict.remove
def remove(self, value): """ L.remove(value) -- remove first occurrence of value. Raises ValueError if the value is not present. """ self._col_list.remove(value) self._col_dict.pop(self._get_object_key(value))
python
def remove(self, value): """ L.remove(value) -- remove first occurrence of value. Raises ValueError if the value is not present. """ self._col_list.remove(value) self._col_dict.pop(self._get_object_key(value))
[ "def", "remove", "(", "self", ",", "value", ")", ":", "self", ".", "_col_list", ".", "remove", "(", "value", ")", "self", ".", "_col_dict", ".", "pop", "(", "self", ".", "_get_object_key", "(", "value", ")", ")" ]
L.remove(value) -- remove first occurrence of value. Raises ValueError if the value is not present.
[ "L", ".", "remove", "(", "value", ")", "--", "remove", "first", "occurrence", "of", "value", ".", "Raises", "ValueError", "if", "the", "value", "is", "not", "present", "." ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L249-L255
train
Removes the first occurrence of value from the list of entries in the column. Raises ValueError if the value is not present.
fuzeman/PyUPnP
pyupnp/lict.py
Lict.sort
def sort(self, cmp=None, key=None, reverse=False): """ L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 """ self._col_list.sort(cmp, key, reverse)
python
def sort(self, cmp=None, key=None, reverse=False): """ L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 """ self._col_list.sort(cmp, key, reverse)
[ "def", "sort", "(", "self", ",", "cmp", "=", "None", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "self", ".", "_col_list", ".", "sort", "(", "cmp", ",", "key", ",", "reverse", ")" ]
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1
[ "L", ".", "sort", "(", "cmp", "=", "None", "key", "=", "None", "reverse", "=", "False", ")", "--", "stable", "sort", "*", "IN", "PLACE", "*", ";", "cmp", "(", "x", "y", ")", "-", ">", "-", "1", "0", "1" ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L262-L267
train
sort - Sort the log entries in the log
fuzeman/PyUPnP
pyupnp/lict.py
Lict.popvalue
def popvalue(self, k, d=None): """ D.popvalue(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised """ if k not in self._col_dict: return d value = self._col_dict.pop(k)...
python
def popvalue(self, k, d=None): """ D.popvalue(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised """ if k not in self._col_dict: return d value = self._col_dict.pop(k)...
[ "def", "popvalue", "(", "self", ",", "k", ",", "d", "=", "None", ")", ":", "if", "k", "not", "in", "self", ".", "_col_dict", ":", "return", "d", "value", "=", "self", ".", "_col_dict", ".", "pop", "(", "k", ")", "self", ".", "_col_list", ".", "...
D.popvalue(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised
[ "D", ".", "popvalue", "(", "k", "[", "d", "]", ")", "-", ">", "v", "remove", "specified", "key", "and", "return", "the", "corresponding", "value", ".", "If", "key", "is", "not", "found", "d", "is", "returned", "if", "given", "otherwise", "KeyError", ...
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L316-L325
train
D. popvalue returns the corresponding value. If d is not given KeyError is raised.
fuzeman/PyUPnP
pyupnp/lict.py
Lict.popitem
def popitem(self): """ D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. """ key, value = self._col_dict.popitem() if value is not None: self._col_list.remove(value) return key, value
python
def popitem(self): """ D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. """ key, value = self._col_dict.popitem() if value is not None: self._col_list.remove(value) return key, value
[ "def", "popitem", "(", "self", ")", ":", "key", ",", "value", "=", "self", ".", "_col_dict", ".", "popitem", "(", ")", "if", "value", "is", "not", "None", ":", "self", ".", "_col_list", ".", "remove", "(", "value", ")", "return", "key", ",", "value...
D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
[ "D", ".", "popitem", "()", "-", ">", "(", "k", "v", ")", "remove", "and", "return", "some", "(", "key", "value", ")", "pair", "as", "a", "2", "-", "tuple", ";", "but", "raise", "KeyError", "if", "D", "is", "empty", "." ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L327-L335
train
D. popitem - remove and return some key - value pair as a 2 - tuple ; but raise KeyError if D is empty.
fuzeman/PyUPnP
pyupnp/lict.py
Lict.setdefault
def setdefault(self, k, d=None): """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """ if k not in self._col_dict: self._set_key(k, d) return self._col_dict.get(k)
python
def setdefault(self, k, d=None): """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """ if k not in self._col_dict: self._set_key(k, d) return self._col_dict.get(k)
[ "def", "setdefault", "(", "self", ",", "k", ",", "d", "=", "None", ")", ":", "if", "k", "not", "in", "self", ".", "_col_dict", ":", "self", ".", "_set_key", "(", "k", ",", "d", ")", "return", "self", ".", "_col_dict", ".", "get", "(", "k", ")" ...
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
[ "D", ".", "setdefault", "(", "k", "[", "d", "]", ")", "-", ">", "D", ".", "get", "(", "k", "d", ")", "also", "set", "D", "[", "k", "]", "=", "d", "if", "k", "not", "in", "D" ]
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L337-L341
train
set default value for the key k to d
fuzeman/PyUPnP
pyupnp/lict.py
Lict.update
def update(self, E=None, **F): """ D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followe...
python
def update(self, E=None, **F): """ D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followe...
[ "def", "update", "(", "self", ",", "E", "=", "None", ",", "*", "*", "F", ")", ":", "if", "hasattr", "(", "E", ",", "'keys'", ")", ":", "self", ".", "extend", "(", "E", ")", "else", ":", "for", "key", ",", "value", "in", "E", ":", "self", "....
D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
[ "D", ".", "update", "(", "[", "E", "]", "**", "F", ")", "-", ">", "None", ".", "Update", "D", "from", "dict", "/", "iterable", "E", "and", "F", ".", "If", "E", "present", "and", "has", "a", ".", "keys", "()", "method", "does", ":", "for", "k"...
6dea64be299952346a14300ab6cc7dac42736433
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L343-L355
train
Update the internal dictionary with the contents of E and F.
south-coast-science/scs_core
src/scs_core/gas/pid_temp_comp.py
PIDTempComp.correct
def correct(self, temp, we_t): """ Compute weC from weT """ if not PIDTempComp.in_range(temp): return None n_t = self.cf_t(temp) if n_t is None: return None we_c = we_t * n_t return we_c
python
def correct(self, temp, we_t): """ Compute weC from weT """ if not PIDTempComp.in_range(temp): return None n_t = self.cf_t(temp) if n_t is None: return None we_c = we_t * n_t return we_c
[ "def", "correct", "(", "self", ",", "temp", ",", "we_t", ")", ":", "if", "not", "PIDTempComp", ".", "in_range", "(", "temp", ")", ":", "return", "None", "n_t", "=", "self", ".", "cf_t", "(", "temp", ")", "if", "n_t", "is", "None", ":", "return", ...
Compute weC from weT
[ "Compute", "weC", "from", "weT" ]
a4152b0bbed6acbbf257e1bba6a912f6ebe578e5
https://github.com/south-coast-science/scs_core/blob/a4152b0bbed6acbbf257e1bba6a912f6ebe578e5/src/scs_core/gas/pid_temp_comp.py#L66-L80
train
Compute weC from weT and weT
geophysics-ubonn/reda
lib/reda/utils/norrec.py
average_repetitions
def average_repetitions(df, keys_mean): """average duplicate measurements. This requires that IDs and norrec labels were assigned using the *assign_norrec_to_df* function. Parameters ---------- df DataFrame keys_mean: list list of keys to average. For all other keys the first en...
python
def average_repetitions(df, keys_mean): """average duplicate measurements. This requires that IDs and norrec labels were assigned using the *assign_norrec_to_df* function. Parameters ---------- df DataFrame keys_mean: list list of keys to average. For all other keys the first en...
[ "def", "average_repetitions", "(", "df", ",", "keys_mean", ")", ":", "if", "'norrec'", "not", "in", "df", ".", "columns", ":", "raise", "Exception", "(", "'The \"norrec\" column is required for this function to work!'", ")", "# Get column order to restore later", "cols", ...
average duplicate measurements. This requires that IDs and norrec labels were assigned using the *assign_norrec_to_df* function. Parameters ---------- df DataFrame keys_mean: list list of keys to average. For all other keys the first entry will be used.
[ "average", "duplicate", "measurements", ".", "This", "requires", "that", "IDs", "and", "norrec", "labels", "were", "assigned", "using", "the", "*", "assign_norrec_to_df", "*", "function", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/norrec.py#L12-L45
train
average duplicate measurements over a single node
geophysics-ubonn/reda
lib/reda/utils/norrec.py
compute_norrec_differences
def compute_norrec_differences(df, keys_diff): """DO NOT USE ANY MORE - DEPRECIATED! """ raise Exception('This function is depreciated!') print('computing normal-reciprocal differences') # df.sort_index(level='norrec') def norrec_diff(x): """compute norrec_diff""" if x.shape[0]...
python
def compute_norrec_differences(df, keys_diff): """DO NOT USE ANY MORE - DEPRECIATED! """ raise Exception('This function is depreciated!') print('computing normal-reciprocal differences') # df.sort_index(level='norrec') def norrec_diff(x): """compute norrec_diff""" if x.shape[0]...
[ "def", "compute_norrec_differences", "(", "df", ",", "keys_diff", ")", ":", "raise", "Exception", "(", "'This function is depreciated!'", ")", "print", "(", "'computing normal-reciprocal differences'", ")", "# df.sort_index(level='norrec')", "def", "norrec_diff", "(", "x", ...
DO NOT USE ANY MORE - DEPRECIATED!
[ "DO", "NOT", "USE", "ANY", "MORE", "-", "DEPRECIATED!" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/norrec.py#L48-L75
train
compute the differences between the norrec and the normal - reciprocal differences
geophysics-ubonn/reda
lib/reda/utils/norrec.py
_normalize_abmn
def _normalize_abmn(abmn): """return a normalized version of abmn """ abmn_2d = np.atleast_2d(abmn) abmn_normalized = np.hstack(( np.sort(abmn_2d[:, 0:2], axis=1), np.sort(abmn_2d[:, 2:4], axis=1), )) return abmn_normalized
python
def _normalize_abmn(abmn): """return a normalized version of abmn """ abmn_2d = np.atleast_2d(abmn) abmn_normalized = np.hstack(( np.sort(abmn_2d[:, 0:2], axis=1), np.sort(abmn_2d[:, 2:4], axis=1), )) return abmn_normalized
[ "def", "_normalize_abmn", "(", "abmn", ")", ":", "abmn_2d", "=", "np", ".", "atleast_2d", "(", "abmn", ")", "abmn_normalized", "=", "np", ".", "hstack", "(", "(", "np", ".", "sort", "(", "abmn_2d", "[", ":", ",", "0", ":", "2", "]", ",", "axis", ...
return a normalized version of abmn
[ "return", "a", "normalized", "version", "of", "abmn" ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/norrec.py#L78-L86
train
return a normalized version of abmn
geophysics-ubonn/reda
lib/reda/utils/norrec.py
assign_norrec_to_df
def assign_norrec_to_df(df): """Determine normal-reciprocal pairs for a given dataframe. Parameters ---------- df: pandas.DataFrame The data Returns ------- df_new: pandas.DataFrame The data with two new columns: "id" and "norrec" """ if df.shape[0] == 0: #...
python
def assign_norrec_to_df(df): """Determine normal-reciprocal pairs for a given dataframe. Parameters ---------- df: pandas.DataFrame The data Returns ------- df_new: pandas.DataFrame The data with two new columns: "id" and "norrec" """ if df.shape[0] == 0: #...
[ "def", "assign_norrec_to_df", "(", "df", ")", ":", "if", "df", ".", "shape", "[", "0", "]", "==", "0", ":", "# empty dataframe, just return a copy", "return", "df", ".", "copy", "(", ")", "c", "=", "df", "[", "[", "'a'", ",", "'b'", ",", "'m'", ",", ...
Determine normal-reciprocal pairs for a given dataframe. Parameters ---------- df: pandas.DataFrame The data Returns ------- df_new: pandas.DataFrame The data with two new columns: "id" and "norrec"
[ "Determine", "normal", "-", "reciprocal", "pairs", "for", "a", "given", "dataframe", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/norrec.py#L89-L279
train
Assign the norrec to the current or current electrodes for a given dataframe.
geophysics-ubonn/reda
lib/reda/utils/norrec.py
assign_norrec_diffs
def assign_norrec_diffs(df, diff_list): """Compute and write the difference between normal and reciprocal values for all columns specified in the diff_list parameter. Note that the DataFrame is directly written to. That is, it is changed during the call of this function. No need to use the returned obj...
python
def assign_norrec_diffs(df, diff_list): """Compute and write the difference between normal and reciprocal values for all columns specified in the diff_list parameter. Note that the DataFrame is directly written to. That is, it is changed during the call of this function. No need to use the returned obj...
[ "def", "assign_norrec_diffs", "(", "df", ",", "diff_list", ")", ":", "extra_dims", "=", "[", "x", "for", "x", "in", "(", "'timestep'", ",", "'frequency'", ",", "'id'", ")", "if", "x", "in", "df", ".", "columns", "]", "g", "=", "df", ".", "groupby", ...
Compute and write the difference between normal and reciprocal values for all columns specified in the diff_list parameter. Note that the DataFrame is directly written to. That is, it is changed during the call of this function. No need to use the returned object. Parameters ---------- df: pan...
[ "Compute", "and", "write", "the", "difference", "between", "normal", "and", "reciprocal", "values", "for", "all", "columns", "specified", "in", "the", "diff_list", "parameter", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/norrec.py#L336-L378
train
Compute and write the difference between normal and reciprocal values for all columns specified in the diff_list parameter.
marazmiki/django-ulogin
django_ulogin/views.py
PostBackView.handle_authenticated_user
def handle_authenticated_user(self, response): """ Handles the ULogin response if user is already authenticated """ current_user = get_user(self.request) ulogin, registered = ULoginUser.objects.get_or_create( uid=response['uid'], network=response[...
python
def handle_authenticated_user(self, response): """ Handles the ULogin response if user is already authenticated """ current_user = get_user(self.request) ulogin, registered = ULoginUser.objects.get_or_create( uid=response['uid'], network=response[...
[ "def", "handle_authenticated_user", "(", "self", ",", "response", ")", ":", "current_user", "=", "get_user", "(", "self", ".", "request", ")", "ulogin", ",", "registered", "=", "ULoginUser", ".", "objects", ".", "get_or_create", "(", "uid", "=", "response", ...
Handles the ULogin response if user is already authenticated
[ "Handles", "the", "ULogin", "response", "if", "user", "is", "already", "authenticated" ]
f41ad4b4ca130ad8af25be72ad882c8cf94a80dc
https://github.com/marazmiki/django-ulogin/blob/f41ad4b4ca130ad8af25be72ad882c8cf94a80dc/django_ulogin/views.py#L82-L107
train
Handles the response from the ULogin API to the user API.
marazmiki/django-ulogin
django_ulogin/views.py
PostBackView.handle_anonymous_user
def handle_anonymous_user(self, response): """ Handles the ULogin response if user is not authenticated (anonymous) """ try: ulogin = ULoginUser.objects.get(network=response['network'], uid=response['uid']) except ULoginUser...
python
def handle_anonymous_user(self, response): """ Handles the ULogin response if user is not authenticated (anonymous) """ try: ulogin = ULoginUser.objects.get(network=response['network'], uid=response['uid']) except ULoginUser...
[ "def", "handle_anonymous_user", "(", "self", ",", "response", ")", ":", "try", ":", "ulogin", "=", "ULoginUser", ".", "objects", ".", "get", "(", "network", "=", "response", "[", "'network'", "]", ",", "uid", "=", "response", "[", "'uid'", "]", ")", "e...
Handles the ULogin response if user is not authenticated (anonymous)
[ "Handles", "the", "ULogin", "response", "if", "user", "is", "not", "authenticated", "(", "anonymous", ")" ]
f41ad4b4ca130ad8af25be72ad882c8cf94a80dc
https://github.com/marazmiki/django-ulogin/blob/f41ad4b4ca130ad8af25be72ad882c8cf94a80dc/django_ulogin/views.py#L109-L133
train
Handles the anonymous response from the ULogin server.
marazmiki/django-ulogin
django_ulogin/views.py
PostBackView.form_valid
def form_valid(self, form): """ The request from ulogin service is correct """ response = self.ulogin_response(form.cleaned_data['token'], self.request.get_host()) if 'error' in response: return render(self.request, self.error_...
python
def form_valid(self, form): """ The request from ulogin service is correct """ response = self.ulogin_response(form.cleaned_data['token'], self.request.get_host()) if 'error' in response: return render(self.request, self.error_...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "response", "=", "self", ".", "ulogin_response", "(", "form", ".", "cleaned_data", "[", "'token'", "]", ",", "self", ".", "request", ".", "get_host", "(", ")", ")", "if", "'error'", "in", "respon...
The request from ulogin service is correct
[ "The", "request", "from", "ulogin", "service", "is", "correct" ]
f41ad4b4ca130ad8af25be72ad882c8cf94a80dc
https://github.com/marazmiki/django-ulogin/blob/f41ad4b4ca130ad8af25be72ad882c8cf94a80dc/django_ulogin/views.py#L135-L159
train
Check if the request from ulogin service is correct
marazmiki/django-ulogin
django_ulogin/views.py
PostBackView.ulogin_response
def ulogin_response(self, token, host): """ Makes a request to ULOGIN """ response = requests.get( settings.TOKEN_URL, params={ 'token': token, 'host': host }) content = response.content if sys.version_i...
python
def ulogin_response(self, token, host): """ Makes a request to ULOGIN """ response = requests.get( settings.TOKEN_URL, params={ 'token': token, 'host': host }) content = response.content if sys.version_i...
[ "def", "ulogin_response", "(", "self", ",", "token", ",", "host", ")", ":", "response", "=", "requests", ".", "get", "(", "settings", ".", "TOKEN_URL", ",", "params", "=", "{", "'token'", ":", "token", ",", "'host'", ":", "host", "}", ")", "content", ...
Makes a request to ULOGIN
[ "Makes", "a", "request", "to", "ULOGIN" ]
f41ad4b4ca130ad8af25be72ad882c8cf94a80dc
https://github.com/marazmiki/django-ulogin/blob/f41ad4b4ca130ad8af25be72ad882c8cf94a80dc/django_ulogin/views.py#L167-L182
train
Makes a request to ULOGIN and returns the ULOGIN object