body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
@_with_element def button(self, element, label, key=None): "Display a button widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this button is for.\n key : str\n An optional string to use as the unique key for the widget.\n...
8,915,156,771,501,557,000
Display a button widget. Parameters ---------- label : str A short label explaining to the user what this button is for. key : str An optional string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. Multiple widgets of the same ty...
lib/streamlit/DeltaGenerator.py
button
OakNorthAI/streamlit-base
python
@_with_element def button(self, element, label, key=None): "Display a button widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this button is for.\n key : str\n An optional string to use as the unique key for the widget.\n...
@_with_element def checkbox(self, element, label, value=False, key=None): "Display a checkbox widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this checkbox is for.\n value : bool\n Preselect the checkbox when it first re...
4,435,925,171,239,557,000
Display a checkbox widget. Parameters ---------- label : str A short label explaining to the user what this checkbox is for. value : bool Preselect the checkbox when it first renders. This will be cast to bool internally. key : str An optional string to use as the unique key for the widget. If this...
lib/streamlit/DeltaGenerator.py
checkbox
OakNorthAI/streamlit-base
python
@_with_element def checkbox(self, element, label, value=False, key=None): "Display a checkbox widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this checkbox is for.\n value : bool\n Preselect the checkbox when it first re...
@_with_element def multiselect(self, element, label, options, default=None, format_func=str, key=None): "Display a multiselect widget.\n The multiselect widget starts as empty.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this select wi...
-4,061,092,096,204,065,000
Display a multiselect widget. The multiselect widget starts as empty. Parameters ---------- label : str A short label explaining to the user what this select widget is for. options : list, tuple, numpy.ndarray, or pandas.Series Labels for the select options. This will be cast to str internally by default. ...
lib/streamlit/DeltaGenerator.py
multiselect
OakNorthAI/streamlit-base
python
@_with_element def multiselect(self, element, label, options, default=None, format_func=str, key=None): "Display a multiselect widget.\n The multiselect widget starts as empty.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this select wi...
@_with_element def radio(self, element, label, options, index=0, format_func=str, key=None): 'Display a radio button widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this radio group is for.\n options : list, tuple, numpy.ndarray, o...
-1,261,307,580,793,010,700
Display a radio button widget. Parameters ---------- label : str A short label explaining to the user what this radio group is for. options : list, tuple, numpy.ndarray, or pandas.Series Labels for the radio options. This will be cast to str internally by default. index : int The index of the preselect...
lib/streamlit/DeltaGenerator.py
radio
OakNorthAI/streamlit-base
python
@_with_element def radio(self, element, label, options, index=0, format_func=str, key=None): 'Display a radio button widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this radio group is for.\n options : list, tuple, numpy.ndarray, o...
@_with_element def selectbox(self, element, label, options, index=0, format_func=str, key=None): "Display a select widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this select widget is for.\n options : list, tuple, numpy.ndarray, o...
-5,761,214,060,143,018,000
Display a select widget. Parameters ---------- label : str A short label explaining to the user what this select widget is for. options : list, tuple, numpy.ndarray, or pandas.Series Labels for the select options. This will be cast to str internally by default. index : int The index of the preselected ...
lib/streamlit/DeltaGenerator.py
selectbox
OakNorthAI/streamlit-base
python
@_with_element def selectbox(self, element, label, options, index=0, format_func=str, key=None): "Display a select widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this select widget is for.\n options : list, tuple, numpy.ndarray, o...
@_with_element def slider(self, element, label, min_value=None, max_value=None, value=None, step=None, format=None, key=None): 'Display a slider widget.\n\n This also allows you to render a range slider by passing a two-element tuple or list as the `value`.\n\n Parameters\n ----------\n ...
7,022,913,251,441,921,000
Display a slider widget. This also allows you to render a range slider by passing a two-element tuple or list as the `value`. Parameters ---------- label : str or None A short label explaining to the user what this slider is for. min_value : int/float or None The minimum permitted value. Defaults to 0 if ...
lib/streamlit/DeltaGenerator.py
slider
OakNorthAI/streamlit-base
python
@_with_element def slider(self, element, label, min_value=None, max_value=None, value=None, step=None, format=None, key=None): 'Display a slider widget.\n\n This also allows you to render a range slider by passing a two-element tuple or list as the `value`.\n\n Parameters\n ----------\n ...
@_with_element def file_uploader(self, element, label, type=None, encoding='auto', key=None): 'Display a file uploader widget.\n\n By default, uploaded files are limited to 200MB. You can configure\n this using the `server.maxUploadSize` config option.\n\n Parameters\n ----------\n ...
-8,024,954,997,992,139,000
Display a file uploader widget. By default, uploaded files are limited to 200MB. You can configure this using the `server.maxUploadSize` config option. Parameters ---------- label : str or None A short label explaining to the user what this file uploader is for. type : str or list of str or None Array of allo...
lib/streamlit/DeltaGenerator.py
file_uploader
OakNorthAI/streamlit-base
python
@_with_element def file_uploader(self, element, label, type=None, encoding='auto', key=None): 'Display a file uploader widget.\n\n By default, uploaded files are limited to 200MB. You can configure\n this using the `server.maxUploadSize` config option.\n\n Parameters\n ----------\n ...
@_with_element def beta_color_picker(self, element, label, value=None, key=None): "Display a color picker widget.\n\n Note: This is a beta feature. See\n https://docs.streamlit.io/en/latest/pre_release_features.html for more\n information.\n\n Parameters\n ----------\n labe...
8,279,966,507,809,524,000
Display a color picker widget. Note: This is a beta feature. See https://docs.streamlit.io/en/latest/pre_release_features.html for more information. Parameters ---------- label : str A short label explaining to the user what this input is for. value : str or None The hex value of this widget when it first ren...
lib/streamlit/DeltaGenerator.py
beta_color_picker
OakNorthAI/streamlit-base
python
@_with_element def beta_color_picker(self, element, label, value=None, key=None): "Display a color picker widget.\n\n Note: This is a beta feature. See\n https://docs.streamlit.io/en/latest/pre_release_features.html for more\n information.\n\n Parameters\n ----------\n labe...
@_with_element def text_input(self, element, label, value='', max_chars=None, key=None, type='default'): 'Display a single-line text input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this input is for.\n value : any\n ...
7,888,950,086,938,866,000
Display a single-line text input widget. Parameters ---------- label : str A short label explaining to the user what this input is for. value : any The text value of this widget when it first renders. This will be cast to str internally. max_chars : int or None Max number of characters allowed in text ...
lib/streamlit/DeltaGenerator.py
text_input
OakNorthAI/streamlit-base
python
@_with_element def text_input(self, element, label, value=, max_chars=None, key=None, type='default'): 'Display a single-line text input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this input is for.\n value : any\n ...
@_with_element def text_area(self, element, label, value='', height=None, max_chars=None, key=None): "Display a multi-line text input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this input is for.\n value : any\n The...
4,256,666,320,738,230,000
Display a multi-line text input widget. Parameters ---------- label : str A short label explaining to the user what this input is for. value : any The text value of this widget when it first renders. This will be cast to str internally. height : int or None Desired height of the UI element expressed in...
lib/streamlit/DeltaGenerator.py
text_area
OakNorthAI/streamlit-base
python
@_with_element def text_area(self, element, label, value=, height=None, max_chars=None, key=None): "Display a multi-line text input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this input is for.\n value : any\n The t...
@_with_element def time_input(self, element, label, value=None, key=None): "Display a time input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this time input is for.\n value : datetime.time/datetime.datetime\n The val...
6,452,685,206,723,403,000
Display a time input widget. Parameters ---------- label : str A short label explaining to the user what this time input is for. value : datetime.time/datetime.datetime The value of this widget when it first renders. This will be cast to str internally. Defaults to the current time. key : str An option...
lib/streamlit/DeltaGenerator.py
time_input
OakNorthAI/streamlit-base
python
@_with_element def time_input(self, element, label, value=None, key=None): "Display a time input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this time input is for.\n value : datetime.time/datetime.datetime\n The val...
@_with_element def date_input(self, element, label, value=None, min_value=datetime.min, max_value=None, key=None): 'Display a date input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this date input is for.\n value : datetime.dat...
-8,081,064,151,479,856,000
Display a date input widget. Parameters ---------- label : str A short label explaining to the user what this date input is for. value : datetime.date or datetime.datetime or list/tuple of datetime.date or datetime.datetime or None The value of this widget when it first renders. If a list/tuple with 0 to 2...
lib/streamlit/DeltaGenerator.py
date_input
OakNorthAI/streamlit-base
python
@_with_element def date_input(self, element, label, value=None, min_value=datetime.min, max_value=None, key=None): 'Display a date input widget.\n\n Parameters\n ----------\n label : str\n A short label explaining to the user what this date input is for.\n value : datetime.dat...
@_with_element def number_input(self, element, label, min_value=None, max_value=None, value=NoValue(), step=None, format=None, key=None): "Display a numeric input widget.\n\n Parameters\n ----------\n label : str or None\n A short label explaining to the user what this input is for.\...
-85,386,675,137,491,120
Display a numeric input widget. Parameters ---------- label : str or None A short label explaining to the user what this input is for. min_value : int or float or None The minimum permitted value. If None, there will be no minimum. max_value : int or float or None The maximum permitted value. If No...
lib/streamlit/DeltaGenerator.py
number_input
OakNorthAI/streamlit-base
python
@_with_element def number_input(self, element, label, min_value=None, max_value=None, value=NoValue(), step=None, format=None, key=None): "Display a numeric input widget.\n\n Parameters\n ----------\n label : str or None\n A short label explaining to the user what this input is for.\...
@_with_element def progress(self, element, value): 'Display a progress bar.\n\n Parameters\n ----------\n value : int or float\n 0 <= value <= 100 for int\n\n 0.0 <= value <= 1.0 for float\n\n Example\n -------\n Here is an example of a progress bar in...
-3,351,466,489,674,978,300
Display a progress bar. Parameters ---------- value : int or float 0 <= value <= 100 for int 0.0 <= value <= 1.0 for float Example ------- Here is an example of a progress bar increasing over time: >>> import time >>> >>> my_bar = st.progress(0) >>> >>> for percent_complete in range(100): ... time.sleep...
lib/streamlit/DeltaGenerator.py
progress
OakNorthAI/streamlit-base
python
@_with_element def progress(self, element, value): 'Display a progress bar.\n\n Parameters\n ----------\n value : int or float\n 0 <= value <= 100 for int\n\n 0.0 <= value <= 1.0 for float\n\n Example\n -------\n Here is an example of a progress bar in...
@_with_element def empty(self, element): 'Add a placeholder to the app.\n\n The placeholder can be filled any time by calling methods on the return\n value.\n\n Example\n -------\n >>> my_placeholder = st.empty()\n >>>\n >>> # Now replace the placeholder with some te...
-2,141,839,062,786,735,400
Add a placeholder to the app. The placeholder can be filled any time by calling methods on the return value. Example ------- >>> my_placeholder = st.empty() >>> >>> # Now replace the placeholder with some text: >>> my_placeholder.text("Hello world!") >>> >>> # And replace the text with an image: >>> my_placeholder.im...
lib/streamlit/DeltaGenerator.py
empty
OakNorthAI/streamlit-base
python
@_with_element def empty(self, element): 'Add a placeholder to the app.\n\n The placeholder can be filled any time by calling methods on the return\n value.\n\n Example\n -------\n >>> my_placeholder = st.empty()\n >>>\n >>> # Now replace the placeholder with some te...
@_with_element def map(self, element, data=None, zoom=None, use_container_width=True): "Display a map with points on it.\n\n This is a wrapper around st.pydeck_chart to quickly create scatterplot\n charts on top of a map, with auto-centering and auto-zoom.\n\n When using this command, we advise...
-8,430,331,400,841,698,000
Display a map with points on it. This is a wrapper around st.pydeck_chart to quickly create scatterplot charts on top of a map, with auto-centering and auto-zoom. When using this command, we advise all users to use a personal Mapbox token. This ensures the map tiles used in this chart are more robust. You can do this...
lib/streamlit/DeltaGenerator.py
map
OakNorthAI/streamlit-base
python
@_with_element def map(self, element, data=None, zoom=None, use_container_width=True): "Display a map with points on it.\n\n This is a wrapper around st.pydeck_chart to quickly create scatterplot\n charts on top of a map, with auto-centering and auto-zoom.\n\n When using this command, we advise...
@_with_element def deck_gl_chart(self, element, spec=None, use_container_width=False, **kwargs): 'Draw a map chart using the Deck.GL library.\n\n This API closely follows Deck.GL\'s JavaScript API\n (https://deck.gl/#/documentation), with a few small adaptations and\n some syntax sugar.\n\n ...
-622,602,971,289,724,700
Draw a map chart using the Deck.GL library. This API closely follows Deck.GL's JavaScript API (https://deck.gl/#/documentation), with a few small adaptations and some syntax sugar. When using this command, we advise all users to use a personal Mapbox token. This ensures the map tiles used in this chart are more robus...
lib/streamlit/DeltaGenerator.py
deck_gl_chart
OakNorthAI/streamlit-base
python
@_with_element def deck_gl_chart(self, element, spec=None, use_container_width=False, **kwargs): 'Draw a map chart using the Deck.GL library.\n\n This API closely follows Deck.GL\'s JavaScript API\n (https://deck.gl/#/documentation), with a few small adaptations and\n some syntax sugar.\n\n ...
@_with_element def pydeck_chart(self, element, pydeck_obj=None, use_container_width=False): "Draw a chart using the PyDeck library.\n\n This supports 3D maps, point clouds, and more! More info about PyDeck\n at https://deckgl.readthedocs.io/en/latest/.\n\n These docs are also quite useful:\n\n ...
-2,861,997,039,057,345,500
Draw a chart using the PyDeck library. This supports 3D maps, point clouds, and more! More info about PyDeck at https://deckgl.readthedocs.io/en/latest/. These docs are also quite useful: - DeckGL docs: https://github.com/uber/deck.gl/tree/master/docs - DeckGL JSON docs: https://github.com/uber/deck.gl/tree/master/m...
lib/streamlit/DeltaGenerator.py
pydeck_chart
OakNorthAI/streamlit-base
python
@_with_element def pydeck_chart(self, element, pydeck_obj=None, use_container_width=False): "Draw a chart using the PyDeck library.\n\n This supports 3D maps, point clouds, and more! More info about PyDeck\n at https://deckgl.readthedocs.io/en/latest/.\n\n These docs are also quite useful:\n\n ...
@_with_element def table(self, element, data=None): "Display a static table.\n\n This differs from `st.dataframe` in that the table in this case is\n static: its entire contents are just laid out directly on the page.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.S...
-684,845,808,264,782,800
Display a static table. This differs from `st.dataframe` in that the table in this case is static: its entire contents are just laid out directly on the page. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict, or None The table data. Example ------- >>> df = pd.DataF...
lib/streamlit/DeltaGenerator.py
table
OakNorthAI/streamlit-base
python
@_with_element def table(self, element, data=None): "Display a static table.\n\n This differs from `st.dataframe` in that the table in this case is\n static: its entire contents are just laid out directly on the page.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.S...
def add_rows(self, data=None, **kwargs): "Concatenate a dataframe to the bottom of the current one.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n Table to concat. Optional.\n\n **kwargs : pandas.DataFram...
2,071,386,834,757,964,800
Concatenate a dataframe to the bottom of the current one. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict, or None Table to concat. Optional. **kwargs : pandas.DataFrame, numpy.ndarray, Iterable, dict, or None The named dataset to concat. Optional. You can only pass...
lib/streamlit/DeltaGenerator.py
add_rows
OakNorthAI/streamlit-base
python
def add_rows(self, data=None, **kwargs): "Concatenate a dataframe to the bottom of the current one.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n Table to concat. Optional.\n\n **kwargs : pandas.DataFram...
def zangle_to_quat(zangle): '\n\t:param zangle in rad\n\t:return: quaternion\n\t' return (Quaternion(axis=[0, 0, 1], angle=np.pi) * Quaternion(axis=[(- 1), 0, 0], angle=zangle)).elements
-907,394,938,173,475,800
:param zangle in rad :return: quaternion
multiworld/envs/mujoco/sawyer_xyz/pickPlace/sawyer_coffee.py
zangle_to_quat
Neo-X/R_multiworld
python
def zangle_to_quat(zangle): '\n\t:param zangle in rad\n\t:return: quaternion\n\t' return (Quaternion(axis=[0, 0, 1], angle=np.pi) * Quaternion(axis=[(- 1), 0, 0], angle=zangle)).elements
def plot_runs(runs): ' Plot population evolutions\n ' ts = range(len(runs[0])) cmap = plt.get_cmap('viridis') for (i, r) in enumerate(runs): (mean, var) = zip(*r) (bm, cm) = zip(*mean) (bv, cv) = zip(*var) color = cmap((float(i) / len(runs))) plt.errorbar(ts, b...
-7,779,025,106,322,543,000
Plot population evolutions
evolutionary_optimization.py
plot_runs
kpj/PySpaMo
python
def plot_runs(runs): ' \n ' ts = range(len(runs[0])) cmap = plt.get_cmap('viridis') for (i, r) in enumerate(runs): (mean, var) = zip(*r) (bm, cm) = zip(*mean) (bv, cv) = zip(*var) color = cmap((float(i) / len(runs))) plt.errorbar(ts, bm, fmt='-', yerr=bv, c=col...
def work(i): ' Handle one optimization case\n ' opti = SnowdriftOptimizer() return opti.run(20)
-7,797,655,574,561,887,000
Handle one optimization case
evolutionary_optimization.py
work
kpj/PySpaMo
python
def work(i): ' \n ' opti = SnowdriftOptimizer() return opti.run(20)
def main(): ' Setup environment\n ' core_num = int(((multiprocessing.cpu_count() * 4) / 5)) print(('Using %d cores' % core_num)) with multiprocessing.Pool(core_num) as p: runs = [i for i in p.imap_unordered(work, range(10))] plot_runs(runs)
-2,119,673,749,091,162,600
Setup environment
evolutionary_optimization.py
main
kpj/PySpaMo
python
def main(): ' \n ' core_num = int(((multiprocessing.cpu_count() * 4) / 5)) print(('Using %d cores' % core_num)) with multiprocessing.Pool(core_num) as p: runs = [i for i in p.imap_unordered(work, range(10))] plot_runs(runs)
def __init__(self): ' Set some parameters\n ' self.mutation_probability = 0.02
-3,959,449,045,668,069,400
Set some parameters
evolutionary_optimization.py
__init__
kpj/PySpaMo
python
def __init__(self): ' \n ' self.mutation_probability = 0.02
def init(self, size): ' Generate initial population\n ' raise NotImplementedError
-5,409,400,848,608,050,000
Generate initial population
evolutionary_optimization.py
init
kpj/PySpaMo
python
def init(self, size): ' \n ' raise NotImplementedError
def get_fitness(self, obj): ' Compute fitness of individual of population\n ' raise NotImplementedError
-4,544,634,260,429,295,600
Compute fitness of individual of population
evolutionary_optimization.py
get_fitness
kpj/PySpaMo
python
def get_fitness(self, obj): ' \n ' raise NotImplementedError
def mutate(self, obj): ' Mutate single individual\n ' raise NotImplementedError
7,139,653,781,928,916,000
Mutate single individual
evolutionary_optimization.py
mutate
kpj/PySpaMo
python
def mutate(self, obj): ' \n ' raise NotImplementedError
def crossover(self, mom, dad): ' Generate offspring from parents\n ' raise NotImplementedError
8,467,720,466,242,567,000
Generate offspring from parents
evolutionary_optimization.py
crossover
kpj/PySpaMo
python
def crossover(self, mom, dad): ' \n ' raise NotImplementedError
def run(self, size, max_iter=100): ' Let life begin\n ' population = self.init(size) res = [] for _ in tqdm(range(max_iter)): pop_fitness = [self.get_fitness(o) for o in population] best_indiv = np.argpartition(pop_fitness, (- 2))[(- 2):] (mom, dad) = population[best_indiv...
2,553,331,538,359,015,400
Let life begin
evolutionary_optimization.py
run
kpj/PySpaMo
python
def run(self, size, max_iter=100): ' \n ' population = self.init(size) res = [] for _ in tqdm(range(max_iter)): pop_fitness = [self.get_fitness(o) for o in population] best_indiv = np.argpartition(pop_fitness, (- 2))[(- 2):] (mom, dad) = population[best_indiv] chil...
def __init__(self, xid=None, flags=None, miss_send_len=None): 'Create a SetConfig with the optional parameters below.\n\n Args:\n xid (int): xid to be used on the message header.\n flags (~pyof.v0x01.controller2switch.common.ConfigFlag):\n OFPC_* flags.\n miss_...
7,739,435,916,392,614,000
Create a SetConfig with the optional parameters below. Args: xid (int): xid to be used on the message header. flags (~pyof.v0x01.controller2switch.common.ConfigFlag): OFPC_* flags. miss_send_len (int): UBInt16 max bytes of new flow that the datapath should send to the controller.
pyof/v0x01/controller2switch/set_config.py
__init__
Niehaus/python-openflow
python
def __init__(self, xid=None, flags=None, miss_send_len=None): 'Create a SetConfig with the optional parameters below.\n\n Args:\n xid (int): xid to be used on the message header.\n flags (~pyof.v0x01.controller2switch.common.ConfigFlag):\n OFPC_* flags.\n miss_...
def __init__(self, domain_range=None, n_basis=None, order=4, knots=None): 'Bspline basis constructor.\n\n Args:\n domain_range (tuple, optional): Definition of the interval where\n the basis defines a space. Defaults to (0,1) if knots are not\n specified. If knots are...
-2,689,459,971,197,850,000
Bspline basis constructor. Args: domain_range (tuple, optional): Definition of the interval where the basis defines a space. Defaults to (0,1) if knots are not specified. If knots are specified defaults to the first and last element of the knots. n_basis (int, optional): Number of splin...
skfda/representation/basis/_bspline.py
__init__
alejandro-ariza/scikit-fda
python
def __init__(self, domain_range=None, n_basis=None, order=4, knots=None): 'Bspline basis constructor.\n\n Args:\n domain_range (tuple, optional): Definition of the interval where\n the basis defines a space. Defaults to (0,1) if knots are not\n specified. If knots are...
def _evaluation_knots(self): '\n Get the knots adding m knots to the boundary in order to allow a\n discontinuous behaviour at the boundaries of the domain [RS05]_.\n\n References:\n .. [RS05] Ramsay, J., Silverman, B. W. (2005). *Functional Data\n Analysis*. Springer....
6,353,720,271,965,828,000
Get the knots adding m knots to the boundary in order to allow a discontinuous behaviour at the boundaries of the domain [RS05]_. References: .. [RS05] Ramsay, J., Silverman, B. W. (2005). *Functional Data Analysis*. Springer. 50-51.
skfda/representation/basis/_bspline.py
_evaluation_knots
alejandro-ariza/scikit-fda
python
def _evaluation_knots(self): '\n Get the knots adding m knots to the boundary in order to allow a\n discontinuous behaviour at the boundaries of the domain [RS05]_.\n\n References:\n .. [RS05] Ramsay, J., Silverman, B. W. (2005). *Functional Data\n Analysis*. Springer....
def rescale(self, domain_range=None): 'Return a copy of the basis with a new domain range, with the\n corresponding values rescaled to the new bounds.\n The knots of the BSpline will be rescaled in the new interval.\n\n Args:\n domain_range (tuple, optional): Definiti...
6,704,090,157,816,201,000
Return a copy of the basis with a new domain range, with the corresponding values rescaled to the new bounds. The knots of the BSpline will be rescaled in the new interval. Args: domain_range (tuple, optional): Definition of the interval where the basis defines a space. Defaults uses the same as th...
skfda/representation/basis/_bspline.py
rescale
alejandro-ariza/scikit-fda
python
def rescale(self, domain_range=None): 'Return a copy of the basis with a new domain range, with the\n corresponding values rescaled to the new bounds.\n The knots of the BSpline will be rescaled in the new interval.\n\n Args:\n domain_range (tuple, optional): Definiti...
def __repr__(self): 'Representation of a BSpline basis.' return f'{self.__class__.__name__}(domain_range={self.domain_range}, n_basis={self.n_basis}, order={self.order}, knots={self.knots})'
6,928,560,861,686,392,000
Representation of a BSpline basis.
skfda/representation/basis/_bspline.py
__repr__
alejandro-ariza/scikit-fda
python
def __repr__(self): return f'{self.__class__.__name__}(domain_range={self.domain_range}, n_basis={self.n_basis}, order={self.order}, knots={self.knots})'
@property def inknots(self): 'Return number of basis.' return self.knots[1:(len(self.knots) - 1)]
-1,807,174,253,610,676,000
Return number of basis.
skfda/representation/basis/_bspline.py
inknots
alejandro-ariza/scikit-fda
python
@property def inknots(self): return self.knots[1:(len(self.knots) - 1)]
def test_boolean(): 'Test boolean validation.' schema = vol.Schema(cv.boolean) for value in ('T', 'negative', 'lock'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('true', 'On', '1', 'YES', 'enable', 1, True): assert schema(value) for value in ('fa...
8,999,340,782,815,011,000
Test boolean validation.
tests/helpers/test_config_validation.py
test_boolean
AidasK/home-assistant
python
def test_boolean(): schema = vol.Schema(cv.boolean) for value in ('T', 'negative', 'lock'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('true', 'On', '1', 'YES', 'enable', 1, True): assert schema(value) for value in ('false', 'Off', '0', 'NO', 'd...
def test_latitude(): 'Test latitude validation.' schema = vol.Schema(cv.latitude) for value in ('invalid', None, (- 91), 91, '-91', '91', '123.01A'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('-89', 89, '12.34'): schema(value)
5,405,025,922,743,942,000
Test latitude validation.
tests/helpers/test_config_validation.py
test_latitude
AidasK/home-assistant
python
def test_latitude(): schema = vol.Schema(cv.latitude) for value in ('invalid', None, (- 91), 91, '-91', '91', '123.01A'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('-89', 89, '12.34'): schema(value)
def test_longitude(): 'Test longitude validation.' schema = vol.Schema(cv.longitude) for value in ('invalid', None, (- 181), 181, '-181', '181', '123.01A'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('-179', 179, '12.34'): schema(value)
-8,674,121,212,617,102,000
Test longitude validation.
tests/helpers/test_config_validation.py
test_longitude
AidasK/home-assistant
python
def test_longitude(): schema = vol.Schema(cv.longitude) for value in ('invalid', None, (- 181), 181, '-181', '181', '123.01A'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('-179', 179, '12.34'): schema(value)
def test_port(): 'Test TCP/UDP network port.' schema = vol.Schema(cv.port) for value in ('invalid', None, (- 1), 0, 80000, '81000'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('1000', 21, 24574): schema(value)
-3,224,789,181,267,330,000
Test TCP/UDP network port.
tests/helpers/test_config_validation.py
test_port
AidasK/home-assistant
python
def test_port(): schema = vol.Schema(cv.port) for value in ('invalid', None, (- 1), 0, 80000, '81000'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('1000', 21, 24574): schema(value)
def test_isfile(): 'Validate that the value is an existing file.' schema = vol.Schema(cv.isfile) fake_file = 'this-file-does-not.exist' assert (not os.path.isfile(fake_file)) for value in ('invalid', None, (- 1), 0, 80000, fake_file): with pytest.raises(vol.Invalid): schema(value...
309,000,967,761,043,600
Validate that the value is an existing file.
tests/helpers/test_config_validation.py
test_isfile
AidasK/home-assistant
python
def test_isfile(): schema = vol.Schema(cv.isfile) fake_file = 'this-file-does-not.exist' assert (not os.path.isfile(fake_file)) for value in ('invalid', None, (- 1), 0, 80000, fake_file): with pytest.raises(vol.Invalid): schema(value) with patch('os.path.isfile', Mock(return...
def test_url(): 'Test URL.' schema = vol.Schema(cv.url) for value in ('invalid', None, 100, 'htp://ha.io', 'http//ha.io', 'http://??,**', 'https://??,**'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('http://localhost', 'https://localhost/test/index.html', 'h...
6,016,607,326,846,040,000
Test URL.
tests/helpers/test_config_validation.py
test_url
AidasK/home-assistant
python
def test_url(): schema = vol.Schema(cv.url) for value in ('invalid', None, 100, 'htp://ha.io', 'http//ha.io', 'http://??,**', 'https://??,**'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ('http://localhost', 'https://localhost/test/index.html', 'http://home-...
def test_platform_config(): 'Test platform config validation.' options = ({}, {'hello': 'world'}) for value in options: with pytest.raises(vol.MultipleInvalid): cv.PLATFORM_SCHEMA(value) options = ({'platform': 'mqtt'}, {'platform': 'mqtt', 'beer': 'yes'}) for value in options: ...
-3,896,017,594,280,178,700
Test platform config validation.
tests/helpers/test_config_validation.py
test_platform_config
AidasK/home-assistant
python
def test_platform_config(): options = ({}, {'hello': 'world'}) for value in options: with pytest.raises(vol.MultipleInvalid): cv.PLATFORM_SCHEMA(value) options = ({'platform': 'mqtt'}, {'platform': 'mqtt', 'beer': 'yes'}) for value in options: cv.PLATFORM_SCHEMA(value)
def test_ensure_list(): 'Test ensure_list.' schema = vol.Schema(cv.ensure_list) assert ([] == schema(None)) assert ([1] == schema(1)) assert ([1] == schema([1])) assert (['1'] == schema('1')) assert (['1'] == schema(['1'])) assert ([{'1': '2'}] == schema({'1': '2'}))
8,073,574,953,741,535,000
Test ensure_list.
tests/helpers/test_config_validation.py
test_ensure_list
AidasK/home-assistant
python
def test_ensure_list(): schema = vol.Schema(cv.ensure_list) assert ([] == schema(None)) assert ([1] == schema(1)) assert ([1] == schema([1])) assert (['1'] == schema('1')) assert (['1'] == schema(['1'])) assert ([{'1': '2'}] == schema({'1': '2'}))
def test_entity_id(): 'Test entity ID validation.' schema = vol.Schema(cv.entity_id) with pytest.raises(vol.MultipleInvalid): schema('invalid_entity') assert (schema('sensor.LIGHT') == 'sensor.light')
4,234,418,284,068,444,000
Test entity ID validation.
tests/helpers/test_config_validation.py
test_entity_id
AidasK/home-assistant
python
def test_entity_id(): schema = vol.Schema(cv.entity_id) with pytest.raises(vol.MultipleInvalid): schema('invalid_entity') assert (schema('sensor.LIGHT') == 'sensor.light')
def test_entity_ids(): 'Test entity ID validation.' schema = vol.Schema(cv.entity_ids) options = ('invalid_entity', 'sensor.light,sensor_invalid', ['invalid_entity'], ['sensor.light', 'sensor_invalid'], ['sensor.light,sensor_invalid']) for value in options: with pytest.raises(vol.MultipleInvalid...
5,483,656,690,993,181,000
Test entity ID validation.
tests/helpers/test_config_validation.py
test_entity_ids
AidasK/home-assistant
python
def test_entity_ids(): schema = vol.Schema(cv.entity_ids) options = ('invalid_entity', 'sensor.light,sensor_invalid', ['invalid_entity'], ['sensor.light', 'sensor_invalid'], ['sensor.light,sensor_invalid']) for value in options: with pytest.raises(vol.MultipleInvalid): schema(value)...
def test_entity_domain(): 'Test entity domain validation.' schema = vol.Schema(cv.entity_domain('sensor')) options = ('invalid_entity', 'cover.demo') for value in options: with pytest.raises(vol.MultipleInvalid): print(value) schema(value) assert (schema('sensor.LIGHT...
4,741,356,306,411,909,000
Test entity domain validation.
tests/helpers/test_config_validation.py
test_entity_domain
AidasK/home-assistant
python
def test_entity_domain(): schema = vol.Schema(cv.entity_domain('sensor')) options = ('invalid_entity', 'cover.demo') for value in options: with pytest.raises(vol.MultipleInvalid): print(value) schema(value) assert (schema('sensor.LIGHT') == 'sensor.light')
def test_entities_domain(): 'Test entities domain validation.' schema = vol.Schema(cv.entities_domain('sensor')) options = (None, '', 'invalid_entity', ['sensor.light', 'cover.demo'], ['sensor.light', 'sensor_invalid']) for value in options: with pytest.raises(vol.MultipleInvalid): s...
7,033,083,670,923,283,000
Test entities domain validation.
tests/helpers/test_config_validation.py
test_entities_domain
AidasK/home-assistant
python
def test_entities_domain(): schema = vol.Schema(cv.entities_domain('sensor')) options = (None, , 'invalid_entity', ['sensor.light', 'cover.demo'], ['sensor.light', 'sensor_invalid']) for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ('sensor....
def test_ensure_list_csv(): 'Test ensure_list_csv.' schema = vol.Schema(cv.ensure_list_csv) options = (None, 12, [], ['string'], 'string1,string2') for value in options: schema(value) assert (schema('string1, string2 ') == ['string1', 'string2'])
-1,662,028,435,425,543,000
Test ensure_list_csv.
tests/helpers/test_config_validation.py
test_ensure_list_csv
AidasK/home-assistant
python
def test_ensure_list_csv(): schema = vol.Schema(cv.ensure_list_csv) options = (None, 12, [], ['string'], 'string1,string2') for value in options: schema(value) assert (schema('string1, string2 ') == ['string1', 'string2'])
def test_event_schema(): 'Test event_schema validation.' options = ({}, None, {'event_data': {}}, {'event': 'state_changed', 'event_data': 1}) for value in options: with pytest.raises(vol.MultipleInvalid): cv.EVENT_SCHEMA(value) options = ({'event': 'state_changed'}, {'event': 'state...
-7,224,355,690,011,239,000
Test event_schema validation.
tests/helpers/test_config_validation.py
test_event_schema
AidasK/home-assistant
python
def test_event_schema(): options = ({}, None, {'event_data': {}}, {'event': 'state_changed', 'event_data': 1}) for value in options: with pytest.raises(vol.MultipleInvalid): cv.EVENT_SCHEMA(value) options = ({'event': 'state_changed'}, {'event': 'state_changed', 'event_data': {'hell...
def test_icon(): 'Test icon validation.' schema = vol.Schema(cv.icon) for value in (False, 'work'): with pytest.raises(vol.MultipleInvalid): schema(value) schema('mdi:work') schema('custom:prefix')
-6,032,756,510,433,722,000
Test icon validation.
tests/helpers/test_config_validation.py
test_icon
AidasK/home-assistant
python
def test_icon(): schema = vol.Schema(cv.icon) for value in (False, 'work'): with pytest.raises(vol.MultipleInvalid): schema(value) schema('mdi:work') schema('custom:prefix')
def test_time_period(): 'Test time_period validation.' schema = vol.Schema(cv.time_period) options = (None, '', 'hello:world', '12:', '12:34:56:78', {}, {'wrong_key': (- 10)}) for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ('8:20', '23:59',...
5,079,320,819,424,888,000
Test time_period validation.
tests/helpers/test_config_validation.py
test_time_period
AidasK/home-assistant
python
def test_time_period(): schema = vol.Schema(cv.time_period) options = (None, , 'hello:world', '12:', '12:34:56:78', {}, {'wrong_key': (- 10)}) for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ('8:20', '23:59', '-8:20', '-23:59:59', '-48:00',...
def test_service(): 'Test service validation.' schema = vol.Schema(cv.service) with pytest.raises(vol.MultipleInvalid): schema('invalid_turn_on') schema('homeassistant.turn_on')
-3,773,440,342,070,571,000
Test service validation.
tests/helpers/test_config_validation.py
test_service
AidasK/home-assistant
python
def test_service(): schema = vol.Schema(cv.service) with pytest.raises(vol.MultipleInvalid): schema('invalid_turn_on') schema('homeassistant.turn_on')
def test_service_schema(): 'Test service_schema validation.' options = ({}, None, {'service': 'homeassistant.turn_on', 'service_template': 'homeassistant.turn_on'}, {'data': {'entity_id': 'light.kitchen'}}, {'service': 'homeassistant.turn_on', 'data': None}, {'service': 'homeassistant.turn_on', 'data_template':...
769,792,067,807,005,000
Test service_schema validation.
tests/helpers/test_config_validation.py
test_service_schema
AidasK/home-assistant
python
def test_service_schema(): options = ({}, None, {'service': 'homeassistant.turn_on', 'service_template': 'homeassistant.turn_on'}, {'data': {'entity_id': 'light.kitchen'}}, {'service': 'homeassistant.turn_on', 'data': None}, {'service': 'homeassistant.turn_on', 'data_template': {'brightness': '{{ no_end'}}) ...
def test_slug(): 'Test slug validation.' schema = vol.Schema(cv.slug) for value in (None, 'hello world'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in (12345, 'hello'): schema(value)
5,634,292,382,389,411,000
Test slug validation.
tests/helpers/test_config_validation.py
test_slug
AidasK/home-assistant
python
def test_slug(): schema = vol.Schema(cv.slug) for value in (None, 'hello world'): with pytest.raises(vol.MultipleInvalid): schema(value) for value in (12345, 'hello'): schema(value)
def test_string(): 'Test string validation.' schema = vol.Schema(cv.string) with pytest.raises(vol.Invalid): schema(None) with pytest.raises(vol.Invalid): schema([]) with pytest.raises(vol.Invalid): schema({}) for value in (True, 1, 'hello'): schema(value)
6,633,445,761,249,542,000
Test string validation.
tests/helpers/test_config_validation.py
test_string
AidasK/home-assistant
python
def test_string(): schema = vol.Schema(cv.string) with pytest.raises(vol.Invalid): schema(None) with pytest.raises(vol.Invalid): schema([]) with pytest.raises(vol.Invalid): schema({}) for value in (True, 1, 'hello'): schema(value)
def test_temperature_unit(): 'Test temperature unit validation.' schema = vol.Schema(cv.temperature_unit) with pytest.raises(vol.MultipleInvalid): schema('K') schema('C') schema('F')
9,216,878,165,514,072,000
Test temperature unit validation.
tests/helpers/test_config_validation.py
test_temperature_unit
AidasK/home-assistant
python
def test_temperature_unit(): schema = vol.Schema(cv.temperature_unit) with pytest.raises(vol.MultipleInvalid): schema('K') schema('C') schema('F')
def test_x10_address(): 'Test x10 addr validator.' schema = vol.Schema(cv.x10_address) with pytest.raises(vol.Invalid): schema('Q1') schema('q55') schema('garbage_addr') schema('a1') schema('C11')
476,064,791,361,012,160
Test x10 addr validator.
tests/helpers/test_config_validation.py
test_x10_address
AidasK/home-assistant
python
def test_x10_address(): schema = vol.Schema(cv.x10_address) with pytest.raises(vol.Invalid): schema('Q1') schema('q55') schema('garbage_addr') schema('a1') schema('C11')
def test_template(): 'Test template validator.' schema = vol.Schema(cv.template) for value in (None, '{{ partial_print }', '{% if True %}Hello', ['test']): with pytest.raises(vol.Invalid, message='{} not considered invalid'.format(value)): schema(value) options = (1, 'Hello', '{{ bee...
779,638,051,045,150,500
Test template validator.
tests/helpers/test_config_validation.py
test_template
AidasK/home-assistant
python
def test_template(): schema = vol.Schema(cv.template) for value in (None, '{{ partial_print }', '{% if True %}Hello', ['test']): with pytest.raises(vol.Invalid, message='{} not considered invalid'.format(value)): schema(value) options = (1, 'Hello', '{{ beer }}', '{% if 1 == 1 %}Hel...
def test_template_complex(): 'Test template_complex validator.' schema = vol.Schema(cv.template_complex) for value in (None, '{{ partial_print }', '{% if True %}Hello'): with pytest.raises(vol.MultipleInvalid): schema(value) options = (1, 'Hello', '{{ beer }}', '{% if 1 == 1 %}Hello{...
-8,506,853,059,146,775,000
Test template_complex validator.
tests/helpers/test_config_validation.py
test_template_complex
AidasK/home-assistant
python
def test_template_complex(): schema = vol.Schema(cv.template_complex) for value in (None, '{{ partial_print }', '{% if True %}Hello'): with pytest.raises(vol.MultipleInvalid): schema(value) options = (1, 'Hello', '{{ beer }}', '{% if 1 == 1 %}Hello{% else %}World{% endif %}', {'test...
def test_time_zone(): 'Test time zone validation.' schema = vol.Schema(cv.time_zone) with pytest.raises(vol.MultipleInvalid): schema('America/Do_Not_Exist') schema('America/Los_Angeles') schema('UTC')
-3,777,560,921,499,743,000
Test time zone validation.
tests/helpers/test_config_validation.py
test_time_zone
AidasK/home-assistant
python
def test_time_zone(): schema = vol.Schema(cv.time_zone) with pytest.raises(vol.MultipleInvalid): schema('America/Do_Not_Exist') schema('America/Los_Angeles') schema('UTC')
def test_date(): 'Test date validation.' schema = vol.Schema(cv.date) for value in ['Not a date', '23:42', '2016-11-23T18:59:08']: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().date()) schema('2016-11-23')
6,884,820,153,883,477,000
Test date validation.
tests/helpers/test_config_validation.py
test_date
AidasK/home-assistant
python
def test_date(): schema = vol.Schema(cv.date) for value in ['Not a date', '23:42', '2016-11-23T18:59:08']: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().date()) schema('2016-11-23')
def test_time(): 'Test date validation.' schema = vol.Schema(cv.time) for value in ['Not a time', '2016-11-23', '2016-11-23T18:59:08']: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().time()) schema('23:42:00') schema('23:42')
-3,050,492,042,552,543,700
Test date validation.
tests/helpers/test_config_validation.py
test_time
AidasK/home-assistant
python
def test_time(): schema = vol.Schema(cv.time) for value in ['Not a time', '2016-11-23', '2016-11-23T18:59:08']: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().time()) schema('23:42:00') schema('23:42')
def test_datetime(): 'Test date time validation.' schema = vol.Schema(cv.datetime) for value in [date.today(), 'Wrong DateTime', '2016-11-23']: with pytest.raises(vol.MultipleInvalid): schema(value) schema(datetime.now()) schema('2016-11-23T18:59:08')
7,137,674,050,958,346,000
Test date time validation.
tests/helpers/test_config_validation.py
test_datetime
AidasK/home-assistant
python
def test_datetime(): schema = vol.Schema(cv.datetime) for value in [date.today(), 'Wrong DateTime', '2016-11-23']: with pytest.raises(vol.MultipleInvalid): schema(value) schema(datetime.now()) schema('2016-11-23T18:59:08')
def test_deprecated(caplog): 'Test deprecation log.' schema = vol.Schema({'venus': cv.boolean, 'mars': cv.boolean}) deprecated_schema = vol.All(cv.deprecated('mars'), schema) deprecated_schema({'venus': True}) assert (len(caplog.records) == 0) deprecated_schema({'mars': True}) assert (len(ca...
3,538,743,296,813,699,600
Test deprecation log.
tests/helpers/test_config_validation.py
test_deprecated
AidasK/home-assistant
python
def test_deprecated(caplog): schema = vol.Schema({'venus': cv.boolean, 'mars': cv.boolean}) deprecated_schema = vol.All(cv.deprecated('mars'), schema) deprecated_schema({'venus': True}) assert (len(caplog.records) == 0) deprecated_schema({'mars': True}) assert (len(caplog.records) == 1) ...
def test_key_dependency(): 'Test key_dependency validator.' schema = vol.Schema(cv.key_dependency('beer', 'soda')) options = {'beer': None} for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ({'beer': None, 'soda': None}, {'soda': None}, {}) ...
2,016,627,324,186,323,000
Test key_dependency validator.
tests/helpers/test_config_validation.py
test_key_dependency
AidasK/home-assistant
python
def test_key_dependency(): schema = vol.Schema(cv.key_dependency('beer', 'soda')) options = {'beer': None} for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ({'beer': None, 'soda': None}, {'soda': None}, {}) for value in options: ...
def test_has_at_least_one_key(): 'Test has_at_least_one_key validator.' schema = vol.Schema(cv.has_at_least_one_key('beer', 'soda')) for value in (None, [], {}, {'wine': None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({'beer': None}, {'soda': None}): ...
1,057,924,061,279,002,200
Test has_at_least_one_key validator.
tests/helpers/test_config_validation.py
test_has_at_least_one_key
AidasK/home-assistant
python
def test_has_at_least_one_key(): schema = vol.Schema(cv.has_at_least_one_key('beer', 'soda')) for value in (None, [], {}, {'wine': None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({'beer': None}, {'soda': None}): schema(value)
def test_enum(): 'Test enum validator.' class TestEnum(enum.Enum): 'Test enum.' value1 = 'Value 1' value2 = 'Value 2' schema = vol.Schema(cv.enum(TestEnum)) with pytest.raises(vol.Invalid): schema('value3')
-2,516,164,131,956,451,300
Test enum validator.
tests/helpers/test_config_validation.py
test_enum
AidasK/home-assistant
python
def test_enum(): class TestEnum(enum.Enum): 'Test enum.' value1 = 'Value 1' value2 = 'Value 2' schema = vol.Schema(cv.enum(TestEnum)) with pytest.raises(vol.Invalid): schema('value3')
def test_socket_timeout(): 'Test socket timeout validator.' schema = vol.Schema(cv.socket_timeout) with pytest.raises(vol.Invalid): schema(0.0) with pytest.raises(vol.Invalid): schema((- 1)) assert (_GLOBAL_DEFAULT_TIMEOUT == schema(None)) assert (schema(1) == 1.0)
352,976,611,970,499,460
Test socket timeout validator.
tests/helpers/test_config_validation.py
test_socket_timeout
AidasK/home-assistant
python
def test_socket_timeout(): schema = vol.Schema(cv.socket_timeout) with pytest.raises(vol.Invalid): schema(0.0) with pytest.raises(vol.Invalid): schema((- 1)) assert (_GLOBAL_DEFAULT_TIMEOUT == schema(None)) assert (schema(1) == 1.0)
def test_matches_regex(): 'Test matches_regex validator.' schema = vol.Schema(cv.matches_regex('.*uiae.*')) with pytest.raises(vol.Invalid): schema(1.0) with pytest.raises(vol.Invalid): schema(' nrtd ') test_str = 'This is a test including uiae.' assert (schema(test_str) == te...
-8,264,848,067,278,385,000
Test matches_regex validator.
tests/helpers/test_config_validation.py
test_matches_regex
AidasK/home-assistant
python
def test_matches_regex(): schema = vol.Schema(cv.matches_regex('.*uiae.*')) with pytest.raises(vol.Invalid): schema(1.0) with pytest.raises(vol.Invalid): schema(' nrtd ') test_str = 'This is a test including uiae.' assert (schema(test_str) == test_str)
def test_is_regex(): 'Test the is_regex validator.' schema = vol.Schema(cv.is_regex) with pytest.raises(vol.Invalid): schema('(') with pytest.raises(vol.Invalid): schema({'a dict': 'is not a regex'}) valid_re = '.*' schema(valid_re)
-4,981,124,014,004,099,000
Test the is_regex validator.
tests/helpers/test_config_validation.py
test_is_regex
AidasK/home-assistant
python
def test_is_regex(): schema = vol.Schema(cv.is_regex) with pytest.raises(vol.Invalid): schema('(') with pytest.raises(vol.Invalid): schema({'a dict': 'is not a regex'}) valid_re = '.*' schema(valid_re)
def test_comp_entity_ids(): 'Test config validation for component entity IDs.' schema = vol.Schema(cv.comp_entity_ids) for valid in ('ALL', 'all', 'AlL', 'light.kitchen', ['light.kitchen'], ['light.kitchen', 'light.ceiling'], []): schema(valid) for invalid in (['light.kitchen', 'not-entity-id'],...
-8,425,774,353,582,209,000
Test config validation for component entity IDs.
tests/helpers/test_config_validation.py
test_comp_entity_ids
AidasK/home-assistant
python
def test_comp_entity_ids(): schema = vol.Schema(cv.comp_entity_ids) for valid in ('ALL', 'all', 'AlL', 'light.kitchen', ['light.kitchen'], ['light.kitchen', 'light.ceiling'], []): schema(valid) for invalid in (['light.kitchen', 'not-entity-id'], '*', ): with pytest.raises(vol.Invalid): ...
def ra_dec_format(val): ' Ra/Dec string formatting\n\n Converts the input string format of a right ascension/ declination coordinate\n to one recognizable by astroquery\n\n Args:\n val (str): string; an ra/dec expression formatted as "005313.81 +130955.0".\n\n Returns:\n string: the ra/dec coo...
4,864,394,534,267,087,000
Ra/Dec string formatting Converts the input string format of a right ascension/ declination coordinate to one recognizable by astroquery Args: val (str): string; an ra/dec expression formatted as "005313.81 +130955.0". Returns: string: the ra/dec coordinates re-formatted as "00h53m13.81s +13d09m55.0s"
exampledoc/Extractor.py
ra_dec_format
sofiapasquini/Code-Astro-Group-23-Project
python
def ra_dec_format(val): ' Ra/Dec string formatting\n\n Converts the input string format of a right ascension/ declination coordinate\n to one recognizable by astroquery\n\n Args:\n val (str): string; an ra/dec expression formatted as "005313.81 +130955.0".\n\n Returns:\n string: the ra/dec coo...
def extractor(position): "\n This function extracts the information from the SDSS database and returns\n a pandas dataframe with the query region. Please ensure that the 'position'\n input is formatted as '005313.81 +130955.0\n\n extractor(str) --> pd.DataFrame\n " position = ra_dec_format(position) po...
-4,174,108,965,800,909,300
This function extracts the information from the SDSS database and returns a pandas dataframe with the query region. Please ensure that the 'position' input is formatted as '005313.81 +130955.0 extractor(str) --> pd.DataFrame
exampledoc/Extractor.py
extractor
sofiapasquini/Code-Astro-Group-23-Project
python
def extractor(position): "\n This function extracts the information from the SDSS database and returns\n a pandas dataframe with the query region. Please ensure that the 'position'\n input is formatted as '005313.81 +130955.0\n\n extractor(str) --> pd.DataFrame\n " position = ra_dec_format(position) po...
def downloader(data): '\n This function uses extracted information in order to dwonaload spectra, \n separating the data from th SDSS and BOSS.\n\n downloader(pd.Dataframe) --> [list(fits)]\n ' spec_list = [] for i in range(len(data)): results = SDSS.query_specobj(plate=data['plate'][i], mjd=dat...
-2,177,232,159,057,139,500
This function uses extracted information in order to dwonaload spectra, separating the data from th SDSS and BOSS. downloader(pd.Dataframe) --> [list(fits)]
exampledoc/Extractor.py
downloader
sofiapasquini/Code-Astro-Group-23-Project
python
def downloader(data): '\n This function uses extracted information in order to dwonaload spectra, \n separating the data from th SDSS and BOSS.\n\n downloader(pd.Dataframe) --> [list(fits)]\n ' spec_list = [] for i in range(len(data)): results = SDSS.query_specobj(plate=data['plate'][i], mjd=dat...
def extract_msg_headers(self, entity, msg): 'Parse E-Mail headers into FtM properties.' try: entity.add('indexText', msg.values()) except Exception as ex: log.warning('Cannot parse all headers: %r', ex) entity.add('subject', self.get_header(msg, 'Subject')) entity.add('date', self.ge...
-5,171,677,646,401,712,000
Parse E-Mail headers into FtM properties.
services/ingest-file/ingestors/support/email.py
extract_msg_headers
adikadashrieq/aleph
python
def extract_msg_headers(self, entity, msg): try: entity.add('indexText', msg.values()) except Exception as ex: log.warning('Cannot parse all headers: %r', ex) entity.add('subject', self.get_header(msg, 'Subject')) entity.add('date', self.get_dates(msg, 'Date')) entity.add('mimeT...
def __init__(self): ' Initializes this class with VWOLogger and OperandEvaluator ' self.operand_evaluator = OperandEvaluator()
1,181,704,526,880,338,000
Initializes this class with VWOLogger and OperandEvaluator
vwo/services/segmentor/segment_evaluator.py
__init__
MDAkramSiddiqui/vwo-python-sdk
python
def __init__(self): ' ' self.operand_evaluator = OperandEvaluator()
def evaluate(self, segments, custom_variables): 'A parser which recursively evaluates the custom_variables passed against\n the expression tree represented by segments, and returns the result.\n\n Args:\n segments(dict): The segments representing the expression tree\n custom_vari...
-6,698,908,000,189,105,000
A parser which recursively evaluates the custom_variables passed against the expression tree represented by segments, and returns the result. Args: segments(dict): The segments representing the expression tree custom_variables(dict): Key/value pair of variables Returns: bool(result): True or False
vwo/services/segmentor/segment_evaluator.py
evaluate
MDAkramSiddiqui/vwo-python-sdk
python
def evaluate(self, segments, custom_variables): 'A parser which recursively evaluates the custom_variables passed against\n the expression tree represented by segments, and returns the result.\n\n Args:\n segments(dict): The segments representing the expression tree\n custom_vari...
def removeElement(self, nums, val): '\n :type nums: List[int]\n :type val: int\n :rtype: int\n ' j = 0 for i in range(len(nums)): if (nums[i] != val): nums[j] = nums[i] j += 1 return j
-2,103,904,785,688,737,800
:type nums: List[int] :type val: int :rtype: int
1-50/27_remove-element.py
removeElement
ChenhaoJiang/LeetCode-Solution
python
def removeElement(self, nums, val): '\n :type nums: List[int]\n :type val: int\n :rtype: int\n ' j = 0 for i in range(len(nums)): if (nums[i] != val): nums[j] = nums[i] j += 1 return j
def main(): 'Run administrative tasks.' os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uofthacksemergencyfunds.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError("Couldn't import Django. Are you sure it's installed ...
-799,566,234,733,556,400
Run administrative tasks.
manage.py
main
donmin062501/Savings.io
python
def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uofthacksemergencyfunds.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError("Couldn't import Django. Are you sure it's installed and available on your PYTHO...
def create_view(self, es_ordering_fields): 'Create and return test view class instance\n\n Args:\n es_ordering_fields (tuple): ordering fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_ordering_fields = es_ordering_fields ...
-3,597,215,663,825,731,000
Create and return test view class instance Args: es_ordering_fields (tuple): ordering fields Returns: ElasticAPIView: test view instance
tests/test_filters.py
create_view
ArtemBernatskyy/django-rest-elasticsearch
python
def create_view(self, es_ordering_fields): 'Create and return test view class instance\n\n Args:\n es_ordering_fields (tuple): ordering fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_ordering_fields = es_ordering_fields ...
def create_view(self, es_filter_fields): 'Create and return test view class instance\n\n Args:\n es_filter_fields ([ESFieldFilter]): filtering fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataDocType view.es...
-1,043,188,655,335,483,900
Create and return test view class instance Args: es_filter_fields ([ESFieldFilter]): filtering fields Returns: ElasticAPIView: test view instance
tests/test_filters.py
create_view
ArtemBernatskyy/django-rest-elasticsearch
python
def create_view(self, es_filter_fields): 'Create and return test view class instance\n\n Args:\n es_filter_fields ([ESFieldFilter]): filtering fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataDocType view.es...
def create_view(self, es_range_filter_fields): 'Create and return test view class instance\n\n Args:\n es_range_filter_fields ([ESFieldFilter]): filtering range fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataD...
-2,228,615,635,726,304,500
Create and return test view class instance Args: es_range_filter_fields ([ESFieldFilter]): filtering range fields Returns: ElasticAPIView: test view instance
tests/test_filters.py
create_view
ArtemBernatskyy/django-rest-elasticsearch
python
def create_view(self, es_range_filter_fields): 'Create and return test view class instance\n\n Args:\n es_range_filter_fields ([ESFieldFilter]): filtering range fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataD...
def create_view(self, es_search_fields): 'Create and return test view class instance\n\n Args:\n es_search_fields ([ESFieldFilter]): search fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataDocType view.es_se...
-447,006,123,439,172,160
Create and return test view class instance Args: es_search_fields ([ESFieldFilter]): search fields Returns: ElasticAPIView: test view instance
tests/test_filters.py
create_view
ArtemBernatskyy/django-rest-elasticsearch
python
def create_view(self, es_search_fields): 'Create and return test view class instance\n\n Args:\n es_search_fields ([ESFieldFilter]): search fields\n Returns:\n ElasticAPIView: test view instance\n ' view = ElasticAPIView() view.es_model = DataDocType view.es_se...
def get_expected(): 'Return expected data items sorted by id' items = [(item['_id'], item['_source']['first_name'], item['_source']['is_active']) for item in DATA] items = sorted(items, key=(lambda tup: (tup[1], (not tup[2])))) return items
-3,373,630,689,957,980,000
Return expected data items sorted by id
tests/test_filters.py
get_expected
ArtemBernatskyy/django-rest-elasticsearch
python
def get_expected(): items = [(item['_id'], item['_source']['first_name'], item['_source']['is_active']) for item in DATA] items = sorted(items, key=(lambda tup: (tup[1], (not tup[2])))) return items
def _get_vars(fis): 'Get an encoded version of the parameters of the fuzzy sets in a FIS' for variable in fis.variables: for (value_name, value) in variable.values.items(): for (par, default) in value._get_description().items(): if (par != 'type'): (yield ...
2,506,911,759,605,472,000
Get an encoded version of the parameters of the fuzzy sets in a FIS
zadeh/tune.py
_get_vars
Dih5/zadeh
python
def _get_vars(fis): for variable in fis.variables: for (value_name, value) in variable.values.items(): for (par, default) in value._get_description().items(): if (par != 'type'): (yield (((((('var_' + variable.name) + '_') + value_name) + '_') + par), def...
def _set_vars(fis, kwargs): 'Return a modified version of the FIS, setting the changes in the parameters described by kwargs' description = fis._get_description() positions = {variable['name']: i for (i, variable) in enumerate(description['variables'])} for (code, parameter_value) in kwargs.items(): ...
1,468,162,519,079,026,700
Return a modified version of the FIS, setting the changes in the parameters described by kwargs
zadeh/tune.py
_set_vars
Dih5/zadeh
python
def _set_vars(fis, kwargs): description = fis._get_description() positions = {variable['name']: i for (i, variable) in enumerate(description['variables'])} for (code, parameter_value) in kwargs.items(): if code.startswith('var_'): (_, variable_name, fuzzy_value, parameter) = code.sp...
def get_params(self, deep=True): 'Get the parameters in a sklearn-consistent interface' return {'fis': self.fis, 'defuzzification': self.defuzzification, **{parameter: getattr(self, parameter) for (parameter, _) in _get_vars(self.fis)}}
-6,721,509,309,062,285,000
Get the parameters in a sklearn-consistent interface
zadeh/tune.py
get_params
Dih5/zadeh
python
def get_params(self, deep=True): return {'fis': self.fis, 'defuzzification': self.defuzzification, **{parameter: getattr(self, parameter) for (parameter, _) in _get_vars(self.fis)}}
def set_params(self, **parameters): 'Set the parameters in a sklearn-consistent interface' for (parameter, value) in parameters.items(): setattr(self, parameter, value) return self
5,863,062,864,405,496,000
Set the parameters in a sklearn-consistent interface
zadeh/tune.py
set_params
Dih5/zadeh
python
def set_params(self, **parameters): for (parameter, value) in parameters.items(): setattr(self, parameter, value) return self
def fit(self, X=None, y=None): "'Fit' the model (freeze the attributes and compile if available)" self.fis_ = _set_vars(self.fis, {parameter: getattr(self, parameter) for (parameter, _) in _get_vars(self.fis)}) self.fis_.defuzzification = self.defuzzification try: self.fis_ = self.fis_.compile()...
-162,376,375,605,532,580
'Fit' the model (freeze the attributes and compile if available)
zadeh/tune.py
fit
Dih5/zadeh
python
def fit(self, X=None, y=None): self.fis_ = _set_vars(self.fis, {parameter: getattr(self, parameter) for (parameter, _) in _get_vars(self.fis)}) self.fis_.defuzzification = self.defuzzification try: self.fis_ = self.fis_.compile() except Exception: pass return self
def predict(self, X): 'A sklearn-like predict method' return self.fis_.batch_predict(X)
-2,083,909,073,260,690,200
A sklearn-like predict method
zadeh/tune.py
predict
Dih5/zadeh
python
def predict(self, X): return self.fis_.batch_predict(X)
def __init__(self, fis, params, scoring='neg_root_mean_squared_error', n_jobs=None): "\n\n Args:\n fis (FIS): The Fuzzy Inference System to tune\n params (dict of str to list): A mapping from encoded parameters to the list of values to explore.\n scoring (str): The metric use...
7,792,864,546,700,434,000
Args: fis (FIS): The Fuzzy Inference System to tune params (dict of str to list): A mapping from encoded parameters to the list of values to explore. scoring (str): The metric used for scoring. Must be one of sklearn's regression scorings. n_jobs (int): Number of jobs to run in parallel.
zadeh/tune.py
__init__
Dih5/zadeh
python
def __init__(self, fis, params, scoring='neg_root_mean_squared_error', n_jobs=None): "\n\n Args:\n fis (FIS): The Fuzzy Inference System to tune\n params (dict of str to list): A mapping from encoded parameters to the list of values to explore.\n scoring (str): The metric use...
def fit(self, X, y=None): '\n\n Args:\n X (2D array-like): An object suitable for FIS.batch_predict.\n y (1D array-like): An array with true values. If None, but X is a DataFrame, the values are extracted from\n there.\n\n Returns:\n\n ' i...
6,407,149,171,949,012,000
Args: X (2D array-like): An object suitable for FIS.batch_predict. y (1D array-like): An array with true values. If None, but X is a DataFrame, the values are extracted from there. Returns:
zadeh/tune.py
fit
Dih5/zadeh
python
def fit(self, X, y=None): '\n\n Args:\n X (2D array-like): An object suitable for FIS.batch_predict.\n y (1D array-like): An array with true values. If None, but X is a DataFrame, the values are extracted from\n there.\n\n Returns:\n\n ' i...
def parse_arguments(): 'Sets up and parses command-line arguments.\n\n Returns:\n log_level: A logging level to filter log output.\n directory: The directory to search for .cmd files.\n output: Where to write the compile-commands JSON file.\n ' usage = 'Creates a compile_commands.json...
-460,389,302,831,116,800
Sets up and parses command-line arguments. Returns: log_level: A logging level to filter log output. directory: The directory to search for .cmd files. output: Where to write the compile-commands JSON file.
ubuntu-bionic-hwe-edge/scripts/gen_compile_commands.py
parse_arguments
Akh1lesh/Object_Detection_using_Intel_Realsense
python
def parse_arguments(): 'Sets up and parses command-line arguments.\n\n Returns:\n log_level: A logging level to filter log output.\n directory: The directory to search for .cmd files.\n output: Where to write the compile-commands JSON file.\n ' usage = 'Creates a compile_commands.json...
def process_line(root_directory, file_directory, command_prefix, relative_path): 'Extracts information from a .cmd line and creates an entry from it.\n\n Args:\n root_directory: The directory that was searched for .cmd files. Usually\n used directly in the "directory" entry in compile_commands....
-7,944,255,662,804,624,000
Extracts information from a .cmd line and creates an entry from it. Args: root_directory: The directory that was searched for .cmd files. Usually used directly in the "directory" entry in compile_commands.json. file_directory: The path to the directory the .cmd file was found in. command_prefix: Th...
ubuntu-bionic-hwe-edge/scripts/gen_compile_commands.py
process_line
Akh1lesh/Object_Detection_using_Intel_Realsense
python
def process_line(root_directory, file_directory, command_prefix, relative_path): 'Extracts information from a .cmd line and creates an entry from it.\n\n Args:\n root_directory: The directory that was searched for .cmd files. Usually\n used directly in the "directory" entry in compile_commands....
def main(): 'Walks through the directory and finds and parses .cmd files.' (log_level, directory, output) = parse_arguments() level = getattr(logging, log_level) logging.basicConfig(format='%(levelname)s: %(message)s', level=level) filename_matcher = re.compile(_FILENAME_PATTERN) line_matcher = ...
996,443,708,721,818,600
Walks through the directory and finds and parses .cmd files.
ubuntu-bionic-hwe-edge/scripts/gen_compile_commands.py
main
Akh1lesh/Object_Detection_using_Intel_Realsense
python
def main(): (log_level, directory, output) = parse_arguments() level = getattr(logging, log_level) logging.basicConfig(format='%(levelname)s: %(message)s', level=level) filename_matcher = re.compile(_FILENAME_PATTERN) line_matcher = re.compile(_LINE_PATTERN) compile_commands = [] for (d...
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, truncate=None, minmax=None, remote_editing=None, autorefresh=None): 'Setup the namespace browser' assert (self.shellwidget is not None) self.check_all = chec...
-8,554,207,009,777,978,000
Setup the namespace browser
spyderlib/widgets/externalshell/namespacebrowser.py
setup
junglefunkyman/spectracer
python
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, truncate=None, minmax=None, remote_editing=None, autorefresh=None): assert (self.shellwidget is not None) self.check_all = check_all self.exclude_privat...
def set_shellwidget(self, shellwidget): 'Bind shellwidget instance to namespace browser' self.shellwidget = shellwidget from spyderlib.widgets import internalshell self.is_internal_shell = isinstance(self.shellwidget, internalshell.InternalShell) self.is_ipykernel = self.shellwidget.is_ipykernel ...
2,561,803,688,112,527,400
Bind shellwidget instance to namespace browser
spyderlib/widgets/externalshell/namespacebrowser.py
set_shellwidget
junglefunkyman/spectracer
python
def set_shellwidget(self, shellwidget): self.shellwidget = shellwidget from spyderlib.widgets import internalshell self.is_internal_shell = isinstance(self.shellwidget, internalshell.InternalShell) self.is_ipykernel = self.shellwidget.is_ipykernel if (not self.is_internal_shell): shellw...
def set_ipyclient(self, ipyclient): 'Bind ipyclient instance to namespace browser' self.ipyclient = ipyclient
-7,624,842,523,463,780,000
Bind ipyclient instance to namespace browser
spyderlib/widgets/externalshell/namespacebrowser.py
set_ipyclient
junglefunkyman/spectracer
python
def set_ipyclient(self, ipyclient): self.ipyclient = ipyclient
def setup_toolbar(self, exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported, autorefresh): 'Setup toolbar' self.setup_in_progress = True toolbar = [] refresh_button = create_toolbutton(self, text=_('Refresh'), icon=get_icon('reload.png'), triggered=self.refresh_table) self.a...
-159,748,832,943,028,060
Setup toolbar
spyderlib/widgets/externalshell/namespacebrowser.py
setup_toolbar
junglefunkyman/spectracer
python
def setup_toolbar(self, exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported, autorefresh): self.setup_in_progress = True toolbar = [] refresh_button = create_toolbutton(self, text=_('Refresh'), icon=get_icon('reload.png'), triggered=self.refresh_table) self.auto_refresh_but...