_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q248900
create_alarm
train
def create_alarm(panel_json, abode, area='1'): """Create a new alarm device from a panel response.""" panel_json['name'] = CONST.ALARM_NAME panel_json['id'] =
python
{ "resource": "" }
q248901
AbodeAlarm.set_mode
train
def set_mode(self, mode): """Set Abode alarm mode.""" if not mode: raise AbodeException(ERROR.MISSING_ALARM_MODE) elif mode.lower() not in CONST.ALL_MODES: raise AbodeException(ERROR.INVALID_ALARM_MODE, CONST.ALL_MODES) mode = mode.lower() response = sel...
python
{ "resource": "" }
q248902
AbodeAlarm.refresh
train
def refresh(self, url=CONST.PANEL_URL): """Refresh the alarm device.""" response_object = AbodeDevice.refresh(self, url) # pylint: disable=W0212
python
{ "resource": "" }
q248903
AbodeAlarm.mode
train
def mode(self): """Get alarm mode.""" mode
python
{ "resource": "" }
q248904
update
train
def update(dct, dct_merge): """Recursively merge dicts.""" for key, value in dct_merge.items(): if key in dct and isinstance(dct[key], dict):
python
{ "resource": "" }
q248905
RBDConnector.check_valid_device
train
def check_valid_device(self, path, run_as_root=True): """Verify an existing RBD handle is connected and valid.""" if self.im_root: try: with open(path, 'r') as f: f.read(4096) except Exception: return False return Tr...
python
{ "resource": "" }
q248906
setup
train
def setup(config): """Setup persistence to be used in cinderlib. By default memory persistance will be used, but there are other mechanisms available and other ways to use custom mechanisms: - Persistence plugins: Plugin mechanism uses Python entrypoints under namespace cinderlib.persistence.sto...
python
{ "resource": "" }
q248907
Backend._transform_legacy_stats
train
def _transform_legacy_stats(self, stats): """Convert legacy stats to new stats with pools key.""" # Fill pools for legacy driver reports if stats and 'pools' not in stats: pool = stats.copy() pool['pool_name'] = self.id for key in ('driver_version', 'shared_ta...
python
{ "resource": "" }
q248908
Backend._config_parse
train
def _config_parse(self): """Replacer oslo_config.cfg.ConfigParser.parse for in-memory cfg."""
python
{ "resource": "" }
q248909
Backend._update_cinder_config
train
def _update_cinder_config(cls): """Parse in-memory file to update OSLO configuration used by Cinder.""" cls._config_string_io.seek(0) cls._parser.write(cls._config_string_io) # Check if we have any multiopt cls._config_string_io.seek(0) current_cfg = cls._config_string_i...
python
{ "resource": "" }
q248910
Backend._set_cinder_config
train
def _set_cinder_config(cls, host, locks_path, cinder_config_params): """Setup the parser with all the known Cinder configuration.""" cfg.CONF.set_default('state_path', os.getcwd()) cfg.CONF.set_default('lock_path', '$state_path', 'oslo_concurrency') cls._parser = six.moves.configparser....
python
{ "resource": "" }
q248911
Backend.list_supported_drivers
train
def list_supported_drivers(): """Returns dictionary with driver classes names as keys.""" def convert_oslo_config(oslo_options): options = [] for opt in oslo_options: tmp_dict = {k: str(v) for k, v in vars(opt).items() if not k.startsw...
python
{ "resource": "" }
q248912
load
train
def load(json_src, save=False): """Load any json serialized cinderlib object.""" if isinstance(json_src, six.string_types): json_src = json_lib.loads(json_src) if isinstance(json_src, list): return [getattr(objects,
python
{ "resource": "" }
q248913
memoize
train
def memoize(func): """ Cache decorator for functions inside model classes """ def model(cls, energy, *args, **kwargs): try: memoize = cls._memoize cache = cls._cache queue = cls._queue except AttributeError: memoize = False if memoize: ...
python
{ "resource": "" }
q248914
lnprior
train
def lnprior(pars): """ Return probability of parameter values according to prior knowledge. Parameter limits should be done here through uniform prior ditributions
python
{ "resource": "" }
q248915
normal_prior
train
def normal_prior(value, mean, sigma): """Normal prior distribution.
python
{ "resource": "" }
q248916
log_uniform_prior
train
def log_uniform_prior(value, umin=0, umax=None): """Log-uniform prior distribution. """ if value > 0 and value >= umin: if umax is not None: if value <= umax:
python
{ "resource": "" }
q248917
run_sampler
train
def run_sampler(nrun=100, sampler=None, pos=None, **kwargs): """Run an MCMC sampler. If no sampler or initial position vector is provided, extra ``kwargs`` are passed to `get_sampler` to generate a new sampler. Parameters ---------- nrun : int, optional Number of steps to run sampl...
python
{ "resource": "" }
q248918
XMLWriter._fact_to_tuple
train
def _fact_to_tuple(self, fact): """ Convert a ``Fact`` to its normalized tuple. This is where all type conversion for ``Fact`` attributes to strings as well as any normalization happens. Note: Because different writers may require different types, we need to ...
python
{ "resource": "" }
q248919
XMLWriter._write_fact
train
def _write_fact(self, fact_tuple): """ Create new fact element and populate attributes. Once the child is prepared append it to ``fact_list``. """ fact = self.document.createElement("fact") fact.setAttribute('start', fact_tuple.start) fact.setAttribute('end', fac...
python
{ "resource": "" }
q248920
XMLWriter._close
train
def _close(self): """ Append the xml fact list to the main document write file and cleanup. ``toxml`` should take care of encoding everything with UTF-8. """
python
{ "resource": "" }
q248921
execute_sql
train
def execute_sql(server_context, schema_name, sql, container_path=None, max_rows=None, sort=None, offset=None, container_filter=None, save_in_session=None, parameters=None, required_version=None, ...
python
{ "resource": "" }
q248922
update_rows
train
def update_rows(server_context, schema_name, query_name, rows, container_path=None, timeout=_default_timeout): """ Update a set of rows :param server_context: A LabKey server context. See utils.create_server_context. :param schema_name: schema of table :param query_name: table name to update :p...
python
{ "resource": "" }
q248923
get_day_end
train
def get_day_end(config): """ Get the day end time given the day start. This assumes full 24h day. Args: config (dict): Configdict. Needed to extract ``day_start``. Note: This is merely a convinience funtion so we do not have to deduct this from ``day_start`` by hand all the tim...
python
{ "resource": "" }
q248924
end_day_to_datetime
train
def end_day_to_datetime(end_day, config): """ Convert a given end day to its proper datetime. This is non trivial because of variable ``day_start``. We want to make sure that even if an 'end day' is specified the actual point in time may reach into the following day. Args: end (datetim...
python
{ "resource": "" }
q248925
complete_timeframe
train
def complete_timeframe(timeframe, config, partial=False): """ Apply fallback strategy to incomplete timeframes. Our fallback strategy is as follows: * Missing start-date: Fallback to ``today``. * Missing start-time: Fallback to ``store.config['day_start']``. * Missing end-date: Fall...
python
{ "resource": "" }
q248926
validate_start_end_range
train
def validate_start_end_range(range_tuple): """ Perform basic sanity checks on a timeframe. Args: range_tuple (tuple): ``(start, end)`` tuple as returned by ``complete_timeframe``. Raises: ValueError: If start > end. Returns: tuple: ``(start, end)`` tuple that p...
python
{ "resource": "" }
q248927
validate_data_table
train
def validate_data_table(data_table, sed=None): """ Validate all columns of a data table. If a list of tables is passed, all tables will be validated and then concatenated Parameters ---------- data_table : `astropy.table.Table` or list of `astropy.table.Table`. sed : bool, optional ...
python
{ "resource": "" }
q248928
sed_conversion
train
def sed_conversion(energy, model_unit, sed): """ Manage conversion between differential spectrum and SED """ model_pt = model_unit.physical_type ones = np.ones(energy.shape) if sed: # SED f_unit = u.Unit("erg/s") if model_pt == "power" or model_pt == "flux" or model_pt...
python
{ "resource": "" }
q248929
trapz_loglog
train
def trapz_loglog(y, x, axis=-1, intervals=False): """ Integrate along the given axis using the composite trapezoidal rule in loglog space. Integrate `y` (`x`) along given axis in loglog space. Parameters ---------- y : array_like Input array to integrate. x : array_like, option...
python
{ "resource": "" }
q248930
_generate_energy_edges_single
train
def _generate_energy_edges_single(ene): """Generate energy edges for single group""" midene = np.sqrt((ene[1:] * ene[:-1])) elo, ehi = np.zeros(len(ene)) * ene.unit, np.zeros(len(ene)) * ene.unit elo[1:] = ene[1:] - midene
python
{ "resource": "" }
q248931
generate_energy_edges
train
def generate_energy_edges(ene, groups=None): """Generate energy bin edges from given energy array. Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided. Parameters ---------- ene : `astropy.un...
python
{ "resource": "" }
q248932
build_data_table
train
def build_data_table( energy, flux, flux_error=None, flux_error_lo=None, flux_error_hi=None, energy_width=None, energy_lo=None, energy_hi=None, ul=None, cl=None, ): """ Read data into data dict. Parameters ---------- energy : :class:`~astropy.units.Quantity`...
python
{ "resource": "" }
q248933
estimate_B
train
def estimate_B( xray_table, vhe_table, photon_energy_density=0.261 * u.eV / u.cm ** 3 ): """ Estimate magnetic field from synchrotron to Inverse Compton luminosity ratio Estimate the magnetic field from the ratio of X-ray to gamma-ray emission according to: .. math:: \\frac{L_\mathrm{...
python
{ "resource": "" }
q248934
_initializer_wrapper
train
def _initializer_wrapper(actual_initializer, *rest): """ We ignore SIGINT. It's up to our parent to kill us in the typical condition of this arising from ``^C`` on a terminal. If someone is manually killing us with that signal, well...
python
{ "resource": "" }
q248935
PowerLaw.eval
train
def eval(e, amplitude, e_0, alpha): """One dimensional power
python
{ "resource": "" }
q248936
ExponentialCutoffPowerLaw.eval
train
def eval(e, amplitude, e_0, alpha, e_cutoff, beta): """One dimensional power law with an exponential cutoff
python
{ "resource": "" }
q248937
LogParabola.eval
train
def eval(e, amplitude, e_0, alpha, beta): """One dimenional log parabola model function""" ee = e / e_0
python
{ "resource": "" }
q248938
BaseRadiative.flux
train
def flux(self, photon_energy, distance=1 * u.kpc): """Differential flux at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float,...
python
{ "resource": "" }
q248939
BaseRadiative.sed
train
def sed(self, photon_energy, distance=1 * u.kpc): """Spectral energy distribution at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quanti...
python
{ "resource": "" }
q248940
BaseElectron._gam
train
def _gam(self): """ Lorentz factor array """ log10gmin = np.log10(self.Eemin / mec2).value log10gmax = np.log10(self.Eemax / mec2).value
python
{ "resource": "" }
q248941
BaseElectron._nelec
train
def _nelec(self): """ Particles per unit lorentz factor """
python
{ "resource": "" }
q248942
BaseElectron.We
train
def We(self): """ Total energy in electrons used for the radiative calculation """
python
{ "resource": "" }
q248943
BaseElectron.compute_We
train
def compute_We(self, Eemin=None, Eemax=None): """ Total energy in electrons between energies Eemin and Eemax Parameters ---------- Eemin : :class:`~astropy.units.Quantity` float, optional Minimum electron energy for energy content calculation. Eemax : :class:`~astro...
python
{ "resource": "" }
q248944
BaseElectron.set_We
train
def set_We(self, We, Eemin=None, Eemax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in electrons between Eemin and Eemax is We Parameters ---------- We : :class:`~astropy.units.Quantity` float Desired energy in electrons. ...
python
{ "resource": "" }
q248945
Synchrotron._spectrum
train
def _spectrum(self, photon_energy): """Compute intrinsic synchrotron differential spectrum for energies in ``photon_energy`` Compute synchrotron for random magnetic field according to approximation of Aharonian, Kelner, and Prosekin 2010, PhysRev D 82, 3002 (`arXiv:1006.1045 <ht...
python
{ "resource": "" }
q248946
InverseCompton._spectrum
train
def _spectrum(self, photon_energy): """Compute differential IC spectrum for energies in ``photon_energy``. Compute IC spectrum using IC cross-section for isotropic interaction with a blackbody photon spectrum following Khangulyan, Aharonian, and Kelner 2014, ApJ 783, 100 (`arXiv:1310.79...
python
{ "resource": "" }
q248947
InverseCompton.flux
train
def flux(self, photon_energy, distance=1 * u.kpc, seed=None): """Differential flux at a given distance from the source from a single seed photon field Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. ...
python
{ "resource": "" }
q248948
InverseCompton.sed
train
def sed(self, photon_energy, distance=1 * u.kpc, seed=None): """Spectral energy distribution at a given distance from the source Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.un...
python
{ "resource": "" }
q248949
Bremsstrahlung._emiss_ee
train
def _emiss_ee(self, Eph): """ Electron-electron bremsstrahlung emissivity per unit photon energy """ if self.weight_ee == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) # compute integral with electron distribution emiss =
python
{ "resource": "" }
q248950
Bremsstrahlung._emiss_ep
train
def _emiss_ep(self, Eph): """ Electron-proton bremsstrahlung emissivity per unit photon energy """ if self.weight_ep == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) eps = (Eph / mec2).decompose().value # compute integral with electron dis...
python
{ "resource": "" }
q248951
Bremsstrahlung._spectrum
train
def _spectrum(self, photon_energy): """Compute differential bremsstrahlung spectrum for energies in ``photon_energy``. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` instance Photon energy array. """
python
{ "resource": "" }
q248952
BaseProton._Ep
train
def _Ep(self): """ Proton energy array in GeV """ return np.logspace( np.log10(self.Epmin.to("GeV").value),
python
{ "resource": "" }
q248953
BaseProton._J
train
def _J(self): """ Particles per unit proton energy in particles per GeV """
python
{ "resource": "" }
q248954
BaseProton.Wp
train
def Wp(self): """Total energy in protons """ Wp
python
{ "resource": "" }
q248955
BaseProton.compute_Wp
train
def compute_Wp(self, Epmin=None, Epmax=None): """ Total energy in protons between energies Epmin and Epmax Parameters ---------- Epmin : :class:`~astropy.units.Quantity` float, optional Minimum proton energy for energy content calculation. Epmax : :class:`~astropy.u...
python
{ "resource": "" }
q248956
BaseProton.set_Wp
train
def set_Wp(self, Wp, Epmin=None, Epmax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in protons between Epmin and Epmax is Wp Parameters ---------- Wp : :class:`~astropy.units.Quantity` float Desired energy in protons. ...
python
{ "resource": "" }
q248957
PionDecay._sigma_inel
train
def _sigma_inel(self, Tp): """ Inelastic cross-section for p-p interaction. KATV14 Eq. 1 Parameters ---------- Tp : float Kinetic energy of proton (i.e. Ep - m_p*c**2) [GeV]
python
{ "resource": "" }
q248958
PionDecay._sigma_pi_loE
train
def _sigma_pi_loE(self, Tp): """ inclusive cross section for Tth < Tp < 2 GeV Fit from experimental data """ m_p = self._m_p m_pi = self._m_pi Mres = 1.1883 # GeV Gres = 0.2264 # GeV s = 2 * m_p * (Tp + 2 * m_p) # center of mass energy g...
python
{ "resource": "" }
q248959
PionDecay._sigma_pi_midE
train
def _sigma_pi_midE(self, Tp): """ Geant 4.10.0 model for 2 GeV < Tp < 5 GeV """
python
{ "resource": "" }
q248960
PionDecay._diffsigma
train
def _diffsigma(self, Ep, Egamma): """ Differential cross section dsigma/dEg = Amax(Tp) * F(Tp,Egamma) """ Tp = Ep - self._m_p diffsigma = self._Amax(Tp) * self._F(Tp, Egamma)
python
{ "resource": "" }
q248961
PionDecay._nuclear_factor
train
def _nuclear_factor(self, Tp): """ Compute nuclear enhancement factor """ sigmaRpp = 10 * np.pi * 1e-27 sigmainel = self._sigma_inel(Tp) sigmainel0 = self._sigma_inel(1e3) # at 1e3 GeV f = sigmainel / sigmainel0 f2 = np.where(f > 1, f, 1.0) G = 1....
python
{ "resource": "" }
q248962
PionDecayKelner06._Fgamma
train
def _Fgamma(self, x, Ep): """ KAB06 Eq.58 Note: Quantities are not used in this function Parameters ---------- x : float Egamma/Eprot Ep : float Eprot [TeV] """ L = np.log(Ep) B = 1.30 + 0.14 * L + 0.011 * L ** 2 ...
python
{ "resource": "" }
q248963
PionDecayKelner06._sigma_inel
train
def _sigma_inel(self, Ep): """ Inelastic cross-section for p-p interaction. KAB06 Eq. 73, 79 Note: Quantities are not used in this function Parameters ---------- Ep : float Eprot [TeV] Returns ------- sigma_inel : float I...
python
{ "resource": "" }
q248964
PionDecayKelner06._photon_integrand
train
def _photon_integrand(self, x, Egamma): """ Integrand of Eq. 72 """ try: return ( self._sigma_inel(Egamma / x) * self._particle_distribution((Egamma / x))
python
{ "resource": "" }
q248965
PionDecayKelner06._calc_specpp_hiE
train
def _calc_specpp_hiE(self, Egamma): """ Spectrum computed as in Eq. 42 for Egamma >= 0.1 TeV """ # Fixed quad with n=40 is about 15 times faster and is always within # 0.5% of the result of adaptive quad for Egamma>0.1 # WARNING: It also produces artifacts for steep distr...
python
{ "resource": "" }
q248966
PionDecayKelner06._calc_specpp_loE
train
def _calc_specpp_loE(self, Egamma): """ Delta-functional approximation for low energies Egamma < 0.1 TeV """ from scipy.integrate import quad Egamma = Egamma.to("TeV").value
python
{ "resource": "" }
q248967
get_config_path
train
def get_config_path(appdirs=DEFAULT_APPDIRS, file_name=DEFAULT_CONFIG_FILENAME): """ Return the path where the config file is stored. Args: app_name (text_type, optional): Name of the application, defaults to ``'projecthamster``. Allows you to use your own application specific names...
python
{ "resource": "" }
q248968
write_config_file
train
def write_config_file(config_instance, appdirs=DEFAULT_APPDIRS, file_name=DEFAULT_CONFIG_FILENAME): """ Write a ConfigParser instance to file at the correct location. Args: config_instance: Config instance to safe to file. appdirs (HamsterAppDirs, optional): ``HamsterAppDirs`` insta...
python
{ "resource": "" }
q248969
load_config_file
train
def load_config_file(appdirs=DEFAULT_APPDIRS, file_name=DEFAULT_CONFIG_FILENAME, fallback_config_instance=None): """ Retrieve config information from file at default location. If no config file is found a new one will be created either with ``fallback_config_instance`` as content or if none is ...
python
{ "resource": "" }
q248970
get_default_backend_config
train
def get_default_backend_config(appdirs): """ Return a default config dictionary. Args: appdirs (HamsterAppDirs): ``HamsterAppDirs`` instance encapsulating the apps details. Returns: dict: Dictionary with a default configuration. Note: Those defaults are independent of the ...
python
{ "resource": "" }
q248971
backend_config_to_configparser
train
def backend_config_to_configparser(config): """ Return a ConfigParser instance representing a given backend config dictionary. Args: config (dict): Dictionary of config key/value pairs. Returns: SafeConfigParser: SafeConfigParser instance representing config. Note: We do n...
python
{ "resource": "" }
q248972
configparser_to_backend_config
train
def configparser_to_backend_config(cp_instance): """ Return a config dict generated from a configparser instance. This functions main purpose is to ensure config dict values are properly typed. Note: This can be used with any ``ConfigParser`` backend instance not just the default one i...
python
{ "resource": "" }
q248973
HamsterAppDirs.user_data_dir
train
def user_data_dir(self): """Return ``user_data_dir``.""" directory = appdirs.user_data_dir(self.appname, self.appauthor, version=self.version, roaming=self.roaming)
python
{ "resource": "" }
q248974
HamsterAppDirs.site_config_dir
train
def site_config_dir(self): """Return ``site_config_dir``.""" directory = appdirs.site_config_dir(self.appname, self.appauthor, version=self.version, multipath=self.multipath)
python
{ "resource": "" }
q248975
HamsterAppDirs.user_cache_dir
train
def user_cache_dir(self): """Return ``user_cache_dir``.""" directory = appdirs.user_cache_dir(self.appname, self.appauthor, version=self.version)
python
{ "resource": "" }
q248976
HamsterAppDirs._ensure_directory_exists
train
def _ensure_directory_exists(self, directory): """Ensure that the passed path exists."""
python
{ "resource": "" }
q248977
_load_tmp_fact
train
def _load_tmp_fact(filepath): """ Load an 'ongoing fact' from a given location. Args: filepath: Full path to the tmpfile location. Returns: hamster_lib.Fact: ``Fact`` representing the 'ongoing fact'. Returns ``False`` if no file was found. Raises: TypeError: If...
python
{ "resource": "" }
q248978
parse_raw_fact
train
def parse_raw_fact(raw_fact): """ Extract semantically meaningful sub-components from a ``raw fact`` text. Args: raw_fact (text_type): ``raw fact`` text to be parsed. Returns: dict: dict with sub-components as values. """ def at_split(string): """ Return everyth...
python
{ "resource": "" }
q248979
read_run
train
def read_run(filename, modelfn=None): """ Read chain from a hdf5 saved with `save_run`. This function will also read the labels, data table, and metadata blobs stored in the original sampler. If you want to use the result object with `plot_fit` and setting the ``e_range`` parameter, you must provid...
python
{ "resource": "" }
q248980
ElectronIC
train
def ElectronIC(pars, data): """ Define particle distribution model, radiative model, and return model flux at data energy values """ ECPL = ExponentialCutoffPowerLaw( pars[0] /
python
{ "resource": "" }
q248981
SherpaModelECPL._pdist
train
def _pdist(p): """ Return PL or ECPL instance based on parameters p """ index, ref, ampl, cutoff, beta = p[:5] if cutoff == 0.0: pdist = models.PowerLaw( ampl * 1e30 * u.Unit("1/eV"), ref
python
{ "resource": "" }
q248982
plot_chain
train
def plot_chain(sampler, p=None, **kwargs): """Generate a diagnostic plot of the sampler chains. Parameters ---------- sampler : `emcee.EnsembleSampler` Sampler containing the chains to be plotted. p : int (optional) Index of the parameter to plot. If omitted, all chains are plotted....
python
{ "resource": "" }
q248983
_read_or_calc_samples
train
def _read_or_calc_samples( sampler, modelidx=0, n_samples=100, last_step=False, e_range=None, e_npoints=100, threads=None, ): """Get samples from blob or compute them from chain and sampler.modelfn """ if not e_range: # return the results saved in blobs modelx, m...
python
{ "resource": "" }
q248984
_calc_ML
train
def _calc_ML(sampler, modelidx=0, e_range=None, e_npoints=100): """Get ML model from blob or compute them from chain and sampler.modelfn """ ML, MLp, MLerr, ML_model = find_ML(sampler, modelidx) if e_range is not None: # prepare bogus data for calculation e_range = validate_array( ...
python
{ "resource": "" }
q248985
_plot_MLmodel
train
def _plot_MLmodel(ax, sampler, modelidx, e_range, e_npoints, e_unit, sed): """compute and plot ML model""" ML, MLp, MLerr, ML_model = _calc_ML( sampler, modelidx, e_range=e_range, e_npoints=e_npoints ) f_unit, sedf = sed_conversion(ML_model[0], ML_model[1].unit, sed)
python
{ "resource": "" }
q248986
plot_CI
train
def plot_CI( ax, sampler, modelidx=0, sed=True, confs=[3, 1, 0.5], e_unit=u.eV, label=None, e_range=None, e_npoints=100, threads=None, last_step=False, ): """Plot confidence interval. Parameters ---------- ax : `matplotlib.Axes` Axes to plot on. s...
python
{ "resource": "" }
q248987
plot_samples
train
def plot_samples( ax, sampler, modelidx=0, sed=True, n_samples=100, e_unit=u.eV, e_range=None, e_npoints=100, threads=None, label=None, last_step=False, ): """Plot a number of samples from the sampler chain. Parameters ---------- ax : `matplotlib.Axes` ...
python
{ "resource": "" }
q248988
find_ML
train
def find_ML(sampler, modelidx): """ Find Maximum Likelihood parameters as those in the chain with a highest log probability. """ index = np.unravel_index( np.argmax(sampler.lnprobability), sampler.lnprobability.shape ) MLp = sampler.chain[index] if modelidx is not None and hasatt...
python
{ "resource": "" }
q248989
plot_blob
train
def plot_blob( sampler, blobidx=0, label=None, last_step=False, figure=None, **kwargs ): """ Plot a metadata blob as a fit to spectral data or value distribution Additional ``kwargs`` are passed to `plot_fit`. Parameters ---------- sampler : `emcee.EnsembleSampler` Sampler with a s...
python
{ "resource": "" }
q248990
_plot_ulims
train
def _plot_ulims( ax, x, y, xerr, color, capsize=5, height_fraction=0.25, elinewidth=2 ): """ Plot upper limits as arrows with cap at value of upper limit. uplim behaviour has been fixed in matplotlib 1.4 """ ax.errorbar( x, y, xerr=xerr, ls="", color=color, elinewidth=elinewidth, capsiz...
python
{ "resource": "" }
q248991
plot_data
train
def plot_data( input_data, xlabel=None, ylabel=None, sed=True, figure=None, e_unit=None, ulim_opts={}, errorbar_opts={}, ): """ Plot spectral data. Parameters ---------- input_data : `emcee.EnsembleSampler`, `astropy.table.Table`, or `dict` Spectral data to p...
python
{ "resource": "" }
q248992
plot_distribution
train
def plot_distribution(samples, label, figure=None): """ Plot a distribution and print statistics about it""" from scipy import stats import matplotlib.pyplot as plt quant = [16, 50, 84] quantiles = dict(six.moves.zip(quant, np.percentile(samples, quant))) std = np.std(samples) if isinstan...
python
{ "resource": "" }
q248993
plot_corner
train
def plot_corner(sampler, show_ML=True, **kwargs): """ A plot that summarizes the parameter samples by showing them as individual histograms and 2D histograms against each other. The maximum likelihood parameter vector is indicated by a cross. This function is a thin wrapper around `corner.corner`, ...
python
{ "resource": "" }
q248994
NNForwardModel.predict_given_context
train
def predict_given_context(self, x, c, c_dims): """Provide a prediction of x with context c on dimensions c_dims in the output space being S - c_dims @param x an array of float of length dim_x @return predicted y as np.array of float """
python
{ "resource": "" }
q248995
DMPs_rhythmic.gen_front_term
train
def gen_front_term(self, x, dmp_num): """Generates the front term on the forcing term. For rhythmic DMPs it's non-diminishing, so this function is just a placeholder to return 1. x float: the current value of the canonical system dmp_num int: the index
python
{ "resource": "" }
q248996
LWLRForwardModel.predict_y
train
def predict_y(self, xq, sigma=None, k=None): """Provide a prediction of xq in the output space @param xq an array of float of length dim_x @param estimated_sigma if False (default), sigma_sq=self.sigma_sq, else it is estimated from the neighbor distances in self._weights(.) """ ...
python
{ "resource": "" }
q248997
LWLRForwardModel.predict_dims
train
def predict_dims(self, q, dims_x, dims_y, dims_out, sigma=None, k=None): """Provide a prediction of q in the output space @param xq an array of float of length dim_x @param estimated_sigma if False (default), sigma_sq=self.sigma_sq, else it is estimated from the neighbor distances in self._we...
python
{ "resource": "" }
q248998
ExperimentLog.scatter_plot
train
def scatter_plot(self, ax, topic_dims, t=None, ms_limits=True, **kwargs_plot): """ 2D or 3D scatter plot. :param axes ax: matplotlib axes (use Axes3D if 3D data) :param tuple topic_dims: list of (topic, dims) tuples, where topic is a string and dims is a list of dimensions to be plotte...
python
{ "resource": "" }
q248999
Tree.get_nodes
train
def get_nodes(self): """ Get the list of all nodes. """
python
{ "resource": "" }