repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.approximating_model_reg | def approximating_model_reg(self, beta, T, Z, R, Q, h_approx, data, X, state_no):
""" Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for late... | python | def approximating_model_reg(self, beta, T, Z, R, Q, h_approx, data, X, state_no):
""" Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for late... | [
"def",
"approximating_model_reg",
"(",
"self",
",",
"beta",
",",
"T",
",",
"Z",
",",
"R",
",",
"Q",
",",
"h_approx",
",",
"data",
",",
"X",
",",
"state_no",
")",
":",
"H",
"=",
"np",
".",
"ones",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
")",
... | Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
T, Z, R, Q : np.array
State space matrices used in KFS algor... | [
"Creates",
"approximating",
"Gaussian",
"model",
"for",
"Poisson",
"measurement",
"density",
"-",
"dynamic",
"regression",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L86-L131 | train |
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.logpdf | def logpdf(self, mu):
"""
Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | python | def logpdf(self, mu):
"""
Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"poisson",
".",
"logpmf",
"(",
"mu",
",",
"self",
".",
"lmd0",
... | Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Poisson",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L198-L213 | train |
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.setup | def setup():
""" Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
... | python | def setup():
""" Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
... | [
"def",
"setup",
"(",
")",
":",
"name",
"=",
"\"Poisson\"",
"link",
"=",
"np",
".",
"exp",
"scale",
"=",
"False",
"shape",
"=",
"False",
"skewness",
"=",
"False",
"mean_transform",
"=",
"np",
".",
"log",
"cythonized",
"=",
"True",
"return",
"name",
",",... | Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
- mean_transform is a fu... | [
"Returns",
"the",
"attributes",
"of",
"this",
"family"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L243-L265 | train |
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.pdf | def pdf(self, mu):
"""
PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | python | def pdf(self, mu):
"""
PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"poisson",
".",
"pmf",
"(",
"mu",
",",
"self",
".",
"lmd0",
")"
... | PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Poisson",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L294-L309 | train |
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.reg_score_function | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the tim... | python | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the tim... | [
"def",
"reg_score_function",
"(",
"X",
",",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"X",
"*",
"(",
"y",
"-",
"mean",
")"
] | GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time series
mean : float
location parameter for the Po... | [
"GAS",
"Poisson",
"Regression",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L312-L339 | train |
RJT1990/pyflux | pyflux/families/poisson.py | Poisson.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"mean",
")"
] | GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Poisson distribution
scale : float
scale parame... | [
"GAS",
"Poisson",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L342-L366 | train |
RJT1990/pyflux | pyflux/families/inverse_gamma.py | InverseGamma.logpdf | def logpdf(self, x):
"""
Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x))
"""
if self.transform is not None:
x ... | python | def logpdf(self, x):
"""
Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x))
"""
if self.transform is not None:
x ... | [
"def",
"logpdf",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"x",
"=",
"self",
".",
"transform",
"(",
"x",
")",
"return",
"(",
"-",
"self",
".",
"alpha",
"-",
"1",
")",
"*",
"np",
".",
"log",
"("... | Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x)) | [
"Log",
"PDF",
"for",
"Inverse",
"Gamma",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_gamma.py#L33-L48 | train |
RJT1990/pyflux | pyflux/families/inverse_gamma.py | InverseGamma.pdf | def pdf(self, x):
"""
PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x)
"""
if self.transform is not None:
x = self.trans... | python | def pdf(self, x):
"""
PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x)
"""
if self.transform is not None:
x = self.trans... | [
"def",
"pdf",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"x",
"=",
"self",
".",
"transform",
"(",
"x",
")",
"return",
"(",
"x",
"**",
"(",
"-",
"self",
".",
"alpha",
"-",
"1",
")",
")",
"*",
"... | PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x) | [
"PDF",
"for",
"Inverse",
"Gamma",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_gamma.py#L50-L65 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.logpdf | def logpdf(self, mu):
"""
Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | python | def logpdf(self, mu):
"""
Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"mu",
",",
"self",
".",
"loc0",
... | Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Cauchy",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L155-L170 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.pdf | def pdf(self, mu):
"""
PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
return ss.cauchy.pdf(mu, self.loc0, self.scale0) | python | def pdf(self, mu):
"""
PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
return ss.cauchy.pdf(mu, self.loc0, self.scale0) | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"return",
"ss",
".",
"cauchy",
".",
"pdf",
"(",
"mu",
",",
"self",
".",
"loc0",
",",
"self",
".",
"scale0",
")"
] | PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Cauchy",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L172-L185 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.markov_blanket | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distr... | python | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distr... | [
"def",
"markov_blanket",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"y",
",",
"loc",
"=",
"mean",
",",
"scale",
"=",
"scale",
")"
] | Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
scale : float
scale parameter for th... | [
"Markov",
"blanket",
"for",
"each",
"likelihood",
"term",
"-",
"used",
"for",
"state",
"space",
"models"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L188-L212 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.setup | def setup():
""" Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a ... | python | def setup():
""" Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a ... | [
"def",
"setup",
"(",
")",
":",
"name",
"=",
"\"Cauchy\"",
"link",
"=",
"np",
".",
"array",
"scale",
"=",
"True",
"shape",
"=",
"False",
"skewness",
"=",
"False",
"mean_transform",
"=",
"np",
".",
"array",
"cythonized",
"=",
"True",
"# used for GAS models",... | Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma... | [
"Returns",
"the",
"attributes",
"of",
"this",
"family",
"if",
"using",
"in",
"a",
"probabilistic",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L215-L237 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.neg_loglikelihood | def neg_loglikelihood(y, mean, scale, shape, skewness):
""" Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
... | python | def neg_loglikelihood(y, mean, scale, shape, skewness):
""" Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
... | [
"def",
"neg_loglikelihood",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"-",
"np",
".",
"sum",
"(",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"y",
",",
"loc",
"=",
"mean",
",",
"scale",
"=",
"scale",
")"... | Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
scale : float
scale parameter for the Cauchy distrib... | [
"Negative",
"loglikelihood",
"function",
"for",
"this",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L294-L318 | train |
RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.reg_score_function | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time... | python | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time... | [
"def",
"reg_score_function",
"(",
"X",
",",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"2.0",
"*",
"(",
"(",
"y",
"-",
"mean",
")",
"*",
"X",
")",
"/",
"(",
"np",
".",
"power",
"(",
"scale",
",",
"2",
"... | GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time series
mean : float
location parameter for the Cau... | [
"GAS",
"Cauchy",
"Regression",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L322-L349 | train |
RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.general_neg_loglik | def general_neg_loglik(self, beta):
""" Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model
... | python | def general_neg_loglik(self, beta):
""" Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model
... | [
"def",
"general_neg_loglik",
"(",
"self",
",",
"beta",
")",
":",
"mu",
",",
"Y",
"=",
"self",
".",
"_model",
"(",
"beta",
")",
"parm",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"latent_variables",
".",
"z_list",
"[",
"k",
"]",
".",
"prior",
... | Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model | [
"Calculates",
"the",
"negative",
"log",
"-",
"likelihood",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L430-L447 | train |
RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.plot_fit | def plot_fit(self, **kwargs):
"""
Plots the fit of the model against the data
"""
import matplotlib.pyplot as plt
import seaborn as sns
figsize = kwargs.get('figsize',(10,7))
plt.figure(figsize=figsize)
date_index = self.index[self.ar:self.data.shape[0]... | python | def plot_fit(self, **kwargs):
"""
Plots the fit of the model against the data
"""
import matplotlib.pyplot as plt
import seaborn as sns
figsize = kwargs.get('figsize',(10,7))
plt.figure(figsize=figsize)
date_index = self.index[self.ar:self.data.shape[0]... | [
"def",
"plot_fit",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seaborn",
"as",
"sns",
"figsize",
"=",
"kwargs",
".",
"get",
"(",
"'figsize'",
",",
"(",
"10",
",",
"7",
")",
")",
"pl... | Plots the fit of the model against the data | [
"Plots",
"the",
"fit",
"of",
"the",
"model",
"against",
"the",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L487-L503 | train |
RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.predict_is | def predict_is(self, h=5, fit_once=True, fit_method='MLE', intervals=False, **kwargs):
""" Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_o... | python | def predict_is(self, h=5, fit_once=True, fit_method='MLE', intervals=False, **kwargs):
""" Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_o... | [
"def",
"predict_is",
"(",
"self",
",",
"h",
"=",
"5",
",",
"fit_once",
"=",
"True",
",",
"fit_method",
"=",
"'MLE'",
",",
"intervals",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"predictions",
"=",
"[",
"]",
"for",
"t",
"in",
"range",
"(",
... | Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_once : boolean
(default: True) Fits only once before the in-sample prediction; if False,... | [
"Makes",
"dynamic",
"out",
"-",
"of",
"-",
"sample",
"predictions",
"with",
"the",
"estimated",
"model",
"on",
"in",
"-",
"sample",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L557-L603 | train |
RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV.likelihood_markov_blanket | def likelihood_markov_blanket(self, beta):
""" Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
""" ... | python | def likelihood_markov_blanket(self, beta):
""" Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
""" ... | [
"def",
"likelihood_markov_blanket",
"(",
"self",
",",
"beta",
")",
":",
"states",
"=",
"beta",
"[",
"self",
".",
"z_no",
":",
"self",
".",
"z_no",
"+",
"self",
".",
"data_length",
"]",
"# the local level (untransformed)",
"parm",
"=",
"np",
".",
"array",
"... | Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood | [
"Creates",
"likelihood",
"markov",
"blanket",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L135-L150 | train |
RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV._animate_bbvi | def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood):
""" Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes)
"""
from matplotlib.animation import FuncAnimation, writers
import matplotlib.pyplot ... | python | def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood):
""" Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes)
"""
from matplotlib.animation import FuncAnimation, writers
import matplotlib.pyplot ... | [
"def",
"_animate_bbvi",
"(",
"self",
",",
"stored_latent_variables",
",",
"stored_predictive_likelihood",
")",
":",
"from",
"matplotlib",
".",
"animation",
"import",
"FuncAnimation",
",",
"writers",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seab... | Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes) | [
"Produces",
"animated",
"plot",
"of",
"BBVI",
"optimization"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L278-L298 | train |
RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV.initialize_approx_dist | def initialize_approx_dist(self, phi, start_diffuse, gaussian_latents):
""" Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
... | python | def initialize_approx_dist(self, phi, start_diffuse, gaussian_latents):
""" Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
... | [
"def",
"initialize_approx_dist",
"(",
"self",
",",
"phi",
",",
"start_diffuse",
",",
"gaussian_latents",
")",
":",
"# Starting values for approximate distribution",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"latent_variables",
".",
"z_list",
")",
")... | Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
gaussian_latents: LatentVariables object
Latent variables... | [
"Initializes",
"the",
"appoximate",
"distibution",
"for",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L442-L482 | train |
RJT1990/pyflux | pyflux/families/t.py | t.logpdf | def logpdf(self, mu):
"""
Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = self.t... | python | def logpdf(self, mu):
"""
Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = self.t... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"t",
".",
"logpdf",
"(",
"mu",
",",
"df",
"=",
"self",
".",
... | Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"t",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L186-L201 | train |
RJT1990/pyflux | pyflux/families/t.py | t.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t dis... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t dis... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"(",
"shape",
"+",
"1",
")",
"/",
"shape",
")",
"*",
"(",
"y",
"-",
"mean",
")",
"/",
"(",
"np",
".",
"power",
"(",
"scale... | GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t distribution
scale : float
scale parameter for the ... | [
"GAS",
"t",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L330-L354 | train |
RJT1990/pyflux | tools/cythonize.py | load_hashes | def load_hashes(filename):
"""Load the hashes dict from the hashfile"""
# { filename : (sha1 of header if available or 'NA',
# sha1 of input,
# sha1 of output) }
hashes = {}
try:
with open(filename, 'r') as cython_hash_file:
for hash_record in cyt... | python | def load_hashes(filename):
"""Load the hashes dict from the hashfile"""
# { filename : (sha1 of header if available or 'NA',
# sha1 of input,
# sha1 of output) }
hashes = {}
try:
with open(filename, 'r') as cython_hash_file:
for hash_record in cyt... | [
"def",
"load_hashes",
"(",
"filename",
")",
":",
"# { filename : (sha1 of header if available or 'NA',",
"# sha1 of input,",
"# sha1 of output) }",
"hashes",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"... | Load the hashes dict from the hashfile | [
"Load",
"the",
"hashes",
"dict",
"from",
"the",
"hashfile"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L81-L96 | train |
RJT1990/pyflux | tools/cythonize.py | save_hashes | def save_hashes(hashes, filename):
"""Save the hashes dict to the hashfile"""
with open(filename, 'w') as cython_hash_file:
for key, value in hashes.items():
cython_hash_file.write("%s %s %s %s\n"
% (key, value[0], value[1], value[2])) | python | def save_hashes(hashes, filename):
"""Save the hashes dict to the hashfile"""
with open(filename, 'w') as cython_hash_file:
for key, value in hashes.items():
cython_hash_file.write("%s %s %s %s\n"
% (key, value[0], value[1], value[2])) | [
"def",
"save_hashes",
"(",
"hashes",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"cython_hash_file",
":",
"for",
"key",
",",
"value",
"in",
"hashes",
".",
"items",
"(",
")",
":",
"cython_hash_file",
".",
"write",
... | Save the hashes dict to the hashfile | [
"Save",
"the",
"hashes",
"dict",
"to",
"the",
"hashfile"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L99-L104 | train |
RJT1990/pyflux | tools/cythonize.py | clean_path | def clean_path(path):
"""Clean the path"""
path = path.replace(os.sep, '/')
if path.startswith('./'):
path = path[2:]
return path | python | def clean_path(path):
"""Clean the path"""
path = path.replace(os.sep, '/')
if path.startswith('./'):
path = path[2:]
return path | [
"def",
"clean_path",
"(",
"path",
")",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
"if",
"path",
".",
"startswith",
"(",
"'./'",
")",
":",
"path",
"=",
"path",
"[",
"2",
":",
"]",
"return",
"path"
] | Clean the path | [
"Clean",
"the",
"path"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L114-L119 | train |
RJT1990/pyflux | tools/cythonize.py | get_hash_tuple | def get_hash_tuple(header_path, cython_path, gen_file_path):
"""Get the hashes from the given files"""
header_hash = (sha1_of_file(header_path)
if os.path.exists(header_path) else 'NA')
from_hash = sha1_of_file(cython_path)
to_hash = (sha1_of_file(gen_file_path)
if os.... | python | def get_hash_tuple(header_path, cython_path, gen_file_path):
"""Get the hashes from the given files"""
header_hash = (sha1_of_file(header_path)
if os.path.exists(header_path) else 'NA')
from_hash = sha1_of_file(cython_path)
to_hash = (sha1_of_file(gen_file_path)
if os.... | [
"def",
"get_hash_tuple",
"(",
"header_path",
",",
"cython_path",
",",
"gen_file_path",
")",
":",
"header_hash",
"=",
"(",
"sha1_of_file",
"(",
"header_path",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"header_path",
")",
"else",
"'NA'",
")",
"from_has... | Get the hashes from the given files | [
"Get",
"the",
"hashes",
"from",
"the",
"given",
"files"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L122-L131 | train |
RJT1990/pyflux | pyflux/families/truncated_normal.py | TruncatedNormal.logpdf | def logpdf(self, mu):
"""
Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
... | python | def logpdf(self, mu):
"""
Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"if",
"mu",
"<",
"self",
".",
"lower",
"and",
"self",
".",
"lower",
"is",
"not",
"... | Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Truncated",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/truncated_normal.py#L42-L62 | train |
RJT1990/pyflux | pyflux/families/truncated_normal.py | TruncatedNormal.pdf | def pdf(self, mu):
"""
PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = sel... | python | def pdf(self, mu):
"""
PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = sel... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"if",
"mu",
"<",
"self",
".",
"lower",
"and",
"self",
".",
"lower",
"is",
"not",
"Non... | PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Truncated",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/truncated_normal.py#L64-L84 | train |
RJT1990/pyflux | pyflux/inference/metropolis_hastings.py | MetropolisHastings.tune_scale | def tune_scale(acceptance, scale):
""" Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
... | python | def tune_scale(acceptance, scale):
""" Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
... | [
"def",
"tune_scale",
"(",
"acceptance",
",",
"scale",
")",
":",
"if",
"acceptance",
">",
"0.8",
":",
"scale",
"*=",
"2.0",
"elif",
"acceptance",
"<=",
"0.8",
"and",
"acceptance",
">",
"0.4",
":",
"scale",
"*=",
"1.3",
"elif",
"acceptance",
"<",
"0.234",
... | Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
An adjusted scale parameter
Notes
... | [
"Tunes",
"scale",
"for",
"M",
"-",
"H",
"algorithm"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/metropolis_hastings.py#L66-L100 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.draw_variable_local | def draw_variable_local(self, size):
""" Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable
"""
return ... | python | def draw_variable_local(self, size):
""" Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable
"""
return ... | [
"def",
"draw_variable_local",
"(",
"self",
",",
"size",
")",
":",
"return",
"ss",
".",
"norm",
".",
"rvs",
"(",
"loc",
"=",
"self",
".",
"mu0",
",",
"scale",
"=",
"self",
".",
"sigma0",
",",
"size",
"=",
"size",
")"
] | Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable | [
"Simulate",
"from",
"the",
"Normal",
"distribution",
"using",
"instance",
"values"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L154-L166 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.first_order_score | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
... | python | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
... | [
"def",
"first_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"np",
".",
"power",
"(",
"scale",
",",
"2",
")"
] | GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
scale : float
scale parameter for the Normal distri... | [
"GAS",
"Normal",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L169-L193 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.logpdf | def logpdf(self, mu):
"""
Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | python | def logpdf(self, mu):
"""
Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"-",
"np",
".",
"log",
"(",
"float",
"(",
"self",
".",
"sigma0",
")",
")... | Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L195-L210 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.pdf | def pdf(self, mu):
"""
PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | python | def pdf(self, mu):
"""
PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"(",
"1.0",
"/",
"float",
"(",
"self",
".",
"sigma0",
")",
")",
"*",
"np",
... | PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L291-L306 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_change_param | def vi_change_param(self, index, value):
""" Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to
""... | python | def vi_change_param(self, index, value):
""" Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to
""... | [
"def",
"vi_change_param",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"if",
"index",
"==",
"0",
":",
"self",
".",
"mu0",
"=",
"value",
"elif",
"index",
"==",
"1",
":",
"self",
".",
"sigma0",
"=",
"np",
".",
"exp",
"(",
"value",
")"
] | Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to | [
"Wrapper",
"function",
"for",
"changing",
"latent",
"variables",
"-",
"variational",
"inference"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L365-L379 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_return_param | def vi_return_param(self, index):
""" Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed paramete... | python | def vi_return_param(self, index):
""" Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed paramete... | [
"def",
"vi_return_param",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"mu0",
"elif",
"index",
"==",
"1",
":",
"return",
"np",
".",
"log",
"(",
"self",
".",
"sigma0",
")"
] | Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed parameter | [
"Wrapper",
"function",
"for",
"selecting",
"appropriate",
"latent",
"variable",
"for",
"variational",
"inference"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L381-L396 | train |
RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_score | def vi_score(self, x, index):
""" Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the sca... | python | def vi_score(self, x, index):
""" Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the sca... | [
"def",
"vi_score",
"(",
"self",
",",
"x",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"vi_loc_score",
"(",
"x",
")",
"elif",
"index",
"==",
"1",
":",
"return",
"self",
".",
"vi_scale_score",
"(",
"x",
")"
] | Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the scale latent variable at x | [
"Wrapper",
"function",
"for",
"selecting",
"appropriate",
"score"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L426-L444 | train |
RJT1990/pyflux | pyflux/families/laplace.py | Laplace.first_order_score | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
... | python | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
... | [
"def",
"first_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"scale",
"*",
"np",
".",
"abs",
"(",
"y",
"-",
"mean",
")",
")"
] | GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
scale : float
scale parameter for the Laplace dis... | [
"GAS",
"Laplace",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L156-L180 | train |
RJT1990/pyflux | pyflux/families/laplace.py | Laplace.logpdf | def logpdf(self, mu):
"""
Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | python | def logpdf(self, mu):
"""
Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"laplace",
".",
"logpdf",
"(",
"mu",
",",
"loc",
"=",
"self",
... | Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Laplace",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L182-L197 | train |
RJT1990/pyflux | pyflux/families/laplace.py | Laplace.pdf | def pdf(self, mu):
"""
PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | python | def pdf(self, mu):
"""
PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"laplace",
".",
"pdf",
"(",
"mu",
",",
"self",
".",
"loc0",
",",... | PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Laplace",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L278-L293 | train |
RJT1990/pyflux | pyflux/families/laplace.py | Laplace.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"scale",
"*",
"np",
".",
"abs",
"(",
"y",
"-",
"mean",
")",
")",
")",
"/",
... | GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
scale : float
scale parame... | [
"GAS",
"Laplace",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L326-L350 | train |
RJT1990/pyflux | pyflux/data_check.py | data_check | def data_check(data,target):
""" Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw dat... | python | def data_check(data,target):
""" Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw dat... | [
"def",
"data_check",
"(",
"data",
",",
"target",
")",
":",
"# Check pandas or numpy",
"if",
"isinstance",
"(",
"data",
",",
"pd",
".",
"DataFrame",
")",
"or",
"isinstance",
"(",
"data",
",",
"pd",
".",
"core",
".",
"frame",
".",
"DataFrame",
")",
":",
... | Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw data array for use in the model
... | [
"Checks",
"data",
"type"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/data_check.py#L4-L57 | train |
RJT1990/pyflux | pyflux/latent_variables.py | LatentVariables.add_z | def add_z(self, name, prior, q, index=True):
""" Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribu... | python | def add_z(self, name, prior, q, index=True):
""" Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribu... | [
"def",
"add_z",
"(",
"self",
",",
"name",
",",
"prior",
",",
"q",
",",
"index",
"=",
"True",
")",
":",
"self",
".",
"z_list",
".",
"append",
"(",
"LatentVariable",
"(",
"name",
",",
"len",
"(",
"self",
".",
"z_list",
")",
",",
"prior",
",",
"q",
... | Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribution to use for variational approximation
index ... | [
"Adds",
"latent",
"variable"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/latent_variables.py#L46-L70 | train |
RJT1990/pyflux | pyflux/latent_variables.py | LatentVariables.create | def create(self, name, dim, prior, q):
""" Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distributio... | python | def create(self, name, dim, prior, q):
""" Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distributio... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"dim",
",",
"prior",
",",
"q",
")",
":",
"def",
"rec",
"(",
"dim",
",",
"prev",
"=",
"[",
"]",
")",
":",
"if",
"len",
"(",
"dim",
")",
">",
"0",
":",
"return",
"[",
"rec",
"(",
"dim",
"[",
"... | Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution objec... | [
"Creates",
"multiple",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/latent_variables.py#L72-L113 | train |
RJT1990/pyflux | pyflux/gpnarx/kernels.py | ARD.build_latent_variables | def build_latent_variables(self):
""" Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information)
"""
lvs_to_build = []
lvs_to_build.append(['Noise Sigma^2', fam.Flat(transform='exp'), fam.Norm... | python | def build_latent_variables(self):
""" Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information)
"""
lvs_to_build = []
lvs_to_build.append(['Noise Sigma^2', fam.Flat(transform='exp'), fam.Norm... | [
"def",
"build_latent_variables",
"(",
"self",
")",
":",
"lvs_to_build",
"=",
"[",
"]",
"lvs_to_build",
".",
"append",
"(",
"[",
"'Noise Sigma^2'",
",",
"fam",
".",
"Flat",
"(",
"transform",
"=",
"'exp'",
")",
",",
"fam",
".",
"Normal",
"(",
"0",
",",
"... | Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information) | [
"Builds",
"latent",
"variables",
"for",
"this",
"kernel"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/kernels.py#L160-L172 | train |
RJT1990/pyflux | pyflux/arma/nnar.py | NNAR._ar_matrix | def _ar_matrix(self):
""" Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
Y = np.array(self.data[self.max_lag:self.data.shape[0]])
X = self.data[(self.max_lag-1):-1]
if self.ar != 0:
for ... | python | def _ar_matrix(self):
""" Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
Y = np.array(self.data[self.max_lag:self.data.shape[0]])
X = self.data[(self.max_lag-1):-1]
if self.ar != 0:
for ... | [
"def",
"_ar_matrix",
"(",
"self",
")",
":",
"Y",
"=",
"np",
".",
"array",
"(",
"self",
".",
"data",
"[",
"self",
".",
"max_lag",
":",
"self",
".",
"data",
".",
"shape",
"[",
"0",
"]",
"]",
")",
"X",
"=",
"self",
".",
"data",
"[",
"(",
"self",... | Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix | [
"Creates",
"Autoregressive",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnar.py#L118-L134 | train |
RJT1990/pyflux | pyflux/ensembles/mixture_of_experts.py | Aggregate.predict_is | def predict_is(self, h):
""" Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions
"""... | python | def predict_is(self, h):
""" Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions
"""... | [
"def",
"predict_is",
"(",
"self",
",",
"h",
")",
":",
"result",
"=",
"pd",
".",
"DataFrame",
"(",
"[",
"self",
".",
"run",
"(",
"h",
"=",
"h",
")",
"[",
"2",
"]",
"]",
")",
".",
"T",
"result",
".",
"index",
"=",
"self",
".",
"index",
"[",
"... | Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions | [
"Outputs",
"predictions",
"for",
"the",
"Aggregate",
"algorithm",
"on",
"the",
"in",
"-",
"sample",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ensembles/mixture_of_experts.py#L335-L349 | train |
RJT1990/pyflux | pyflux/ensembles/mixture_of_experts.py | Aggregate.summary | def summary(self, h):
"""
Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model
... | python | def summary(self, h):
"""
Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model
... | [
"def",
"summary",
"(",
"self",
",",
"h",
")",
":",
"_",
",",
"losses",
",",
"_",
"=",
"self",
".",
"run",
"(",
"h",
"=",
"h",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"losses",
")",
"df",
".",
"index",
"=",
"[",
"'Ensemble'",
"]",
"+",
... | Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model | [
"Summarize",
"the",
"results",
"for",
"each",
"model",
"for",
"h",
"steps",
"of",
"the",
"algorithm"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ensembles/mixture_of_experts.py#L351-L368 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.extract_geometry | def extract_geometry(self):
"""Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object.
"""
... | python | def extract_geometry(self):
"""Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object.
"""
... | [
"def",
"extract_geometry",
"(",
"self",
")",
":",
"gf",
"=",
"vtk",
".",
"vtkCompositeDataGeometryFilter",
"(",
")",
"gf",
".",
"SetInputData",
"(",
"self",
")",
"gf",
".",
"Update",
"(",
")",
"return",
"wrap",
"(",
"gf",
".",
"GetOutputDataObject",
"(",
... | Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object. | [
"Combines",
"the",
"geomertry",
"of",
"all",
"blocks",
"into",
"a",
"single",
"PolyData",
"object",
".",
"Place",
"this",
"filter",
"at",
"the",
"end",
"of",
"a",
"pipeline",
"before",
"a",
"polydata",
"consumer",
"such",
"as",
"a",
"polydata",
"mapper",
"... | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L58-L67 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.combine | def combine(self, merge_points=False):
"""Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points.
"""
alg = vtk.vtkAppendFilter()
for block in self:
alg.AddInputDa... | python | def combine(self, merge_points=False):
"""Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points.
"""
alg = vtk.vtkAppendFilter()
for block in self:
alg.AddInputDa... | [
"def",
"combine",
"(",
"self",
",",
"merge_points",
"=",
"False",
")",
":",
"alg",
"=",
"vtk",
".",
"vtkAppendFilter",
"(",
")",
"for",
"block",
"in",
"self",
":",
"alg",
".",
"AddInputData",
"(",
"block",
")",
"alg",
".",
"SetMergePoints",
"(",
"merge... | Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points. | [
"Appends",
"all",
"blocks",
"into",
"a",
"single",
"unstructured",
"grid",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L69-L83 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.save | def save(self, filename, binary=True):
"""
Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of... | python | def save(self, filename, binary=True):
"""
Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"binary",
"=",
"True",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"ext",
"=",
"vtki",
".",
"get_ext",
"(",
... | Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of the filename unless overridden with
ftype. Ca... | [
"Writes",
"a",
"MultiBlock",
"dataset",
"to",
"disk",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L111-L146 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.get_index_by_name | def get_index_by_name(self, name):
"""Find the index number by block name"""
for i in range(self.n_blocks):
if self.get_block_name(i) == name:
return i
raise KeyError('Block name ({}) not found'.format(name)) | python | def get_index_by_name(self, name):
"""Find the index number by block name"""
for i in range(self.n_blocks):
if self.get_block_name(i) == name:
return i
raise KeyError('Block name ({}) not found'.format(name)) | [
"def",
"get_index_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n_blocks",
")",
":",
"if",
"self",
".",
"get_block_name",
"(",
"i",
")",
"==",
"name",
":",
"return",
"i",
"raise",
"KeyError",
"(",
"'Block... | Find the index number by block name | [
"Find",
"the",
"index",
"number",
"by",
"block",
"name"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L211-L216 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.append | def append(self, data):
"""Add a data set to the next block index"""
index = self.n_blocks # note off by one so use as index
self[index] = data
self.refs.append(data) | python | def append(self, data):
"""Add a data set to the next block index"""
index = self.n_blocks # note off by one so use as index
self[index] = data
self.refs.append(data) | [
"def",
"append",
"(",
"self",
",",
"data",
")",
":",
"index",
"=",
"self",
".",
"n_blocks",
"# note off by one so use as index",
"self",
"[",
"index",
"]",
"=",
"data",
"self",
".",
"refs",
".",
"append",
"(",
"data",
")"
] | Add a data set to the next block index | [
"Add",
"a",
"data",
"set",
"to",
"the",
"next",
"block",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L234-L238 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.set_block_name | def set_block_name(self, index, name):
"""Set a block's string name at the specified index"""
if name is None:
return
self.GetMetaData(index).Set(vtk.vtkCompositeDataSet.NAME(), name)
self.Modified() | python | def set_block_name(self, index, name):
"""Set a block's string name at the specified index"""
if name is None:
return
self.GetMetaData(index).Set(vtk.vtkCompositeDataSet.NAME(), name)
self.Modified() | [
"def",
"set_block_name",
"(",
"self",
",",
"index",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"GetMetaData",
"(",
"index",
")",
".",
"Set",
"(",
"vtk",
".",
"vtkCompositeDataSet",
".",
"NAME",
"(",
")",
",",
"name... | Set a block's string name at the specified index | [
"Set",
"a",
"block",
"s",
"string",
"name",
"at",
"the",
"specified",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L247-L252 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.get_block_name | def get_block_name(self, index):
"""Returns the string name of the block at the given index"""
meta = self.GetMetaData(index)
if meta is not None:
return meta.Get(vtk.vtkCompositeDataSet.NAME())
return None | python | def get_block_name(self, index):
"""Returns the string name of the block at the given index"""
meta = self.GetMetaData(index)
if meta is not None:
return meta.Get(vtk.vtkCompositeDataSet.NAME())
return None | [
"def",
"get_block_name",
"(",
"self",
",",
"index",
")",
":",
"meta",
"=",
"self",
".",
"GetMetaData",
"(",
"index",
")",
"if",
"meta",
"is",
"not",
"None",
":",
"return",
"meta",
".",
"Get",
"(",
"vtk",
".",
"vtkCompositeDataSet",
".",
"NAME",
"(",
... | Returns the string name of the block at the given index | [
"Returns",
"the",
"string",
"name",
"of",
"the",
"block",
"at",
"the",
"given",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L255-L260 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.keys | def keys(self):
"""Get all the block names in the dataset"""
names = []
for i in range(self.n_blocks):
names.append(self.get_block_name(i))
return names | python | def keys(self):
"""Get all the block names in the dataset"""
names = []
for i in range(self.n_blocks):
names.append(self.get_block_name(i))
return names | [
"def",
"keys",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n_blocks",
")",
":",
"names",
".",
"append",
"(",
"self",
".",
"get_block_name",
"(",
"i",
")",
")",
"return",
"names"
] | Get all the block names in the dataset | [
"Get",
"all",
"the",
"block",
"names",
"in",
"the",
"dataset"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L263-L268 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock.next | def next(self):
"""Get the next block from the iterator"""
if self._iter_n < self.n_blocks:
result = self[self._iter_n]
self._iter_n += 1
return result
else:
raise StopIteration | python | def next(self):
"""Get the next block from the iterator"""
if self._iter_n < self.n_blocks:
result = self[self._iter_n]
self._iter_n += 1
return result
else:
raise StopIteration | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_iter_n",
"<",
"self",
".",
"n_blocks",
":",
"result",
"=",
"self",
"[",
"self",
".",
"_iter_n",
"]",
"self",
".",
"_iter_n",
"+=",
"1",
"return",
"result",
"else",
":",
"raise",
"StopIteratio... | Get the next block from the iterator | [
"Get",
"the",
"next",
"block",
"from",
"the",
"iterator"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L321-L328 | train |
vtkiorg/vtki | vtki/container.py | MultiBlock._repr_html_ | def _repr_html_(self):
"""A pretty representation for Jupyter notebooks"""
fmt = ""
fmt += "<table>"
fmt += "<tr><th>Information</th><th>Blocks</th></tr>"
fmt += "<tr><td>"
fmt += "\n"
fmt += "<table>\n"
fmt += "<tr><th>{}</th><th>Values</th></tr>\n".forma... | python | def _repr_html_(self):
"""A pretty representation for Jupyter notebooks"""
fmt = ""
fmt += "<table>"
fmt += "<tr><th>Information</th><th>Blocks</th></tr>"
fmt += "<tr><td>"
fmt += "\n"
fmt += "<table>\n"
fmt += "<tr><th>{}</th><th>Values</th></tr>\n".forma... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"fmt",
"=",
"\"\"",
"fmt",
"+=",
"\"<table>\"",
"fmt",
"+=",
"\"<tr><th>Information</th><th>Blocks</th></tr>\"",
"fmt",
"+=",
"\"<tr><td>\"",
"fmt",
"+=",
"\"\\n\"",
"fmt",
"+=",
"\"<table>\\n\"",
"fmt",
"+=",
"\"<tr><t... | A pretty representation for Jupyter notebooks | [
"A",
"pretty",
"representation",
"for",
"Jupyter",
"notebooks"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L367-L400 | train |
vtkiorg/vtki | vtki/geometric_objects.py | translate | def translate(surf, center, direction):
"""
Translates and orientates a mesh centered at the origin and
facing in the x direction to a new center and direction
"""
normx = np.array(direction)/np.linalg.norm(direction)
normz = np.cross(normx, [0, 1.0, 0.0000001])
normz /= np.linalg.norm(normz... | python | def translate(surf, center, direction):
"""
Translates and orientates a mesh centered at the origin and
facing in the x direction to a new center and direction
"""
normx = np.array(direction)/np.linalg.norm(direction)
normz = np.cross(normx, [0, 1.0, 0.0000001])
normz /= np.linalg.norm(normz... | [
"def",
"translate",
"(",
"surf",
",",
"center",
",",
"direction",
")",
":",
"normx",
"=",
"np",
".",
"array",
"(",
"direction",
")",
"/",
"np",
".",
"linalg",
".",
"norm",
"(",
"direction",
")",
"normz",
"=",
"np",
".",
"cross",
"(",
"normx",
",",
... | Translates and orientates a mesh centered at the origin and
facing in the x direction to a new center and direction | [
"Translates",
"and",
"orientates",
"a",
"mesh",
"centered",
"at",
"the",
"origin",
"and",
"facing",
"in",
"the",
"x",
"direction",
"to",
"a",
"new",
"center",
"and",
"direction"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L24-L41 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Cylinder | def Cylinder(center=(0.,0.,0.), direction=(1.,0.,0.), radius=0.5, height=1.0,
resolution=100, **kwargs):
"""
Create the surface of a cylinder.
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Di... | python | def Cylinder(center=(0.,0.,0.), direction=(1.,0.,0.), radius=0.5, height=1.0,
resolution=100, **kwargs):
"""
Create the surface of a cylinder.
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Di... | [
"def",
"Cylinder",
"(",
"center",
"=",
"(",
"0.",
",",
"0.",
",",
"0.",
")",
",",
"direction",
"=",
"(",
"1.",
",",
"0.",
",",
"0.",
")",
",",
"radius",
"=",
"0.5",
",",
"height",
"=",
"1.0",
",",
"resolution",
"=",
"100",
",",
"*",
"*",
"kwa... | Create the surface of a cylinder.
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Direction cylinder points to in [x, y, z]
radius : float
Radius of the cylinder.
height : float
Height of ... | [
"Create",
"the",
"surface",
"of",
"a",
"cylinder",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L44-L93 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Arrow | def Arrow(start=(0.,0.,0.), direction=(1.,0.,0.), tip_length=0.25,
tip_radius=0.1, shaft_radius=0.05, shaft_resolution=20):
"""
Create a vtk Arrow
Parameters
----------
start : np.ndarray
Start location in [x, y, z]
direction : list or np.ndarray
Direction the arrow p... | python | def Arrow(start=(0.,0.,0.), direction=(1.,0.,0.), tip_length=0.25,
tip_radius=0.1, shaft_radius=0.05, shaft_resolution=20):
"""
Create a vtk Arrow
Parameters
----------
start : np.ndarray
Start location in [x, y, z]
direction : list or np.ndarray
Direction the arrow p... | [
"def",
"Arrow",
"(",
"start",
"=",
"(",
"0.",
",",
"0.",
",",
"0.",
")",
",",
"direction",
"=",
"(",
"1.",
",",
"0.",
",",
"0.",
")",
",",
"tip_length",
"=",
"0.25",
",",
"tip_radius",
"=",
"0.1",
",",
"shaft_radius",
"=",
"0.05",
",",
"shaft_res... | Create a vtk Arrow
Parameters
----------
start : np.ndarray
Start location in [x, y, z]
direction : list or np.ndarray
Direction the arrow points to in [x, y, z]
tip_length : float, optional
Length of the tip.
tip_radius : float, optional
Radius of the tip.
... | [
"Create",
"a",
"vtk",
"Arrow"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L96-L135 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Sphere | def Sphere(radius=0.5, center=(0, 0, 0), direction=(0, 0, 1), theta_resolution=30,
phi_resolution=30, start_theta=0, end_theta=360, start_phi=0, end_phi=180):
"""
Create a vtk Sphere
Parameters
----------
radius : float, optional
Sphere radius
center : np.ndarray or list, op... | python | def Sphere(radius=0.5, center=(0, 0, 0), direction=(0, 0, 1), theta_resolution=30,
phi_resolution=30, start_theta=0, end_theta=360, start_phi=0, end_phi=180):
"""
Create a vtk Sphere
Parameters
----------
radius : float, optional
Sphere radius
center : np.ndarray or list, op... | [
"def",
"Sphere",
"(",
"radius",
"=",
"0.5",
",",
"center",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"direction",
"=",
"(",
"0",
",",
"0",
",",
"1",
")",
",",
"theta_resolution",
"=",
"30",
",",
"phi_resolution",
"=",
"30",
",",
"start_theta",... | Create a vtk Sphere
Parameters
----------
radius : float, optional
Sphere radius
center : np.ndarray or list, optional
Center in [x, y, z]
direction : list or np.ndarray
Direction the top of the sphere points to in [x, y, z]
theta_resolution: int , optional
Se... | [
"Create",
"a",
"vtk",
"Sphere"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L138-L191 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Plane | def Plane(center=(0, 0, 0), direction=(0, 0, 1), i_size=1, j_size=1,
i_resolution=10, j_resolution=10):
"""
Create a plane
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Direction cylinder points ... | python | def Plane(center=(0, 0, 0), direction=(0, 0, 1), i_size=1, j_size=1,
i_resolution=10, j_resolution=10):
"""
Create a plane
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Direction cylinder points ... | [
"def",
"Plane",
"(",
"center",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"direction",
"=",
"(",
"0",
",",
"0",
",",
"1",
")",
",",
"i_size",
"=",
"1",
",",
"j_size",
"=",
"1",
",",
"i_resolution",
"=",
"10",
",",
"j_resolution",
"=",
"10",... | Create a plane
Parameters
----------
center : list or np.ndarray
Location of the centroid in [x, y, z]
direction : list or np.ndarray
Direction cylinder points to in [x, y, z]
i_size : float
Size of the plane in the i direction.
j_size : float
Size of the pla... | [
"Create",
"a",
"plane"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L194-L236 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Line | def Line(pointa=(-0.5, 0., 0.), pointb=(0.5, 0., 0.), resolution=1):
"""Create a line
Parameters
----------
pointa : np.ndarray or list
Location in [x, y, z].
pointb : np.ndarray or list
Location in [x, y, z].
resolution : int
number of pieces to divide line into
"... | python | def Line(pointa=(-0.5, 0., 0.), pointb=(0.5, 0., 0.), resolution=1):
"""Create a line
Parameters
----------
pointa : np.ndarray or list
Location in [x, y, z].
pointb : np.ndarray or list
Location in [x, y, z].
resolution : int
number of pieces to divide line into
"... | [
"def",
"Line",
"(",
"pointa",
"=",
"(",
"-",
"0.5",
",",
"0.",
",",
"0.",
")",
",",
"pointb",
"=",
"(",
"0.5",
",",
"0.",
",",
"0.",
")",
",",
"resolution",
"=",
"1",
")",
":",
"if",
"np",
".",
"array",
"(",
"pointa",
")",
".",
"size",
"!="... | Create a line
Parameters
----------
pointa : np.ndarray or list
Location in [x, y, z].
pointb : np.ndarray or list
Location in [x, y, z].
resolution : int
number of pieces to divide line into | [
"Create",
"a",
"line"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L239-L262 | train |
vtkiorg/vtki | vtki/geometric_objects.py | Cube | def Cube(center=(0., 0., 0.), x_length=1.0, y_length=1.0, z_length=1.0, bounds=None):
"""Create a cube by either specifying the center and side lengths or just
the bounds of the cube. If ``bounds`` are given, all other arguments are
ignored.
Parameters
----------
center : np.ndarray or list
... | python | def Cube(center=(0., 0., 0.), x_length=1.0, y_length=1.0, z_length=1.0, bounds=None):
"""Create a cube by either specifying the center and side lengths or just
the bounds of the cube. If ``bounds`` are given, all other arguments are
ignored.
Parameters
----------
center : np.ndarray or list
... | [
"def",
"Cube",
"(",
"center",
"=",
"(",
"0.",
",",
"0.",
",",
"0.",
")",
",",
"x_length",
"=",
"1.0",
",",
"y_length",
"=",
"1.0",
",",
"z_length",
"=",
"1.0",
",",
"bounds",
"=",
"None",
")",
":",
"src",
"=",
"vtk",
".",
"vtkCubeSource",
"(",
... | Create a cube by either specifying the center and side lengths or just
the bounds of the cube. If ``bounds`` are given, all other arguments are
ignored.
Parameters
----------
center : np.ndarray or list
Center in [x, y, z].
x_length : float
length of the cube in the x-direction... | [
"Create",
"a",
"cube",
"by",
"either",
"specifying",
"the",
"center",
"and",
"side",
"lengths",
"or",
"just",
"the",
"bounds",
"of",
"the",
"cube",
".",
"If",
"bounds",
"are",
"given",
"all",
"other",
"arguments",
"are",
"ignored",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/geometric_objects.py#L265-L299 | train |
vtkiorg/vtki | vtki/readers.py | standard_reader_routine | def standard_reader_routine(reader, filename, attrs=None):
"""Use a given reader from the ``READERS`` mapping in the common VTK reading
pipeline routine.
Parameters
----------
reader : vtkReader
Any instantiated VTK reader class
filename : str
The string filename to the data fi... | python | def standard_reader_routine(reader, filename, attrs=None):
"""Use a given reader from the ``READERS`` mapping in the common VTK reading
pipeline routine.
Parameters
----------
reader : vtkReader
Any instantiated VTK reader class
filename : str
The string filename to the data fi... | [
"def",
"standard_reader_routine",
"(",
"reader",
",",
"filename",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"attrs",
"is",
"None",
":",
"attrs",
"=",
"{",
"}",
"if",
"not",
"isinstance",
"(",
"attrs",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
... | Use a given reader from the ``READERS`` mapping in the common VTK reading
pipeline routine.
Parameters
----------
reader : vtkReader
Any instantiated VTK reader class
filename : str
The string filename to the data file to read.
attrs : dict, optional
A dictionary of at... | [
"Use",
"a",
"given",
"reader",
"from",
"the",
"READERS",
"mapping",
"in",
"the",
"common",
"VTK",
"reading",
"pipeline",
"routine",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/readers.py#L85-L119 | train |
vtkiorg/vtki | vtki/readers.py | read_legacy | def read_legacy(filename):
"""Use VTK's legacy reader to read a file"""
reader = vtk.vtkDataSetReader()
reader.SetFileName(filename)
# Ensure all data is fetched with poorly formated legacy files
reader.ReadAllScalarsOn()
reader.ReadAllColorScalarsOn()
reader.ReadAllNormalsOn()
reader.Re... | python | def read_legacy(filename):
"""Use VTK's legacy reader to read a file"""
reader = vtk.vtkDataSetReader()
reader.SetFileName(filename)
# Ensure all data is fetched with poorly formated legacy files
reader.ReadAllScalarsOn()
reader.ReadAllColorScalarsOn()
reader.ReadAllNormalsOn()
reader.Re... | [
"def",
"read_legacy",
"(",
"filename",
")",
":",
"reader",
"=",
"vtk",
".",
"vtkDataSetReader",
"(",
")",
"reader",
".",
"SetFileName",
"(",
"filename",
")",
"# Ensure all data is fetched with poorly formated legacy files",
"reader",
".",
"ReadAllScalarsOn",
"(",
")",... | Use VTK's legacy reader to read a file | [
"Use",
"VTK",
"s",
"legacy",
"reader",
"to",
"read",
"a",
"file"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/readers.py#L122-L137 | train |
vtkiorg/vtki | vtki/readers.py | read | def read(filename, attrs=None):
"""This will read any VTK file! It will figure out what reader to use
then wrap the VTK object for use in ``vtki``.
Parameters
----------
attrs : dict, optional
A dictionary of attributes to call on the reader. Keys of dictionary are
the attribute/met... | python | def read(filename, attrs=None):
"""This will read any VTK file! It will figure out what reader to use
then wrap the VTK object for use in ``vtki``.
Parameters
----------
attrs : dict, optional
A dictionary of attributes to call on the reader. Keys of dictionary are
the attribute/met... | [
"def",
"read",
"(",
"filename",
",",
"attrs",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"ext",
"=",
"get_ext",
"(",
"filename",
")",
"# From the ex... | This will read any VTK file! It will figure out what reader to use
then wrap the VTK object for use in ``vtki``.
Parameters
----------
attrs : dict, optional
A dictionary of attributes to call on the reader. Keys of dictionary are
the attribute/method names and values are the arguments ... | [
"This",
"will",
"read",
"any",
"VTK",
"file!",
"It",
"will",
"figure",
"out",
"what",
"reader",
"to",
"use",
"then",
"wrap",
"the",
"VTK",
"object",
"for",
"use",
"in",
"vtki",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/readers.py#L140-L183 | train |
vtkiorg/vtki | vtki/readers.py | read_texture | def read_texture(filename, attrs=None):
"""Loads a ``vtkTexture`` from an image file."""
filename = os.path.abspath(os.path.expanduser(filename))
try:
# intitialize the reader using the extnesion to find it
reader = get_reader(filename)
image = standard_reader_routine(reader, filenam... | python | def read_texture(filename, attrs=None):
"""Loads a ``vtkTexture`` from an image file."""
filename = os.path.abspath(os.path.expanduser(filename))
try:
# intitialize the reader using the extnesion to find it
reader = get_reader(filename)
image = standard_reader_routine(reader, filenam... | [
"def",
"read_texture",
"(",
"filename",
",",
"attrs",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"try",
":",
"# intitialize the reader using the extnesion t... | Loads a ``vtkTexture`` from an image file. | [
"Loads",
"a",
"vtkTexture",
"from",
"an",
"image",
"file",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/readers.py#L186-L197 | train |
vtkiorg/vtki | vtki/examples/downloads.py | delete_downloads | def delete_downloads():
"""Delete all downloaded examples to free space or update the files"""
shutil.rmtree(vtki.EXAMPLES_PATH)
os.makedirs(vtki.EXAMPLES_PATH)
return True | python | def delete_downloads():
"""Delete all downloaded examples to free space or update the files"""
shutil.rmtree(vtki.EXAMPLES_PATH)
os.makedirs(vtki.EXAMPLES_PATH)
return True | [
"def",
"delete_downloads",
"(",
")",
":",
"shutil",
".",
"rmtree",
"(",
"vtki",
".",
"EXAMPLES_PATH",
")",
"os",
".",
"makedirs",
"(",
"vtki",
".",
"EXAMPLES_PATH",
")",
"return",
"True"
] | Delete all downloaded examples to free space or update the files | [
"Delete",
"all",
"downloaded",
"examples",
"to",
"free",
"space",
"or",
"update",
"the",
"files"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/examples/downloads.py#L13-L17 | train |
vtkiorg/vtki | vtki/examples/downloads.py | download_blood_vessels | def download_blood_vessels():
"""data representing the bifurcation of blood vessels."""
local_path, _ = _download_file('pvtu_blood_vessels/blood_vessels.zip')
filename = os.path.join(local_path, 'T0000000500.pvtu')
mesh = vtki.read(filename)
mesh.set_active_vectors('velocity')
return mesh | python | def download_blood_vessels():
"""data representing the bifurcation of blood vessels."""
local_path, _ = _download_file('pvtu_blood_vessels/blood_vessels.zip')
filename = os.path.join(local_path, 'T0000000500.pvtu')
mesh = vtki.read(filename)
mesh.set_active_vectors('velocity')
return mesh | [
"def",
"download_blood_vessels",
"(",
")",
":",
"local_path",
",",
"_",
"=",
"_download_file",
"(",
"'pvtu_blood_vessels/blood_vessels.zip'",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"local_path",
",",
"'T0000000500.pvtu'",
")",
"mesh",
"=",
"v... | data representing the bifurcation of blood vessels. | [
"data",
"representing",
"the",
"bifurcation",
"of",
"blood",
"vessels",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/examples/downloads.py#L137-L143 | train |
vtkiorg/vtki | vtki/examples/downloads.py | download_sparse_points | def download_sparse_points():
"""Used with ``download_saddle_surface``"""
saved_file, _ = _download_file('sparsePoints.txt')
points_reader = vtk.vtkDelimitedTextReader()
points_reader.SetFileName(saved_file)
points_reader.DetectNumericColumnsOn()
points_reader.SetFieldDelimiterCharacters('\t')
... | python | def download_sparse_points():
"""Used with ``download_saddle_surface``"""
saved_file, _ = _download_file('sparsePoints.txt')
points_reader = vtk.vtkDelimitedTextReader()
points_reader.SetFileName(saved_file)
points_reader.DetectNumericColumnsOn()
points_reader.SetFieldDelimiterCharacters('\t')
... | [
"def",
"download_sparse_points",
"(",
")",
":",
"saved_file",
",",
"_",
"=",
"_download_file",
"(",
"'sparsePoints.txt'",
")",
"points_reader",
"=",
"vtk",
".",
"vtkDelimitedTextReader",
"(",
")",
"points_reader",
".",
"SetFileName",
"(",
"saved_file",
")",
"point... | Used with ``download_saddle_surface`` | [
"Used",
"with",
"download_saddle_surface"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/examples/downloads.py#L154-L168 | train |
vtkiorg/vtki | vtki/examples/downloads.py | download_kitchen | def download_kitchen(split=False):
"""Download structured grid of kitchen with velocity field. Use the
``split`` argument to extract all of the furniture in the kitchen.
"""
mesh = _download_and_read('kitchen.vtk')
if not split:
return mesh
extents = {
'door' : (27, 27, 14, 18, ... | python | def download_kitchen(split=False):
"""Download structured grid of kitchen with velocity field. Use the
``split`` argument to extract all of the furniture in the kitchen.
"""
mesh = _download_and_read('kitchen.vtk')
if not split:
return mesh
extents = {
'door' : (27, 27, 14, 18, ... | [
"def",
"download_kitchen",
"(",
"split",
"=",
"False",
")",
":",
"mesh",
"=",
"_download_and_read",
"(",
"'kitchen.vtk'",
")",
"if",
"not",
"split",
":",
"return",
"mesh",
"extents",
"=",
"{",
"'door'",
":",
"(",
"27",
",",
"27",
",",
"14",
",",
"18",
... | Download structured grid of kitchen with velocity field. Use the
``split`` argument to extract all of the furniture in the kitchen. | [
"Download",
"structured",
"grid",
"of",
"kitchen",
"with",
"velocity",
"field",
".",
"Use",
"the",
"split",
"argument",
"to",
"extract",
"all",
"of",
"the",
"furniture",
"in",
"the",
"kitchen",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/examples/downloads.py#L324-L358 | train |
vtkiorg/vtki | vtki/ipy_tools.py | InteractiveTool._get_scalar_names | def _get_scalar_names(self, limit=None):
"""Only give scalar options that have a varying range"""
names = []
if limit == 'point':
inpnames = list(self.input_dataset.point_arrays.keys())
elif limit == 'cell':
inpnames = list(self.input_dataset.cell_arrays.keys())
... | python | def _get_scalar_names(self, limit=None):
"""Only give scalar options that have a varying range"""
names = []
if limit == 'point':
inpnames = list(self.input_dataset.point_arrays.keys())
elif limit == 'cell':
inpnames = list(self.input_dataset.cell_arrays.keys())
... | [
"def",
"_get_scalar_names",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"names",
"=",
"[",
"]",
"if",
"limit",
"==",
"'point'",
":",
"inpnames",
"=",
"list",
"(",
"self",
".",
"input_dataset",
".",
"point_arrays",
".",
"keys",
"(",
")",
")",
"e... | Only give scalar options that have a varying range | [
"Only",
"give",
"scalar",
"options",
"that",
"have",
"a",
"varying",
"range"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/ipy_tools.py#L133-L151 | train |
vtkiorg/vtki | vtki/ipy_tools.py | InteractiveTool._initialize | def _initialize(self, show_bounds, reset_camera, outline):
"""Outlines the input dataset and sets up the scene"""
self.plotter.subplot(*self.loc)
if outline is None:
self.plotter.add_mesh(self.input_dataset.outline_corners(),
reset_camera=False, color=vtki.rcParam... | python | def _initialize(self, show_bounds, reset_camera, outline):
"""Outlines the input dataset and sets up the scene"""
self.plotter.subplot(*self.loc)
if outline is None:
self.plotter.add_mesh(self.input_dataset.outline_corners(),
reset_camera=False, color=vtki.rcParam... | [
"def",
"_initialize",
"(",
"self",
",",
"show_bounds",
",",
"reset_camera",
",",
"outline",
")",
":",
"self",
".",
"plotter",
".",
"subplot",
"(",
"*",
"self",
".",
"loc",
")",
"if",
"outline",
"is",
"None",
":",
"self",
".",
"plotter",
".",
"add_mesh"... | Outlines the input dataset and sets up the scene | [
"Outlines",
"the",
"input",
"dataset",
"and",
"sets",
"up",
"the",
"scene"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/ipy_tools.py#L160-L178 | train |
vtkiorg/vtki | vtki/ipy_tools.py | InteractiveTool._update_plotting_params | def _update_plotting_params(self, **kwargs):
"""Some plotting parameters can be changed through the tool; this
updataes those plotting parameters.
"""
scalars = kwargs.get('scalars', None)
if scalars is not None:
old = self.display_params['scalars']
self.d... | python | def _update_plotting_params(self, **kwargs):
"""Some plotting parameters can be changed through the tool; this
updataes those plotting parameters.
"""
scalars = kwargs.get('scalars', None)
if scalars is not None:
old = self.display_params['scalars']
self.d... | [
"def",
"_update_plotting_params",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"scalars",
"=",
"kwargs",
".",
"get",
"(",
"'scalars'",
",",
"None",
")",
"if",
"scalars",
"is",
"not",
"None",
":",
"old",
"=",
"self",
".",
"display_params",
"[",
"'sca... | Some plotting parameters can be changed through the tool; this
updataes those plotting parameters. | [
"Some",
"plotting",
"parameters",
"can",
"be",
"changed",
"through",
"the",
"tool",
";",
"this",
"updataes",
"those",
"plotting",
"parameters",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/ipy_tools.py#L181-L197 | train |
vtkiorg/vtki | vtki/renderer.py | _remove_mapper_from_plotter | def _remove_mapper_from_plotter(plotter, actor, reset_camera):
"""removes this actor's mapper from the given plotter's _scalar_bar_mappers"""
try:
mapper = actor.GetMapper()
except AttributeError:
return
for name in list(plotter._scalar_bar_mappers.keys()):
try:
plott... | python | def _remove_mapper_from_plotter(plotter, actor, reset_camera):
"""removes this actor's mapper from the given plotter's _scalar_bar_mappers"""
try:
mapper = actor.GetMapper()
except AttributeError:
return
for name in list(plotter._scalar_bar_mappers.keys()):
try:
plott... | [
"def",
"_remove_mapper_from_plotter",
"(",
"plotter",
",",
"actor",
",",
"reset_camera",
")",
":",
"try",
":",
"mapper",
"=",
"actor",
".",
"GetMapper",
"(",
")",
"except",
"AttributeError",
":",
"return",
"for",
"name",
"in",
"list",
"(",
"plotter",
".",
... | removes this actor's mapper from the given plotter's _scalar_bar_mappers | [
"removes",
"this",
"actor",
"s",
"mapper",
"from",
"the",
"given",
"plotter",
"s",
"_scalar_bar_mappers"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L774-L791 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.add_axes_at_origin | def add_axes_at_origin(self):
"""
Add axes actor at origin
Returns
--------
marker_actor : vtk.vtkAxesActor
vtkAxesActor actor
"""
self.marker_actor = vtk.vtkAxesActor()
# renderer = self.renderers[self.loc_to_index(loc)]
self.AddActor... | python | def add_axes_at_origin(self):
"""
Add axes actor at origin
Returns
--------
marker_actor : vtk.vtkAxesActor
vtkAxesActor actor
"""
self.marker_actor = vtk.vtkAxesActor()
# renderer = self.renderers[self.loc_to_index(loc)]
self.AddActor... | [
"def",
"add_axes_at_origin",
"(",
"self",
")",
":",
"self",
".",
"marker_actor",
"=",
"vtk",
".",
"vtkAxesActor",
"(",
")",
"# renderer = self.renderers[self.loc_to_index(loc)]",
"self",
".",
"AddActor",
"(",
"self",
".",
"marker_actor",
")",
"self",
".",
"parent"... | Add axes actor at origin
Returns
--------
marker_actor : vtk.vtkAxesActor
vtkAxesActor actor | [
"Add",
"axes",
"actor",
"at",
"origin"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L128-L141 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.remove_bounding_box | def remove_bounding_box(self):
""" Removes bounding box """
if hasattr(self, '_box_object'):
actor = self.bounding_box_actor
self.bounding_box_actor = None
del self._box_object
self.remove_actor(actor, reset_camera=False) | python | def remove_bounding_box(self):
""" Removes bounding box """
if hasattr(self, '_box_object'):
actor = self.bounding_box_actor
self.bounding_box_actor = None
del self._box_object
self.remove_actor(actor, reset_camera=False) | [
"def",
"remove_bounding_box",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_box_object'",
")",
":",
"actor",
"=",
"self",
".",
"bounding_box_actor",
"self",
".",
"bounding_box_actor",
"=",
"None",
"del",
"self",
".",
"_box_object",
"self",
"."... | Removes bounding box | [
"Removes",
"bounding",
"box"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L433-L439 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.camera_position | def camera_position(self):
""" Returns camera position of active render window """
return [self.camera.GetPosition(),
self.camera.GetFocalPoint(),
self.camera.GetViewUp()] | python | def camera_position(self):
""" Returns camera position of active render window """
return [self.camera.GetPosition(),
self.camera.GetFocalPoint(),
self.camera.GetViewUp()] | [
"def",
"camera_position",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"camera",
".",
"GetPosition",
"(",
")",
",",
"self",
".",
"camera",
".",
"GetFocalPoint",
"(",
")",
",",
"self",
".",
"camera",
".",
"GetViewUp",
"(",
")",
"]"
] | Returns camera position of active render window | [
"Returns",
"camera",
"position",
"of",
"active",
"render",
"window"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L499-L503 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.camera_position | def camera_position(self, camera_location):
""" Set camera position of all active render windows """
if camera_location is None:
return
if isinstance(camera_location, str):
camera_location = camera_location.lower()
if camera_location == 'xy':
... | python | def camera_position(self, camera_location):
""" Set camera position of all active render windows """
if camera_location is None:
return
if isinstance(camera_location, str):
camera_location = camera_location.lower()
if camera_location == 'xy':
... | [
"def",
"camera_position",
"(",
"self",
",",
"camera_location",
")",
":",
"if",
"camera_location",
"is",
"None",
":",
"return",
"if",
"isinstance",
"(",
"camera_location",
",",
"str",
")",
":",
"camera_location",
"=",
"camera_location",
".",
"lower",
"(",
")",
... | Set camera position of all active render windows | [
"Set",
"camera",
"position",
"of",
"all",
"active",
"render",
"windows"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L506-L537 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.remove_actor | def remove_actor(self, actor, reset_camera=False):
"""
Removes an actor from the Renderer.
Parameters
----------
actor : vtk.vtkActor
Actor that has previously added to the Renderer.
reset_camera : bool, optional
Resets camera so all actors can b... | python | def remove_actor(self, actor, reset_camera=False):
"""
Removes an actor from the Renderer.
Parameters
----------
actor : vtk.vtkActor
Actor that has previously added to the Renderer.
reset_camera : bool, optional
Resets camera so all actors can b... | [
"def",
"remove_actor",
"(",
"self",
",",
"actor",
",",
"reset_camera",
"=",
"False",
")",
":",
"name",
"=",
"None",
"if",
"isinstance",
"(",
"actor",
",",
"str",
")",
":",
"name",
"=",
"actor",
"keys",
"=",
"list",
"(",
"self",
".",
"_actors",
".",
... | Removes an actor from the Renderer.
Parameters
----------
actor : vtk.vtkActor
Actor that has previously added to the Renderer.
reset_camera : bool, optional
Resets camera so all actors can be seen.
Returns
-------
success : bool
... | [
"Removes",
"an",
"actor",
"from",
"the",
"Renderer",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L544-L603 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.set_scale | def set_scale(self, xscale=None, yscale=None, zscale=None, reset_camera=True):
"""
Scale all the datasets in the scene.
Scaling in performed independently on the X, Y and Z axis.
A scale of zero is illegal and will be replaced with one.
"""
if xscale is None:
... | python | def set_scale(self, xscale=None, yscale=None, zscale=None, reset_camera=True):
"""
Scale all the datasets in the scene.
Scaling in performed independently on the X, Y and Z axis.
A scale of zero is illegal and will be replaced with one.
"""
if xscale is None:
... | [
"def",
"set_scale",
"(",
"self",
",",
"xscale",
"=",
"None",
",",
"yscale",
"=",
"None",
",",
"zscale",
"=",
"None",
",",
"reset_camera",
"=",
"True",
")",
":",
"if",
"xscale",
"is",
"None",
":",
"xscale",
"=",
"self",
".",
"scale",
"[",
"0",
"]",
... | Scale all the datasets in the scene.
Scaling in performed independently on the X, Y and Z axis.
A scale of zero is illegal and will be replaced with one. | [
"Scale",
"all",
"the",
"datasets",
"in",
"the",
"scene",
".",
"Scaling",
"in",
"performed",
"independently",
"on",
"the",
"X",
"Y",
"and",
"Z",
"axis",
".",
"A",
"scale",
"of",
"zero",
"is",
"illegal",
"and",
"will",
"be",
"replaced",
"with",
"one",
".... | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L605-L626 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.bounds | def bounds(self):
""" Bounds of all actors present in the rendering window """
the_bounds = [np.inf, -np.inf, np.inf, -np.inf, np.inf, -np.inf]
def _update_bounds(bounds):
def update_axis(ax):
if bounds[ax*2] < the_bounds[ax*2]:
the_bounds[ax*2] =... | python | def bounds(self):
""" Bounds of all actors present in the rendering window """
the_bounds = [np.inf, -np.inf, np.inf, -np.inf, np.inf, -np.inf]
def _update_bounds(bounds):
def update_axis(ax):
if bounds[ax*2] < the_bounds[ax*2]:
the_bounds[ax*2] =... | [
"def",
"bounds",
"(",
"self",
")",
":",
"the_bounds",
"=",
"[",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
",",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
",",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
"]",
"def",
"_update_bounds",
... | Bounds of all actors present in the rendering window | [
"Bounds",
"of",
"all",
"actors",
"present",
"in",
"the",
"rendering",
"window"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L629-L650 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.center | def center(self):
"""Center of the bounding box around all data present in the scene"""
bounds = self.bounds
x = (bounds[1] + bounds[0])/2
y = (bounds[3] + bounds[2])/2
z = (bounds[5] + bounds[4])/2
return [x, y, z] | python | def center(self):
"""Center of the bounding box around all data present in the scene"""
bounds = self.bounds
x = (bounds[1] + bounds[0])/2
y = (bounds[3] + bounds[2])/2
z = (bounds[5] + bounds[4])/2
return [x, y, z] | [
"def",
"center",
"(",
"self",
")",
":",
"bounds",
"=",
"self",
".",
"bounds",
"x",
"=",
"(",
"bounds",
"[",
"1",
"]",
"+",
"bounds",
"[",
"0",
"]",
")",
"/",
"2",
"y",
"=",
"(",
"bounds",
"[",
"3",
"]",
"+",
"bounds",
"[",
"2",
"]",
")",
... | Center of the bounding box around all data present in the scene | [
"Center",
"of",
"the",
"bounding",
"box",
"around",
"all",
"data",
"present",
"in",
"the",
"scene"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L653-L659 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.get_default_cam_pos | def get_default_cam_pos(self):
"""
Returns the default focal points and viewup. Uses ResetCamera to
make a useful view.
"""
focal_pt = self.center
return [np.array(rcParams['camera']['position']) + np.array(focal_pt),
focal_pt, rcParams['camera']['viewup']... | python | def get_default_cam_pos(self):
"""
Returns the default focal points and viewup. Uses ResetCamera to
make a useful view.
"""
focal_pt = self.center
return [np.array(rcParams['camera']['position']) + np.array(focal_pt),
focal_pt, rcParams['camera']['viewup']... | [
"def",
"get_default_cam_pos",
"(",
"self",
")",
":",
"focal_pt",
"=",
"self",
".",
"center",
"return",
"[",
"np",
".",
"array",
"(",
"rcParams",
"[",
"'camera'",
"]",
"[",
"'position'",
"]",
")",
"+",
"np",
".",
"array",
"(",
"focal_pt",
")",
",",
"f... | Returns the default focal points and viewup. Uses ResetCamera to
make a useful view. | [
"Returns",
"the",
"default",
"focal",
"points",
"and",
"viewup",
".",
"Uses",
"ResetCamera",
"to",
"make",
"a",
"useful",
"view",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L661-L668 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.update_bounds_axes | def update_bounds_axes(self):
"""Update the bounds axes of the render window """
if (hasattr(self, '_box_object') and self._box_object is not None
and self.bounding_box_actor is not None):
if not np.allclose(self._box_object.bounds, self.bounds):
color = self.... | python | def update_bounds_axes(self):
"""Update the bounds axes of the render window """
if (hasattr(self, '_box_object') and self._box_object is not None
and self.bounding_box_actor is not None):
if not np.allclose(self._box_object.bounds, self.bounds):
color = self.... | [
"def",
"update_bounds_axes",
"(",
"self",
")",
":",
"if",
"(",
"hasattr",
"(",
"self",
",",
"'_box_object'",
")",
"and",
"self",
".",
"_box_object",
"is",
"not",
"None",
"and",
"self",
".",
"bounding_box_actor",
"is",
"not",
"None",
")",
":",
"if",
"not"... | Update the bounds axes of the render window | [
"Update",
"the",
"bounds",
"axes",
"of",
"the",
"render",
"window"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L670-L683 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.view_isometric | def view_isometric(self):
"""
Resets the camera to a default isometric view showing all the
actors in the scene.
"""
self.camera_position = self.get_default_cam_pos()
self.camera_set = False
return self.reset_camera() | python | def view_isometric(self):
"""
Resets the camera to a default isometric view showing all the
actors in the scene.
"""
self.camera_position = self.get_default_cam_pos()
self.camera_set = False
return self.reset_camera() | [
"def",
"view_isometric",
"(",
"self",
")",
":",
"self",
".",
"camera_position",
"=",
"self",
".",
"get_default_cam_pos",
"(",
")",
"self",
".",
"camera_set",
"=",
"False",
"return",
"self",
".",
"reset_camera",
"(",
")"
] | Resets the camera to a default isometric view showing all the
actors in the scene. | [
"Resets",
"the",
"camera",
"to",
"a",
"default",
"isometric",
"view",
"showing",
"all",
"the",
"actors",
"in",
"the",
"scene",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L697-L704 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.view_vector | def view_vector(self, vector, viewup=None):
"""Point the camera in the direction of the given vector"""
focal_pt = self.center
if viewup is None:
viewup = rcParams['camera']['viewup']
cpos = [vector + np.array(focal_pt),
focal_pt, viewup]
self.camera_p... | python | def view_vector(self, vector, viewup=None):
"""Point the camera in the direction of the given vector"""
focal_pt = self.center
if viewup is None:
viewup = rcParams['camera']['viewup']
cpos = [vector + np.array(focal_pt),
focal_pt, viewup]
self.camera_p... | [
"def",
"view_vector",
"(",
"self",
",",
"vector",
",",
"viewup",
"=",
"None",
")",
":",
"focal_pt",
"=",
"self",
".",
"center",
"if",
"viewup",
"is",
"None",
":",
"viewup",
"=",
"rcParams",
"[",
"'camera'",
"]",
"[",
"'viewup'",
"]",
"cpos",
"=",
"["... | Point the camera in the direction of the given vector | [
"Point",
"the",
"camera",
"in",
"the",
"direction",
"of",
"the",
"given",
"vector"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L706-L714 | train |
vtkiorg/vtki | vtki/renderer.py | Renderer.view_xy | def view_xy(self, negative=False):
"""View the XY plane"""
vec = np.array([0,0,1])
viewup = np.array([0,1,0])
if negative:
vec = np.array([0,0,-1])
return self.view_vector(vec, viewup) | python | def view_xy(self, negative=False):
"""View the XY plane"""
vec = np.array([0,0,1])
viewup = np.array([0,1,0])
if negative:
vec = np.array([0,0,-1])
return self.view_vector(vec, viewup) | [
"def",
"view_xy",
"(",
"self",
",",
"negative",
"=",
"False",
")",
":",
"vec",
"=",
"np",
".",
"array",
"(",
"[",
"0",
",",
"0",
",",
"1",
"]",
")",
"viewup",
"=",
"np",
".",
"array",
"(",
"[",
"0",
",",
"1",
",",
"0",
"]",
")",
"if",
"ne... | View the XY plane | [
"View",
"the",
"XY",
"plane"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L716-L722 | train |
vtkiorg/vtki | vtki/utilities.py | cell_scalar | def cell_scalar(mesh, name):
""" Returns cell scalars of a vtk object """
vtkarr = mesh.GetCellData().GetArray(name)
if vtkarr:
if isinstance(vtkarr, vtk.vtkBitArray):
vtkarr = vtk_bit_array_to_char(vtkarr)
return vtk_to_numpy(vtkarr) | python | def cell_scalar(mesh, name):
""" Returns cell scalars of a vtk object """
vtkarr = mesh.GetCellData().GetArray(name)
if vtkarr:
if isinstance(vtkarr, vtk.vtkBitArray):
vtkarr = vtk_bit_array_to_char(vtkarr)
return vtk_to_numpy(vtkarr) | [
"def",
"cell_scalar",
"(",
"mesh",
",",
"name",
")",
":",
"vtkarr",
"=",
"mesh",
".",
"GetCellData",
"(",
")",
".",
"GetArray",
"(",
"name",
")",
"if",
"vtkarr",
":",
"if",
"isinstance",
"(",
"vtkarr",
",",
"vtk",
".",
"vtkBitArray",
")",
":",
"vtkar... | Returns cell scalars of a vtk object | [
"Returns",
"cell",
"scalars",
"of",
"a",
"vtk",
"object"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L44-L50 | train |
vtkiorg/vtki | vtki/utilities.py | vtk_points | def vtk_points(points, deep=True):
""" Convert numpy points to a vtkPoints object """
if not points.flags['C_CONTIGUOUS']:
points = np.ascontiguousarray(points)
vtkpts = vtk.vtkPoints()
vtkpts.SetData(numpy_to_vtk(points, deep=deep))
return vtkpts | python | def vtk_points(points, deep=True):
""" Convert numpy points to a vtkPoints object """
if not points.flags['C_CONTIGUOUS']:
points = np.ascontiguousarray(points)
vtkpts = vtk.vtkPoints()
vtkpts.SetData(numpy_to_vtk(points, deep=deep))
return vtkpts | [
"def",
"vtk_points",
"(",
"points",
",",
"deep",
"=",
"True",
")",
":",
"if",
"not",
"points",
".",
"flags",
"[",
"'C_CONTIGUOUS'",
"]",
":",
"points",
"=",
"np",
".",
"ascontiguousarray",
"(",
"points",
")",
"vtkpts",
"=",
"vtk",
".",
"vtkPoints",
"("... | Convert numpy points to a vtkPoints object | [
"Convert",
"numpy",
"points",
"to",
"a",
"vtkPoints",
"object"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L109-L115 | train |
vtkiorg/vtki | vtki/utilities.py | lines_from_points | def lines_from_points(points):
"""
Generates line from points. Assumes points are ordered as line segments.
Parameters
----------
points : np.ndarray
Points representing line segments. For example, two line segments
would be represented as:
np.array([[0, 0, 0], [1, 0, 0],... | python | def lines_from_points(points):
"""
Generates line from points. Assumes points are ordered as line segments.
Parameters
----------
points : np.ndarray
Points representing line segments. For example, two line segments
would be represented as:
np.array([[0, 0, 0], [1, 0, 0],... | [
"def",
"lines_from_points",
"(",
"points",
")",
":",
"# Assuming ordered points, create array defining line order",
"npoints",
"=",
"points",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
"lines",
"=",
"np",
".",
"vstack",
"(",
"(",
"2",
"*",
"np",
".",
"ones",
"("... | Generates line from points. Assumes points are ordered as line segments.
Parameters
----------
points : np.ndarray
Points representing line segments. For example, two line segments
would be represented as:
np.array([[0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 1, 0]])
Returns
--... | [
"Generates",
"line",
"from",
"points",
".",
"Assumes",
"points",
"are",
"ordered",
"as",
"line",
"segments",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L118-L152 | train |
vtkiorg/vtki | vtki/utilities.py | vector_poly_data | def vector_poly_data(orig, vec):
""" Creates a vtkPolyData object composed of vectors """
# shape, dimention checking
if not isinstance(orig, np.ndarray):
orig = np.asarray(orig)
if not isinstance(vec, np.ndarray):
vec = np.asarray(vec)
if orig.ndim != 2:
orig = orig.resha... | python | def vector_poly_data(orig, vec):
""" Creates a vtkPolyData object composed of vectors """
# shape, dimention checking
if not isinstance(orig, np.ndarray):
orig = np.asarray(orig)
if not isinstance(vec, np.ndarray):
vec = np.asarray(vec)
if orig.ndim != 2:
orig = orig.resha... | [
"def",
"vector_poly_data",
"(",
"orig",
",",
"vec",
")",
":",
"# shape, dimention checking",
"if",
"not",
"isinstance",
"(",
"orig",
",",
"np",
".",
"ndarray",
")",
":",
"orig",
"=",
"np",
".",
"asarray",
"(",
"orig",
")",
"if",
"not",
"isinstance",
"(",... | Creates a vtkPolyData object composed of vectors | [
"Creates",
"a",
"vtkPolyData",
"object",
"composed",
"of",
"vectors"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L155-L209 | train |
vtkiorg/vtki | vtki/utilities.py | trans_from_matrix | def trans_from_matrix(matrix):
""" Convert a vtk matrix to a numpy.ndarray """
t = np.zeros((4, 4))
for i in range(4):
for j in range(4):
t[i, j] = matrix.GetElement(i, j)
return t | python | def trans_from_matrix(matrix):
""" Convert a vtk matrix to a numpy.ndarray """
t = np.zeros((4, 4))
for i in range(4):
for j in range(4):
t[i, j] = matrix.GetElement(i, j)
return t | [
"def",
"trans_from_matrix",
"(",
"matrix",
")",
":",
"t",
"=",
"np",
".",
"zeros",
"(",
"(",
"4",
",",
"4",
")",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"for",
"j",
"in",
"range",
"(",
"4",
")",
":",
"t",
"[",
"i",
",",
"j",
"... | Convert a vtk matrix to a numpy.ndarray | [
"Convert",
"a",
"vtk",
"matrix",
"to",
"a",
"numpy",
".",
"ndarray"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L212-L218 | train |
vtkiorg/vtki | vtki/utilities.py | wrap | def wrap(vtkdataset):
"""This is a convenience method to safely wrap any given VTK data object
to its appropriate ``vtki`` data object.
"""
wrappers = {
'vtkUnstructuredGrid' : vtki.UnstructuredGrid,
'vtkRectilinearGrid' : vtki.RectilinearGrid,
'vtkStructuredGrid' : vtki.Structur... | python | def wrap(vtkdataset):
"""This is a convenience method to safely wrap any given VTK data object
to its appropriate ``vtki`` data object.
"""
wrappers = {
'vtkUnstructuredGrid' : vtki.UnstructuredGrid,
'vtkRectilinearGrid' : vtki.RectilinearGrid,
'vtkStructuredGrid' : vtki.Structur... | [
"def",
"wrap",
"(",
"vtkdataset",
")",
":",
"wrappers",
"=",
"{",
"'vtkUnstructuredGrid'",
":",
"vtki",
".",
"UnstructuredGrid",
",",
"'vtkRectilinearGrid'",
":",
"vtki",
".",
"RectilinearGrid",
",",
"'vtkStructuredGrid'",
":",
"vtki",
".",
"StructuredGrid",
",",
... | This is a convenience method to safely wrap any given VTK data object
to its appropriate ``vtki`` data object. | [
"This",
"is",
"a",
"convenience",
"method",
"to",
"safely",
"wrap",
"any",
"given",
"VTK",
"data",
"object",
"to",
"its",
"appropriate",
"vtki",
"data",
"object",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L221-L240 | train |
vtkiorg/vtki | vtki/utilities.py | image_to_texture | def image_to_texture(image):
"""Converts ``vtkImageData`` to a ``vtkTexture``"""
vtex = vtk.vtkTexture()
vtex.SetInputDataObject(image)
vtex.Update()
return vtex | python | def image_to_texture(image):
"""Converts ``vtkImageData`` to a ``vtkTexture``"""
vtex = vtk.vtkTexture()
vtex.SetInputDataObject(image)
vtex.Update()
return vtex | [
"def",
"image_to_texture",
"(",
"image",
")",
":",
"vtex",
"=",
"vtk",
".",
"vtkTexture",
"(",
")",
"vtex",
".",
"SetInputDataObject",
"(",
"image",
")",
"vtex",
".",
"Update",
"(",
")",
"return",
"vtex"
] | Converts ``vtkImageData`` to a ``vtkTexture`` | [
"Converts",
"vtkImageData",
"to",
"a",
"vtkTexture"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L243-L248 | train |
vtkiorg/vtki | vtki/utilities.py | numpy_to_texture | def numpy_to_texture(image):
"""Convert a NumPy image array to a vtk.vtkTexture"""
if not isinstance(image, np.ndarray):
raise TypeError('Unknown input type ({})'.format(type(image)))
if image.ndim != 3 or image.shape[2] != 3:
raise AssertionError('Input image must be nn by nm by RGB')
g... | python | def numpy_to_texture(image):
"""Convert a NumPy image array to a vtk.vtkTexture"""
if not isinstance(image, np.ndarray):
raise TypeError('Unknown input type ({})'.format(type(image)))
if image.ndim != 3 or image.shape[2] != 3:
raise AssertionError('Input image must be nn by nm by RGB')
g... | [
"def",
"numpy_to_texture",
"(",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"TypeError",
"(",
"'Unknown input type ({})'",
".",
"format",
"(",
"type",
"(",
"image",
")",
")",
")",
"if",
"image... | Convert a NumPy image array to a vtk.vtkTexture | [
"Convert",
"a",
"NumPy",
"image",
"array",
"to",
"a",
"vtk",
".",
"vtkTexture"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L251-L260 | train |
vtkiorg/vtki | vtki/utilities.py | is_inside_bounds | def is_inside_bounds(point, bounds):
""" Checks if a point is inside a set of bounds. This is implemented
through recursion so that this is N-dimensional.
"""
if isinstance(point, (int, float)):
point = [point]
if isinstance(point, collections.Iterable) and not isinstance(point, collections.... | python | def is_inside_bounds(point, bounds):
""" Checks if a point is inside a set of bounds. This is implemented
through recursion so that this is N-dimensional.
"""
if isinstance(point, (int, float)):
point = [point]
if isinstance(point, collections.Iterable) and not isinstance(point, collections.... | [
"def",
"is_inside_bounds",
"(",
"point",
",",
"bounds",
")",
":",
"if",
"isinstance",
"(",
"point",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"point",
"=",
"[",
"point",
"]",
"if",
"isinstance",
"(",
"point",
",",
"collections",
".",
"Iterable",
... | Checks if a point is inside a set of bounds. This is implemented
through recursion so that this is N-dimensional. | [
"Checks",
"if",
"a",
"point",
"is",
"inside",
"a",
"set",
"of",
"bounds",
".",
"This",
"is",
"implemented",
"through",
"recursion",
"so",
"that",
"this",
"is",
"N",
"-",
"dimensional",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L263-L283 | train |
vtkiorg/vtki | vtki/utilities.py | fit_plane_to_points | def fit_plane_to_points(points, return_meta=False):
"""
Fits a plane to a set of points
Parameters
----------
points : np.ndarray
Size n by 3 array of points to fit a plane through
return_meta : bool
If true, also returns the center and normal used to generate the plane
"""... | python | def fit_plane_to_points(points, return_meta=False):
"""
Fits a plane to a set of points
Parameters
----------
points : np.ndarray
Size n by 3 array of points to fit a plane through
return_meta : bool
If true, also returns the center and normal used to generate the plane
"""... | [
"def",
"fit_plane_to_points",
"(",
"points",
",",
"return_meta",
"=",
"False",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"points",
")",
"center",
"=",
"data",
".",
"mean",
"(",
"axis",
"=",
"0",
")",
"result",
"=",
"np",
".",
"linalg",
".",
"... | Fits a plane to a set of points
Parameters
----------
points : np.ndarray
Size n by 3 array of points to fit a plane through
return_meta : bool
If true, also returns the center and normal used to generate the plane | [
"Fits",
"a",
"plane",
"to",
"a",
"set",
"of",
"points"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/utilities.py#L286-L305 | train |
vtkiorg/vtki | vtki/plotting.py | set_plot_theme | def set_plot_theme(theme):
"""Set the plotting parameters to a predefined theme"""
if theme.lower() in ['paraview', 'pv']:
rcParams['background'] = PV_BACKGROUND
rcParams['cmap'] = 'coolwarm'
rcParams['font']['family'] = 'arial'
rcParams['font']['label_size'] = 16
rcParam... | python | def set_plot_theme(theme):
"""Set the plotting parameters to a predefined theme"""
if theme.lower() in ['paraview', 'pv']:
rcParams['background'] = PV_BACKGROUND
rcParams['cmap'] = 'coolwarm'
rcParams['font']['family'] = 'arial'
rcParams['font']['label_size'] = 16
rcParam... | [
"def",
"set_plot_theme",
"(",
"theme",
")",
":",
"if",
"theme",
".",
"lower",
"(",
")",
"in",
"[",
"'paraview'",
",",
"'pv'",
"]",
":",
"rcParams",
"[",
"'background'",
"]",
"=",
"PV_BACKGROUND",
"rcParams",
"[",
"'cmap'",
"]",
"=",
"'coolwarm'",
"rcPara... | Set the plotting parameters to a predefined theme | [
"Set",
"the",
"plotting",
"parameters",
"to",
"a",
"predefined",
"theme"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/plotting.py#L85-L112 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.