hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
eval_dispersion_mapping
<not_specific>
def eval_dispersion_mapping(self, XZ, samples, neuron): """ Posterior predictive mean of the dispersion model. """ disp, disp_var = self.dispersion_mapping.compute_F(XZ) dh = self.mc_gen(disp, disp_var, samples, neuron) return self.dispersion_mapping.f(dh).mean(0)
Posterior predictive mean of the dispersion model.
Posterior predictive mean of the dispersion model.
[ "Posterior", "predictive", "mean", "of", "the", "dispersion", "model", "." ]
def eval_dispersion_mapping(self, XZ, samples, neuron): disp, disp_var = self.dispersion_mapping.compute_F(XZ) dh = self.mc_gen(disp, disp_var, samples, neuron) return self.dispersion_mapping.f(dh).mean(0)
[ "def", "eval_dispersion_mapping", "(", "self", ",", "XZ", ",", "samples", ",", "neuron", ")", ":", "disp", ",", "disp_var", "=", "self", ".", "dispersion_mapping", ".", "compute_F", "(", "XZ", ")", "dh", "=", "self", ".", "mc_gen", "(", "disp", ",", "d...
Posterior predictive mean of the dispersion model.
[ "Posterior", "predictive", "mean", "of", "the", "dispersion", "model", "." ]
[ "\"\"\"\n Posterior predictive mean of the dispersion model.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "XZ", "type": null }, { "param": "samples", "type": null }, { "param": "neuron", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "XZ", "type": null, "docstring": null, "docstring_tokens": [],...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): """ Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the lik...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the likelihood samples. This is all combin...
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): if mode == 'MC': h = self.mc_gen(F_mu, F_var, samples, neuron) rates, l_rates, spikes = self.sample_helper(h, b, neuron, samples) ws = torch.tensor(1./rates.shape[0]) elif mode == 'GH': ...
[ "def", "objective", "(", "self", ",", "F_mu", ",", "F_var", ",", "XZ", ",", "b", ",", "neuron", ",", "samples", "=", "10", ",", "mode", "=", "'MC'", ")", ":", "if", "mode", "==", "'MC'", ":", "h", "=", "self", ".", "mc_gen", "(", "F_mu", ",", ...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives.
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
[ "\"\"\"\n Computes the terms for variational expectation :math:`\\mathbb{E}_{q(f)q(z)}[]`, which \n can be used to compute different likelihood objectives.\n The returned tensor will have sample dimension as MC over :math:`q(z)`, depending \n on the evaluation mode will be MC or GH or ex...
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "F_var", "type": null }, { "param": "XZ", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type"...
{ "returns": [ { "docstring": "negative likelihood term of shape (samples, timesteps), sample weights (samples, 1", "docstring_tokens": [ "negative", "likelihood", "term", "of", "shape", "(", "samples", "timesteps", ")", "...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
rate_rescale
<not_specific>
def rate_rescale(self, neuron, spike_ind, rates, duplicate, minimum=1e-8): """ Rate rescaling with option to dequantize, which will be random per sample. :param torch.tensor rates: input rates of shape (trials, neurons, timesteps) :returns: list of rescaled ISIs, list index over...
Rate rescaling with option to dequantize, which will be random per sample. :param torch.tensor rates: input rates of shape (trials, neurons, timesteps) :returns: list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs) :rtype: list
Rate rescaling with option to dequantize, which will be random per sample.
[ "Rate", "rescaling", "with", "option", "to", "dequantize", "which", "will", "be", "random", "per", "sample", "." ]
def rate_rescale(self, neuron, spike_ind, rates, duplicate, minimum=1e-8): rtime = torch.cumsum(rates, dim=-1)*self.tbin samples = rtime.shape[0] rISI = [] for tr in range(self.trials): isis = [] for en, n in enumerate(neuron): if len(spike_ind[tr]...
[ "def", "rate_rescale", "(", "self", ",", "neuron", ",", "spike_ind", ",", "rates", ",", "duplicate", ",", "minimum", "=", "1e-8", ")", ":", "rtime", "=", "torch", ".", "cumsum", "(", "rates", ",", "dim", "=", "-", "1", ")", "*", "self", ".", "tbin"...
Rate rescaling with option to dequantize, which will be random per sample.
[ "Rate", "rescaling", "with", "option", "to", "dequantize", "which", "will", "be", "random", "per", "sample", "." ]
[ "\"\"\"\n Rate rescaling with option to dequantize, which will be random per sample.\n \n :param torch.tensor rates: input rates of shape (trials, neurons, timesteps)\n :returns: list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)\n :rtype: list\n ...
[ { "param": "self", "type": null }, { "param": "neuron", "type": null }, { "param": "spike_ind", "type": null }, { "param": "rates", "type": null }, { "param": "duplicate", "type": null }, { "param": "minimum", "type": null } ]
{ "returns": [ { "docstring": "list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)", "docstring_tokens": [ "list", "of", "rescaled", "ISIs", "list", "index", "over", "neurons", "elements", "of"...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Sample spike trains from the modulated renewal process. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array """ ...
Sample spike trains from the modulated renewal process. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array
Sample spike trains from the modulated renewal process.
[ "Sample", "spike", "trains", "from", "the", "modulated", "renewal", "process", "." ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) spiketimes = point_process.gen_IRP(self.ISI_dist(neuron), rate[:, neuron, :], self.tbin.item()) tr_t_spike = [] for sp in spiketimes: tr_t_spike.append(self.ind_to_train(torch.tensor(sp), rat...
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "spiketimes", "=", "point_process", ".", "gen_IRP", "(", "self", ".", "ISI_dist...
Sample spike trains from the modulated renewal process.
[ "Sample", "spike", "trains", "from", "the", "modulated", "renewal", "process", "." ]
[ "\"\"\"\n Sample spike trains from the modulated renewal process.\n \n :param numpy.array rate: input rate of shape (trials, neuron, timestep)\n :returns: spike train of shape (trials, neuron, timesteps)\n :rtype: np.array\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [ { "docstring": "spike train of shape (trials, neuron, timesteps)", "docstring_tokens": [ "spike", "train", "of", "shape", "(", "trials", "neuron", "timesteps", ")" ], "type": "np.array" } ], "rai...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
onehot_to_counts
<not_specific>
def onehot_to_counts(self, onehot): """ Convert one-hot vector representation of counts. Assumes the event dimension is the last. :param torch.tensor onehot: one-hot vector representation of shape (..., event) :returns: spike counts :rtype: torch.tensor """ ...
Convert one-hot vector representation of counts. Assumes the event dimension is the last. :param torch.tensor onehot: one-hot vector representation of shape (..., event) :returns: spike counts :rtype: torch.tensor
Convert one-hot vector representation of counts. Assumes the event dimension is the last.
[ "Convert", "one", "-", "hot", "vector", "representation", "of", "counts", ".", "Assumes", "the", "event", "dimension", "is", "the", "last", "." ]
def onehot_to_counts(self, onehot): counts = torch.zeros(*onehot.shape[:-1], device=onehot.device) inds = torch.where(onehot) counts[inds[:-1]] = inds[-1].float() return counts
[ "def", "onehot_to_counts", "(", "self", ",", "onehot", ")", ":", "counts", "=", "torch", ".", "zeros", "(", "*", "onehot", ".", "shape", "[", ":", "-", "1", "]", ",", "device", "=", "onehot", ".", "device", ")", "inds", "=", "torch", ".", "where", ...
Convert one-hot vector representation of counts.
[ "Convert", "one", "-", "hot", "vector", "representation", "of", "counts", "." ]
[ "\"\"\"\n Convert one-hot vector representation of counts. Assumes the event dimension is the last.\n \n :param torch.tensor onehot: one-hot vector representation of shape (..., event)\n :returns: spike counts\n :rtype: torch.tensor\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "onehot", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "torch.tensor" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
counts_to_onehot
<not_specific>
def counts_to_onehot(self, counts): """ Convert counts to one-hot vector representation. Adds the event dimension at the end. :param torch.tensor counts: spike counts of some tensor shape :param int max_counts: size of the event dimension (max_counts + 1) :returns: one-h...
Convert counts to one-hot vector representation. Adds the event dimension at the end. :param torch.tensor counts: spike counts of some tensor shape :param int max_counts: size of the event dimension (max_counts + 1) :returns: one-hot representation of shape (counts.shape, event...
Convert counts to one-hot vector representation. Adds the event dimension at the end.
[ "Convert", "counts", "to", "one", "-", "hot", "vector", "representation", ".", "Adds", "the", "event", "dimension", "at", "the", "end", "." ]
def counts_to_onehot(self, counts): onehot = torch.zeros(*counts.shape, self.K, device=counts.device) onehot_ = onehot.view(-1, self.K) g = onehot_.shape[0] onehot_[np.arange(g), counts.flatten()[np.arange(g)].long()] = 1 return onehot_.view(*onehot.shape)
[ "def", "counts_to_onehot", "(", "self", ",", "counts", ")", ":", "onehot", "=", "torch", ".", "zeros", "(", "*", "counts", ".", "shape", ",", "self", ".", "K", ",", "device", "=", "counts", ".", "device", ")", "onehot_", "=", "onehot", ".", "view", ...
Convert counts to one-hot vector representation.
[ "Convert", "counts", "to", "one", "-", "hot", "vector", "representation", "." ]
[ "\"\"\"\n Convert counts to one-hot vector representation. Adds the event dimension at the end.\n \n :param torch.tensor counts: spike counts of some tensor shape\n :param int max_counts: size of the event dimension (max_counts + 1)\n :returns: one-hot representation of shape (cou...
[ { "param": "self", "type": null }, { "param": "counts", "type": null } ]
{ "returns": [ { "docstring": "one-hot representation of shape (counts.shape, event)", "docstring_tokens": [ "one", "-", "hot", "representation", "of", "shape", "(", "counts", ".", "shape", "event", ")" ...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample_helper
<not_specific>
def sample_helper(self, h, b, neuron, samples): """ NLL helper function for sample evaluation. Note the F_mu dimensions here is equal to NxC. """ logp = self.get_logp(h, neuron) spikes = self.spikes[b][:, neuron, self.filter_len-1:].to(self.tbin.device) if self.trials != ...
NLL helper function for sample evaluation. Note the F_mu dimensions here is equal to NxC.
NLL helper function for sample evaluation. Note the F_mu dimensions here is equal to NxC.
[ "NLL", "helper", "function", "for", "sample", "evaluation", ".", "Note", "the", "F_mu", "dimensions", "here", "is", "equal", "to", "NxC", "." ]
def sample_helper(self, h, b, neuron, samples): logp = self.get_logp(h, neuron) spikes = self.spikes[b][:, neuron, self.filter_len-1:].to(self.tbin.device) if self.trials != 1 and samples > 1 and self.trials < h.shape[0]: spikes = spikes.repeat(samples, 1, 1) tar = self.coun...
[ "def", "sample_helper", "(", "self", ",", "h", ",", "b", ",", "neuron", ",", "samples", ")", ":", "logp", "=", "self", ".", "get_logp", "(", "h", ",", "neuron", ")", "spikes", "=", "self", ".", "spikes", "[", "b", "]", "[", ":", ",", "neuron", ...
NLL helper function for sample evaluation.
[ "NLL", "helper", "function", "for", "sample", "evaluation", "." ]
[ "\"\"\"\n NLL helper function for sample evaluation. Note the F_mu dimensions here is equal to NxC.\n \"\"\"", "# cannot rely on broadcasting" ]
[ { "param": "self", "type": null }, { "param": "h", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": null, "docstring": null, "docstring_tokens": [], ...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
_neuron_to_F
<not_specific>
def _neuron_to_F(self, neuron): """ Access subset of neurons in expanded space. """ neuron = self._validate_neuron(neuron) if len(neuron) == self.neurons: F_dims = list(range(self.F_dims)) else: # access subset of neurons F_dims = list(np.concatena...
Access subset of neurons in expanded space.
Access subset of neurons in expanded space.
[ "Access", "subset", "of", "neurons", "in", "expanded", "space", "." ]
def _neuron_to_F(self, neuron): neuron = self._validate_neuron(neuron) if len(neuron) == self.neurons: F_dims = list(range(self.F_dims)) else: F_dims = list(np.concatenate([np.arange(n*self.C, (n+1)*self.C) for n in neuron])) return F_dims
[ "def", "_neuron_to_F", "(", "self", ",", "neuron", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "if", "len", "(", "neuron", ")", "==", "self", ".", "neurons", ":", "F_dims", "=", "list", "(", "range", "(", "self", "."...
Access subset of neurons in expanded space.
[ "Access", "subset", "of", "neurons", "in", "expanded", "space", "." ]
[ "\"\"\"\n Access subset of neurons in expanded space.\n \"\"\"", "# access subset of neurons" ]
[ { "param": "self", "type": null }, { "param": "neuron", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "neuron", "type": null, "docstring": null, "docstring_tokens":...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): """ Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the lik...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the likelihood samples. This is all combin...
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): F_dims = self._neuron_to_F(neuron) if mode == 'MC': h = self.mc_gen(F_mu, F_var, samples, F_dims) logp, tar = self.sample_helper(h, b, neuron, samples) ws = torch.tensor(1./logp.shape[0]) ...
[ "def", "objective", "(", "self", ",", "F_mu", ",", "F_var", ",", "XZ", ",", "b", ",", "neuron", ",", "samples", "=", "10", ",", "mode", "=", "'MC'", ")", ":", "F_dims", "=", "self", ".", "_neuron_to_F", "(", "neuron", ")", "if", "mode", "==", "'M...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives.
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
[ "\"\"\"\n Computes the terms for variational expectation :math:`\\mathbb{E}_{q(f)q(z)}[]`, which \n can be used to compute different likelihood objectives.\n The returned tensor will have sample dimension as MC over :math:`q(z)`, depending \n on the evaluation mode will be MC or GH or ex...
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "F_var", "type": null }, { "param": "XZ", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type"...
{ "returns": [ { "docstring": "negative likelihood term of shape (samples, timesteps)", "docstring_tokens": [ "negative", "likelihood", "term", "of", "shape", "(", "samples", "timesteps", ")" ], "type": null } ],...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, F_mu, neuron, XZ=None): """ Sample from the categorical distribution. :param numpy.array log_probs: log count probabilities (trials, neuron, timestep, counts), no need to be normalized :returns: spike train of shape (trials...
Sample from the categorical distribution. :param numpy.array log_probs: log count probabilities (trials, neuron, timestep, counts), no need to be normalized :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array ...
Sample from the categorical distribution.
[ "Sample", "from", "the", "categorical", "distribution", "." ]
def sample(self, F_mu, neuron, XZ=None): F_dims = self._neuron_to_F(neuron) log_probs = self.get_logp(torch.tensor(F_mu[:, F_dims, :], dtype=self.tensor_type)) c_dist = mdl.distributions.Categorical(logits=log_probs) cnt_prob = torch.exp(log_probs) return c_dist.sample().numpy()
[ "def", "sample", "(", "self", ",", "F_mu", ",", "neuron", ",", "XZ", "=", "None", ")", ":", "F_dims", "=", "self", ".", "_neuron_to_F", "(", "neuron", ")", "log_probs", "=", "self", ".", "get_logp", "(", "torch", ".", "tensor", "(", "F_mu", "[", ":...
Sample from the categorical distribution.
[ "Sample", "from", "the", "categorical", "distribution", "." ]
[ "\"\"\"\n Sample from the categorical distribution.\n \n :param numpy.array log_probs: log count probabilities (trials, neuron, timestep, counts), no \n need to be normalized\n :returns: spike train of shape (trials, neuron, timesteps)\n :rtype...
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [ { "docstring": "spike train of shape (trials, neuron, timesteps)", "docstring_tokens": [ "spike", "train", "of", "shape", "(", "trials", "neuron", "timesteps", ")" ], "type": "np.array" } ], "rai...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Takes into account the quantization bias if we sample IPP with dilation factor. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np...
Takes into account the quantization bias if we sample IPP with dilation factor. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array
Takes into account the quantization bias if we sample IPP with dilation factor.
[ "Takes", "into", "account", "the", "quantization", "bias", "if", "we", "sample", "IPP", "with", "dilation", "factor", "." ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) return point_process.gen_IBP(rate[:, neuron, :]*self.tbin.item())
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "return", "point_process", ".", "gen_IBP", "(", "rate", "[", ":", ",", "neuro...
Takes into account the quantization bias if we sample IPP with dilation factor.
[ "Takes", "into", "account", "the", "quantization", "bias", "if", "we", "sample", "IPP", "with", "dilation", "factor", "." ]
[ "\"\"\"\n Takes into account the quantization bias if we sample IPP with dilation factor.\n \n :param numpy.array rate: input rate of shape (trials, neuron, timestep)\n :returns: spike train of shape (trials, neuron, timesteps)\n :rtype: np.array\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [ { "docstring": "spike train of shape (trials, neuron, timesteps)", "docstring_tokens": [ "spike", "train", "of", "shape", "(", "trials", "neuron", "timesteps", ")" ], "type": "np.array" } ], "rai...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): """ The Poisson likelihood with the log Cox process has an exact variational likelihood term. """ if self.inv_link == 'exp': # exact if isinstance(F_var, numbers.Number) is False and len(F_var.shape) == 4...
The Poisson likelihood with the log Cox process has an exact variational likelihood term.
The Poisson likelihood with the log Cox process has an exact variational likelihood term.
[ "The", "Poisson", "likelihood", "with", "the", "log", "Cox", "process", "has", "an", "exact", "variational", "likelihood", "term", "." ]
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): if self.inv_link == 'exp': if isinstance(F_var, numbers.Number) is False and len(F_var.shape) == 4: F_var = F_var.view(*F_var.shape[:2], -1)[:, :, ::F_var.shape[-1]+1] spikes = self.spikes[b][:, neu...
[ "def", "objective", "(", "self", ",", "F_mu", ",", "F_var", ",", "XZ", ",", "b", ",", "neuron", ",", "samples", "=", "10", ",", "mode", "=", "'MC'", ")", ":", "if", "self", ".", "inv_link", "==", "'exp'", ":", "if", "isinstance", "(", "F_var", ",...
The Poisson likelihood with the log Cox process has an exact variational likelihood term.
[ "The", "Poisson", "likelihood", "with", "the", "log", "Cox", "process", "has", "an", "exact", "variational", "likelihood", "term", "." ]
[ "\"\"\"\n The Poisson likelihood with the log Cox process has an exact variational likelihood term.\n \"\"\"", "# exact", "# diagonalize", "# watch out for underflow or overflow here", "# first dimension is summed over later (MC over Z), hence divide by shape[0]" ]
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "F_var", "type": null }, { "param": "XZ", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type"...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "F_mu", "type": null, "docstring": null, "docstring_tokens": [...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
nll
<not_specific>
def nll(self, b, rates, l_rates, spikes, neuron, disper_param=None): """ The negative log likelihood function. Note that if disper_param is not None, it will use those values for the dispersion parameter rather than its own dispersion parameters. :param int b: batch index to ev...
The negative log likelihood function. Note that if disper_param is not None, it will use those values for the dispersion parameter rather than its own dispersion parameters. :param int b: batch index to evaluate :param torch.tensor rates: rates of shape (trial, neuron, time) ...
The negative log likelihood function. Note that if disper_param is not None, it will use those values for the dispersion parameter rather than its own dispersion parameters.
[ "The", "negative", "log", "likelihood", "function", ".", "Note", "that", "if", "disper_param", "is", "not", "None", "it", "will", "use", "those", "values", "for", "the", "dispersion", "parameter", "rather", "than", "its", "own", "dispersion", "parameters", "."...
def nll(self, b, rates, l_rates, spikes, neuron, disper_param=None): if disper_param is None: r_ = 1./(self.r_inv.expand(1, self.neurons)[:, neuron, None] + 1e-6) else: r_ = 1./(disper_param + 1e-6) tfact, lfact = self.get_saved_factors(b, neuron, spikes) lambd =...
[ "def", "nll", "(", "self", ",", "b", ",", "rates", ",", "l_rates", ",", "spikes", ",", "neuron", ",", "disper_param", "=", "None", ")", ":", "if", "disper_param", "is", "None", ":", "r_", "=", "1.", "/", "(", "self", ".", "r_inv", ".", "expand", ...
The negative log likelihood function.
[ "The", "negative", "log", "likelihood", "function", "." ]
[ "\"\"\"\n The negative log likelihood function. Note that if disper_param is not None, it will use those values for \n the dispersion parameter rather than its own dispersion parameters.\n \n :param int b: batch index to evaluate\n :param torch.tensor rates: rates of shape (trial,...
[ { "param": "self", "type": null }, { "param": "b", "type": null }, { "param": "rates", "type": null }, { "param": "l_rates", "type": null }, { "param": "spikes", "type": null }, { "param": "neuron", "type": null }, { "param": "disper_param"...
{ "returns": [ { "docstring": "NLL of shape (trial, time)", "docstring_tokens": [ "NLL", "of", "shape", "(", "trial", "time", ")" ], "type": "torch.tensor" } ], "raises": [], "params": [ { "identifier": "self", ...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Sample from the Gamma-Poisson mixture. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :param int max_count: maximum number of spike counts per time bin :returns: spike train of shape (trials, neur...
Sample from the Gamma-Poisson mixture. :param numpy.array rate: input rate of shape (trials, neuron, timestep) :param int max_count: maximum number of spike counts per time bin :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array
Sample from the Gamma-Poisson mixture.
[ "Sample", "from", "the", "Gamma", "-", "Poisson", "mixture", "." ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) rate_ = rate[:, neuron, :] if self.dispersion_mapping is None: r_ = 1./(self.r_inv[None, :, None].expand(rate.shape[0], self.neurons, rate_.shap...
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "rate_", "=", "rate", "[", ":", ",", "neuron", ",", ":", "]", "if", "self...
Sample from the Gamma-Poisson mixture.
[ "Sample", "from", "the", "Gamma", "-", "Poisson", "mixture", "." ]
[ "\"\"\"\n Sample from the Gamma-Poisson mixture.\n \n :param numpy.array rate: input rate of shape (trials, neuron, timestep)\n :param int max_count: maximum number of spike counts per time bin\n :returns: spike train of shape (trials, neuron, timesteps)\n :rtype: np.array\...
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [ { "docstring": "spike train of shape (trials, neuron, timesteps)", "docstring_tokens": [ "spike", "train", "of", "shape", "(", "trials", "neuron", "timesteps", ")" ], "type": "np.array" } ], "rai...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Sample from the CMP distribution. :param numpy.array rate: input rate of shape (neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array """ neuron = self._validate_neu...
Sample from the CMP distribution. :param numpy.array rate: input rate of shape (neuron, timestep) :returns: spike train of shape (trials, neuron, timesteps) :rtype: np.array
Sample from the CMP distribution.
[ "Sample", "from", "the", "CMP", "distribution", "." ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) mu_ = rate[:, neuron, :]*self.tbin.item() if self.dispersion_mapping is None: nu_ = torch.exp(self.log_nu)[None, :, None].expand( rate.shape[0], self.neurons, mu_.shape[-1]).data.cpu(...
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "mu_", "=", "rate", "[", ":", ",", "neuron", ",", ":", "]", "*", "self", ...
Sample from the CMP distribution.
[ "Sample", "from", "the", "CMP", "distribution", "." ]
[ "\"\"\"\n Sample from the CMP distribution.\n \n :param numpy.array rate: input rate of shape (neuron, timestep)\n :returns: spike train of shape (trials, neuron, timesteps)\n :rtype: np.array\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [ { "docstring": "spike train of shape (trials, neuron, timesteps)", "docstring_tokens": [ "spike", "train", "of", "shape", "(", "trials", "neuron", "timesteps", ")" ], "type": "np.array" } ], "rai...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
nll
<not_specific>
def nll(self, l_rates, rISI, neuron): """ Gamma case, approximates the spiketrain NLL (takes tbin into account for NLL). :param np.array neuron: fit over given neurons, must be an array :param torch.tensor F_mu: F_mu product with shape (samples, neurons, timesteps) :para...
Gamma case, approximates the spiketrain NLL (takes tbin into account for NLL). :param np.array neuron: fit over given neurons, must be an array :param torch.tensor F_mu: F_mu product with shape (samples, neurons, timesteps) :param torch.tensor F_var: variance of the F_mu values...
Gamma case, approximates the spiketrain NLL (takes tbin into account for NLL).
[ "Gamma", "case", "approximates", "the", "spiketrain", "NLL", "(", "takes", "tbin", "into", "account", "for", "NLL", ")", "." ]
def nll(self, l_rates, rISI, neuron): samples_ = l_rates.shape[0] shape_ = self.shape.expand(1, self.F_dims)[:, neuron] intervals = torch.zeros((samples_, len(neuron)), device=self.tbin.device) T = torch.empty((samples_, len(neuron)), device=self.tbin.device) l_Lambda = torch.e...
[ "def", "nll", "(", "self", ",", "l_rates", ",", "rISI", ",", "neuron", ")", ":", "samples_", "=", "l_rates", ".", "shape", "[", "0", "]", "shape_", "=", "self", ".", "shape", ".", "expand", "(", "1", ",", "self", ".", "F_dims", ")", "[", ":", "...
Gamma case, approximates the spiketrain NLL (takes tbin into account for NLL).
[ "Gamma", "case", "approximates", "the", "spiketrain", "NLL", "(", "takes", "tbin", "into", "account", "for", "NLL", ")", "." ]
[ "\"\"\"\n Gamma case, approximates the spiketrain NLL (takes tbin into account for NLL).\n \n :param np.array neuron: fit over given neurons, must be an array\n :param torch.tensor F_mu: F_mu product with shape (samples, neurons, timesteps)\n :param torch.tensor F_var: variance of...
[ { "param": "self", "type": null }, { "param": "l_rates", "type": null }, { "param": "rISI", "type": null }, { "param": "neuron", "type": null } ]
{ "returns": [ { "docstring": "NLL array over sample dimensions", "docstring_tokens": [ "NLL", "array", "over", "sample", "dimensions" ], "type": "torch.tensor" } ], "raises": [], "params": [ { "identifier": "self", "type": ...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample_helper
<not_specific>
def sample_helper(self, h, b, neuron, samples): """ NLL helper function for MC sample evaluation. """ rates = self.f(h) # watch out for underflow or overflow here spikes = self.spikes[b][:, neuron, self.filter_len-1:].to(self.tbin.device) return rates, spikes
NLL helper function for MC sample evaluation.
NLL helper function for MC sample evaluation.
[ "NLL", "helper", "function", "for", "MC", "sample", "evaluation", "." ]
def sample_helper(self, h, b, neuron, samples): rates = self.f(h) spikes = self.spikes[b][:, neuron, self.filter_len-1:].to(self.tbin.device) return rates, spikes
[ "def", "sample_helper", "(", "self", ",", "h", ",", "b", ",", "neuron", ",", "samples", ")", ":", "rates", "=", "self", ".", "f", "(", "h", ")", "spikes", "=", "self", ".", "spikes", "[", "b", "]", "[", ":", ",", "neuron", ",", "self", ".", "...
NLL helper function for MC sample evaluation.
[ "NLL", "helper", "function", "for", "MC", "sample", "evaluation", "." ]
[ "\"\"\"\n NLL helper function for MC sample evaluation.\n \"\"\"", "# watch out for underflow or overflow here" ]
[ { "param": "self", "type": null }, { "param": "h", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": null, "docstring": null, "docstring_tokens": [], ...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): """ Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the lik...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives. The returned tensor will have sample dimension as MC over :math:`q(z)`, depending on the evaluation mode will be MC or GH or exact over the likelihood samples. This is all combin...
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
def objective(self, F_mu, F_var, XZ, b, neuron, samples=10, mode='MC'): if disper is None: if self.log_var.shape[0] == 1: log_var = self.log_var.expand(1, len(neuron))[..., None] else: log_var = self.log_var[None, neuron, None] else: dh...
[ "def", "objective", "(", "self", ",", "F_mu", ",", "F_var", ",", "XZ", ",", "b", ",", "neuron", ",", "samples", "=", "10", ",", "mode", "=", "'MC'", ")", ":", "if", "disper", "is", "None", ":", "if", "self", ".", "log_var", ".", "shape", "[", "...
Computes the terms for variational expectation :math:`\mathbb{E}_{q(f)q(z)}[]`, which can be used to compute different likelihood objectives.
[ "Computes", "the", "terms", "for", "variational", "expectation", ":", "math", ":", "`", "\\", "mathbb", "{", "E", "}", "_", "{", "q", "(", "f", ")", "q", "(", "z", ")", "}", "[]", "`", "which", "can", "be", "used", "to", "compute", "different", "...
[ "\"\"\"\n Computes the terms for variational expectation :math:`\\mathbb{E}_{q(f)q(z)}[]`, which \n can be used to compute different likelihood objectives.\n The returned tensor will have sample dimension as MC over :math:`q(z)`, depending \n on the evaluation mode will be MC or GH or ex...
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "F_var", "type": null }, { "param": "XZ", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type"...
{ "returns": [ { "docstring": "negative likelihood term of shape (samples, timesteps), sample weights (samples, 1", "docstring_tokens": [ "negative", "likelihood", "term", "of", "shape", "(", "samples", "timesteps", ")", "...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Sample activity trains [trial, neuron, timestep] """ neuron = self._validate_neuron(neuron) rate_ = rate[:, neuron, :] if self.log_var.shape[0] == 1: log_var = self.log_var.expand(1, len(neuron)).data[...
Sample activity trains [trial, neuron, timestep]
Sample activity trains [trial, neuron, timestep]
[ "Sample", "activity", "trains", "[", "trial", "neuron", "timestep", "]" ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) rate_ = rate[:, neuron, :] if self.log_var.shape[0] == 1: log_var = self.log_var.expand(1, len(neuron)).data[..., None].cpu().numpy() else: log_var = self.log_var.data[None, neuro...
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "rate_", "=", "rate", "[", ":", ",", "neuron", ",", ":", "]", "if", "self...
Sample activity trains [trial, neuron, timestep]
[ "Sample", "activity", "trains", "[", "trial", "neuron", "timestep", "]" ]
[ "\"\"\"\n Sample activity trains [trial, neuron, timestep]\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rate", "type": null, "docstring": null, "docstring_tokens": [...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, F_mu, F_var, XZ, b, neuron, samples, mode='MC'): """ Gaussian likelihood for activity train samples introduces a sample dimension from the left F_mu has shape (samples, neuron, timesteps) if F_var = 0, we don't expand by samples in the sample dimension...
Gaussian likelihood for activity train samples introduces a sample dimension from the left F_mu has shape (samples, neuron, timesteps) if F_var = 0, we don't expand by samples in the sample dimension
Gaussian likelihood for activity train samples introduces a sample dimension from the left F_mu has shape (samples, neuron, timesteps) if F_var = 0, we don't expand by samples in the sample dimension
[ "Gaussian", "likelihood", "for", "activity", "train", "samples", "introduces", "a", "sample", "dimension", "from", "the", "left", "F_mu", "has", "shape", "(", "samples", "neuron", "timesteps", ")", "if", "F_var", "=", "0", "we", "don", "'", "t", "expand", ...
def objective(self, F_mu, F_var, XZ, b, neuron, samples, mode='MC'): spikes = self.spikes[b][None, neuron, self.filter_len-1:].to(self.tbin.device) batch_size = F_mu.shape[-1] if self.inv_link == 'identity': noise_var = (self.L @ self.L.t())[None, neuron, None] + F_var[:, n...
[ "def", "objective", "(", "self", ",", "F_mu", ",", "F_var", ",", "XZ", ",", "b", ",", "neuron", ",", "samples", ",", "mode", "=", "'MC'", ")", ":", "spikes", "=", "self", ".", "spikes", "[", "b", "]", "[", "None", ",", "neuron", ",", "self", "....
Gaussian likelihood for activity train samples introduces a sample dimension from the left F_mu has shape (samples, neuron, timesteps) if F_var = 0, we don't expand by samples in the sample dimension
[ "Gaussian", "likelihood", "for", "activity", "train", "samples", "introduces", "a", "sample", "dimension", "from", "the", "left", "F_mu", "has", "shape", "(", "samples", "neuron", "timesteps", ")", "if", "F_var", "=", "0", "we", "don", "'", "t", "expand", ...
[ "\"\"\"\n Gaussian likelihood for activity train\n samples introduces a sample dimension from the left\n F_mu has shape (samples, neuron, timesteps)\n if F_var = 0, we don't expand by samples in the sample dimension\n \"\"\"", "# activity", "# exact", "# MC samples" ]
[ { "param": "self", "type": null }, { "param": "F_mu", "type": null }, { "param": "F_var", "type": null }, { "param": "XZ", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "samples", "type"...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "F_mu", "type": null, "docstring": null, "docstring_tokens": [...
4e64fcbc8a1e888ed6c2d0f2a48db8eaa9c5aa1d
davindicode/universal_count_model
neuroprob/likelihoods.py
[ "MIT" ]
Python
sample
<not_specific>
def sample(self, rate, neuron=None, XZ=None): """ Sample activity trains [trial, neuron, timestep] """ neuron = self._validate_neuron(neuron) act = rate + torch.exp(self.log_var).data.sqrt().cpu().numpy()*np.random.randn((rate.shape[0], len(neuron), rate.shape[-1])) retur...
Sample activity trains [trial, neuron, timestep]
Sample activity trains [trial, neuron, timestep]
[ "Sample", "activity", "trains", "[", "trial", "neuron", "timestep", "]" ]
def sample(self, rate, neuron=None, XZ=None): neuron = self._validate_neuron(neuron) act = rate + torch.exp(self.log_var).data.sqrt().cpu().numpy()*np.random.randn((rate.shape[0], len(neuron), rate.shape[-1])) return act
[ "def", "sample", "(", "self", ",", "rate", ",", "neuron", "=", "None", ",", "XZ", "=", "None", ")", ":", "neuron", "=", "self", ".", "_validate_neuron", "(", "neuron", ")", "act", "=", "rate", "+", "torch", ".", "exp", "(", "self", ".", "log_var", ...
Sample activity trains [trial, neuron, timestep]
[ "Sample", "activity", "trains", "[", "trial", "neuron", "timestep", "]" ]
[ "\"\"\"\n Sample activity trains [trial, neuron, timestep]\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rate", "type": null }, { "param": "neuron", "type": null }, { "param": "XZ", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rate", "type": null, "docstring": null, "docstring_tokens": [...
d31b669ee0e20d485b4915942912aea4387a623c
davindicode/universal_count_model
neuroprob/utils/decoding.py
[ "MIT" ]
Python
fit_decoder
<not_specific>
def fit_decoder(decoding_triplets, batches, timesteps, optimizer, max_epochs, loss_margin=0.0, margin_epochs=10, scheduler=None, sch_st=None, dev='cpu'): """ Fit the optimal probabilistic decoder with cross entropy loss. Optimizes a list of decoders for different dimensions/topologies. ...
Fit the optimal probabilistic decoder with cross entropy loss. Optimizes a list of decoders for different dimensions/topologies.
Fit the optimal probabilistic decoder with cross entropy loss. Optimizes a list of decoders for different dimensions/topologies.
[ "Fit", "the", "optimal", "probabilistic", "decoder", "with", "cross", "entropy", "loss", ".", "Optimizes", "a", "list", "of", "decoders", "for", "different", "dimensions", "/", "topologies", "." ]
def fit_decoder(decoding_triplets, batches, timesteps, optimizer, max_epochs, loss_margin=0.0, margin_epochs=10, scheduler=None, sch_st=None, dev='cpu'): loss_tracker = [] minloss = np.inf cnt = 0 iterator = tqdm(range(max_epochs)) for epoch in iterator: sloss = 0 fo...
[ "def", "fit_decoder", "(", "decoding_triplets", ",", "batches", ",", "timesteps", ",", "optimizer", ",", "max_epochs", ",", "loss_margin", "=", "0.0", ",", "margin_epochs", "=", "10", ",", "scheduler", "=", "None", ",", "sch_st", "=", "None", ",", "dev", "...
Fit the optimal probabilistic decoder with cross entropy loss.
[ "Fit", "the", "optimal", "probabilistic", "decoder", "with", "cross", "entropy", "loss", "." ]
[ "\"\"\"\n Fit the optimal probabilistic decoder with cross entropy loss.\n Optimizes a list of decoders for different dimensions/topologies.\n \"\"\"" ]
[ { "param": "decoding_triplets", "type": null }, { "param": "batches", "type": null }, { "param": "timesteps", "type": null }, { "param": "optimizer", "type": null }, { "param": "max_epochs", "type": null }, { "param": "loss_margin", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "decoding_triplets", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "batches", "type": null, "docstring": null, "docs...
258bbd734bb4cb6c69f2ed29511950f01c72806f
davindicode/universal_count_model
neuroprob/rate_models.py
[ "MIT" ]
Python
w_to_gaussian
<not_specific>
def w_to_gaussian(w): """ Get Gaussian and orthogonal theta parameterization from the GLM parameters. :param np.array w: input GLM parameters of shape (neurons, dims), dims labelling (w_1, w_x, w_y, w_xx, w_yy, w_xy, w_cos, w_sin) """ neurons = mu.shape[0] w_spat = w[...
Get Gaussian and orthogonal theta parameterization from the GLM parameters. :param np.array w: input GLM parameters of shape (neurons, dims), dims labelling (w_1, w_x, w_y, w_xx, w_yy, w_xy, w_cos, w_sin)
Get Gaussian and orthogonal theta parameterization from the GLM parameters.
[ "Get", "Gaussian", "and", "orthogonal", "theta", "parameterization", "from", "the", "GLM", "parameters", "." ]
def w_to_gaussian(w): neurons = mu.shape[0] w_spat = w[:, 0:6] prec = np.empty((neurons, 3)) mu = np.empty((neurons, 2)) prec[:, 0] = -2*w_spat[:, 3] prec[:, 1] = -2*w_spat[:, 4] prec[:, 2] = -w_spat[:, 5] prec_mat = [] for n in range(neurons): prec_mat.append([[prec[n, 0],...
[ "def", "w_to_gaussian", "(", "w", ")", ":", "neurons", "=", "mu", ".", "shape", "[", "0", "]", "w_spat", "=", "w", "[", ":", ",", "0", ":", "6", "]", "prec", "=", "np", ".", "empty", "(", "(", "neurons", ",", "3", ")", ")", "mu", "=", "np",...
Get Gaussian and orthogonal theta parameterization from the GLM parameters.
[ "Get", "Gaussian", "and", "orthogonal", "theta", "parameterization", "from", "the", "GLM", "parameters", "." ]
[ "\"\"\"\n Get Gaussian and orthogonal theta parameterization from the GLM parameters.\n \n :param np.array w: input GLM parameters of shape (neurons, dims), dims labelling (w_1, w_x,\n w_y, w_xx, w_yy, w_xy, w_cos, w_sin)\n \"\"\"", "# xx, yy and xy/yx", "# x and y" ]
[ { "param": "w", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": null, "docstring": "input GLM parameters of shape (neurons, dims), dims labelling (w_1, w_x,\nw_y, w_xx, w_yy, w_xy, w_cos, w_sin)", "docstring_tokens": [ "input", "GLM", "parameters", ...
258bbd734bb4cb6c69f2ed29511950f01c72806f
davindicode/universal_count_model
neuroprob/rate_models.py
[ "MIT" ]
Python
gaussian_to_w
<not_specific>
def gaussian_to_w(mu, prec, rate_0, theta_p): """ Get GLM parameters from Gaussian and orthogonal theta parameterization :param np.array mu: mean of the Gaussian field of shape (neurons, 2) :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3) :param np.array rate...
Get GLM parameters from Gaussian and orthogonal theta parameterization :param np.array mu: mean of the Gaussian field of shape (neurons, 2) :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3) :param np.array rate_0: rate amplitude of shape (neurons) :param np.a...
Get GLM parameters from Gaussian and orthogonal theta parameterization
[ "Get", "GLM", "parameters", "from", "Gaussian", "and", "orthogonal", "theta", "parameterization" ]
def gaussian_to_w(mu, prec, rate_0, theta_p): neurons = mu.shape[0] prec_mat = [] for n in range(neurons): prec_mat.append([[prec[n, 0], prec[n, 2]], [prec[n, 2], prec[n, 1]]]) prec_mat = np.array(prec_mat) w = np.empty((neurons, 8)) w[:, 0] = np.log(rate_0) - 0.5*(mu * np.einsum('nij,nj...
[ "def", "gaussian_to_w", "(", "mu", ",", "prec", ",", "rate_0", ",", "theta_p", ")", ":", "neurons", "=", "mu", ".", "shape", "[", "0", "]", "prec_mat", "=", "[", "]", "for", "n", "in", "range", "(", "neurons", ")", ":", "prec_mat", ".", "append", ...
Get GLM parameters from Gaussian and orthogonal theta parameterization
[ "Get", "GLM", "parameters", "from", "Gaussian", "and", "orthogonal", "theta", "parameterization" ]
[ "\"\"\"\n Get GLM parameters from Gaussian and orthogonal theta parameterization\n \n :param np.array mu: mean of the Gaussian field of shape (neurons, 2)\n :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3)\n :param np.array rate_0: rate amplitude of shape (neurons)...
[ { "param": "mu", "type": null }, { "param": "prec", "type": null }, { "param": "rate_0", "type": null }, { "param": "theta_p", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mu", "type": null, "docstring": "mean of the Gaussian field of shape (neurons, 2)", "docstring_tokens": [ "mean", "of", "the", "Gaussian", "field", "of", "shape", ...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, x, y, xs, device, iters=1000): """ Probabilistic MAP fitting of spline (loss with regularizer) """ f = Parameter(torch.tensor(y, device=device)) y_ = torch.tensor(y, device=device) optimizer = optim.Adam([shift], lr=1e-2) losses = [] for k ...
Probabilistic MAP fitting of spline (loss with regularizer)
Probabilistic MAP fitting of spline (loss with regularizer)
[ "Probabilistic", "MAP", "fitting", "of", "spline", "(", "loss", "with", "regularizer", ")" ]
def fit(self, x, y, xs, device, iters=1000): f = Parameter(torch.tensor(y, device=device)) y_ = torch.tensor(y, device=device) optimizer = optim.Adam([shift], lr=1e-2) losses = [] for k in range(iters): optimizer.zero_grad() f_ = self.interp(x, f.data.cpu(...
[ "def", "fit", "(", "self", ",", "x", ",", "y", ",", "xs", ",", "device", ",", "iters", "=", "1000", ")", ":", "f", "=", "Parameter", "(", "torch", ".", "tensor", "(", "y", ",", "device", "=", "device", ")", ")", "y_", "=", "torch", ".", "tens...
Probabilistic MAP fitting of spline (loss with regularizer)
[ "Probabilistic", "MAP", "fitting", "of", "spline", "(", "loss", "with", "regularizer", ")" ]
[ "\"\"\"\n Probabilistic MAP fitting of spline (loss with regularizer)\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "y", "type": null }, { "param": "xs", "type": null }, { "param": "device", "type": null }, { "param": "iters", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
nb_count_prob
<not_specific>
def nb_count_prob(n, rate, r_inv, sim_time): """ Negative binomial count probability. The mean is given by :math:`r \cdot \Delta t` like in the Poisson case. """ g = rate*sim_time if g == 0: return (n == 0).astype(float) r = 1./r_inv log_terms = sps.loggamma(r+n) - sps.logg...
Negative binomial count probability. The mean is given by :math:`r \cdot \Delta t` like in the Poisson case.
Negative binomial count probability. The mean is given by :math:`r \cdot \Delta t` like in the Poisson case.
[ "Negative", "binomial", "count", "probability", ".", "The", "mean", "is", "given", "by", ":", "math", ":", "`", "r", "\\", "cdot", "\\", "Delta", "t", "`", "like", "in", "the", "Poisson", "case", "." ]
def nb_count_prob(n, rate, r_inv, sim_time): g = rate*sim_time if g == 0: return (n == 0).astype(float) r = 1./r_inv log_terms = sps.loggamma(r+n) - sps.loggamma(r) - (n+r)*np.log(g+r) + r*np.log(r) return np.exp(np.log(g)*n - sps.gammaln(n+1) + log_terms)
[ "def", "nb_count_prob", "(", "n", ",", "rate", ",", "r_inv", ",", "sim_time", ")", ":", "g", "=", "rate", "*", "sim_time", "if", "g", "==", "0", ":", "return", "(", "n", "==", "0", ")", ".", "astype", "(", "float", ")", "r", "=", "1.", "/", "...
Negative binomial count probability.
[ "Negative", "binomial", "count", "probability", "." ]
[ "\"\"\"\n Negative binomial count probability. The mean is given by :math:`r \\cdot \\Delta t` like in \n the Poisson case.\n \"\"\"" ]
[ { "param": "n", "type": null }, { "param": "rate", "type": null }, { "param": "r_inv", "type": null }, { "param": "sim_time", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rate", "type": null, "docstring": null, "docstring_tokens": [], ...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
cmp_count_prob
<not_specific>
def cmp_count_prob(n, rate, nu, sim_time, J=100): """ Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp inspired methodology to avoid floating point overflows. """ g = rate*sim_time if g == 0: return (n == 0).astype(float) j = np.ara...
Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp inspired methodology to avoid floating point overflows.
Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp inspired methodology to avoid floating point overflows.
[ "Conway", "-", "Maxwell", "-", "Poisson", "count", "distribution", ".", "The", "partition", "function", "is", "evaluated", "using", "logsumexp", "inspired", "methodology", "to", "avoid", "floating", "point", "overflows", "." ]
def cmp_count_prob(n, rate, nu, sim_time, J=100): g = rate*sim_time if g == 0: return (n == 0).astype(float) j = np.arange(J+1) lnum = np.log(g)*j lden = np.log(sps.factorial(j))*nu dl = lnum-lden dl_m = dl.max() logsumexp_Z = np.log(np.exp(dl-dl_m).sum()) + dl_m return np.e...
[ "def", "cmp_count_prob", "(", "n", ",", "rate", ",", "nu", ",", "sim_time", ",", "J", "=", "100", ")", ":", "g", "=", "rate", "*", "sim_time", "if", "g", "==", "0", ":", "return", "(", "n", "==", "0", ")", ".", "astype", "(", "float", ")", "j...
Conway-Maxwell-Poisson count distribution.
[ "Conway", "-", "Maxwell", "-", "Poisson", "count", "distribution", "." ]
[ "\"\"\"\n Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp \n inspired methodology to avoid floating point overflows.\n \"\"\"", "# numerically stable" ]
[ { "param": "n", "type": null }, { "param": "rate", "type": null }, { "param": "nu", "type": null }, { "param": "sim_time", "type": null }, { "param": "J", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rate", "type": null, "docstring": null, "docstring_tokens": [], ...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
modulated_count_dist
null
def modulated_count_dist(count_dist, mult_gain, add_gain, samples): """ Generate distribution samples from the modulated count process with additive and multiplicate gains. .. math:: P_{mod}(n|\lambda) = \int P_{count}(n|G_{mul}\lambda + G_{add}) P(G_{mu]}, G_{add}) \mathrm{d}G_{mul} \mathr...
Generate distribution samples from the modulated count process with additive and multiplicate gains. .. math:: P_{mod}(n|\lambda) = \int P_{count}(n|G_{mul}\lambda + G_{add}) P(G_{mu]}, G_{add}) \mathrm{d}G_{mul} \mathrm{d}G_{add}, where :math:`p(y \mid f)` is the likelihood. ...
Generate distribution samples from the modulated count process with additive and multiplicate gains. [1] `Dethroning the Fano Factor: A Flexible, Model-Based Approach to Partitioning Neural Variability`, Adam S. Charles, Mijung Park, J.
[ "Generate", "distribution", "samples", "from", "the", "modulated", "count", "process", "with", "additive", "and", "multiplicate", "gains", ".", "[", "1", "]", "`", "Dethroning", "the", "Fano", "Factor", ":", "A", "Flexible", "Model", "-", "Based", "Approach", ...
def modulated_count_dist(count_dist, mult_gain, add_gain, samples): raise NotImplementedError
[ "def", "modulated_count_dist", "(", "count_dist", ",", "mult_gain", ",", "add_gain", ",", "samples", ")", ":", "raise", "NotImplementedError" ]
Generate distribution samples from the modulated count process with additive and multiplicate gains.
[ "Generate", "distribution", "samples", "from", "the", "modulated", "count", "process", "with", "additive", "and", "multiplicate", "gains", "." ]
[ "\"\"\"\n Generate distribution samples from the modulated count process with additive and multiplicate gains.\n \n .. math::\n P_{mod}(n|\\lambda) = \\int P_{count}(n|G_{mul}\\lambda + G_{add}) P(G_{mu]}, G_{add}) \\mathrm{d}G_{mul} \\mathrm{d}G_{add},\n\n where :math:`p(y \\mid f)` is t...
[ { "param": "count_dist", "type": null }, { "param": "mult_gain", "type": null }, { "param": "add_gain", "type": null }, { "param": "samples", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "count_dist", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mult_gain", "type": null, "docstring": null, "docstring...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
cdf_count_deq
<not_specific>
def cdf_count_deq(n, deq, count_prob, N_MAX=100): """ Compute the dequantized cdf count. :param int n: integer spike count :param float deq: dequantization noise :param LambdaFunction count_prob: """ N = np.arange(n+1) C = count_prob(N) cdf = C[:n].sum() + deq*C[n] return c...
Compute the dequantized cdf count. :param int n: integer spike count :param float deq: dequantization noise :param LambdaFunction count_prob:
Compute the dequantized cdf count.
[ "Compute", "the", "dequantized", "cdf", "count", "." ]
def cdf_count_deq(n, deq, count_prob, N_MAX=100): N = np.arange(n+1) C = count_prob(N) cdf = C[:n].sum() + deq*C[n] return cdf
[ "def", "cdf_count_deq", "(", "n", ",", "deq", ",", "count_prob", ",", "N_MAX", "=", "100", ")", ":", "N", "=", "np", ".", "arange", "(", "n", "+", "1", ")", "C", "=", "count_prob", "(", "N", ")", "cdf", "=", "C", "[", ":", "n", "]", ".", "s...
Compute the dequantized cdf count.
[ "Compute", "the", "dequantized", "cdf", "count", "." ]
[ "\"\"\"\n Compute the dequantized cdf count.\n \n :param int n: integer spike count\n :param float deq: dequantization noise\n :param LambdaFunction count_prob: \n \"\"\"" ]
[ { "param": "n", "type": null }, { "param": "deq", "type": null }, { "param": "count_prob", "type": null }, { "param": "N_MAX", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": "integer spike count", "docstring_tokens": [ "integer", "spike", "count" ], "default": null, "is_optional": false }, { "identifier": "deq",...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
count_KS_method
<not_specific>
def count_KS_method(count_dist, mean_func, sample_bin, spike_binned, rate, shape=None, deq_noise=None): """ Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov statistics. Trajectory lengths are given, unless the expected count is below min_spikes (avo...
Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov statistics. Trajectory lengths are given, unless the expected count is below min_spikes (avoid dequantization effect) :param LambdaType count_dist: lambda function with input (count, rate, time) and output p :pa...
Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov statistics. Trajectory lengths are given, unless the expected count is below min_spikes (avoid dequantization effect)
[ "Overdispersion", "analysis", "using", "rate", "-", "rescaled", "distributions", "and", "Kolmogorov", "-", "Smirnov", "statistics", ".", "Trajectory", "lengths", "are", "given", "unless", "the", "expected", "count", "is", "below", "min_spikes", "(", "avoid", "dequ...
def count_KS_method(count_dist, mean_func, sample_bin, spike_binned, rate, shape=None, deq_noise=None): if shape is not None: assert rate.shape[0] == shape.shape[0] traj_lens = rate.shape[0] q_cdf = [] if deq_noise is None: deq_noise = np.random.uniform(size=spike_bi...
[ "def", "count_KS_method", "(", "count_dist", ",", "mean_func", ",", "sample_bin", ",", "spike_binned", ",", "rate", ",", "shape", "=", "None", ",", "deq_noise", "=", "None", ")", ":", "if", "shape", "is", "not", "None", ":", "assert", "rate", ".", "shape...
Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov statistics.
[ "Overdispersion", "analysis", "using", "rate", "-", "rescaled", "distributions", "and", "Kolmogorov", "-", "Smirnov", "statistics", "." ]
[ "\"\"\"\n Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov \n statistics. Trajectory lengths are given, unless the expected count is below \n min_spikes (avoid dequantization effect)\n \n :param LambdaType count_dist: lambda function with input (count, rate, time) and ...
[ { "param": "count_dist", "type": null }, { "param": "mean_func", "type": null }, { "param": "sample_bin", "type": null }, { "param": "spike_binned", "type": null }, { "param": "rate", "type": null }, { "param": "shape", "type": null }, { "p...
{ "returns": [ { "docstring": "quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS", "docstring_tokens": [ "quantiles", "q_order", "ks_y", "T_DS", "T_KS", "sign_DS", "sign_KS" ], "type": "tuple" } ], "raises": [], "params...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
discrete_rate_rescale
<not_specific>
def discrete_rate_rescale(sample_bin, rate, spike_ind): r""" Treats the rate as a step-wise constant continuous function, see [1]. We dequantize the rescaled times by adding uniform noise between discrete steps in the rescaled times. References: [1] `Rescaling, thinning or complementing? ...
r""" Treats the rate as a step-wise constant continuous function, see [1]. We dequantize the rescaled times by adding uniform noise between discrete steps in the rescaled times. References: [1] `Rescaling, thinning or complementing? On goodness-of-fit procedures for point process models ...
r""" Treats the rate as a step-wise constant continuous function, see [1]. We dequantize the rescaled times by adding uniform noise between discrete steps in the rescaled times. [1] `Rescaling, thinning or complementing. On goodness-of-fit procedures for point process models and Generalized Linear Models`, Felipe Ge...
[ "r", "\"", "\"", "\"", "Treats", "the", "rate", "as", "a", "step", "-", "wise", "constant", "continuous", "function", "see", "[", "1", "]", ".", "We", "dequantize", "the", "rescaled", "times", "by", "adding", "uniform", "noise", "between", "discrete", "s...
def discrete_rate_rescale(sample_bin, rate, spike_ind): rtime = np.cumsum(rate)*sample_bin drtime = np.concatenate((rtime[0:1], rtime[1:] - rtime[:-1])) rspk = rtime[spike_ind] - np.random.rand(*spike_ind.shape)*drtime[spike_ind] rspk = np.sort(rspk) return rspk
[ "def", "discrete_rate_rescale", "(", "sample_bin", ",", "rate", ",", "spike_ind", ")", ":", "rtime", "=", "np", ".", "cumsum", "(", "rate", ")", "*", "sample_bin", "drtime", "=", "np", ".", "concatenate", "(", "(", "rtime", "[", "0", ":", "1", "]", "...
r""" Treats the rate as a step-wise constant continuous function, see [1].
[ "r", "\"", "\"", "\"", "Treats", "the", "rate", "as", "a", "step", "-", "wise", "constant", "continuous", "function", "see", "[", "1", "]", "." ]
[ "r\"\"\"\n Treats the rate as a step-wise constant continuous function, see [1]. We dequantize the \n rescaled times by adding uniform noise between discrete steps in the rescaled times.\n \n References:\n \n [1] `Rescaling, thinning or complementing? On goodness-of-fit procedures for \n point ...
[ { "param": "sample_bin", "type": null }, { "param": "rate", "type": null }, { "param": "spike_ind", "type": null } ]
{ "returns": [ { "docstring": "Spike times as rescaled with rate rescaling in units of sample_bin", "docstring_tokens": [ "Spike", "times", "as", "rescaled", "with", "rate", "rescaling", "in", "units", "of", "sampl...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
ISI_KS_method
<not_specific>
def ISI_KS_method(interval_dist, sample_bin, spike_ind, rate): """ Overdispersion analysis using time-rescaled ISIs and Kolmogorov-Smirnov statistics :param ISI_class interval_dist: the interval dist :param float sample_bin: :param numpy.array spike_ind: indices of the spike times :param n...
Overdispersion analysis using time-rescaled ISIs and Kolmogorov-Smirnov statistics :param ISI_class interval_dist: the interval dist :param float sample_bin: :param numpy.array spike_ind: indices of the spike times :param numpy.array rate: 1D rate array, sampled at sample_bin :param float...
Overdispersion analysis using time-rescaled ISIs and Kolmogorov-Smirnov statistics
[ "Overdispersion", "analysis", "using", "time", "-", "rescaled", "ISIs", "and", "Kolmogorov", "-", "Smirnov", "statistics" ]
def ISI_KS_method(interval_dist, sample_bin, spike_ind, rate): rtime = discrete_rate_rescale(sample_bin, rate, spike_ind) rISI = rtime[1:] - rtime[:-1] quantiles = interval_dist.cum_prob(rISI) return quantiles
[ "def", "ISI_KS_method", "(", "interval_dist", ",", "sample_bin", ",", "spike_ind", ",", "rate", ")", ":", "rtime", "=", "discrete_rate_rescale", "(", "sample_bin", ",", "rate", ",", "spike_ind", ")", "rISI", "=", "rtime", "[", "1", ":", "]", "-", "rtime", ...
Overdispersion analysis using time-rescaled ISIs and Kolmogorov-Smirnov statistics
[ "Overdispersion", "analysis", "using", "time", "-", "rescaled", "ISIs", "and", "Kolmogorov", "-", "Smirnov", "statistics" ]
[ "\"\"\"\n Overdispersion analysis using time-rescaled ISIs and Kolmogorov-Smirnov statistics\n \n :param ISI_class interval_dist: the interval dist\n :param float sample_bin: \n :param numpy.array spike_ind: indices of the spike times\n :param numpy.array rate: 1D rate array, sampled at sample_bin...
[ { "param": "interval_dist", "type": null }, { "param": "sample_bin", "type": null }, { "param": "spike_ind", "type": null }, { "param": "rate", "type": null } ]
{ "returns": [ { "docstring": "quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS", "docstring_tokens": [ "quantiles", "q_order", "ks_y", "T_DS", "T_KS", "sign_DS", "sign_KS" ], "type": "tuple" } ], "raises": [], "params...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
invISI_KS_method
<not_specific>
def invISI_KS_method(inv_interval_dist, sample_bin, spike_ind, rate): """ Overdispersion analysis using time-rescaled ISIs. :param ISI_class interval_dist: the interval dist :param float sample_bin: :param numpy.array spike_ind: indices of the spike times :param numpy.array rate: 1D rate a...
Overdispersion analysis using time-rescaled ISIs. :param ISI_class interval_dist: the interval dist :param float sample_bin: :param numpy.array spike_ind: indices of the spike times :param numpy.array rate: 1D rate array, sampled at sample_bin :param float alpha: significance level of the...
Overdispersion analysis using time-rescaled ISIs.
[ "Overdispersion", "analysis", "using", "time", "-", "rescaled", "ISIs", "." ]
def invISI_KS_method(inv_interval_dist, sample_bin, spike_ind, rate): rtime = discrete_rate_rescale(sample_bin, rate, spike_ind) rISI = rtime[1:] - rtime[:-1] quantiles = inv_interval_dist.cum_prob(1/(rISI+1e-12)) return quantiles
[ "def", "invISI_KS_method", "(", "inv_interval_dist", ",", "sample_bin", ",", "spike_ind", ",", "rate", ")", ":", "rtime", "=", "discrete_rate_rescale", "(", "sample_bin", ",", "rate", ",", "spike_ind", ")", "rISI", "=", "rtime", "[", "1", ":", "]", "-", "r...
Overdispersion analysis using time-rescaled ISIs.
[ "Overdispersion", "analysis", "using", "time", "-", "rescaled", "ISIs", "." ]
[ "\"\"\"\n Overdispersion analysis using time-rescaled ISIs.\n \n :param ISI_class interval_dist: the interval dist\n :param float sample_bin: \n :param numpy.array spike_ind: indices of the spike times\n :param numpy.array rate: 1D rate array, sampled at sample_bin\n :param float alpha: signifi...
[ { "param": "inv_interval_dist", "type": null }, { "param": "sample_bin", "type": null }, { "param": "spike_ind", "type": null }, { "param": "rate", "type": null } ]
{ "returns": [ { "docstring": "quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS", "docstring_tokens": [ "quantiles", "q_order", "ks_y", "T_DS", "T_KS", "sign_DS", "sign_KS" ], "type": "tuple" } ], "raises": [], "params...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
q_to_Z
<not_specific>
def q_to_Z(quantiles, LIM=1e-15): """ Inverse transform to Gaussian variables from uniform variables. """ _q = (1. - quantiles) _q[_q < LIM] = LIM _q[_q > 1.-LIM] = 1.-LIM z = scstats.norm.isf(_q) return z
Inverse transform to Gaussian variables from uniform variables.
Inverse transform to Gaussian variables from uniform variables.
[ "Inverse", "transform", "to", "Gaussian", "variables", "from", "uniform", "variables", "." ]
def q_to_Z(quantiles, LIM=1e-15): _q = (1. - quantiles) _q[_q < LIM] = LIM _q[_q > 1.-LIM] = 1.-LIM z = scstats.norm.isf(_q) return z
[ "def", "q_to_Z", "(", "quantiles", ",", "LIM", "=", "1e-15", ")", ":", "_q", "=", "(", "1.", "-", "quantiles", ")", "_q", "[", "_q", "<", "LIM", "]", "=", "LIM", "_q", "[", "_q", ">", "1.", "-", "LIM", "]", "=", "1.", "-", "LIM", "z", "=", ...
Inverse transform to Gaussian variables from uniform variables.
[ "Inverse", "transform", "to", "Gaussian", "variables", "from", "uniform", "variables", "." ]
[ "\"\"\"\n Inverse transform to Gaussian variables from uniform variables.\n \"\"\"" ]
[ { "param": "quantiles", "type": null }, { "param": "LIM", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "quantiles", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "LIM", "type": null, "docstring": null, "docstring_tokens...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
Z_to_q
<not_specific>
def Z_to_q(Z, LIM=1e-15): """ Inverse transform to Gaussian variables from uniform variables. """ q = scstats.norm.cdf(Z) return q
Inverse transform to Gaussian variables from uniform variables.
Inverse transform to Gaussian variables from uniform variables.
[ "Inverse", "transform", "to", "Gaussian", "variables", "from", "uniform", "variables", "." ]
def Z_to_q(Z, LIM=1e-15): q = scstats.norm.cdf(Z) return q
[ "def", "Z_to_q", "(", "Z", ",", "LIM", "=", "1e-15", ")", ":", "q", "=", "scstats", ".", "norm", ".", "cdf", "(", "Z", ")", "return", "q" ]
Inverse transform to Gaussian variables from uniform variables.
[ "Inverse", "transform", "to", "Gaussian", "variables", "from", "uniform", "variables", "." ]
[ "\"\"\"\n Inverse transform to Gaussian variables from uniform variables.\n \"\"\"" ]
[ { "param": "Z", "type": null }, { "param": "LIM", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Z", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "LIM", "type": null, "docstring": null, "docstring_tokens": [], ...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
KS_sampling_dist
<not_specific>
def KS_sampling_dist(x, samples, K=100000): """ Sampling distribution for the Brownian bridge supremum (KS test sampling distribution). """ k = np.arange(1,K+1)[None, :] return 8*x * ((-1)**(k-1) * k**2 * np.exp(-2*k**2 * x[:, None]**2 * samples)).sum(-1) * samples
Sampling distribution for the Brownian bridge supremum (KS test sampling distribution).
Sampling distribution for the Brownian bridge supremum (KS test sampling distribution).
[ "Sampling", "distribution", "for", "the", "Brownian", "bridge", "supremum", "(", "KS", "test", "sampling", "distribution", ")", "." ]
def KS_sampling_dist(x, samples, K=100000): k = np.arange(1,K+1)[None, :] return 8*x * ((-1)**(k-1) * k**2 * np.exp(-2*k**2 * x[:, None]**2 * samples)).sum(-1) * samples
[ "def", "KS_sampling_dist", "(", "x", ",", "samples", ",", "K", "=", "100000", ")", ":", "k", "=", "np", ".", "arange", "(", "1", ",", "K", "+", "1", ")", "[", "None", ",", ":", "]", "return", "8", "*", "x", "*", "(", "(", "-", "1", ")", "...
Sampling distribution for the Brownian bridge supremum (KS test sampling distribution).
[ "Sampling", "distribution", "for", "the", "Brownian", "bridge", "supremum", "(", "KS", "test", "sampling", "distribution", ")", "." ]
[ "\"\"\"\n Sampling distribution for the Brownian bridge supremum (KS test sampling distribution).\n \"\"\"" ]
[ { "param": "x", "type": null }, { "param": "samples", "type": null }, { "param": "K", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samples", "type": null, "docstring": null, "docstring_tokens": [...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
KS_statistics
<not_specific>
def KS_statistics(quantiles, alpha=0.05, alpha_s=0.05): """ Kolmogorov-Smirnov statistics using quantiles. """ samples = quantiles.shape[0] assert samples > 1 q_order = np.append(np.array([0]), np.sort(quantiles)) ks_y = np.arange(samples+1)/samples - q_order # dispersion scores ...
Kolmogorov-Smirnov statistics using quantiles.
Kolmogorov-Smirnov statistics using quantiles.
[ "Kolmogorov", "-", "Smirnov", "statistics", "using", "quantiles", "." ]
def KS_statistics(quantiles, alpha=0.05, alpha_s=0.05): samples = quantiles.shape[0] assert samples > 1 q_order = np.append(np.array([0]), np.sort(quantiles)) ks_y = np.arange(samples+1)/samples - q_order T_KS = np.abs(ks_y).max() z = q_to_Z(quantiles) T_DS = np.log((z**2).mean()) + 1/sample...
[ "def", "KS_statistics", "(", "quantiles", ",", "alpha", "=", "0.05", ",", "alpha_s", "=", "0.05", ")", ":", "samples", "=", "quantiles", ".", "shape", "[", "0", "]", "assert", "samples", ">", "1", "q_order", "=", "np", ".", "append", "(", "np", ".", ...
Kolmogorov-Smirnov statistics using quantiles.
[ "Kolmogorov", "-", "Smirnov", "statistics", "using", "quantiles", "." ]
[ "\"\"\"\n Kolmogorov-Smirnov statistics using quantiles.\n \"\"\"", "# dispersion scores", "# unit normal null distribution", "#ref_sign_DS = sps.erfinv(1-alpha_s/2.)*np.sqrt(2)", "#T_DS /= ref_sign_DS", "#sign_DS /= ref_sign_DS" ]
[ { "param": "quantiles", "type": null }, { "param": "alpha", "type": null }, { "param": "alpha_s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "quantiles", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "alpha", "type": null, "docstring": null, "docstring_toke...
2b5a5e3f81dc2726d5188056ec32b5f718f7ece2
davindicode/universal_count_model
neuroprob/utils/stats.py
[ "MIT" ]
Python
corr_lin_circ_Kempter
<not_specific>
def corr_lin_circ_Kempter(x, theta, a): """ Circular-linear correlation coefficient as defined by the following papers: :param numpy.array x: input array x of shape (samples,) :param numpy.array theta: input array theta of shape (samples,) :param float a: slope divided by 2pi References: ...
Circular-linear correlation coefficient as defined by the following papers: :param numpy.array x: input array x of shape (samples,) :param numpy.array theta: input array theta of shape (samples,) :param float a: slope divided by 2pi References: [1] Kempter et al. (2012) Note: phi and theta a...
Circular-linear correlation coefficient as defined by the following papers.
[ "Circular", "-", "linear", "correlation", "coefficient", "as", "defined", "by", "the", "following", "papers", "." ]
def corr_lin_circ_Kempter(x, theta, a): theta_bar = np.arctan2(np.sum(np.sin(theta)),np.sum(np.cos(theta))) phi = 2*np.pi*a*x % (2*np.pi) phi_bar = np.arctan2(np.sum(np.sin(phi)), np.sum(np.cos(phi))) num = np.sum(np.sin(theta - theta_bar) * np.sin(phi - phi_bar)) den = np.sqrt(np.sum(np.sin(theta -...
[ "def", "corr_lin_circ_Kempter", "(", "x", ",", "theta", ",", "a", ")", ":", "theta_bar", "=", "np", ".", "arctan2", "(", "np", ".", "sum", "(", "np", ".", "sin", "(", "theta", ")", ")", ",", "np", ".", "sum", "(", "np", ".", "cos", "(", "theta"...
Circular-linear correlation coefficient as defined by the following papers:
[ "Circular", "-", "linear", "correlation", "coefficient", "as", "defined", "by", "the", "following", "papers", ":" ]
[ "\"\"\"\n Circular-linear correlation coefficient as defined by the following papers:\n\n :param numpy.array x: input array x of shape (samples,)\n :param numpy.array theta: input array theta of shape (samples,)\n :param float a: slope divided by 2pi\n\n References:\n\n [1] Kempter et al. (2012) N...
[ { "param": "x", "type": null }, { "param": "theta", "type": null }, { "param": "a", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": null, "docstring": "input array x of shape (samples,)", "docstring_tokens": [ "input", "array", "x", "of", "shape", "(", "samples", ")" ], ...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
validate_model
null
def validate_model(self, likelihood_set=True): """ Checks model validity and consistency, after setting data. When setting up a model for sampling, call this method with likelihood_set depending on whether spike trains have been loaded (needed for sampling conditional processes...
Checks model validity and consistency, after setting data. When setting up a model for sampling, call this method with likelihood_set depending on whether spike trains have been loaded (needed for sampling conditional processes).
Checks model validity and consistency, after setting data. When setting up a model for sampling, call this method with likelihood_set depending on whether spike trains have been loaded (needed for sampling conditional processes).
[ "Checks", "model", "validity", "and", "consistency", "after", "setting", "data", ".", "When", "setting", "up", "a", "model", "for", "sampling", "call", "this", "method", "with", "likelihood_set", "depending", "on", "whether", "spike", "trains", "have", "been", ...
def validate_model(self, likelihood_set=True): if self.inputs.XZ is None: raise ValueError('Inputs object has not been set with data using .set_XZ()') if likelihood_set: if self.likelihood.spikes is None: raise ValueError('Likelihood object has not been set with d...
[ "def", "validate_model", "(", "self", ",", "likelihood_set", "=", "True", ")", ":", "if", "self", ".", "inputs", ".", "XZ", "is", "None", ":", "raise", "ValueError", "(", "'Inputs object has not been set with data using .set_XZ()'", ")", "if", "likelihood_set", ":...
Checks model validity and consistency, after setting data.
[ "Checks", "model", "validity", "and", "consistency", "after", "setting", "data", "." ]
[ "\"\"\"\n Checks model validity and consistency, after setting data.\n \n When setting up a model for sampling, call this method with likelihood_set depending on \n whether spike trains have been loaded (needed for sampling conditional processes).\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "likelihood_set", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "likelihood_set", "type": null, "docstring": null, "docstring_...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
constrain
null
def constrain(self): """ Constrain the optimization step, in particular constrain rate model parameters, stimulus history and spike history/coupling filters, the HMM parameters to the simplex. """ self.inputs.constrain() self.mapping.constrain() self.likelihood.c...
Constrain the optimization step, in particular constrain rate model parameters, stimulus history and spike history/coupling filters, the HMM parameters to the simplex.
Constrain the optimization step, in particular constrain rate model parameters, stimulus history and spike history/coupling filters, the HMM parameters to the simplex.
[ "Constrain", "the", "optimization", "step", "in", "particular", "constrain", "rate", "model", "parameters", "stimulus", "history", "and", "spike", "history", "/", "coupling", "filters", "the", "HMM", "parameters", "to", "the", "simplex", "." ]
def constrain(self): self.inputs.constrain() self.mapping.constrain() self.likelihood.constrain()
[ "def", "constrain", "(", "self", ")", ":", "self", ".", "inputs", ".", "constrain", "(", ")", "self", ".", "mapping", ".", "constrain", "(", ")", "self", ".", "likelihood", ".", "constrain", "(", ")" ]
Constrain the optimization step, in particular constrain rate model parameters, stimulus history and spike history/coupling filters, the HMM parameters to the simplex.
[ "Constrain", "the", "optimization", "step", "in", "particular", "constrain", "rate", "model", "parameters", "stimulus", "history", "and", "spike", "history", "/", "coupling", "filters", "the", "HMM", "parameters", "to", "the", "simplex", "." ]
[ "\"\"\"\n Constrain the optimization step, in particular constrain rate model parameters, stimulus history and spike \n history/coupling filters, the HMM parameters to the simplex.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
objective
<not_specific>
def objective(self, b, neuron=None, beta=1.0, beta_z=1.0, cov_samples=1, ll_samples=10, bound='ELBO', ll_mode='MC', lv_input=None): """ Compute the rate and then spike train log likelihood. Mapping prior is for SVGP the KL term in the variational ELBO. When rate output...
Compute the rate and then spike train log likelihood. Mapping prior is for SVGP the KL term in the variational ELBO. When rate output is deterministic (inner_var=0) the ll_samples parameter is irrelevant in the 'MC' in that case, where no sampling will occur. Note that MC is used for t...
Compute the rate and then spike train log likelihood. Mapping prior is for SVGP the KL term in the variational ELBO. When rate output is deterministic (inner_var=0) the ll_samples parameter is irrelevant in the 'MC' in that case, where no sampling will occur. Note that MC is used for the expectation over the latent var...
[ "Compute", "the", "rate", "and", "then", "spike", "train", "log", "likelihood", ".", "Mapping", "prior", "is", "for", "SVGP", "the", "KL", "term", "in", "the", "variational", "ELBO", ".", "When", "rate", "output", "is", "deterministic", "(", "inner_var", "...
def objective(self, b, neuron=None, beta=1.0, beta_z=1.0, cov_samples=1, ll_samples=10, bound='ELBO', ll_mode='MC', lv_input=None): if (bound != 'ELBO') and (bound != 'PLL') and (bound != 'IWAE'): raise ValueError('Bound parameter not known') entropy = False if bound == 'I...
[ "def", "objective", "(", "self", ",", "b", ",", "neuron", "=", "None", ",", "beta", "=", "1.0", ",", "beta_z", "=", "1.0", ",", "cov_samples", "=", "1", ",", "ll_samples", "=", "10", ",", "bound", "=", "'ELBO'", ",", "ll_mode", "=", "'MC'", ",", ...
Compute the rate and then spike train log likelihood.
[ "Compute", "the", "rate", "and", "then", "spike", "train", "log", "likelihood", "." ]
[ "\"\"\"\n Compute the rate and then spike train log likelihood.\n Mapping prior is for SVGP the KL term in the variational ELBO.\n When rate output is deterministic (inner_var=0) the ll_samples parameter is irrelevant in the \n 'MC' in that case, where no sampling will occur. Note that M...
[ { "param": "self", "type": null }, { "param": "b", "type": null }, { "param": "neuron", "type": null }, { "param": "beta", "type": null }, { "param": "beta_z", "type": null }, { "param": "cov_samples", "type": null }, { "param": "ll_samples...
{ "returns": [ { "docstring": "variational approximation to negative marginal log likelihood", "docstring_tokens": [ "variational", "approximation", "to", "negative", "marginal", "log", "likelihood" ], "type": "torch.tensor\nReference...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
evaluate
<not_specific>
def evaluate(self, batch, obs_neuron=None, cov_samples=1, ll_samples=1, ll_mode='MC', lv_input=None): """ Sample from the predictive posterior. Sample from the neural encoding model. Note when sampling the latent state (neuron=[], >1 HMM states), the likelihood module will be s...
Sample from the predictive posterior. Sample from the neural encoding model. Note when sampling the latent state (neuron=[], >1 HMM states), the likelihood module will be set with *preprocess()* and affects model fitting after calling this. .. note:: The model is eval...
Sample from the predictive posterior. Sample from the neural encoding model. Note when sampling the latent state (neuron=[], >1 HMM states), the likelihood module will be set with *preprocess()* and affects model fitting after calling this. : The model is evaluated with its variational posterior mean values, which is ...
[ "Sample", "from", "the", "predictive", "posterior", ".", "Sample", "from", "the", "neural", "encoding", "model", ".", "Note", "when", "sampling", "the", "latent", "state", "(", "neuron", "=", "[]", ">", "1", "HMM", "states", ")", "the", "likelihood", "modu...
def evaluate(self, batch, obs_neuron=None, cov_samples=1, ll_samples=1, ll_mode='MC', lv_input=None): with torch.no_grad(): XZ, _, _, _ = self.inputs.sample_XZ(batch, cov_samples, lv_input, False) timesteps = XZ.shape[1] obs_neuron = self.likelihood._validate_neuron(obs_neuro...
[ "def", "evaluate", "(", "self", ",", "batch", ",", "obs_neuron", "=", "None", ",", "cov_samples", "=", "1", ",", "ll_samples", "=", "1", ",", "ll_mode", "=", "'MC'", ",", "lv_input", "=", "None", ")", ":", "with", "torch", ".", "no_grad", "(", ")", ...
Sample from the predictive posterior.
[ "Sample", "from", "the", "predictive", "posterior", "." ]
[ "\"\"\"\n Sample from the predictive posterior.\n \n Sample from the neural encoding model. Note when sampling the latent state (neuron=[], >1 HMM states), \n the likelihood module will be set with *preprocess()* and affects model fitting after calling this.\n \n .. note:: ...
[ { "param": "self", "type": null }, { "param": "batch", "type": null }, { "param": "obs_neuron", "type": null }, { "param": "cov_samples", "type": null }, { "param": "ll_samples", "type": null }, { "param": "ll_mode", "type": null }, { "para...
{ "returns": [ { "docstring": "[samples, trial, neuron, timestep] of spiketrain generated, rate, hmm_state", "docstring_tokens": [ "[", "samples", "trial", "neuron", "timestep", "]", "of", "spiketrain", "generated", "rate"...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
fit
<not_specific>
def fit(self, max_epochs, margin_epochs=10, loss_margin=0.0, neuron=None, kl_anneal_func=None, z_anneal_func=None, retain_graph=False, cov_samples=1, ll_samples=1, bound='ELBO', ll_mode='MC', lv_input=None, callback=None): """ Can fit to all neurons present in the data (default)...
Can fit to all neurons present in the data (default), or fits only a subset of neurons. margin_epochs sets the early stop when the loss is still above lowest loss in given iterations. :param int max_epochs: maximum number of iterations over the dataset :param int margin_epochs:...
Can fit to all neurons present in the data (default), or fits only a subset of neurons. margin_epochs sets the early stop when the loss is still above lowest loss in given iterations.
[ "Can", "fit", "to", "all", "neurons", "present", "in", "the", "data", "(", "default", ")", "or", "fits", "only", "a", "subset", "of", "neurons", ".", "margin_epochs", "sets", "the", "early", "stop", "when", "the", "loss", "is", "still", "above", "lowest"...
def fit(self, max_epochs, margin_epochs=10, loss_margin=0.0, neuron=None, kl_anneal_func=None, z_anneal_func=None, retain_graph=False, cov_samples=1, ll_samples=1, bound='ELBO', ll_mode='MC', lv_input=None, callback=None): self.validate_model() batches = self.likelihood.batches ...
[ "def", "fit", "(", "self", ",", "max_epochs", ",", "margin_epochs", "=", "10", ",", "loss_margin", "=", "0.0", ",", "neuron", "=", "None", ",", "kl_anneal_func", "=", "None", ",", "z_anneal_func", "=", "None", ",", "retain_graph", "=", "False", ",", "cov...
Can fit to all neurons present in the data (default), or fits only a subset of neurons.
[ "Can", "fit", "to", "all", "neurons", "present", "in", "the", "data", "(", "default", ")", "or", "fits", "only", "a", "subset", "of", "neurons", "." ]
[ "\"\"\"\n Can fit to all neurons present in the data (default), or fits only a subset of neurons.\n margin_epochs sets the early stop when the loss is still above lowest loss in given iterations.\n \n :param int max_epochs: maximum number of iterations over the dataset\n :param in...
[ { "param": "self", "type": null }, { "param": "max_epochs", "type": null }, { "param": "margin_epochs", "type": null }, { "param": "loss_margin", "type": null }, { "param": "neuron", "type": null }, { "param": "kl_anneal_func", "type": null }, ...
{ "returns": [ { "docstring": "time series of loss during training", "docstring_tokens": [ "time", "series", "of", "loss", "during", "training" ], "type": "list" } ], "raises": [], "params": [ { "identifier": "self", ...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
VI_filtering
<not_specific>
def VI_filtering(model, ini_X, spikes, VI_steps, fitting_options, past_spikes=None): """ Decode causally taking into account covariate prior. In the most general case, treat model as LVM but fix the latent variables at all timesteps except the last and fit model with fixed tuning. Note filtering has t...
Decode causally taking into account covariate prior. In the most general case, treat model as LVM but fix the latent variables at all timesteps except the last and fit model with fixed tuning. Note filtering has to be done recursively, simultaneous inference of LVM is smoothing. Past covariate value...
Decode causally taking into account covariate prior. In the most general case, treat model as LVM but fix the latent variables at all timesteps except the last and fit model with fixed tuning. Note filtering has to be done recursively, simultaneous inference of LVM is smoothing. Past covariate values before the decodi...
[ "Decode", "causally", "taking", "into", "account", "covariate", "prior", ".", "In", "the", "most", "general", "case", "treat", "model", "as", "LVM", "but", "fix", "the", "latent", "variables", "at", "all", "timesteps", "except", "the", "last", "and", "fit", ...
def VI_filtering(model, ini_X, spikes, VI_steps, fitting_options, past_spikes=None): assert self.maps == 1 rc_t = np.concatenate((past_spikes, spikes), dim=-1) if past_spikes is not None else spikes decode_len = spikes.shape[-1] past_len = past_spikes.shape[-1] if past_spikes is not None else 0 res...
[ "def", "VI_filtering", "(", "model", ",", "ini_X", ",", "spikes", ",", "VI_steps", ",", "fitting_options", ",", "past_spikes", "=", "None", ")", ":", "assert", "self", ".", "maps", "==", "1", "rc_t", "=", "np", ".", "concatenate", "(", "(", "past_spikes"...
Decode causally taking into account covariate prior.
[ "Decode", "causally", "taking", "into", "account", "covariate", "prior", "." ]
[ "\"\"\"\n Decode causally taking into account covariate prior. In the most general case, treat model as LVM \n but fix the latent variables at all timesteps except the last and fit model with fixed tuning. Note \n filtering has to be done recursively, simultaneous inference of LVM is smoothing.\n\n Past...
[ { "param": "model", "type": null }, { "param": "ini_X", "type": null }, { "param": "spikes", "type": null }, { "param": "VI_steps", "type": null }, { "param": "fitting_options", "type": null }, { "param": "past_spikes", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ini_X", "type": null, "docstring": null, "docstring_tokens":...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
update
null
def update(self, eval_rate, activity, tbin): """ Use IPP likelihood for cognitive maps to assign weights TODO use NLL directly """ units = len(activity) fact = factorial(activity) w = 1. for u in range(units): rT = tbin*eval_rate[u]((self.sampl...
Use IPP likelihood for cognitive maps to assign weights TODO use NLL directly
Use IPP likelihood for cognitive maps to assign weights TODO use NLL directly
[ "Use", "IPP", "likelihood", "for", "cognitive", "maps", "to", "assign", "weights", "TODO", "use", "NLL", "directly" ]
def update(self, eval_rate, activity, tbin): units = len(activity) fact = factorial(activity) w = 1. for u in range(units): rT = tbin*eval_rate[u]((self.samples[:, 0], self.samples[:, 1], np.zeros_like(self.samples[:, 0]))) if activity[u] > 0: w *=...
[ "def", "update", "(", "self", ",", "eval_rate", ",", "activity", ",", "tbin", ")", ":", "units", "=", "len", "(", "activity", ")", "fact", "=", "factorial", "(", "activity", ")", "w", "=", "1.", "for", "u", "in", "range", "(", "units", ")", ":", ...
Use IPP likelihood for cognitive maps to assign weights TODO use NLL directly
[ "Use", "IPP", "likelihood", "for", "cognitive", "maps", "to", "assign", "weights", "TODO", "use", "NLL", "directly" ]
[ "\"\"\"\n Use IPP likelihood for cognitive maps to assign weights\n TODO use NLL directly\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "eval_rate", "type": null }, { "param": "activity", "type": null }, { "param": "tbin", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eval_rate", "type": null, "docstring": null, "docstring_token...
63e7a4d2dfc27fb1347c6262483a711a492ee89d
davindicode/universal_count_model
neuroprob/inference.py
[ "MIT" ]
Python
MCMC
<not_specific>
def MCMC(prob_model): """ Samples exact posterior samples from the probabilistic model, which has been fit with VI before. :param VI_optimized prob_model: the probabilistic model to sample from """ return
Samples exact posterior samples from the probabilistic model, which has been fit with VI before. :param VI_optimized prob_model: the probabilistic model to sample from
Samples exact posterior samples from the probabilistic model, which has been fit with VI before.
[ "Samples", "exact", "posterior", "samples", "from", "the", "probabilistic", "model", "which", "has", "been", "fit", "with", "VI", "before", "." ]
def MCMC(prob_model): return
[ "def", "MCMC", "(", "prob_model", ")", ":", "return" ]
Samples exact posterior samples from the probabilistic model, which has been fit with VI before.
[ "Samples", "exact", "posterior", "samples", "from", "the", "probabilistic", "model", "which", "has", "been", "fit", "with", "VI", "before", "." ]
[ "\"\"\"\n Samples exact posterior samples from the probabilistic model, which has been fit with VI before.\n \n :param VI_optimized prob_model: the probabilistic model to sample from\n \"\"\"" ]
[ { "param": "prob_model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "prob_model", "type": null, "docstring": "the probabilistic model to sample from", "docstring_tokens": [ "the", "probabilistic", "model", "to", "sample", "from" ], "de...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
compute_P
<not_specific>
def compute_P(full_model, covariates, show_neuron, MC=1000): """ Compute predictive count distribution given X. """ h = full_model.sample_F(covariates, MC, show_neuron) with torch.no_grad(): logp = full_model.likelihood.get_logp(h, show_neuron).data # samples, N, time, K P_mc = torch.exp...
Compute predictive count distribution given X.
Compute predictive count distribution given X.
[ "Compute", "predictive", "count", "distribution", "given", "X", "." ]
def compute_P(full_model, covariates, show_neuron, MC=1000): h = full_model.sample_F(covariates, MC, show_neuron) with torch.no_grad(): logp = full_model.likelihood.get_logp(h, show_neuron).data P_mc = torch.exp(logp) return P_mc
[ "def", "compute_P", "(", "full_model", ",", "covariates", ",", "show_neuron", ",", "MC", "=", "1000", ")", ":", "h", "=", "full_model", ".", "sample_F", "(", "covariates", ",", "MC", ",", "show_neuron", ")", "with", "torch", ".", "no_grad", "(", ")", "...
Compute predictive count distribution given X.
[ "Compute", "predictive", "count", "distribution", "given", "X", "." ]
[ "\"\"\"\n Compute predictive count distribution given X.\n \"\"\"", "# samples, N, time, K" ]
[ { "param": "full_model", "type": null }, { "param": "covariates", "type": null }, { "param": "show_neuron", "type": null }, { "param": "MC", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "full_model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "covariates", "type": null, "docstring": null, "docstrin...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
compute_pred_P
<not_specific>
def compute_pred_P(full_model, batch, use_neuron, ts, cov_samples=10, ll_samples=1, tr=0): """ Predictive posterior computed from model. """ _, h, _ = full_model.evaluate(batch, obs_neuron=None, cov_samples=cov_samples, ll_samples=ll_samples, ll_mode='MC', lv_input=No...
Predictive posterior computed from model.
Predictive posterior computed from model.
[ "Predictive", "posterior", "computed", "from", "model", "." ]
def compute_pred_P(full_model, batch, use_neuron, ts, cov_samples=10, ll_samples=1, tr=0): _, h, _ = full_model.evaluate(batch, obs_neuron=None, cov_samples=cov_samples, ll_samples=ll_samples, ll_mode='MC', lv_input=None) with torch.no_grad(): F_dims = full_model.like...
[ "def", "compute_pred_P", "(", "full_model", ",", "batch", ",", "use_neuron", ",", "ts", ",", "cov_samples", "=", "10", ",", "ll_samples", "=", "1", ",", "tr", "=", "0", ")", ":", "_", ",", "h", ",", "_", "=", "full_model", ".", "evaluate", "(", "ba...
Predictive posterior computed from model.
[ "Predictive", "posterior", "computed", "from", "model", "." ]
[ "\"\"\"\n Predictive posterior computed from model.\n \"\"\"", "# samples, N, time, K" ]
[ { "param": "full_model", "type": null }, { "param": "batch", "type": null }, { "param": "use_neuron", "type": null }, { "param": "ts", "type": null }, { "param": "cov_samples", "type": null }, { "param": "ll_samples", "type": null }, { "par...
{ "returns": [], "raises": [], "params": [ { "identifier": "full_model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "batch", "type": null, "docstring": null, "docstring_tok...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
marginalized_P
<not_specific>
def marginalized_P(full_model, eval_points, eval_dims, rcov, bs, use_neuron, MC=100, skip=1): """ Marginalize over the behaviour p(X) for X not evaluated over. """ rcov = [rc[::skip] for rc in rcov] # set dilution animal_T = rcov[0].shape[0] Ep = eval_points[0].shape[0] tot_len = Ep*animal_T...
Marginalize over the behaviour p(X) for X not evaluated over.
Marginalize over the behaviour p(X) for X not evaluated over.
[ "Marginalize", "over", "the", "behaviour", "p", "(", "X", ")", "for", "X", "not", "evaluated", "over", "." ]
def marginalized_P(full_model, eval_points, eval_dims, rcov, bs, use_neuron, MC=100, skip=1): rcov = [rc[::skip] for rc in rcov] animal_T = rcov[0].shape[0] Ep = eval_points[0].shape[0] tot_len = Ep*animal_T covariates = [] k = 0 for d, rc in enumerate(rcov): if d in eval_dims: ...
[ "def", "marginalized_P", "(", "full_model", ",", "eval_points", ",", "eval_dims", ",", "rcov", ",", "bs", ",", "use_neuron", ",", "MC", "=", "100", ",", "skip", "=", "1", ")", ":", "rcov", "=", "[", "rc", "[", ":", ":", "skip", "]", "for", "rc", ...
Marginalize over the behaviour p(X) for X not evaluated over.
[ "Marginalize", "over", "the", "behaviour", "p", "(", "X", ")", "for", "X", "not", "evaluated", "over", "." ]
[ "\"\"\"\n Marginalize over the behaviour p(X) for X not evaluated over.\n \"\"\"", "# set dilution" ]
[ { "param": "full_model", "type": null }, { "param": "eval_points", "type": null }, { "param": "eval_dims", "type": null }, { "param": "rcov", "type": null }, { "param": "bs", "type": null }, { "param": "use_neuron", "type": null }, { "param...
{ "returns": [], "raises": [], "params": [ { "identifier": "full_model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eval_points", "type": null, "docstring": null, "docstri...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
ind_to_pair
<not_specific>
def ind_to_pair(ind, N): """ Convert index (k,) to a pair index (i, j) for neural population correlation """ a = ind k = 1 while a >= 0: a -= (N-k) k += 1 n = k-1 m = N-n + a return n-1, m
Convert index (k,) to a pair index (i, j) for neural population correlation
Convert index (k,) to a pair index (i, j) for neural population correlation
[ "Convert", "index", "(", "k", ")", "to", "a", "pair", "index", "(", "i", "j", ")", "for", "neural", "population", "correlation" ]
def ind_to_pair(ind, N): a = ind k = 1 while a >= 0: a -= (N-k) k += 1 n = k-1 m = N-n + a return n-1, m
[ "def", "ind_to_pair", "(", "ind", ",", "N", ")", ":", "a", "=", "ind", "k", "=", "1", "while", "a", ">=", "0", ":", "a", "-=", "(", "N", "-", "k", ")", "k", "+=", "1", "n", "=", "k", "-", "1", "m", "=", "N", "-", "n", "+", "a", "retur...
Convert index (k,) to a pair index (i, j) for neural population correlation
[ "Convert", "index", "(", "k", ")", "to", "a", "pair", "index", "(", "i", "j", ")", "for", "neural", "population", "correlation" ]
[ "\"\"\"\n Convert index (k,) to a pair index (i, j) for neural population correlation\n \"\"\"" ]
[ { "param": "ind", "type": null }, { "param": "N", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ind", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": null, "docstring": null, "docstring_tokens": [], ...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
compute_count_stats
<not_specific>
def compute_count_stats(glm, ll_mode, tbin, spktrain, behav_list, neuron, traj_len=None, traj_spikes=None, start=0, T=100000, bs=5000): """ Compute the dispersion statistics, per neuron in a population. :param string mode: *single* mode refers to computing separate single neuron...
Compute the dispersion statistics, per neuron in a population. :param string mode: *single* mode refers to computing separate single neuron quantities, *population* mode refers to computing over a population indicated by neurons, *peer* mode involves the p...
Compute the dispersion statistics, per neuron in a population.
[ "Compute", "the", "dispersion", "statistics", "per", "neuron", "in", "a", "population", "." ]
def compute_count_stats(glm, ll_mode, tbin, spktrain, behav_list, neuron, traj_len=None, traj_spikes=None, start=0, T=100000, bs=5000): N = int(np.ceil(T/bs)) rate_model = [] shape_model = [] spktrain = spktrain[:, start:start+T] behav_list = [b[start:start+T] for b in behav_...
[ "def", "compute_count_stats", "(", "glm", ",", "ll_mode", ",", "tbin", ",", "spktrain", ",", "behav_list", ",", "neuron", ",", "traj_len", "=", "None", ",", "traj_spikes", "=", "None", ",", "start", "=", "0", ",", "T", "=", "100000", ",", "bs", "=", ...
Compute the dispersion statistics, per neuron in a population.
[ "Compute", "the", "dispersion", "statistics", "per", "neuron", "in", "a", "population", "." ]
[ "\"\"\"\n Compute the dispersion statistics, per neuron in a population.\n \n :param string mode: *single* mode refers to computing separate single neuron quantities, *population* mode \n refers to computing over a population indicated by neurons, *peer* mode involves the \n ...
[ { "param": "glm", "type": null }, { "param": "ll_mode", "type": null }, { "param": "tbin", "type": null }, { "param": "spktrain", "type": null }, { "param": "behav_list", "type": null }, { "param": "neuron", "type": null }, { "param": "traj...
{ "returns": [], "raises": [], "params": [ { "identifier": "glm", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ll_mode", "type": null, "docstring": null, "docstring_tokens":...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
RG_pred_ll
<not_specific>
def RG_pred_ll(model, r_mode, cov_used, cv_set, neuron_group=None, ll_mode='GH', ll_samples=100, cov_samples=1, beta=1.0, bound='ELBO'): """ Compute the predictive log likelihood (ELBO). """ ftrain, fcov, vtrain, vcov = cv_set time_steps = vtrain.shape[-1] vcov = cov_used(r_...
Compute the predictive log likelihood (ELBO).
Compute the predictive log likelihood (ELBO).
[ "Compute", "the", "predictive", "log", "likelihood", "(", "ELBO", ")", "." ]
def RG_pred_ll(model, r_mode, cov_used, cv_set, neuron_group=None, ll_mode='GH', ll_samples=100, cov_samples=1, beta=1.0, bound='ELBO'): ftrain, fcov, vtrain, vcov = cv_set time_steps = vtrain.shape[-1] vcov = cov_used(r_mode, vcov) model.inputs.set_XZ(vcov, time_steps, batch_size=time_s...
[ "def", "RG_pred_ll", "(", "model", ",", "r_mode", ",", "cov_used", ",", "cv_set", ",", "neuron_group", "=", "None", ",", "ll_mode", "=", "'GH'", ",", "ll_samples", "=", "100", ",", "cov_samples", "=", "1", ",", "beta", "=", "1.0", ",", "bound", "=", ...
Compute the predictive log likelihood (ELBO).
[ "Compute", "the", "predictive", "log", "likelihood", "(", "ELBO", ")", "." ]
[ "\"\"\"\n Compute the predictive log likelihood (ELBO).\n \"\"\"" ]
[ { "param": "model", "type": null }, { "param": "r_mode", "type": null }, { "param": "cov_used", "type": null }, { "param": "cv_set", "type": null }, { "param": "neuron_group", "type": null }, { "param": "ll_mode", "type": null }, { "param":...
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r_mode", "type": null, "docstring": null, "docstring_tokens"...
1bfd22fb1849bce3b32ba39424f6dbe1f507264d
davindicode/universal_count_model
scripts/model_utils.py
[ "MIT" ]
Python
LVM_pred_ll
<not_specific>
def LVM_pred_ll(model, z_dims, mode, cov_used, cv_set, f_neuron, v_neuron, eval_cov_MC=1, eval_ll_MC=100, eval_ll_mode='GH', cov_MC=16, ll_MC=1, ll_mode='MC', beta=1.0, beta_z=1.0, bound='ELBO', max_iters=3000): """ Compute the predictive log likelihood (ELBO). """ ftrain, fcov, vtrain,...
Compute the predictive log likelihood (ELBO).
Compute the predictive log likelihood (ELBO).
[ "Compute", "the", "predictive", "log", "likelihood", "(", "ELBO", ")", "." ]
def LVM_pred_ll(model, z_dims, mode, cov_used, cv_set, f_neuron, v_neuron, eval_cov_MC=1, eval_ll_MC=100, eval_ll_mode='GH', cov_MC=16, ll_MC=1, ll_mode='MC', beta=1.0, beta_z=1.0, bound='ELBO', max_iters=3000): ftrain, fcov, vtrain, vcov = cv_set time_steps = vtrain.shape[-1] vcov = cov_us...
[ "def", "LVM_pred_ll", "(", "model", ",", "z_dims", ",", "mode", ",", "cov_used", ",", "cv_set", ",", "f_neuron", ",", "v_neuron", ",", "eval_cov_MC", "=", "1", ",", "eval_ll_MC", "=", "100", ",", "eval_ll_mode", "=", "'GH'", ",", "cov_MC", "=", "16", "...
Compute the predictive log likelihood (ELBO).
[ "Compute", "the", "predictive", "log", "likelihood", "(", "ELBO", ")", "." ]
[ "\"\"\"\n Compute the predictive log likelihood (ELBO).\n \"\"\"", "# fit", "#min(1.0, 0.002*x)" ]
[ { "param": "model", "type": null }, { "param": "z_dims", "type": null }, { "param": "mode", "type": null }, { "param": "cov_used", "type": null }, { "param": "cv_set", "type": null }, { "param": "f_neuron", "type": null }, { "param": "v_neu...
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "z_dims", "type": null, "docstring": null, "docstring_tokens"...
0dc8200fe79faa8c813c4fbe1ddc5f25ea7f3991
NelisW/cqMore
cqmore/polyhedron.py
[ "Apache-2.0" ]
Python
tetrahedron
Polyhedron
def tetrahedron(radius: float, detail: int = 0) -> Polyhedron: ''' Create a tetrahedron. ## Parameters - `radius`: radius of the tetrahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a tetrahedron. ## Examples from cqmore.polyhedron import...
Create a tetrahedron. ## Parameters - `radius`: radius of the tetrahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a tetrahedron. ## Examples from cqmore.polyhedron import tetrahedron from cqmore import Workplane radius = 1 ...
Create a tetrahedron. Parameters `radius`: radius of the tetrahedron. `detail`: setting this to a value greater than 0 adds vertices making it no longer a tetrahedron. Examples from cqmore.polyhedron import tetrahedron from cqmore import Workplane
[ "Create", "a", "tetrahedron", ".", "Parameters", "`", "radius", "`", ":", "radius", "of", "the", "tetrahedron", ".", "`", "detail", "`", ":", "setting", "this", "to", "a", "value", "greater", "than", "0", "adds", "vertices", "making", "it", "no", "longer...
def tetrahedron(radius: float, detail: int = 0) -> Polyhedron: vectors = ( Vector(1, 1, 1), Vector(-1, -1, 1), Vector(-1, 1, -1), Vector(1, -1, -1) ) faces = ( (2, 1, 0), (0, 3, 2), (1, 3, 0), (2, 3, 1) ) return _divide_project(vectors, faces, radius, detail)
[ "def", "tetrahedron", "(", "radius", ":", "float", ",", "detail", ":", "int", "=", "0", ")", "->", "Polyhedron", ":", "vectors", "=", "(", "Vector", "(", "1", ",", "1", ",", "1", ")", ",", "Vector", "(", "-", "1", ",", "-", "1", ",", "1", ")"...
Create a tetrahedron.
[ "Create", "a", "tetrahedron", "." ]
[ "'''\n Create a tetrahedron.\n\n ## Parameters\n\n - `radius`: radius of the tetrahedron.\n - `detail`: setting this to a value greater than 0 adds vertices making it no longer a tetrahedron.\n\n ## Examples \n\n from cqmore.polyhedron import tetrahedron\n from cqmore import Workplane\n...
[ { "param": "radius", "type": "float" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "radius", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_to...
0dc8200fe79faa8c813c4fbe1ddc5f25ea7f3991
NelisW/cqMore
cqmore/polyhedron.py
[ "Apache-2.0" ]
Python
hexahedron
Polyhedron
def hexahedron(radius: float, detail: int = 0) -> Polyhedron: ''' Create a hexahedron. ## Parameters - `radius`: radius of the hexahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a hexahedron. ## Examples from cqmore.polyhedron import hex...
Create a hexahedron. ## Parameters - `radius`: radius of the hexahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a hexahedron. ## Examples from cqmore.polyhedron import hexahedron from cqmore import Workplane radius = 1 ...
Create a hexahedron. Parameters `radius`: radius of the hexahedron. `detail`: setting this to a value greater than 0 adds vertices making it no longer a hexahedron. Examples from cqmore.polyhedron import hexahedron from cqmore import Workplane
[ "Create", "a", "hexahedron", ".", "Parameters", "`", "radius", "`", ":", "radius", "of", "the", "hexahedron", ".", "`", "detail", "`", ":", "setting", "this", "to", "a", "value", "greater", "than", "0", "adds", "vertices", "making", "it", "no", "longer",...
def hexahedron(radius: float, detail: int = 0) -> Polyhedron: t = 1 / (3 ** 0.5) vectors = ( Vector(t, t, t), Vector(-t, t, t), Vector(-t, -t, t), Vector(t, -t, t), Vector(t, t, -t), Vector(-t, t, -t), Vector(-t, -t, -t), Vector(t, -t, -t) ) faces = ( (3, 7, 0), (7, 4, 0), ...
[ "def", "hexahedron", "(", "radius", ":", "float", ",", "detail", ":", "int", "=", "0", ")", "->", "Polyhedron", ":", "t", "=", "1", "/", "(", "3", "**", "0.5", ")", "vectors", "=", "(", "Vector", "(", "t", ",", "t", ",", "t", ")", ",", "Vecto...
Create a hexahedron.
[ "Create", "a", "hexahedron", "." ]
[ "'''\n Create a hexahedron.\n\n ## Parameters\n\n - `radius`: radius of the hexahedron.\n - `detail`: setting this to a value greater than 0 adds vertices making it no longer a hexahedron.\n\n ## Examples \n\n from cqmore.polyhedron import hexahedron\n from cqmore import Workplane\n\n ...
[ { "param": "radius", "type": "float" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "radius", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_to...
0dc8200fe79faa8c813c4fbe1ddc5f25ea7f3991
NelisW/cqMore
cqmore/polyhedron.py
[ "Apache-2.0" ]
Python
octahedron
Polyhedron
def octahedron(radius: float, detail: int = 0) -> Polyhedron: ''' Create a octahedron. ## Parameters - `radius`: radius of the octahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a octahedron. ## Examples from cqmore.polyhedron import oct...
Create a octahedron. ## Parameters - `radius`: radius of the octahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a octahedron. ## Examples from cqmore.polyhedron import octahedron from cqmore import Workplane radius = 1 ...
Create a octahedron. Parameters `radius`: radius of the octahedron. `detail`: setting this to a value greater than 0 adds vertices making it no longer a octahedron. Examples from cqmore.polyhedron import octahedron from cqmore import Workplane
[ "Create", "a", "octahedron", ".", "Parameters", "`", "radius", "`", ":", "radius", "of", "the", "octahedron", ".", "`", "detail", "`", ":", "setting", "this", "to", "a", "value", "greater", "than", "0", "adds", "vertices", "making", "it", "no", "longer",...
def octahedron(radius: float, detail: int = 0) -> Polyhedron: vectors = ( Vector(1, 0, 0), Vector(-1, 0, 0), Vector(0, 1, 0), Vector(0, -1, 0), Vector(0, 0, 1), Vector(0, 0, -1) ) faces = ( (0, 2, 4), (0, 4, 3), (0, 3, 5), (0, 5, 2), (1, 2, 5), (1, 5, 3), (1, 3...
[ "def", "octahedron", "(", "radius", ":", "float", ",", "detail", ":", "int", "=", "0", ")", "->", "Polyhedron", ":", "vectors", "=", "(", "Vector", "(", "1", ",", "0", ",", "0", ")", ",", "Vector", "(", "-", "1", ",", "0", ",", "0", ")", ",",...
Create a octahedron.
[ "Create", "a", "octahedron", "." ]
[ "'''\n Create a octahedron.\n\n ## Parameters\n\n - `radius`: radius of the octahedron.\n - `detail`: setting this to a value greater than 0 adds vertices making it no longer a octahedron.\n\n ## Examples \n\n from cqmore.polyhedron import octahedron\n from cqmore import Workplane\n\n ...
[ { "param": "radius", "type": "float" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "radius", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_to...
0dc8200fe79faa8c813c4fbe1ddc5f25ea7f3991
NelisW/cqMore
cqmore/polyhedron.py
[ "Apache-2.0" ]
Python
dodecahedron
Polyhedron
def dodecahedron(radius: float, detail: int = 0) -> Polyhedron: ''' Create a dodecahedron. ## Parameters - `radius`: radius of the dodecahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron. ## Examples from cqmore.polyhedron im...
Create a dodecahedron. ## Parameters - `radius`: radius of the dodecahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron. ## Examples from cqmore.polyhedron import dodecahedron from cqmore import Workplane radius ...
Create a dodecahedron. Parameters `radius`: radius of the dodecahedron. `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron. Examples from cqmore.polyhedron import dodecahedron from cqmore import Workplane
[ "Create", "a", "dodecahedron", ".", "Parameters", "`", "radius", "`", ":", "radius", "of", "the", "dodecahedron", ".", "`", "detail", "`", ":", "setting", "this", "to", "a", "value", "greater", "than", "0", "adds", "vertices", "making", "it", "no", "long...
def dodecahedron(radius: float, detail: int = 0) -> Polyhedron: t = (1 + 5 ** 0.5) / 2 r = 1 / t vectors = ( Vector(-1, -1, -1), Vector(-1, -1, 1), Vector(-1, 1, -1), Vector(-1, 1, 1), Vector(1, -1, -1), Vector(1, -1, 1), Vector(1, 1, -1), Vector(1, 1, 1), Vector(0, -...
[ "def", "dodecahedron", "(", "radius", ":", "float", ",", "detail", ":", "int", "=", "0", ")", "->", "Polyhedron", ":", "t", "=", "(", "1", "+", "5", "**", "0.5", ")", "/", "2", "r", "=", "1", "/", "t", "vectors", "=", "(", "Vector", "(", "-",...
Create a dodecahedron.
[ "Create", "a", "dodecahedron", "." ]
[ "'''\n Create a dodecahedron.\n\n ## Parameters\n\n - `radius`: radius of the dodecahedron.\n - `detail`: setting this to a value greater than 0 adds vertices making it no longer a dodecahedron.\n\n ## Examples \n\n from cqmore.polyhedron import dodecahedron\n from cqmore import Workpla...
[ { "param": "radius", "type": "float" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "radius", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_to...
0dc8200fe79faa8c813c4fbe1ddc5f25ea7f3991
NelisW/cqMore
cqmore/polyhedron.py
[ "Apache-2.0" ]
Python
icosahedron
Polyhedron
def icosahedron(radius: float, detail: int = 0) -> Polyhedron: ''' Create a icosahedron. ## Parameters - `radius`: radius of the icosahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a icosahedron. ## Examples from cqmore.polyhedron import...
Create a icosahedron. ## Parameters - `radius`: radius of the icosahedron. - `detail`: setting this to a value greater than 0 adds vertices making it no longer a icosahedron. ## Examples from cqmore.polyhedron import icosahedron from cqmore import Workplane radius = 1 ...
Create a icosahedron. Parameters `radius`: radius of the icosahedron. `detail`: setting this to a value greater than 0 adds vertices making it no longer a icosahedron. Examples from cqmore.polyhedron import icosahedron from cqmore import Workplane
[ "Create", "a", "icosahedron", ".", "Parameters", "`", "radius", "`", ":", "radius", "of", "the", "icosahedron", ".", "`", "detail", "`", ":", "setting", "this", "to", "a", "value", "greater", "than", "0", "adds", "vertices", "making", "it", "no", "longer...
def icosahedron(radius: float, detail: int = 0) -> Polyhedron: t = (1 + 5 ** 0.5) / 2 vectors = ( Vector(-1, t, 0), Vector(1, t, 0), Vector(- 1, -t, 0), Vector(1, -t, 0), Vector(0, -1, t), Vector(0, 1, t), Vector(0, -1, -t), Vector(0, 1, -t), Vector(t, 0, -1), Vector(t, 0, 1), Vector(-t...
[ "def", "icosahedron", "(", "radius", ":", "float", ",", "detail", ":", "int", "=", "0", ")", "->", "Polyhedron", ":", "t", "=", "(", "1", "+", "5", "**", "0.5", ")", "/", "2", "vectors", "=", "(", "Vector", "(", "-", "1", ",", "t", ",", "0", ...
Create a icosahedron.
[ "Create", "a", "icosahedron", "." ]
[ "'''\n Create a icosahedron.\n\n ## Parameters\n\n - `radius`: radius of the icosahedron.\n - `detail`: setting this to a value greater than 0 adds vertices making it no longer a icosahedron.\n\n ## Examples \n\n from cqmore.polyhedron import icosahedron\n from cqmore import Workplane\n...
[ { "param": "radius", "type": "float" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "radius", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_to...
b4a37e45d05ba7cd0d7e6e225a1b8c97f84d9f57
jgcasta/lostatnight
get_images.py
[ "CC-BY-4.0" ]
Python
skip_bad_lines
<not_specific>
def skip_bad_lines(self, str_vals, ncols): """Simply ignore every line with the wrong number of columns.""" print 'Skipping line:', ' '.join(str_vals) return None
Simply ignore every line with the wrong number of columns.
Simply ignore every line with the wrong number of columns.
[ "Simply", "ignore", "every", "line", "with", "the", "wrong", "number", "of", "columns", "." ]
def skip_bad_lines(self, str_vals, ncols): print 'Skipping line:', ' '.join(str_vals) return None
[ "def", "skip_bad_lines", "(", "self", ",", "str_vals", ",", "ncols", ")", ":", "print", "'Skipping line:'", ",", "' '", ".", "join", "(", "str_vals", ")", "return", "None" ]
Simply ignore every line with the wrong number of columns.
[ "Simply", "ignore", "every", "line", "with", "the", "wrong", "number", "of", "columns", "." ]
[ "\"\"\"Simply ignore every line with the wrong number of columns.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "str_vals", "type": null }, { "param": "ncols", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str_vals", "type": null, "docstring": null, "docstring_tokens...
99652e280dfed98ab9e4131b0db17562b0fcc62d
jgcasta/lostatnight
createTasks.py
[ "CC-BY-4.0" ]
Python
format_error
null
def format_error(module, error): """Format the error for the given module""" logging.error(module) # Beautify JSON error if type(error) == list: print "Application not found" else: print json.dumps(error, sort_keys=True, indent=4, separators=(',', ': ')) ...
Format the error for the given module
Format the error for the given module
[ "Format", "the", "error", "for", "the", "given", "module" ]
def format_error(module, error): logging.error(module) if type(error) == list: print "Application not found" else: print json.dumps(error, sort_keys=True, indent=4, separators=(',', ': ')) exit(1)
[ "def", "format_error", "(", "module", ",", "error", ")", ":", "logging", ".", "error", "(", "module", ")", "if", "type", "(", "error", ")", "==", "list", ":", "print", "\"Application not found\"", "else", ":", "print", "json", ".", "dumps", "(", "error",...
Format the error for the given module
[ "Format", "the", "error", "for", "the", "given", "module" ]
[ "\"\"\"Format the error for the given module\"\"\"", "# Beautify JSON error" ]
[ { "param": "module", "type": null }, { "param": "error", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "module", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "error", "type": null, "docstring": null, "docstring_tokens"...
c3ebe5ea21ba7a9f2f391e9293bd5ded5fb27732
koursaros-ai/sentence-transformers
sentence_transformers/BiSentenceTransformer.py
[ "Apache-2.0" ]
Python
fit
null
def fit(self, train_objective: Tuple[DataLoader, nn.Module], evaluator: SentenceEvaluator, epochs: int = 1, scheduler: str = 'WarmupLinear', warmup_steps: int = 10000, optimizer_class: Type[Optimizer] = pytorch_transformers.AdamW, optim...
Train the model with the given training objective Each training objective is sampled in turn for one batch. We sample only as many batches from each objective as there are in the smallest one to make sure of equal training with each dataset. :param weight_decay: :param...
Train the model with the given training objective Each training objective is sampled in turn for one batch. We sample only as many batches from each objective as there are in the smallest one to make sure of equal training with each dataset.
[ "Train", "the", "model", "with", "the", "given", "training", "objective", "Each", "training", "objective", "is", "sampled", "in", "turn", "for", "one", "batch", ".", "We", "sample", "only", "as", "many", "batches", "from", "each", "objective", "as", "there",...
def fit(self, train_objective: Tuple[DataLoader, nn.Module], evaluator: SentenceEvaluator, epochs: int = 1, scheduler: str = 'WarmupLinear', warmup_steps: int = 10000, optimizer_class: Type[Optimizer] = pytorch_transformers.AdamW, optim...
[ "def", "fit", "(", "self", ",", "train_objective", ":", "Tuple", "[", "DataLoader", ",", "nn", ".", "Module", "]", ",", "evaluator", ":", "SentenceEvaluator", ",", "epochs", ":", "int", "=", "1", ",", "scheduler", ":", "str", "=", "'WarmupLinear'", ",", ...
Train the model with the given training objective Each training objective is sampled in turn for one batch.
[ "Train", "the", "model", "with", "the", "given", "training", "objective", "Each", "training", "objective", "is", "sampled", "in", "turn", "for", "one", "batch", "." ]
[ "\"\"\"\n Train the model with the given training objective\n\n Each training objective is sampled in turn for one batch.\n We sample only as many batches from each objective as there are in the smallest one\n to make sure of equal training with each dataset.\n\n :param weight_dec...
[ { "param": "self", "type": null }, { "param": "train_objective", "type": "Tuple[DataLoader, nn.Module]" }, { "param": "evaluator", "type": "SentenceEvaluator" }, { "param": "epochs", "type": "int" }, { "param": "scheduler", "type": "str" }, { "param": ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "train_objective", "type": "Tuple[DataLoader, nn.Module]", "docstrin...
302fd28868c90419975b81bdff7869c68c0516d7
apasanen/sklearn-porter
setup.py
[ "MIT" ]
Python
parse_requirements
<not_specific>
def parse_requirements(): """Parse the modules from requirements.txt""" src_dir = os.path.abspath(os.path.dirname(__file__)) req_file = os.path.join(src_dir, 'requirements.txt') reqs = open(req_file, 'r').read().strip().split('\n') reqs = [req.strip() for req in reqs if 'git+' not in req] return...
Parse the modules from requirements.txt
Parse the modules from requirements.txt
[ "Parse", "the", "modules", "from", "requirements", ".", "txt" ]
def parse_requirements(): src_dir = os.path.abspath(os.path.dirname(__file__)) req_file = os.path.join(src_dir, 'requirements.txt') reqs = open(req_file, 'r').read().strip().split('\n') reqs = [req.strip() for req in reqs if 'git+' not in req] return reqs
[ "def", "parse_requirements", "(", ")", ":", "src_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "req_file", "=", "os", ".", "path", ".", "join", "(", "src_dir", ",", "'requirements.txt'"...
Parse the modules from requirements.txt
[ "Parse", "the", "modules", "from", "requirements", ".", "txt" ]
[ "\"\"\"Parse the modules from requirements.txt\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
new
Res
async def new( method: str, url: str, **kwargs ) -> Res: """ Create a request **kwargs are the extra arguments of aiohttp.request """ async with request( method = method, url = url, **kwargs ) as ...
Create a request **kwargs are the extra arguments of aiohttp.request
Create a request kwargs are the extra arguments of aiohttp.request
[ "Create", "a", "request", "kwargs", "are", "the", "extra", "arguments", "of", "aiohttp", ".", "request" ]
async def new( method: str, url: str, **kwargs ) -> Res: async with request( method = method, url = url, **kwargs ) as res: return await Res._make(res)
[ "async", "def", "new", "(", "method", ":", "str", ",", "url", ":", "str", ",", "**", "kwargs", ")", "->", "Res", ":", "async", "with", "request", "(", "method", "=", "method", ",", "url", "=", "url", ",", "**", "kwargs", ")", "as", "res", ":", ...
Create a request kwargs are the extra arguments of aiohttp.request
[ "Create", "a", "request", "kwargs", "are", "the", "extra", "arguments", "of", "aiohttp", ".", "request" ]
[ "\"\"\"\n Create a request\n\n **kwargs are the extra arguments of aiohttp.request\n \"\"\"" ]
[ { "param": "method", "type": "str" }, { "param": "url", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "method", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "url", "type": "str", "docstring": null, "docstring_tokens"...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
_req
Res
async def _req( method: str, url: str, data: dict[str, Any] | None = None, need_dumps: bool = True ) -> Res: """ Create a request for the amino api Headers are automatically inserted into the request #### need_dumps If need use ujson.dumps on the d...
Create a request for the amino api Headers are automatically inserted into the request #### need_dumps If need use ujson.dumps on the data
Create a request for the amino api Headers are automatically inserted into the request need_dumps If need use ujson.dumps on the data
[ "Create", "a", "request", "for", "the", "amino", "api", "Headers", "are", "automatically", "inserted", "into", "the", "request", "need_dumps", "If", "need", "use", "ujson", ".", "dumps", "on", "the", "data" ]
async def _req( method: str, url: str, data: dict[str, Any] | None = None, need_dumps: bool = True ) -> Res: res = await Req.new( method = method, url = API + url, data = dumps(data) if need_dumps else data, headers = headers ...
[ "async", "def", "_req", "(", "method", ":", "str", ",", "url", ":", "str", ",", "data", ":", "dict", "[", "str", ",", "Any", "]", "|", "None", "=", "None", ",", "need_dumps", ":", "bool", "=", "True", ")", "->", "Res", ":", "res", "=", "await",...
Create a request for the amino api Headers are automatically inserted into the request
[ "Create", "a", "request", "for", "the", "amino", "api", "Headers", "are", "automatically", "inserted", "into", "the", "request" ]
[ "\"\"\"\n Create a request for the amino api\n\n Headers are automatically inserted into the request\n\n #### need_dumps\n If need use ujson.dumps on the data\n \"\"\"" ]
[ { "param": "method", "type": "str" }, { "param": "url", "type": "str" }, { "param": "data", "type": "dict[str, Any] | None" }, { "param": "need_dumps", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "method", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "url", "type": "str", "docstring": null, "docstring_tokens"...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
upload_media
str
async def upload_media(file: str) -> str: """ Send a file to be used when posting a blog Returns the file link """ return ( await _req( 'post', '/g/s/media/upload', await File.get(file), False, ) ).json['mediaValue']
Send a file to be used when posting a blog Returns the file link
Send a file to be used when posting a blog Returns the file link
[ "Send", "a", "file", "to", "be", "used", "when", "posting", "a", "blog", "Returns", "the", "file", "link" ]
async def upload_media(file: str) -> str: return ( await _req( 'post', '/g/s/media/upload', await File.get(file), False, ) ).json['mediaValue']
[ "async", "def", "upload_media", "(", "file", ":", "str", ")", "->", "str", ":", "return", "(", "await", "_req", "(", "'post'", ",", "'/g/s/media/upload'", ",", "await", "File", ".", "get", "(", "file", ")", ",", "False", ",", ")", ")", ".", "json", ...
Send a file to be used when posting a blog Returns the file link
[ "Send", "a", "file", "to", "be", "used", "when", "posting", "a", "blog", "Returns", "the", "file", "link" ]
[ "\"\"\"\n Send a file to be used when posting a blog\n\n Returns the file link\n \"\"\"" ]
[ { "param": "file", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
upload_chat_bg
str
async def upload_chat_bg(file: str) -> str: """ Send a file to be used as chat background Returns the file link """ return ( await _req( 'post', 'g/s/media/upload/target/chat-background', await File.get(file), False, ) ).json['med...
Send a file to be used as chat background Returns the file link
Send a file to be used as chat background Returns the file link
[ "Send", "a", "file", "to", "be", "used", "as", "chat", "background", "Returns", "the", "file", "link" ]
async def upload_chat_bg(file: str) -> str: return ( await _req( 'post', 'g/s/media/upload/target/chat-background', await File.get(file), False, ) ).json['mediaValue']
[ "async", "def", "upload_chat_bg", "(", "file", ":", "str", ")", "->", "str", ":", "return", "(", "await", "_req", "(", "'post'", ",", "'g/s/media/upload/target/chat-background'", ",", "await", "File", ".", "get", "(", "file", ")", ",", "False", ",", ")", ...
Send a file to be used as chat background Returns the file link
[ "Send", "a", "file", "to", "be", "used", "as", "chat", "background", "Returns", "the", "file", "link" ]
[ "\"\"\"\n Send a file to be used as chat background\n\n Returns the file link\n \"\"\"" ]
[ { "param": "file", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
upload_chat_icon
str
async def upload_chat_icon(file: str) -> str: """ Send a file to be used as chat icon Returns the file link """ return ( await _req( 'post', 'g/s/media/upload/target/chat-cover', await File.get(file), False, ) ).json['mediaValue']
Send a file to be used as chat icon Returns the file link
Send a file to be used as chat icon Returns the file link
[ "Send", "a", "file", "to", "be", "used", "as", "chat", "icon", "Returns", "the", "file", "link" ]
async def upload_chat_icon(file: str) -> str: return ( await _req( 'post', 'g/s/media/upload/target/chat-cover', await File.get(file), False, ) ).json['mediaValue']
[ "async", "def", "upload_chat_icon", "(", "file", ":", "str", ")", "->", "str", ":", "return", "(", "await", "_req", "(", "'post'", ",", "'g/s/media/upload/target/chat-cover'", ",", "await", "File", ".", "get", "(", "file", ")", ",", "False", ",", ")", ")...
Send a file to be used as chat icon Returns the file link
[ "Send", "a", "file", "to", "be", "used", "as", "chat", "icon", "Returns", "the", "file", "link" ]
[ "\"\"\"\n Send a file to be used as chat icon\n\n Returns the file link\n \"\"\"" ]
[ { "param": "file", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
from_ws
Msg
def from_ws(self, j: Dict[str, Any]) -> Msg: """ Returns a Msg containing the information from the websocket message Update actual_com and actual_chat with the chat and community of the message received """ global actual_chat, actual_com actual_chat = get_value...
Returns a Msg containing the information from the websocket message Update actual_com and actual_chat with the chat and community of the message received
Returns a Msg containing the information from the websocket message Update actual_com and actual_chat with the chat and community of the message received
[ "Returns", "a", "Msg", "containing", "the", "information", "from", "the", "websocket", "message", "Update", "actual_com", "and", "actual_chat", "with", "the", "chat", "and", "community", "of", "the", "message", "received" ]
def from_ws(self, j: Dict[str, Any]) -> Msg: global actual_chat, actual_com actual_chat = get_value(j, 'chatMessage', 'threadId', convert=str) actual_com = get_value(j, 'ndcId', convert=str) return Msg._make(j)
[ "def", "from_ws", "(", "self", ",", "j", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Msg", ":", "global", "actual_chat", ",", "actual_com", "actual_chat", "=", "get_value", "(", "j", ",", "'chatMessage'", ",", "'threadId'", ",", "convert", "=...
Returns a Msg containing the information from the websocket message Update actual_com and actual_chat with the chat and community of the message received
[ "Returns", "a", "Msg", "containing", "the", "information", "from", "the", "websocket", "message", "Update", "actual_com", "and", "actual_chat", "with", "the", "chat", "and", "community", "of", "the", "message", "received" ]
[ "\"\"\"\n Returns a Msg containing the information from the websocket message\n \n Update actual_com and actual_chat with the chat and community of the message received\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "j", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "j", "type": "Dict[str, Any]", "docstring": null, "docstring_t...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
from_chat
ChatMsg
def from_chat(self, j: Dict[str, Any]) -> ChatMsg: """ Returns a ChatMsg containing information from Chat.messages messages """ return ChatMsg._make(j)
Returns a ChatMsg containing information from Chat.messages messages
Returns a ChatMsg containing information from Chat.messages messages
[ "Returns", "a", "ChatMsg", "containing", "information", "from", "Chat", ".", "messages", "messages" ]
def from_chat(self, j: Dict[str, Any]) -> ChatMsg: return ChatMsg._make(j)
[ "def", "from_chat", "(", "self", ",", "j", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "ChatMsg", ":", "return", "ChatMsg", ".", "_make", "(", "j", ")" ]
Returns a ChatMsg containing information from Chat.messages messages
[ "Returns", "a", "ChatMsg", "containing", "information", "from", "Chat", ".", "messages", "messages" ]
[ "\"\"\"\n Returns a ChatMsg containing information from Chat.messages messages\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "j", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "j", "type": "Dict[str, Any]", "docstring": null, "docstring_t...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
msg
list[Dict[str, Any]]
async def msg( type: int, msgs: list[str], reply: Reply ) -> list[Dict[str, Any]]: """ Creates the data for sending a message """ return [ {'type': type, 'content': i, 'replyMessageId': reply} ...
Creates the data for sending a message
Creates the data for sending a message
[ "Creates", "the", "data", "for", "sending", "a", "message" ]
async def msg( type: int, msgs: list[str], reply: Reply ) -> list[Dict[str, Any]]: return [ {'type': type, 'content': i, 'replyMessageId': reply} if reply else {'type': type, 'content': i} for i in ...
[ "async", "def", "msg", "(", "type", ":", "int", ",", "msgs", ":", "list", "[", "str", "]", ",", "reply", ":", "Reply", ")", "->", "list", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "[", "{", "'type'", ":", "type", ",", "'co...
Creates the data for sending a message
[ "Creates", "the", "data", "for", "sending", "a", "message" ]
[ "\"\"\"\n Creates the data for sending a message\n \"\"\"" ]
[ { "param": "type", "type": "int" }, { "param": "msgs", "type": "list[str]" }, { "param": "reply", "type": "Reply" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msgs", "type": "list[str]", "docstring": null, "docstring_to...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
file
list[Dict[str, Any]]
async def file(files: list[str | bytes]) -> list[Dict[str, Any]]: """ Creates the data for sending a file """ return [await File.process(i) for i in files]
Creates the data for sending a file
Creates the data for sending a file
[ "Creates", "the", "data", "for", "sending", "a", "file" ]
async def file(files: list[str | bytes]) -> list[Dict[str, Any]]: return [await File.process(i) for i in files]
[ "async", "def", "file", "(", "files", ":", "list", "[", "str", "|", "bytes", "]", ")", "->", "list", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "[", "await", "File", ".", "process", "(", "i", ")", "for", "i", "in", "files", ...
Creates the data for sending a file
[ "Creates", "the", "data", "for", "sending", "a", "file" ]
[ "\"\"\"\n Creates the data for sending a file\n \"\"\"" ]
[ { "param": "files", "type": "list[str | bytes]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "files", "type": "list[str | bytes]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
embed
list[Dict[str, Any]]
async def embed(embed: Embed) -> list[Dict[str, Any]]: """ Creates the data for sending a embed """ if embed.image: embed.image = [[100, await upload_media(embed.image), None]] return [ { 'content': embed.ms...
Creates the data for sending a embed
Creates the data for sending a embed
[ "Creates", "the", "data", "for", "sending", "a", "embed" ]
async def embed(embed: Embed) -> list[Dict[str, Any]]: if embed.image: embed.image = [[100, await upload_media(embed.image), None]] return [ { 'content': embed.msg_text, 'attachedObject': { 'link': ...
[ "async", "def", "embed", "(", "embed", ":", "Embed", ")", "->", "list", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "if", "embed", ".", "image", ":", "embed", ".", "image", "=", "[", "[", "100", ",", "await", "upload_media", "(", "embed",...
Creates the data for sending a embed
[ "Creates", "the", "data", "for", "sending", "a", "embed" ]
[ "\"\"\"\n Creates the data for sending a embed\n \"\"\"" ]
[ { "param": "embed", "type": "Embed" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "embed", "type": "Embed", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
send
Res | list[Res]
async def send( self, *msgs: list[str], files: str | list[str] | None = None, type_: int | None = 0, embed: Embed | None = None, reply: str | None = None, com: str | None = None, chat: str | None...
Send a message, file, embed or reply #### reply Message id to reply
Send a message, file, embed or reply reply Message id to reply
[ "Send", "a", "message", "file", "embed", "or", "reply", "reply", "Message", "id", "to", "reply" ]
async def send( self, *msgs: list[str], files: str | list[str] | None = None, type_: int | None = 0, embed: Embed | None = None, reply: str | None = None, com: str | None = None, chat: str | None...
[ "async", "def", "send", "(", "self", ",", "*", "msgs", ":", "list", "[", "str", "]", ",", "files", ":", "str", "|", "list", "[", "str", "]", "|", "None", "=", "None", ",", "type_", ":", "int", "|", "None", "=", "0", ",", "embed", ":", "Embed"...
Send a message, file, embed or reply reply
[ "Send", "a", "message", "file", "embed", "or", "reply", "reply" ]
[ "\"\"\"\n Send a message, file, embed or reply\n\n #### reply\n\n Message id to reply\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "msgs", "type": "list[str]" }, { "param": "files", "type": "str | list[str] | None" }, { "param": "type_", "type": "int | None" }, { "param": "embed", "type": "Embed | None" }, { "param": "reply", "...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msgs", "type": "list[str]", "docstring": null, "docstring_tok...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
search
DataUser | list[DataUser]
async def search( uids: str | list[str], com: str | None = None ) -> DataUser | list[DataUser]: """ Get profile information for a community user """ com = com or actual_com uids = to_list(uids) async def foo(uid: str) -> DataUser: return...
Get profile information for a community user
Get profile information for a community user
[ "Get", "profile", "information", "for", "a", "community", "user" ]
async def search( uids: str | list[str], com: str | None = None ) -> DataUser | list[DataUser]: com = com or actual_com uids = to_list(uids) async def foo(uid: str) -> DataUser: return DataUser._make((await _req('get', f'x{com}/s/user-profile/{uid}')).json['userP...
[ "async", "def", "search", "(", "uids", ":", "str", "|", "list", "[", "str", "]", ",", "com", ":", "str", "|", "None", "=", "None", ")", "->", "DataUser", "|", "list", "[", "DataUser", "]", ":", "com", "=", "com", "or", "actual_com", "uids", "=", ...
Get profile information for a community user
[ "Get", "profile", "information", "for", "a", "community", "user" ]
[ "\"\"\"\n Get profile information for a community user\n \"\"\"" ]
[ { "param": "uids", "type": "str | list[str]" }, { "param": "com", "type": "str | None" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uids", "type": "str | list[str]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "com", "type": "str | None", "docstring": null, "...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
type
Literal[MediaType.LINK, MediaType.BYTES, MediaType.PATH]
def type(file: str | bytes) -> Literal[MediaType.LINK, MediaType.BYTES, MediaType.PATH]: """ Checks whether the file is a link, bytes or path """ if isinstance(file, str) and file.startswith('http'): return MediaType.LINK if isinstance(file, bytes): retu...
Checks whether the file is a link, bytes or path
Checks whether the file is a link, bytes or path
[ "Checks", "whether", "the", "file", "is", "a", "link", "bytes", "or", "path" ]
def type(file: str | bytes) -> Literal[MediaType.LINK, MediaType.BYTES, MediaType.PATH]: if isinstance(file, str) and file.startswith('http'): return MediaType.LINK if isinstance(file, bytes): return MediaType.BYTES return MediaType.PATH
[ "def", "type", "(", "file", ":", "str", "|", "bytes", ")", "->", "Literal", "[", "MediaType", ".", "LINK", ",", "MediaType", ".", "BYTES", ",", "MediaType", ".", "PATH", "]", ":", "if", "isinstance", "(", "file", ",", "str", ")", "and", "file", "."...
Checks whether the file is a link, bytes or path
[ "Checks", "whether", "the", "file", "is", "a", "link", "bytes", "or", "path" ]
[ "\"\"\"\n Checks whether the file is a link, bytes or path\n \"\"\"" ]
[ { "param": "file", "type": "str | bytes" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "str | bytes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
change_co_hosts
Res | list[Res]
async def change_co_hosts( add: list[str] | str | None = None, remove: list[str] | str | None = None, com: str | None = None, chat: str | None = None ) -> Res | list[Res]: """ Add or remove co-hosts """ com = com or actual_com chat = c...
Add or remove co-hosts
Add or remove co-hosts
[ "Add", "or", "remove", "co", "-", "hosts" ]
async def change_co_hosts( add: list[str] | str | None = None, remove: list[str] | str | None = None, com: str | None = None, chat: str | None = None ) -> Res | list[Res]: com = com or actual_com chat = chat or actual_chat add = to_list(add) if...
[ "async", "def", "change_co_hosts", "(", "add", ":", "list", "[", "str", "]", "|", "str", "|", "None", "=", "None", ",", "remove", ":", "list", "[", "str", "]", "|", "str", "|", "None", "=", "None", ",", "com", ":", "str", "|", "None", "=", "Non...
Add or remove co-hosts
[ "Add", "or", "remove", "co", "-", "hosts" ]
[ "\"\"\"\n Add or remove co-hosts\n \"\"\"" ]
[ { "param": "add", "type": "list[str] | str | None" }, { "param": "remove", "type": "list[str] | str | None" }, { "param": "com", "type": "str | None" }, { "param": "chat", "type": "str | None" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "add", "type": "list[str] | str | None", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "remove", "type": "list[str] | str | None", "docs...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
save
None
async def save(filename: str | None = None) -> None: """ Saves all information from a chat to a .json """ chat = await Chat.search() info = { 'name': chat.name, 'text': chat.text, 'announcement': chat.announcement, 'bg': chat.bg, ...
Saves all information from a chat to a .json
Saves all information from a chat to a .json
[ "Saves", "all", "information", "from", "a", "chat", "to", "a", ".", "json" ]
async def save(filename: str | None = None) -> None: chat = await Chat.search() info = { 'name': chat.name, 'text': chat.text, 'announcement': chat.announcement, 'bg': chat.bg, 'icon': chat.icon, 'adm': chat.adm, 'co_hos...
[ "async", "def", "save", "(", "filename", ":", "str", "|", "None", "=", "None", ")", "->", "None", ":", "chat", "=", "await", "Chat", ".", "search", "(", ")", "info", "=", "{", "'name'", ":", "chat", ".", "name", ",", "'text'", ":", "chat", ".", ...
Saves all information from a chat to a .json
[ "Saves", "all", "information", "from", "a", "chat", "to", "a", ".", "json" ]
[ "\"\"\"\n Saves all information from a chat to a .json\n \"\"\"" ]
[ { "param": "filename", "type": "str | None" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "str | None", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
load
str
async def load(filename: str) -> str: """ Creates a chat containing the .json information created by Chat.save The name will be a uuid4 in the beginning for the program to identify the chat that was created, after that it will change to the correct name """ with open(fi...
Creates a chat containing the .json information created by Chat.save The name will be a uuid4 in the beginning for the program to identify the chat that was created, after that it will change to the correct name
Creates a chat containing the .json information created by Chat.save The name will be a uuid4 in the beginning for the program to identify the chat that was created, after that it will change to the correct name
[ "Creates", "a", "chat", "containing", "the", ".", "json", "information", "created", "by", "Chat", ".", "save", "The", "name", "will", "be", "a", "uuid4", "in", "the", "beginning", "for", "the", "program", "to", "identify", "the", "chat", "that", "was", "...
async def load(filename: str) -> str: with open(filename, 'r') as f: f = load(f) tmp_chat_name = str(uuid4()) await Chat.create( name = tmp_chat_name, text = f['text'], bg = f['bg'], icon = f['i...
[ "async", "def", "load", "(", "filename", ":", "str", ")", "->", "str", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "f", "=", "load", "(", "f", ")", "tmp_chat_name", "=", "str", "(", "uuid4", "(", ")", ")", "await", "C...
Creates a chat containing the .json information created by Chat.save The name will be a uuid4 in the beginning for the program to identify the chat that was created, after that it will change to the correct name
[ "Creates", "a", "chat", "containing", "the", ".", "json", "information", "created", "by", "Chat", ".", "save", "The", "name", "will", "be", "a", "uuid4", "in", "the", "beginning", "for", "the", "program", "to", "identify", "the", "chat", "that", "was", "...
[ "\"\"\"\n Creates a chat containing the .json information created by Chat.save\n\n The name will be a uuid4 in the beginning for the program to identify the chat that was created,\n after that it will change to the correct name\n \"\"\"" ]
[ { "param": "filename", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
chats
dict[str, list[DataChat]]
async def chats( need_print: bool = False, ignore_ascii: bool = False, com: str | None = None ) -> dict[str, list[DataChat]]: """ Returns the chats that you are in the community ### need_print Print the chats in a readable form ...
Returns the chats that you are in the community ### need_print Print the chats in a readable form ### ignore_ascii Removes special characters, which can disrupt the need_print
Returns the chats that you are in the community need_print Print the chats in a readable form ignore_ascii Removes special characters, which can disrupt the need_print
[ "Returns", "the", "chats", "that", "you", "are", "in", "the", "community", "need_print", "Print", "the", "chats", "in", "a", "readable", "form", "ignore_ascii", "Removes", "special", "characters", "which", "can", "disrupt", "the", "need_print" ]
async def chats( need_print: bool = False, ignore_ascii: bool = False, com: str | None = None ) -> dict[str, list[DataChat]]: if not (com := to_list(com or actual_com)): raise EmptyCom('Enter a com or send a message in a chat') async def foo...
[ "async", "def", "chats", "(", "need_print", ":", "bool", "=", "False", ",", "ignore_ascii", ":", "bool", "=", "False", ",", "com", ":", "str", "|", "None", "=", "None", ")", "->", "dict", "[", "str", ",", "list", "[", "DataChat", "]", "]", ":", "...
Returns the chats that you are in the community need_print Print the chats in a readable form
[ "Returns", "the", "chats", "that", "you", "are", "in", "the", "community", "need_print", "Print", "the", "chats", "in", "a", "readable", "form" ]
[ "\"\"\"\n Returns the chats that you are in the community\n\n ### need_print\n Print the chats in a readable form\n\n ### ignore_ascii\n Removes special characters, which can disrupt the need_print\n \"\"\"" ]
[ { "param": "need_print", "type": "bool" }, { "param": "ignore_ascii", "type": "bool" }, { "param": "com", "type": "str | None" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "need_print", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ignore_ascii", "type": "bool", "docstring": null, "do...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
staff
Dict[list[Dict[str, str]]]
async def staff(com=None) -> Dict[list[Dict[str, str]]]: """ Returns a dictionary containing community leaders and curators """ if not (com := com or actual_com): raise EmptyCom('Enter a com or send a message in a chat') leaders = [{'nickname': i['nickname'], 'uid'...
Returns a dictionary containing community leaders and curators
Returns a dictionary containing community leaders and curators
[ "Returns", "a", "dictionary", "containing", "community", "leaders", "and", "curators" ]
async def staff(com=None) -> Dict[list[Dict[str, str]]]: if not (com := com or actual_com): raise EmptyCom('Enter a com or send a message in a chat') leaders = [{'nickname': i['nickname'], 'uid': i['uid']} for i in (await _req('get', f'x{com}/s/user-profile?type=leaders&start=0&size=100'))....
[ "async", "def", "staff", "(", "com", "=", "None", ")", "->", "Dict", "[", "list", "[", "Dict", "[", "str", ",", "str", "]", "]", "]", ":", "if", "not", "(", "com", ":=", "com", "or", "actual_com", ")", ":", "raise", "EmptyCom", "(", "'Enter a com...
Returns a dictionary containing community leaders and curators
[ "Returns", "a", "dictionary", "containing", "community", "leaders", "and", "curators" ]
[ "\"\"\"\n Returns a dictionary containing community leaders and curators\n \"\"\"" ]
[ { "param": "com", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "com", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
chats
dict[str, list[str, list[str]]]
async def chats( need_print: bool = False, ignore_ascii: bool = False ) -> dict[str, list[str, list[str]]]: """ Returns chats in which you are from all communities ### need_print Print the chats in a readable form ### ignore_ascii Removes special c...
Returns chats in which you are from all communities ### need_print Print the chats in a readable form ### ignore_ascii Removes special characters, which can disrupt the need_print
Returns chats in which you are from all communities need_print Print the chats in a readable form ignore_ascii Removes special characters, which can disrupt the need_print
[ "Returns", "chats", "in", "which", "you", "are", "from", "all", "communities", "need_print", "Print", "the", "chats", "in", "a", "readable", "form", "ignore_ascii", "Removes", "special", "characters", "which", "can", "disrupt", "the", "need_print" ]
async def chats( need_print: bool = False, ignore_ascii: bool = False ) -> dict[str, list[str, list[str]]]: res = await _req('get', 'g/s/community/joined?v=1&start=0&size=50') coms = {str(i['ndcId']): [i['name'], []] for i in res.json['communityList']} async def foo(i): ...
[ "async", "def", "chats", "(", "need_print", ":", "bool", "=", "False", ",", "ignore_ascii", ":", "bool", "=", "False", ")", "->", "dict", "[", "str", ",", "list", "[", "str", ",", "list", "[", "str", "]", "]", "]", ":", "res", "=", "await", "_req...
Returns chats in which you are from all communities need_print Print the chats in a readable form
[ "Returns", "chats", "in", "which", "you", "are", "from", "all", "communities", "need_print", "Print", "the", "chats", "in", "a", "readable", "form" ]
[ "\"\"\"\n Returns chats in which you are from all communities\n\n ### need_print\n Print the chats in a readable form\n\n ### ignore_ascii\n Removes special characters, which can disrupt the need_print\n \"\"\"" ]
[ { "param": "need_print", "type": "bool" }, { "param": "ignore_ascii", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "need_print", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ignore_ascii", "type": "bool", "docstring": null, "do...
a4a3bb8a30301895947dd5bdff4bf191d2edab43
ellandor/Amsync
amsync/obj.py
[ "MIT" ]
Python
communities
dict[str, str]
async def communities( need_print: bool = False, ignore_ascii: bool = False ) -> dict[str, str]: """ Returns all the communities you are in ### need_print Print the chats in a readable form ### ignore_ascii Removes special characters, which can dis...
Returns all the communities you are in ### need_print Print the chats in a readable form ### ignore_ascii Removes special characters, which can disrupt the need_print
Returns all the communities you are in need_print Print the chats in a readable form ignore_ascii Removes special characters, which can disrupt the need_print
[ "Returns", "all", "the", "communities", "you", "are", "in", "need_print", "Print", "the", "chats", "in", "a", "readable", "form", "ignore_ascii", "Removes", "special", "characters", "which", "can", "disrupt", "the", "need_print" ]
async def communities( need_print: bool = False, ignore_ascii: bool = False ) -> dict[str, str]: res = await _req('get', f'g/s/community/joined?v=1&start=0&size=100') coms = { i['name'] if not ignore_ascii else fix_ascii(i['name']): str(i['ndcId'...
[ "async", "def", "communities", "(", "need_print", ":", "bool", "=", "False", ",", "ignore_ascii", ":", "bool", "=", "False", ")", "->", "dict", "[", "str", ",", "str", "]", ":", "res", "=", "await", "_req", "(", "'get'", ",", "f'g/s/community/joined?v=1&...
Returns all the communities you are in need_print Print the chats in a readable form
[ "Returns", "all", "the", "communities", "you", "are", "in", "need_print", "Print", "the", "chats", "in", "a", "readable", "form" ]
[ "\"\"\"\n Returns all the communities you are in\n\n ### need_print\n Print the chats in a readable form\n\n ### ignore_ascii\n Removes special characters, which can disrupt the need_print\n \"\"\"" ]
[ { "param": "need_print", "type": "bool" }, { "param": "ignore_ascii", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "need_print", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ignore_ascii", "type": "bool", "docstring": null, "do...
9707cbdeb1203c09604b7a8b1f41342222289c88
andrewwbutler/resume
generate.py
[ "MIT" ]
Python
main
null
def main(): """Parse command line arguments and process actions.""" # Parse the command line arguments parser = argparse.ArgumentParser( description='Generates HTML, LaTeX, and Markdown resumes from data in ' 'YAML files.') parser.add_argument( 'yamls', metavar='YAML_FILE', nargs...
Parse command line arguments and process actions.
Parse command line arguments and process actions.
[ "Parse", "command", "line", "arguments", "and", "process", "actions", "." ]
def main(): parser = argparse.ArgumentParser( description='Generates HTML, LaTeX, and Markdown resumes from data in ' 'YAML files.') parser.add_argument( 'yamls', metavar='YAML_FILE', nargs='+', help='the YAML files that contain the resume details, in order of ' 'inc...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Generates HTML, LaTeX, and Markdown resumes from data in '", "'YAML files.'", ")", "parser", ".", "add_argument", "(", "'yamls'", ",", "metavar", "=", "'YAML_FIL...
Parse command line arguments and process actions.
[ "Parse", "command", "line", "arguments", "and", "process", "actions", "." ]
[ "\"\"\"Parse command line arguments and process actions.\"\"\"", "# Parse the command line arguments", "# Sub into the publications section as its items, if they don't exist", "# Remove the publications section if it exists and has no items" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
display
null
def display(self): """Displays the visualization. Calls the Bokeh methods to make the application start. Note the server actually renders the GUI in the browser. Returns: None""" curdoc().add_root(self.tabs) curdoc().title = 'UT330BUI'
Displays the visualization. Calls the Bokeh methods to make the application start. Note the server actually renders the GUI in the browser. Returns: None
Displays the visualization. Calls the Bokeh methods to make the application start. Note the server actually renders the GUI in the browser.
[ "Displays", "the", "visualization", ".", "Calls", "the", "Bokeh", "methods", "to", "make", "the", "application", "start", ".", "Note", "the", "server", "actually", "renders", "the", "GUI", "in", "the", "browser", "." ]
def display(self): curdoc().add_root(self.tabs) curdoc().title = 'UT330BUI'
[ "def", "display", "(", "self", ")", ":", "curdoc", "(", ")", ".", "add_root", "(", "self", ".", "tabs", ")", "curdoc", "(", ")", ".", "title", "=", "'UT330BUI'" ]
Displays the visualization.
[ "Displays", "the", "visualization", "." ]
[ "\"\"\"Displays the visualization. Calls the Bokeh methods to make the\n application start. Note the server actually renders the GUI in the\n browser.\n Returns:\n None\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
erase
<not_specific>
def erase(self): """Erases data from UT330B device.""" if not self.connected: self.status = ("Cannot erase UT330B data because " "the UT330B is not connected.") self.update() return try: self.UT330B.delete_data(...
Erases data from UT330B device.
Erases data from UT330B device.
[ "Erases", "data", "from", "UT330B", "device", "." ]
def erase(self): if not self.connected: self.status = ("Cannot erase UT330B data because " "the UT330B is not connected.") self.update() return try: self.UT330B.delete_data() self.status = "Data erased from UT330B." ...
[ "def", "erase", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot erase UT330B data because \"", "\"the UT330B is not connected.\"", ")", "self", ".", "update", "(", ")", "return", "try", ":", "self",...
Erases data from UT330B device.
[ "Erases", "data", "from", "UT330B", "device", "." ]
[ "\"\"\"Erases data from UT330B device.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
read_data
<not_specific>
def read_data(self): """Reads data from UT330B device.""" if not self.connected: self.status = ("Cannot read UT330B data because the UT330B is " "not connected.") self.update() return self.status = ("Reading UT330B data. This may t...
Reads data from UT330B device.
Reads data from UT330B device.
[ "Reads", "data", "from", "UT330B", "device", "." ]
def read_data(self): if not self.connected: self.status = ("Cannot read UT330B data because the UT330B is " "not connected.") self.update() return self.status = ("Reading UT330B data. This may take some time " "if ther...
[ "def", "read_data", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot read UT330B data because the UT330B is \"", "\"not connected.\"", ")", "self", ".", "update", "(", ")", "return", "self", ".", "st...
Reads data from UT330B device.
[ "Reads", "data", "from", "UT330B", "device", "." ]
[ "\"\"\"Reads data from UT330B device.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
read_config
<not_specific>
def read_config(self): """Reads config from UT330B device.""" if not self.connected: self.status = ("Cannot read UT330B configuration because " "the UT330B is not connected.") self.update() return try: self.devi...
Reads config from UT330B device.
Reads config from UT330B device.
[ "Reads", "config", "from", "UT330B", "device", "." ]
def read_config(self): if not self.connected: self.status = ("Cannot read UT330B configuration because " "the UT330B is not connected.") self.update() return try: self.device_config = self.UT330B.read_config() self.st...
[ "def", "read_config", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot read UT330B configuration because \"", "\"the UT330B is not connected.\"", ")", "self", ".", "update", "(", ")", "return", "try", ...
Reads config from UT330B device.
[ "Reads", "config", "from", "UT330B", "device", "." ]
[ "\"\"\"Reads config from UT330B device.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
write_config
<not_specific>
def write_config(self, config): """Writes config data to UT330B device.""" if not self.connected: self.status = ("Cannot write UT330B configuration because " "the UT330B is not connected.") self.update() return try: se...
Writes config data to UT330B device.
Writes config data to UT330B device.
[ "Writes", "config", "data", "to", "UT330B", "device", "." ]
def write_config(self, config): if not self.connected: self.status = ("Cannot write UT330B configuration because " "the UT330B is not connected.") self.update() return try: self.UT330B.write_config(config) self.status...
[ "def", "write_config", "(", "self", ",", "config", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot write UT330B configuration because \"", "\"the UT330B is not connected.\"", ")", "self", ".", "update", "(", ")", ...
Writes config data to UT330B device.
[ "Writes", "config", "data", "to", "UT330B", "device", "." ]
[ "\"\"\"Writes config data to UT330B device.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "config", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config", "type": null, "docstring": null, "docstring_tokens":...
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
read_offsets
<not_specific>
def read_offsets(self): """Reads offsets from UT330B device.""" if not self.connected: self.status = ("Cannot read UT330B offsets because " "the UT330B is not connected.") self.update() return try: self.device_offsets =...
Reads offsets from UT330B device.
Reads offsets from UT330B device.
[ "Reads", "offsets", "from", "UT330B", "device", "." ]
def read_offsets(self): if not self.connected: self.status = ("Cannot read UT330B offsets because " "the UT330B is not connected.") self.update() return try: self.device_offsets = self.UT330B.read_offsets() self.statu...
[ "def", "read_offsets", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot read UT330B offsets because \"", "\"the UT330B is not connected.\"", ")", "self", ".", "update", "(", ")", "return", "try", ":", ...
Reads offsets from UT330B device.
[ "Reads", "offsets", "from", "UT330B", "device", "." ]
[ "\"\"\"Reads offsets from UT330B device.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
052ee8eefb4de8830f2e623d89904586975ab923
duncanbarth/UT330B
UT330BUI/controller/controller.py
[ "MIT" ]
Python
write_offsets
<not_specific>
def write_offsets(self, offsets): """Writes config data to UT330B device.""" if not self.connected: self.status = ("Cannot write UT330B offsets because " "the UT330B is not connected.") self.update() return try: ...
Writes config data to UT330B device.
Writes config data to UT330B device.
[ "Writes", "config", "data", "to", "UT330B", "device", "." ]
def write_offsets(self, offsets): if not self.connected: self.status = ("Cannot write UT330B offsets because " "the UT330B is not connected.") self.update() return try: self.UT330B.write_offsets(offsets) self.status =...
[ "def", "write_offsets", "(", "self", ",", "offsets", ")", ":", "if", "not", "self", ".", "connected", ":", "self", ".", "status", "=", "(", "\"Cannot write UT330B offsets because \"", "\"the UT330B is not connected.\"", ")", "self", ".", "update", "(", ")", "ret...
Writes config data to UT330B device.
[ "Writes", "config", "data", "to", "UT330B", "device", "." ]
[ "\"\"\"Writes config data to UT330B device.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "offsets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offsets", "type": null, "docstring": null, "docstring_tokens"...
dabd60813d69906fe775a5f15b5e5a7a29c26106
duncanbarth/UT330B
UT330BUI/view/readsave.py
[ "MIT" ]
Python
callback_write_to_disk
<not_specific>
def callback_write_to_disk(self): """Callback method for Write to disk""" df = pd.DataFrame(self.controller.device_data) if df.empty: self.status.text = ("Can't write data to UT330B because " "there's no data to write.") return d...
Callback method for Write to disk
Callback method for Write to disk
[ "Callback", "method", "for", "Write", "to", "disk" ]
def callback_write_to_disk(self): df = pd.DataFrame(self.controller.device_data) if df.empty: self.status.text = ("Can't write data to UT330B because " "there's no data to write.") return df['Timestamp'] = pd.to_datetime(df['Timestamp']) ...
[ "def", "callback_write_to_disk", "(", "self", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "self", ".", "controller", ".", "device_data", ")", "if", "df", ".", "empty", ":", "self", ".", "status", ".", "text", "=", "(", "\"Can't write data to UT330B b...
Callback method for Write to disk
[ "Callback", "method", "for", "Write", "to", "disk" ]
[ "\"\"\"Callback method for Write to disk\"\"\"", "# Check folder exists, if not, create it " ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
buffer_safety
<not_specific>
def buffer_safety(func): """There can be timing errors where a read takes place when the buffer is either partially written or not written at all. These errors can be removed by a short pause of 10ms. This function decorator makes sure there's at least 10ms between calls.""" def buffer_protection(...
There can be timing errors where a read takes place when the buffer is either partially written or not written at all. These errors can be removed by a short pause of 10ms. This function decorator makes sure there's at least 10ms between calls.
There can be timing errors where a read takes place when the buffer is either partially written or not written at all. These errors can be removed by a short pause of 10ms. This function decorator makes sure there's at least 10ms between calls.
[ "There", "can", "be", "timing", "errors", "where", "a", "read", "takes", "place", "when", "the", "buffer", "is", "either", "partially", "written", "or", "not", "written", "at", "all", ".", "These", "errors", "can", "be", "removed", "by", "a", "short", "p...
def buffer_safety(func): def buffer_protection(self, argument=None): if datetime.datetime.now() - self.last_op_time \ < datetime.timedelta(0, 0, 10000): time.sleep(0.01) if argument is None: data = func(self) else: data = func(self, argument) ...
[ "def", "buffer_safety", "(", "func", ")", ":", "def", "buffer_protection", "(", "self", ",", "argument", "=", "None", ")", ":", "if", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "self", ".", "last_op_time", "<", "datetime", ".", "timedelta", ...
There can be timing errors where a read takes place when the buffer is either partially written or not written at all.
[ "There", "can", "be", "timing", "errors", "where", "a", "read", "takes", "place", "when", "the", "buffer", "is", "either", "partially", "written", "or", "not", "written", "at", "all", "." ]
[ "\"\"\"There can be timing errors where a read takes place when the buffer\n is either partially written or not written at all. These errors can be\n removed by a short pause of 10ms. This function decorator makes sure\n there's at least 10ms between calls.\"\"\"", "# If we're less than 10ms since the la...
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
modbusCRC
<not_specific>
def modbusCRC(data): """Returns the Modbus CRC as two bytes. Be careful of the order.""" # If the contnets of the data list are not all integers, this function # will have problems. Future action is to check all elements are ints crc = 0xFFFF for number in data: crc = (crc >> 8) ^ TABLE[...
Returns the Modbus CRC as two bytes. Be careful of the order.
Returns the Modbus CRC as two bytes. Be careful of the order.
[ "Returns", "the", "Modbus", "CRC", "as", "two", "bytes", ".", "Be", "careful", "of", "the", "order", "." ]
def modbusCRC(data): crc = 0xFFFF for number in data: crc = (crc >> 8) ^ TABLE[(crc ^ number) & 0xFF] MSB = crc >> 8 LSB = crc & 255 return MSB, LSB
[ "def", "modbusCRC", "(", "data", ")", ":", "crc", "=", "0xFFFF", "for", "number", "in", "data", ":", "crc", "=", "(", "crc", ">>", "8", ")", "^", "TABLE", "[", "(", "crc", "^", "number", ")", "&", "0xFF", "]", "MSB", "=", "crc", ">>", "8", "L...
Returns the Modbus CRC as two bytes.
[ "Returns", "the", "Modbus", "CRC", "as", "two", "bytes", "." ]
[ "\"\"\"Returns the Modbus CRC as two bytes. Be careful of the order.\"\"\"", "# If the contnets of the data list are not all integers, this function", "# will have problems. Future action is to check all elements are ints", "# Most Significant Byte", "# Least Significant Byte" ]
[ { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
connect
null
def connect(self): """Connects to the device or raises an error""" # Get the port the device is connected to # --------------------------------------- port = None # Get all the serial ports port_list = serial.tools.list_ports.comports() serial.tools.list_ports....
Connects to the device or raises an error
Connects to the device or raises an error
[ "Connects", "to", "the", "device", "or", "raises", "an", "error" ]
def connect(self): port = None port_list = serial.tools.list_ports.comports() serial.tools.list_ports.comports for trial in port_list: if trial.vid == 4292 and trial.pid == 60000: port = trial if port is None: raise IOError('Error! The UT33...
[ "def", "connect", "(", "self", ")", ":", "port", "=", "None", "port_list", "=", "serial", ".", "tools", ".", "list_ports", ".", "comports", "(", ")", "serial", ".", "tools", ".", "list_ports", ".", "comports", "for", "trial", "in", "port_list", ":", "i...
Connects to the device or raises an error
[ "Connects", "to", "the", "device", "or", "raises", "an", "error" ]
[ "\"\"\"Connects to the device or raises an error\"\"\"", "# Get the port the device is connected to", "# ---------------------------------------", "# Get all the serial ports", "# Now find which port has our device", "# I'm not sure this is specific enough for general use. It may", "# give a false repor...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
_read_buffer
null
def _read_buffer(self, byte_count): """Reads the contents of the buffer and returns it as an integer list. """ # If the page_size is set much larger than this number we tend # to get problems with partially filled buffers page_size = 32768 self._buffer = [] # ...
Reads the contents of the buffer and returns it as an integer list.
Reads the contents of the buffer and returns it as an integer list.
[ "Reads", "the", "contents", "of", "the", "buffer", "and", "returns", "it", "as", "an", "integer", "list", "." ]
def _read_buffer(self, byte_count): page_size = 32768 self._buffer = [] for i in range(int(byte_count/page_size)): self._buffer += self._ut330.read(page_size) self._buffer += self._ut330.read(byte_count % page_size)
[ "def", "_read_buffer", "(", "self", ",", "byte_count", ")", ":", "page_size", "=", "32768", "self", ".", "_buffer", "=", "[", "]", "for", "i", "in", "range", "(", "int", "(", "byte_count", "/", "page_size", ")", ")", ":", "self", ".", "_buffer", "+="...
Reads the contents of the buffer and returns it as an integer list.
[ "Reads", "the", "contents", "of", "the", "buffer", "and", "returns", "it", "as", "an", "integer", "list", "." ]
[ "\"\"\"Reads the contents of the buffer and returns it as an integer list.\n \"\"\"", "# If the page_size is set much larger than this number we tend", "# to get problems with partially filled buffers", "# Read in data in as large chuncks as possible to speed up reading.", "# Read in the largest poss...
[ { "param": "self", "type": null }, { "param": "byte_count", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "byte_count", "type": null, "docstring": null, "docstring_toke...
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
_write_buffer
null
def _write_buffer(self): """Writes the command string to the buffer""" bytes_written = self._ut330.write(bytearray(self._buffer)) if bytes_written != len(self._buffer): raise ValueError('Error! _write_buffer: not all command bytes ' 'written')
Writes the command string to the buffer
Writes the command string to the buffer
[ "Writes", "the", "command", "string", "to", "the", "buffer" ]
def _write_buffer(self): bytes_written = self._ut330.write(bytearray(self._buffer)) if bytes_written != len(self._buffer): raise ValueError('Error! _write_buffer: not all command bytes ' 'written')
[ "def", "_write_buffer", "(", "self", ")", ":", "bytes_written", "=", "self", ".", "_ut330", ".", "write", "(", "bytearray", "(", "self", ".", "_buffer", ")", ")", "if", "bytes_written", "!=", "len", "(", "self", ".", "_buffer", ")", ":", "raise", "Valu...
Writes the command string to the buffer
[ "Writes", "the", "command", "string", "to", "the", "buffer" ]
[ "\"\"\"Writes the command string to the buffer\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
_get_datetime
<not_specific>
def _get_datetime(self): """Returns the date and time as a timestamp""" timestamp = datetime.datetime(2000 + self._buffer[self._index], self._buffer[self._index + 1], self._buffer[self._index + 2], ...
Returns the date and time as a timestamp
Returns the date and time as a timestamp
[ "Returns", "the", "date", "and", "time", "as", "a", "timestamp" ]
def _get_datetime(self): timestamp = datetime.datetime(2000 + self._buffer[self._index], self._buffer[self._index + 1], self._buffer[self._index + 2], self._buffer[self._index + 3], ...
[ "def", "_get_datetime", "(", "self", ")", ":", "timestamp", "=", "datetime", ".", "datetime", "(", "2000", "+", "self", ".", "_buffer", "[", "self", ".", "_index", "]", ",", "self", ".", "_buffer", "[", "self", ".", "_index", "+", "1", "]", ",", "s...
Returns the date and time as a timestamp
[ "Returns", "the", "date", "and", "time", "as", "a", "timestamp" ]
[ "\"\"\"Returns the date and time as a timestamp\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
_get_temperature
<not_specific>
def _get_temperature(self): """Returns the temperature from the device buffer data - including negative temperatures""" # Look to see if the temperature's negative - using two's complement # to represent negative numbers if self._buffer[self._index + 1] >= 128: temp...
Returns the temperature from the device buffer data - including negative temperatures
Returns the temperature from the device buffer data - including negative temperatures
[ "Returns", "the", "temperature", "from", "the", "device", "buffer", "data", "-", "including", "negative", "temperatures" ]
def _get_temperature(self): if self._buffer[self._index + 1] >= 128: temperature = -float(256*(self._buffer[self._index + 1] ^ 0xff) + (self._buffer[self._index] ^ 0xff) + 1)/10 else: temperature = float(256*self._buffer[self._index + 1] + ...
[ "def", "_get_temperature", "(", "self", ")", ":", "if", "self", ".", "_buffer", "[", "self", ".", "_index", "+", "1", "]", ">=", "128", ":", "temperature", "=", "-", "float", "(", "256", "*", "(", "self", ".", "_buffer", "[", "self", ".", "_index",...
Returns the temperature from the device buffer data - including negative temperatures
[ "Returns", "the", "temperature", "from", "the", "device", "buffer", "data", "-", "including", "negative", "temperatures" ]
[ "\"\"\"Returns the temperature from the device buffer data - including\n negative temperatures\"\"\"", "# Look to see if the temperature's negative - using two's complement", "# to represent negative numbers", "# Temperature is positive" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
_get_name
<not_specific>
def _get_name(self): """Retrieves the device name from the buffer data""" temp = self._buffer[self._index: self._index + 10] return ''.join(chr(entry) for entry in temp).strip()
Retrieves the device name from the buffer data
Retrieves the device name from the buffer data
[ "Retrieves", "the", "device", "name", "from", "the", "buffer", "data" ]
def _get_name(self): temp = self._buffer[self._index: self._index + 10] return ''.join(chr(entry) for entry in temp).strip()
[ "def", "_get_name", "(", "self", ")", ":", "temp", "=", "self", ".", "_buffer", "[", "self", ".", "_index", ":", "self", ".", "_index", "+", "10", "]", "return", "''", ".", "join", "(", "chr", "(", "entry", ")", "for", "entry", "in", "temp", ")",...
Retrieves the device name from the buffer data
[ "Retrieves", "the", "device", "name", "from", "the", "buffer", "data" ]
[ "\"\"\"Retrieves the device name from the buffer data\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ccc1f64370ace7ca49451275029b6738329d4522
duncanbarth/UT330B
UT330BUI/model/UT330.py
[ "MIT" ]
Python
read_data
<not_specific>
def read_data(self): """Downloads the device buffer data (temperature, humidity, pressure), and decodes it""" # We split this function into a header and data part to speed up # reading. Reading the header tells us how much data there is in the # data part # The read da...
Downloads the device buffer data (temperature, humidity, pressure), and decodes it
Downloads the device buffer data (temperature, humidity, pressure), and decodes it
[ "Downloads", "the", "device", "buffer", "data", "(", "temperature", "humidity", "pressure", ")", "and", "decodes", "it" ]
def read_data(self): self._buffer = [0xab, 0xcd, 0x03, 0x19, 0x70, 0xc5] self._write_buffer() self._read_buffer(8) if len(self._buffer) == 0: print("Warning! Empty buffer returned by device") return [] length = (self._buffer[4] + 256*self._buffer[5] + ...
[ "def", "read_data", "(", "self", ")", ":", "self", ".", "_buffer", "=", "[", "0xab", ",", "0xcd", ",", "0x03", ",", "0x19", ",", "0x70", ",", "0xc5", "]", "self", ".", "_write_buffer", "(", ")", "self", ".", "_read_buffer", "(", "8", ")", "if", "...
Downloads the device buffer data (temperature, humidity, pressure), and decodes it
[ "Downloads", "the", "device", "buffer", "data", "(", "temperature", "humidity", "pressure", ")", "and", "decodes", "it" ]
[ "\"\"\"Downloads the device buffer data (temperature, humidity, pressure),\n and decodes it\"\"\"", "# We split this function into a header and data part to speed up", "# reading. Reading the header tells us how much data there is in the", "# data part", "# The read data command", "# Write the comm...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }