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
openxc/openxc-python
openxc/controllers/base.py
Controller.write_translated
def write_translated(self, name, value, event=None): """Send a translated write request to the VI. """ data = {'name': name} if value is not None: data['value'] = self._massage_write_value(value) if event is not None: data['event'] = self._massage_write_va...
python
def write_translated(self, name, value, event=None): """Send a translated write request to the VI. """ data = {'name': name} if value is not None: data['value'] = self._massage_write_value(value) if event is not None: data['event'] = self._massage_write_va...
[ "def", "write_translated", "(", "self", ",", "name", ",", "value", ",", "event", "=", "None", ")", ":", "data", "=", "{", "'name'", ":", "name", "}", "if", "value", "is", "not", "None", ":", "data", "[", "'value'", "]", "=", "self", ".", "_massage_...
Send a translated write request to the VI.
[ "Send", "a", "translated", "write", "request", "to", "the", "VI", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L401-L412
train
openxc/openxc-python
openxc/controllers/base.py
Controller.write_raw
def write_raw(self, message_id, data, bus=None, frame_format=None): """Send a raw write request to the VI. """ if not isinstance(message_id, numbers.Number): try: message_id = int(message_id, 0) except ValueError: raise ValueError("ID must ...
python
def write_raw(self, message_id, data, bus=None, frame_format=None): """Send a raw write request to the VI. """ if not isinstance(message_id, numbers.Number): try: message_id = int(message_id, 0) except ValueError: raise ValueError("ID must ...
[ "def", "write_raw", "(", "self", ",", "message_id", ",", "data", ",", "bus", "=", "None", ",", "frame_format", "=", "None", ")", ":", "if", "not", "isinstance", "(", "message_id", ",", "numbers", ".", "Number", ")", ":", "try", ":", "message_id", "=", ...
Send a raw write request to the VI.
[ "Send", "a", "raw", "write", "request", "to", "the", "VI", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L414-L430
train
openxc/openxc-python
openxc/controllers/base.py
Controller._massage_write_value
def _massage_write_value(cls, value): """Convert string values from command-line arguments into first-order Python boolean and float objects, if applicable. """ if not isinstance(value, numbers.Number): if value == "true": value = True elif value =...
python
def _massage_write_value(cls, value): """Convert string values from command-line arguments into first-order Python boolean and float objects, if applicable. """ if not isinstance(value, numbers.Number): if value == "true": value = True elif value =...
[ "def", "_massage_write_value", "(", "cls", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "numbers", ".", "Number", ")", ":", "if", "value", "==", "\"true\"", ":", "value", "=", "True", "elif", "value", "==", "\"false\"", ":", "v...
Convert string values from command-line arguments into first-order Python boolean and float objects, if applicable.
[ "Convert", "string", "values", "from", "command", "-", "line", "arguments", "into", "first", "-", "order", "Python", "boolean", "and", "float", "objects", "if", "applicable", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L440-L456
train
openxc/openxc-python
openxc/formats/json.py
JsonFormatter._validate
def _validate(cls, message): """Confirm the validitiy of a given dict as an OpenXC message. Returns: ``True`` if the message contains at least a ``name`` and ``value``. """ valid = False if(('name' in message and 'value' in message) or ('id' in messag...
python
def _validate(cls, message): """Confirm the validitiy of a given dict as an OpenXC message. Returns: ``True`` if the message contains at least a ``name`` and ``value``. """ valid = False if(('name' in message and 'value' in message) or ('id' in messag...
[ "def", "_validate", "(", "cls", ",", "message", ")", ":", "valid", "=", "False", "if", "(", "(", "'name'", "in", "message", "and", "'value'", "in", "message", ")", "or", "(", "'id'", "in", "message", "and", "'data'", "in", "message", ")", ")", ":", ...
Confirm the validitiy of a given dict as an OpenXC message. Returns: ``True`` if the message contains at least a ``name`` and ``value``.
[ "Confirm", "the", "validitiy", "of", "a", "given", "dict", "as", "an", "OpenXC", "message", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/formats/json.py#L42-L52
train
openxc/openxc-python
openxc/measurements.py
Measurement.value
def value(self, new_value): """Set the value of this measurement. Raises: AttributeError: if the new value isn't of the correct units. """ if self.unit != units.Undefined and new_value.unit != self.unit: raise AttributeError("%s must be in %s" % ( ...
python
def value(self, new_value): """Set the value of this measurement. Raises: AttributeError: if the new value isn't of the correct units. """ if self.unit != units.Undefined and new_value.unit != self.unit: raise AttributeError("%s must be in %s" % ( ...
[ "def", "value", "(", "self", ",", "new_value", ")", ":", "if", "self", ".", "unit", "!=", "units", ".", "Undefined", "and", "new_value", ".", "unit", "!=", "self", ".", "unit", ":", "raise", "AttributeError", "(", "\"%s must be in %s\"", "%", "(", "self"...
Set the value of this measurement. Raises: AttributeError: if the new value isn't of the correct units.
[ "Set", "the", "value", "of", "this", "measurement", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/measurements.py#L66-L75
train
openxc/openxc-python
openxc/measurements.py
Measurement.from_dict
def from_dict(cls, data): """Create a new Measurement subclass instance using the given dict. If Measurement.name_from_class was previously called with this data's associated Measurement sub-class in Python, the returned object will be an instance of that sub-class. If the measurement n...
python
def from_dict(cls, data): """Create a new Measurement subclass instance using the given dict. If Measurement.name_from_class was previously called with this data's associated Measurement sub-class in Python, the returned object will be an instance of that sub-class. If the measurement n...
[ "def", "from_dict", "(", "cls", ",", "data", ")", ":", "args", "=", "[", "]", "if", "'id'", "in", "data", "and", "'data'", "in", "data", ":", "measurement_class", "=", "CanMessage", "args", ".", "append", "(", "\"Bus %s: 0x%x\"", "%", "(", "data", ".",...
Create a new Measurement subclass instance using the given dict. If Measurement.name_from_class was previously called with this data's associated Measurement sub-class in Python, the returned object will be an instance of that sub-class. If the measurement name in ``data`` is unrecogniz...
[ "Create", "a", "new", "Measurement", "subclass", "instance", "using", "the", "given", "dict", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/measurements.py#L78-L106
train
openxc/openxc-python
openxc/measurements.py
Measurement.name_from_class
def name_from_class(cls, measurement_class): """For a given measurement class, return its generic name. The given class is expected to have a ``name`` attribute, otherwise this function will raise an execption. The point of using this method instead of just trying to grab that attribute...
python
def name_from_class(cls, measurement_class): """For a given measurement class, return its generic name. The given class is expected to have a ``name`` attribute, otherwise this function will raise an execption. The point of using this method instead of just trying to grab that attribute...
[ "def", "name_from_class", "(", "cls", ",", "measurement_class", ")", ":", "if", "not", "getattr", "(", "cls", ",", "'_measurements_initialized'", ",", "False", ")", ":", "cls", ".", "_measurement_map", "=", "dict", "(", "(", "m", ".", "name", ",", "m", "...
For a given measurement class, return its generic name. The given class is expected to have a ``name`` attribute, otherwise this function will raise an execption. The point of using this method instead of just trying to grab that attribute in the application is to cache measurement name...
[ "For", "a", "given", "measurement", "class", "return", "its", "generic", "name", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/measurements.py#L109-L135
train
openxc/openxc-python
openxc/sources/trace.py
TraceDataSource._store_timestamp
def _store_timestamp(self, timestamp): """If not already saved, cache the first timestamp in the active trace file on the instance. """ if getattr(self, 'first_timestamp', None) is None: self.first_timestamp = timestamp LOG.debug("Storing %d as the first timestamp...
python
def _store_timestamp(self, timestamp): """If not already saved, cache the first timestamp in the active trace file on the instance. """ if getattr(self, 'first_timestamp', None) is None: self.first_timestamp = timestamp LOG.debug("Storing %d as the first timestamp...
[ "def", "_store_timestamp", "(", "self", ",", "timestamp", ")", ":", "if", "getattr", "(", "self", ",", "'first_timestamp'", ",", "None", ")", "is", "None", ":", "self", ".", "first_timestamp", "=", "timestamp", "LOG", ".", "debug", "(", "\"Storing %d as the ...
If not already saved, cache the first timestamp in the active trace file on the instance.
[ "If", "not", "already", "saved", "cache", "the", "first", "timestamp", "in", "the", "active", "trace", "file", "on", "the", "instance", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sources/trace.py#L45-L52
train
openxc/openxc-python
openxc/sources/trace.py
TraceDataSource.read
def read(self): """Read a line of data from the input source at a time.""" line = self.trace_file.readline() if line == '': if self.loop: self._reopen_file() else: self.trace_file.close() self.trace_file = None ...
python
def read(self): """Read a line of data from the input source at a time.""" line = self.trace_file.readline() if line == '': if self.loop: self._reopen_file() else: self.trace_file.close() self.trace_file = None ...
[ "def", "read", "(", "self", ")", ":", "line", "=", "self", ".", "trace_file", ".", "readline", "(", ")", "if", "line", "==", "''", ":", "if", "self", ".", "loop", ":", "self", ".", "_reopen_file", "(", ")", "else", ":", "self", ".", "trace_file", ...
Read a line of data from the input source at a time.
[ "Read", "a", "line", "of", "data", "from", "the", "input", "source", "at", "a", "time", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sources/trace.py#L54-L70
train
openxc/openxc-python
openxc/sources/trace.py
TraceDataSource._open_file
def _open_file(filename): """Attempt to open the the file at ``filename`` for reading. Raises: DataSourceError, if the file cannot be opened. """ if filename is None: raise DataSourceError("Trace filename is not defined") try: trace_file = op...
python
def _open_file(filename): """Attempt to open the the file at ``filename`` for reading. Raises: DataSourceError, if the file cannot be opened. """ if filename is None: raise DataSourceError("Trace filename is not defined") try: trace_file = op...
[ "def", "_open_file", "(", "filename", ")", ":", "if", "filename", "is", "None", ":", "raise", "DataSourceError", "(", "\"Trace filename is not defined\"", ")", "try", ":", "trace_file", "=", "open", "(", "filename", ",", "\"r\"", ")", "except", "IOError", "as"...
Attempt to open the the file at ``filename`` for reading. Raises: DataSourceError, if the file cannot be opened.
[ "Attempt", "to", "open", "the", "the", "file", "at", "filename", "for", "reading", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sources/trace.py#L73-L88
train
openxc/openxc-python
openxc/sources/trace.py
TraceDataSource._wait
def _wait(starting_time, first_timestamp, timestamp): """Given that the first timestamp in the trace file is ``first_timestamp`` and we started playing back the file at ``starting_time``, block until the current ``timestamp`` should occur. """ target_time = starting_time + (times...
python
def _wait(starting_time, first_timestamp, timestamp): """Given that the first timestamp in the trace file is ``first_timestamp`` and we started playing back the file at ``starting_time``, block until the current ``timestamp`` should occur. """ target_time = starting_time + (times...
[ "def", "_wait", "(", "starting_time", ",", "first_timestamp", ",", "timestamp", ")", ":", "target_time", "=", "starting_time", "+", "(", "timestamp", "-", "first_timestamp", ")", "time", ".", "sleep", "(", "max", "(", "target_time", "-", "time", ".", "time",...
Given that the first timestamp in the trace file is ``first_timestamp`` and we started playing back the file at ``starting_time``, block until the current ``timestamp`` should occur.
[ "Given", "that", "the", "first", "timestamp", "in", "the", "trace", "file", "is", "first_timestamp", "and", "we", "started", "playing", "back", "the", "file", "at", "starting_time", "block", "until", "the", "current", "timestamp", "should", "occur", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sources/trace.py#L91-L97
train
openxc/openxc-python
openxc/generator/xml_to_json.py
XMLBackedSignal.from_xml_node
def from_xml_node(cls, node): """Construct a Signal instance from an XML node exported from a Vector CANoe .dbc file.""" return cls(name=node.find("Name").text, bit_position=int(node.find("Bitposition").text), bit_size=int(node.find("Bitsize").text), ...
python
def from_xml_node(cls, node): """Construct a Signal instance from an XML node exported from a Vector CANoe .dbc file.""" return cls(name=node.find("Name").text, bit_position=int(node.find("Bitposition").text), bit_size=int(node.find("Bitsize").text), ...
[ "def", "from_xml_node", "(", "cls", ",", "node", ")", ":", "return", "cls", "(", "name", "=", "node", ".", "find", "(", "\"Name\"", ")", ".", "text", ",", "bit_position", "=", "int", "(", "node", ".", "find", "(", "\"Bitposition\"", ")", ".", "text",...
Construct a Signal instance from an XML node exported from a Vector CANoe .dbc file.
[ "Construct", "a", "Signal", "instance", "from", "an", "XML", "node", "exported", "from", "a", "Vector", "CANoe", ".", "dbc", "file", "." ]
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/generator/xml_to_json.py#L62-L71
train
openxc/openxc-python
openxc/sources/base.py
SourceLogger.run
def run(self): """Continuously read data from the source and attempt to parse a valid message from the buffer of bytes. When a message is parsed, passes it off to the callback if one is set. """ message_buffer = b"" while self.running: try: mes...
python
def run(self): """Continuously read data from the source and attempt to parse a valid message from the buffer of bytes. When a message is parsed, passes it off to the callback if one is set. """ message_buffer = b"" while self.running: try: mes...
[ "def", "run", "(", "self", ")", ":", "message_buffer", "=", "b\"\"", "while", "self", ".", "running", ":", "try", ":", "message_buffer", "+=", "self", ".", "source", ".", "read_logs", "(", ")", "except", "DataSourceError", "as", "e", ":", "if", "self", ...
Continuously read data from the source and attempt to parse a valid message from the buffer of bytes. When a message is parsed, passes it off to the callback if one is set.
[ "Continuously", "read", "data", "from", "the", "source", "and", "attempt", "to", "parse", "a", "valid", "message", "from", "the", "buffer", "of", "bytes", ".", "When", "a", "message", "is", "parsed", "passes", "it", "off", "to", "the", "callback", "if", ...
4becb4a6310bd658c125195ef6ffea4deaf7d7e7
https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/sources/base.py#L141-L163
train
dfm/celerite
celerite/celerite.py
GP.compute
def compute(self, t, yerr=1.123e-12, check_sorted=True, A=None, U=None, V=None): """ Compute the extended form of the covariance matrix and factorize Args: x (array[n]): The independent coordinates of the data points. This array must be _sorted_ in as...
python
def compute(self, t, yerr=1.123e-12, check_sorted=True, A=None, U=None, V=None): """ Compute the extended form of the covariance matrix and factorize Args: x (array[n]): The independent coordinates of the data points. This array must be _sorted_ in as...
[ "def", "compute", "(", "self", ",", "t", ",", "yerr", "=", "1.123e-12", ",", "check_sorted", "=", "True", ",", "A", "=", "None", ",", "U", "=", "None", ",", "V", "=", "None", ")", ":", "t", "=", "np", ".", "atleast_1d", "(", "t", ")", "if", "...
Compute the extended form of the covariance matrix and factorize Args: x (array[n]): The independent coordinates of the data points. This array must be _sorted_ in ascending order. yerr (Optional[float or array[n]]): The measurement uncertainties for the ...
[ "Compute", "the", "extended", "form", "of", "the", "covariance", "matrix", "and", "factorize" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L97-L139
train
dfm/celerite
celerite/celerite.py
GP.log_likelihood
def log_likelihood(self, y, _const=math.log(2.0*math.pi), quiet=False): """ Compute the marginalized likelihood of the GP model The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. Args: y (array[n]): The ob...
python
def log_likelihood(self, y, _const=math.log(2.0*math.pi), quiet=False): """ Compute the marginalized likelihood of the GP model The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. Args: y (array[n]): The ob...
[ "def", "log_likelihood", "(", "self", ",", "y", ",", "_const", "=", "math", ".", "log", "(", "2.0", "*", "math", ".", "pi", ")", ",", "quiet", "=", "False", ")", ":", "y", "=", "self", ".", "_process_input", "(", "y", ")", "resid", "=", "y", "-...
Compute the marginalized likelihood of the GP model The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. Args: y (array[n]): The observations at coordinates ``x`` from :func:`GP.compute`. quiet (...
[ "Compute", "the", "marginalized", "likelihood", "of", "the", "GP", "model" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L155-L192
train
dfm/celerite
celerite/celerite.py
GP.grad_log_likelihood
def grad_log_likelihood(self, y, quiet=False): """ Compute the gradient of the marginalized likelihood The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. The gradient is taken with respect to the parameters returned by...
python
def grad_log_likelihood(self, y, quiet=False): """ Compute the gradient of the marginalized likelihood The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. The gradient is taken with respect to the parameters returned by...
[ "def", "grad_log_likelihood", "(", "self", ",", "y", ",", "quiet", "=", "False", ")", ":", "if", "not", "solver", ".", "has_autodiff", "(", ")", ":", "raise", "RuntimeError", "(", "\"celerite must be compiled with autodiff \"", "\"support to use the gradient methods\"...
Compute the gradient of the marginalized likelihood The factorized matrix from the previous call to :func:`GP.compute` is used so ``compute`` must be called first. The gradient is taken with respect to the parameters returned by :func:`GP.get_parameter_vector`. This function requires th...
[ "Compute", "the", "gradient", "of", "the", "marginalized", "likelihood" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L194-L263
train
dfm/celerite
celerite/celerite.py
GP.apply_inverse
def apply_inverse(self, y): """ Apply the inverse of the covariance matrix to a vector or matrix Solve ``K.x = y`` for ``x`` where ``K`` is the covariance matrix of the GP with the white noise and ``yerr`` components included on the diagonal. Args: y (array[...
python
def apply_inverse(self, y): """ Apply the inverse of the covariance matrix to a vector or matrix Solve ``K.x = y`` for ``x`` where ``K`` is the covariance matrix of the GP with the white noise and ``yerr`` components included on the diagonal. Args: y (array[...
[ "def", "apply_inverse", "(", "self", ",", "y", ")", ":", "self", ".", "_recompute", "(", ")", "return", "self", ".", "solver", ".", "solve", "(", "self", ".", "_process_input", "(", "y", ")", ")" ]
Apply the inverse of the covariance matrix to a vector or matrix Solve ``K.x = y`` for ``x`` where ``K`` is the covariance matrix of the GP with the white noise and ``yerr`` components included on the diagonal. Args: y (array[n] or array[n, nrhs]): The vector or matrix ``y`...
[ "Apply", "the", "inverse", "of", "the", "covariance", "matrix", "to", "a", "vector", "or", "matrix" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L265-L286
train
dfm/celerite
celerite/celerite.py
GP.dot
def dot(self, y, t=None, A=None, U=None, V=None, kernel=None, check_sorted=True): """ Dot the covariance matrix into a vector or matrix Compute ``K.y`` where ``K`` is the covariance matrix of the GP without the white noise or ``yerr`` values on the diagonal. Args: ...
python
def dot(self, y, t=None, A=None, U=None, V=None, kernel=None, check_sorted=True): """ Dot the covariance matrix into a vector or matrix Compute ``K.y`` where ``K`` is the covariance matrix of the GP without the white noise or ``yerr`` values on the diagonal. Args: ...
[ "def", "dot", "(", "self", ",", "y", ",", "t", "=", "None", ",", "A", "=", "None", ",", "U", "=", "None", ",", "V", "=", "None", ",", "kernel", "=", "None", ",", "check_sorted", "=", "True", ")", ":", "if", "kernel", "is", "None", ":", "kerne...
Dot the covariance matrix into a vector or matrix Compute ``K.y`` where ``K`` is the covariance matrix of the GP without the white noise or ``yerr`` values on the diagonal. Args: y (array[n] or array[n, nrhs]): The vector or matrix ``y`` described above. ...
[ "Dot", "the", "covariance", "matrix", "into", "a", "vector", "or", "matrix" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L288-L341
train
dfm/celerite
celerite/celerite.py
GP.predict
def predict(self, y, t=None, return_cov=True, return_var=False): """ Compute the conditional predictive distribution of the model You must call :func:`GP.compute` before this method. Args: y (array[n]): The observations at coordinates ``x`` from :func:`GP.co...
python
def predict(self, y, t=None, return_cov=True, return_var=False): """ Compute the conditional predictive distribution of the model You must call :func:`GP.compute` before this method. Args: y (array[n]): The observations at coordinates ``x`` from :func:`GP.co...
[ "def", "predict", "(", "self", ",", "y", ",", "t", "=", "None", ",", "return_cov", "=", "True", ",", "return_var", "=", "False", ")", ":", "y", "=", "self", ".", "_process_input", "(", "y", ")", "if", "len", "(", "y", ".", "shape", ")", ">", "1...
Compute the conditional predictive distribution of the model You must call :func:`GP.compute` before this method. Args: y (array[n]): The observations at coordinates ``x`` from :func:`GP.compute`. t (Optional[array[ntest]]): The independent coordinates where the...
[ "Compute", "the", "conditional", "predictive", "distribution", "of", "the", "model" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L343-L418
train
dfm/celerite
celerite/celerite.py
GP.get_matrix
def get_matrix(self, x1=None, x2=None, include_diagonal=None, include_general=None): """ Get the covariance matrix at given independent coordinates Args: x1 (Optional[array[n1]]): The first set of independent coordinates. If this is omitted, ``x1``...
python
def get_matrix(self, x1=None, x2=None, include_diagonal=None, include_general=None): """ Get the covariance matrix at given independent coordinates Args: x1 (Optional[array[n1]]): The first set of independent coordinates. If this is omitted, ``x1``...
[ "def", "get_matrix", "(", "self", ",", "x1", "=", "None", ",", "x2", "=", "None", ",", "include_diagonal", "=", "None", ",", "include_general", "=", "None", ")", ":", "if", "x1", "is", "None", "and", "x2", "is", "None", ":", "if", "self", ".", "_t"...
Get the covariance matrix at given independent coordinates Args: x1 (Optional[array[n1]]): The first set of independent coordinates. If this is omitted, ``x1`` will be assumed to be equal to ``x`` from a previous call to :func:`GP.compute`. x2 (Optional[a...
[ "Get", "the", "covariance", "matrix", "at", "given", "independent", "coordinates" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L420-L459
train
dfm/celerite
celerite/celerite.py
GP.sample
def sample(self, size=None): """ Sample from the prior distribution over datasets Args: size (Optional[int]): The number of samples to draw. Returns: array[n] or array[size, n]: The samples from the prior distribution over datasets. """ ...
python
def sample(self, size=None): """ Sample from the prior distribution over datasets Args: size (Optional[int]): The number of samples to draw. Returns: array[n] or array[size, n]: The samples from the prior distribution over datasets. """ ...
[ "def", "sample", "(", "self", ",", "size", "=", "None", ")", ":", "self", ".", "_recompute", "(", ")", "if", "size", "is", "None", ":", "n", "=", "np", ".", "random", ".", "randn", "(", "len", "(", "self", ".", "_t", ")", ")", "else", ":", "n...
Sample from the prior distribution over datasets Args: size (Optional[int]): The number of samples to draw. Returns: array[n] or array[size, n]: The samples from the prior distribution over datasets.
[ "Sample", "from", "the", "prior", "distribution", "over", "datasets" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L461-L481
train
dfm/celerite
celerite/terms.py
Term.get_value
def get_value(self, tau): """ Compute the value of the term for an array of lags Args: tau (array[...]): An array of lags where the term should be evaluated. Returns: The value of the term for each ``tau``. This will have the same sha...
python
def get_value(self, tau): """ Compute the value of the term for an array of lags Args: tau (array[...]): An array of lags where the term should be evaluated. Returns: The value of the term for each ``tau``. This will have the same sha...
[ "def", "get_value", "(", "self", ",", "tau", ")", ":", "tau", "=", "np", ".", "asarray", "(", "tau", ")", "(", "alpha_real", ",", "beta_real", ",", "alpha_complex_real", ",", "alpha_complex_imag", ",", "beta_complex_real", ",", "beta_complex_imag", ")", "=",...
Compute the value of the term for an array of lags Args: tau (array[...]): An array of lags where the term should be evaluated. Returns: The value of the term for each ``tau``. This will have the same shape as ``tau``.
[ "Compute", "the", "value", "of", "the", "term", "for", "an", "array", "of", "lags" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/terms.py#L43-L65
train
dfm/celerite
celerite/terms.py
Term.get_psd
def get_psd(self, omega): """ Compute the PSD of the term for an array of angular frequencies Args: omega (array[...]): An array of frequencies where the PSD should be evaluated. Returns: The value of the PSD for each ``omega``. This will have th...
python
def get_psd(self, omega): """ Compute the PSD of the term for an array of angular frequencies Args: omega (array[...]): An array of frequencies where the PSD should be evaluated. Returns: The value of the PSD for each ``omega``. This will have th...
[ "def", "get_psd", "(", "self", ",", "omega", ")", ":", "w", "=", "np", ".", "asarray", "(", "omega", ")", "(", "alpha_real", ",", "beta_real", ",", "alpha_complex_real", ",", "alpha_complex_imag", ",", "beta_complex_real", ",", "beta_complex_imag", ")", "=",...
Compute the PSD of the term for an array of angular frequencies Args: omega (array[...]): An array of frequencies where the PSD should be evaluated. Returns: The value of the PSD for each ``omega``. This will have the same shape as ``omega``.
[ "Compute", "the", "PSD", "of", "the", "term", "for", "an", "array", "of", "angular", "frequencies" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/terms.py#L67-L89
train
dfm/celerite
celerite/terms.py
Term.coefficients
def coefficients(self): """ All of the coefficient arrays This property is the concatenation of the results from :func:`terms.Term.get_real_coefficients` and :func:`terms.Term.get_complex_coefficients` but it will always return a tuple of length 6, even if ``alpha_comple...
python
def coefficients(self): """ All of the coefficient arrays This property is the concatenation of the results from :func:`terms.Term.get_real_coefficients` and :func:`terms.Term.get_complex_coefficients` but it will always return a tuple of length 6, even if ``alpha_comple...
[ "def", "coefficients", "(", "self", ")", ":", "vector", "=", "self", ".", "get_parameter_vector", "(", "include_frozen", "=", "True", ")", "pars", "=", "self", ".", "get_all_coefficients", "(", "vector", ")", "if", "len", "(", "pars", ")", "!=", "6", ":"...
All of the coefficient arrays This property is the concatenation of the results from :func:`terms.Term.get_real_coefficients` and :func:`terms.Term.get_complex_coefficients` but it will always return a tuple of length 6, even if ``alpha_complex_imag`` was omitted from ``get_comp...
[ "All", "of", "the", "coefficient", "arrays" ]
ad3f471f06b18d233f3dab71bb1c20a316173cae
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/terms.py#L157-L188
train
shoyer/h5netcdf
h5netcdf/core.py
Group._determine_current_dimension_size
def _determine_current_dimension_size(self, dim_name, max_size): """ Helper method to determine the current size of a dimension. """ # Limited dimension. if self.dimensions[dim_name] is not None: return max_size def _find_dim(h5group, dim): if dim...
python
def _determine_current_dimension_size(self, dim_name, max_size): """ Helper method to determine the current size of a dimension. """ # Limited dimension. if self.dimensions[dim_name] is not None: return max_size def _find_dim(h5group, dim): if dim...
[ "def", "_determine_current_dimension_size", "(", "self", ",", "dim_name", ",", "max_size", ")", ":", "if", "self", ".", "dimensions", "[", "dim_name", "]", "is", "not", "None", ":", "return", "max_size", "def", "_find_dim", "(", "h5group", ",", "dim", ")", ...
Helper method to determine the current size of a dimension.
[ "Helper", "method", "to", "determine", "the", "current", "size", "of", "a", "dimension", "." ]
3ae35cd58297281a1dc69c46fb0b315a0007ac2b
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/core.py#L273-L300
train
shoyer/h5netcdf
h5netcdf/core.py
Group._create_dim_scales
def _create_dim_scales(self): """Create all necessary HDF5 dimension scale.""" dim_order = self._dim_order.maps[0] for dim in sorted(dim_order, key=lambda d: dim_order[d]): if dim not in self._h5group: size = self._current_dim_sizes[dim] kwargs = {} ...
python
def _create_dim_scales(self): """Create all necessary HDF5 dimension scale.""" dim_order = self._dim_order.maps[0] for dim in sorted(dim_order, key=lambda d: dim_order[d]): if dim not in self._h5group: size = self._current_dim_sizes[dim] kwargs = {} ...
[ "def", "_create_dim_scales", "(", "self", ")", ":", "dim_order", "=", "self", ".", "_dim_order", ".", "maps", "[", "0", "]", "for", "dim", "in", "sorted", "(", "dim_order", ",", "key", "=", "lambda", "d", ":", "dim_order", "[", "d", "]", ")", ":", ...
Create all necessary HDF5 dimension scale.
[ "Create", "all", "necessary", "HDF5", "dimension", "scale", "." ]
3ae35cd58297281a1dc69c46fb0b315a0007ac2b
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/core.py#L459-L483
train
shoyer/h5netcdf
h5netcdf/core.py
Group._attach_dim_scales
def _attach_dim_scales(self): """Attach dimension scales to all variables.""" for name, var in self.variables.items(): if name not in self.dimensions: for n, dim in enumerate(var.dimensions): var._h5ds.dims[n].attach_scale(self._all_h5groups[dim]) ...
python
def _attach_dim_scales(self): """Attach dimension scales to all variables.""" for name, var in self.variables.items(): if name not in self.dimensions: for n, dim in enumerate(var.dimensions): var._h5ds.dims[n].attach_scale(self._all_h5groups[dim]) ...
[ "def", "_attach_dim_scales", "(", "self", ")", ":", "for", "name", ",", "var", "in", "self", ".", "variables", ".", "items", "(", ")", ":", "if", "name", "not", "in", "self", ".", "dimensions", ":", "for", "n", ",", "dim", "in", "enumerate", "(", "...
Attach dimension scales to all variables.
[ "Attach", "dimension", "scales", "to", "all", "variables", "." ]
3ae35cd58297281a1dc69c46fb0b315a0007ac2b
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/core.py#L485-L493
train
shoyer/h5netcdf
h5netcdf/core.py
Group._detach_dim_scale
def _detach_dim_scale(self, name): """Detach the dimension scale corresponding to a dimension name.""" for var in self.variables.values(): for n, dim in enumerate(var.dimensions): if dim == name: var._h5ds.dims[n].detach_scale(self._all_h5groups[dim]) ...
python
def _detach_dim_scale(self, name): """Detach the dimension scale corresponding to a dimension name.""" for var in self.variables.values(): for n, dim in enumerate(var.dimensions): if dim == name: var._h5ds.dims[n].detach_scale(self._all_h5groups[dim]) ...
[ "def", "_detach_dim_scale", "(", "self", ",", "name", ")", ":", "for", "var", "in", "self", ".", "variables", ".", "values", "(", ")", ":", "for", "n", ",", "dim", "in", "enumerate", "(", "var", ".", "dimensions", ")", ":", "if", "dim", "==", "name...
Detach the dimension scale corresponding to a dimension name.
[ "Detach", "the", "dimension", "scale", "corresponding", "to", "a", "dimension", "name", "." ]
3ae35cd58297281a1dc69c46fb0b315a0007ac2b
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/core.py#L495-L504
train
shoyer/h5netcdf
h5netcdf/core.py
Group.resize_dimension
def resize_dimension(self, dimension, size): """ Resize a dimension to a certain size. It will pad with the underlying HDF5 data sets' fill values (usually zero) where necessary. """ if self.dimensions[dimension] is not None: raise ValueError("Dimension '%s' ...
python
def resize_dimension(self, dimension, size): """ Resize a dimension to a certain size. It will pad with the underlying HDF5 data sets' fill values (usually zero) where necessary. """ if self.dimensions[dimension] is not None: raise ValueError("Dimension '%s' ...
[ "def", "resize_dimension", "(", "self", ",", "dimension", ",", "size", ")", ":", "if", "self", ".", "dimensions", "[", "dimension", "]", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Dimension '%s' is not unlimited and thus \"", "\"cannot be resized.\"", ...
Resize a dimension to a certain size. It will pad with the underlying HDF5 data sets' fill values (usually zero) where necessary.
[ "Resize", "a", "dimension", "to", "a", "certain", "size", "." ]
3ae35cd58297281a1dc69c46fb0b315a0007ac2b
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/core.py#L550-L575
train
vijayvarma392/surfinBH
surfinBH/_utils.py
alignVec_quat
def alignVec_quat(vec): """Returns a unit quaternion that will align vec with the z-axis""" alpha = np.arctan2(vec[1], vec[0]) beta = np.arccos(vec[2]) gamma = -alpha*vec[2] cb = np.cos(0.5*beta) sb = np.sin(0.5*beta) return np.array([cb*np.cos(0.5*(alpha + gamma)), sb*n...
python
def alignVec_quat(vec): """Returns a unit quaternion that will align vec with the z-axis""" alpha = np.arctan2(vec[1], vec[0]) beta = np.arccos(vec[2]) gamma = -alpha*vec[2] cb = np.cos(0.5*beta) sb = np.sin(0.5*beta) return np.array([cb*np.cos(0.5*(alpha + gamma)), sb*n...
[ "def", "alignVec_quat", "(", "vec", ")", ":", "alpha", "=", "np", ".", "arctan2", "(", "vec", "[", "1", "]", ",", "vec", "[", "0", "]", ")", "beta", "=", "np", ".", "arccos", "(", "vec", "[", "2", "]", ")", "gamma", "=", "-", "alpha", "*", ...
Returns a unit quaternion that will align vec with the z-axis
[ "Returns", "a", "unit", "quaternion", "that", "will", "align", "vec", "with", "the", "z", "-", "axis" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_utils.py#L21-L31
train
vijayvarma392/surfinBH
surfinBH/_utils.py
rotate_in_plane
def rotate_in_plane(chi, phase): """For transforming spins between the coprecessing and coorbital frames""" v = chi.T sp = np.sin(phase) cp = np.cos(phase) res = 1.*v res[0] = v[0]*cp + v[1]*sp res[1] = v[1]*cp - v[0]*sp return res.T
python
def rotate_in_plane(chi, phase): """For transforming spins between the coprecessing and coorbital frames""" v = chi.T sp = np.sin(phase) cp = np.cos(phase) res = 1.*v res[0] = v[0]*cp + v[1]*sp res[1] = v[1]*cp - v[0]*sp return res.T
[ "def", "rotate_in_plane", "(", "chi", ",", "phase", ")", ":", "v", "=", "chi", ".", "T", "sp", "=", "np", ".", "sin", "(", "phase", ")", "cp", "=", "np", ".", "cos", "(", "phase", ")", "res", "=", "1.", "*", "v", "res", "[", "0", "]", "=", ...
For transforming spins between the coprecessing and coorbital frames
[ "For", "transforming", "spins", "between", "the", "coprecessing", "and", "coorbital", "frames" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_utils.py#L54-L62
train
vijayvarma392/surfinBH
surfinBH/_utils.py
transform_error_coorb_to_inertial
def transform_error_coorb_to_inertial(vec_coorb, vec_err_coorb, orbPhase, quat_copr): """ Transform error in a vector from the coorbital frame to the inertial frame. Generates distributions in the coorbital frame, transforms them to inertial frame and returns 1-simga widths in the inertial frame. ...
python
def transform_error_coorb_to_inertial(vec_coorb, vec_err_coorb, orbPhase, quat_copr): """ Transform error in a vector from the coorbital frame to the inertial frame. Generates distributions in the coorbital frame, transforms them to inertial frame and returns 1-simga widths in the inertial frame. ...
[ "def", "transform_error_coorb_to_inertial", "(", "vec_coorb", ",", "vec_err_coorb", ",", "orbPhase", ",", "quat_copr", ")", ":", "np", ".", "random", ".", "seed", "(", "0", ")", "dist_coorb", "=", "np", ".", "array", "(", "[", "np", ".", "random", ".", "...
Transform error in a vector from the coorbital frame to the inertial frame. Generates distributions in the coorbital frame, transforms them to inertial frame and returns 1-simga widths in the inertial frame.
[ "Transform", "error", "in", "a", "vector", "from", "the", "coorbital", "frame", "to", "the", "inertial", "frame", ".", "Generates", "distributions", "in", "the", "coorbital", "frame", "transforms", "them", "to", "inertial", "frame", "and", "returns", "1", "-",...
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_utils.py#L81-L105
train
vijayvarma392/surfinBH
surfinBH/_fit_evaluators/fit_7dq2.py
Fit7dq2._extra_regression_kwargs
def _extra_regression_kwargs(self): """ List of additional kwargs to use in regression tests. """ # larger than default sometimes needed when extrapolating omega_switch_test = 0.019 extra_args = [] extra_args.append({ 'omega0': 5e-3, 'PN_approxim...
python
def _extra_regression_kwargs(self): """ List of additional kwargs to use in regression tests. """ # larger than default sometimes needed when extrapolating omega_switch_test = 0.019 extra_args = [] extra_args.append({ 'omega0': 5e-3, 'PN_approxim...
[ "def", "_extra_regression_kwargs", "(", "self", ")", ":", "omega_switch_test", "=", "0.019", "extra_args", "=", "[", "]", "extra_args", ".", "append", "(", "{", "'omega0'", ":", "5e-3", ",", "'PN_approximant'", ":", "'SpinTaylorT4'", ",", "'PN_dt'", ":", "0.1"...
List of additional kwargs to use in regression tests.
[ "List", "of", "additional", "kwargs", "to", "use", "in", "regression", "tests", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_fit_evaluators/fit_7dq2.py#L159-L199
train
vijayvarma392/surfinBH
surfinBH/_fit_evaluators/fit_7dq2.py
Fit7dq2._evolve_spins
def _evolve_spins(self, q, chiA0, chiB0, omega0, PN_approximant, PN_dt, PN_spin0, PN_phase0, omega0_nrsur): """ Evolves spins of the component BHs from an initial orbital frequency = omega0 until t=-100 M from the peak of the waveform. If omega0 < omega0_nrsur, use PN to evolve the s...
python
def _evolve_spins(self, q, chiA0, chiB0, omega0, PN_approximant, PN_dt, PN_spin0, PN_phase0, omega0_nrsur): """ Evolves spins of the component BHs from an initial orbital frequency = omega0 until t=-100 M from the peak of the waveform. If omega0 < omega0_nrsur, use PN to evolve the s...
[ "def", "_evolve_spins", "(", "self", ",", "q", ",", "chiA0", ",", "chiB0", ",", "omega0", ",", "PN_approximant", ",", "PN_dt", ",", "PN_spin0", ",", "PN_phase0", ",", "omega0_nrsur", ")", ":", "if", "omega0", "<", "omega0_nrsur", ":", "chiA0_nrsur_copr", "...
Evolves spins of the component BHs from an initial orbital frequency = omega0 until t=-100 M from the peak of the waveform. If omega0 < omega0_nrsur, use PN to evolve the spins until orbital frequency = omega0. Then evolves further with the NRSur7dq2 waveform model until t=-100M from the...
[ "Evolves", "spins", "of", "the", "component", "BHs", "from", "an", "initial", "orbital", "frequency", "=", "omega0", "until", "t", "=", "-", "100", "M", "from", "the", "peak", "of", "the", "waveform", ".", "If", "omega0", "<", "omega0_nrsur", "use", "PN"...
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_fit_evaluators/fit_7dq2.py#L226-L295
train
vijayvarma392/surfinBH
surfinBH/_fit_evaluators/fit_7dq2.py
Fit7dq2._eval_wrapper
def _eval_wrapper(self, fit_key, q, chiA, chiB, **kwargs): """Evaluates the surfinBH7dq2 model. """ chiA = np.array(chiA) chiB = np.array(chiB) # Warn/Exit if extrapolating allow_extrap = kwargs.pop('allow_extrap', False) self._check_param_limits(q, chiA, chiB, a...
python
def _eval_wrapper(self, fit_key, q, chiA, chiB, **kwargs): """Evaluates the surfinBH7dq2 model. """ chiA = np.array(chiA) chiB = np.array(chiB) # Warn/Exit if extrapolating allow_extrap = kwargs.pop('allow_extrap', False) self._check_param_limits(q, chiA, chiB, a...
[ "def", "_eval_wrapper", "(", "self", ",", "fit_key", ",", "q", ",", "chiA", ",", "chiB", ",", "**", "kwargs", ")", ":", "chiA", "=", "np", ".", "array", "(", "chiA", ")", "chiB", "=", "np", ".", "array", "(", "chiB", ")", "allow_extrap", "=", "kw...
Evaluates the surfinBH7dq2 model.
[ "Evaluates", "the", "surfinBH7dq2", "model", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_fit_evaluators/fit_7dq2.py#L298-L363
train
vijayvarma392/surfinBH
surfinBH/_loadFits.py
LoadFits
def LoadFits(name): """ Loads data for a fit. If data is not available, downloads it before loading. """ if name not in fits_collection.keys(): raise Exception('Invalid fit name : %s'%name) else: testPath = DataPath() + '/' + fits_collection[name].data_url.split('/')[-1] if (...
python
def LoadFits(name): """ Loads data for a fit. If data is not available, downloads it before loading. """ if name not in fits_collection.keys(): raise Exception('Invalid fit name : %s'%name) else: testPath = DataPath() + '/' + fits_collection[name].data_url.split('/')[-1] if (...
[ "def", "LoadFits", "(", "name", ")", ":", "if", "name", "not", "in", "fits_collection", ".", "keys", "(", ")", ":", "raise", "Exception", "(", "'Invalid fit name : %s'", "%", "name", ")", "else", ":", "testPath", "=", "DataPath", "(", ")", "+", "'/'", ...
Loads data for a fit. If data is not available, downloads it before loading.
[ "Loads", "data", "for", "a", "fit", ".", "If", "data", "is", "not", "available", "downloads", "it", "before", "loading", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_loadFits.py#L25-L37
train
vijayvarma392/surfinBH
surfinBH/_fit_evaluators/fit_3dq8.py
Fit3dq8._eval_wrapper
def _eval_wrapper(self, fit_key, q, chiA, chiB, **kwargs): """ Evaluates the surfinBH3dq8 model. """ chiA = np.array(chiA) chiB = np.array(chiB) # Warn/Exit if extrapolating allow_extrap = kwargs.pop('allow_extrap', False) self._check_param_limits(q, chiA, chiB, ...
python
def _eval_wrapper(self, fit_key, q, chiA, chiB, **kwargs): """ Evaluates the surfinBH3dq8 model. """ chiA = np.array(chiA) chiB = np.array(chiB) # Warn/Exit if extrapolating allow_extrap = kwargs.pop('allow_extrap', False) self._check_param_limits(q, chiA, chiB, ...
[ "def", "_eval_wrapper", "(", "self", ",", "fit_key", ",", "q", ",", "chiA", ",", "chiB", ",", "**", "kwargs", ")", ":", "chiA", "=", "np", ".", "array", "(", "chiA", ")", "chiB", "=", "np", ".", "array", "(", "chiB", ")", "allow_extrap", "=", "kw...
Evaluates the surfinBH3dq8 model.
[ "Evaluates", "the", "surfinBH3dq8", "model", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_fit_evaluators/fit_3dq8.py#L112-L143
train
vijayvarma392/surfinBH
surfinBH/_lal_spin_evolution.py
evolve_pn_spins
def evolve_pn_spins(q, chiA0, chiB0, omega0, omegaTimesM_final, approximant='SpinTaylorT4', dt=0.1, spinO=7, phaseO=7): """ Evolves PN spins from a starting orbital frequency and spins to a final frequency. Inputs: q: Mass ratio (q>=1) chiA0: Dimless sp...
python
def evolve_pn_spins(q, chiA0, chiB0, omega0, omegaTimesM_final, approximant='SpinTaylorT4', dt=0.1, spinO=7, phaseO=7): """ Evolves PN spins from a starting orbital frequency and spins to a final frequency. Inputs: q: Mass ratio (q>=1) chiA0: Dimless sp...
[ "def", "evolve_pn_spins", "(", "q", ",", "chiA0", ",", "chiB0", ",", "omega0", ",", "omegaTimesM_final", ",", "approximant", "=", "'SpinTaylorT4'", ",", "dt", "=", "0.1", ",", "spinO", "=", "7", ",", "phaseO", "=", "7", ")", ":", "omega", ",", "phi", ...
Evolves PN spins from a starting orbital frequency and spins to a final frequency. Inputs: q: Mass ratio (q>=1) chiA0: Dimless spin of BhA at initial freq. chiB0: Dimless spin of BhB at initial freq. omega0: Initial orbital freque...
[ "Evolves", "PN", "spins", "from", "a", "starting", "orbital", "frequency", "and", "spins", "to", "a", "final", "frequency", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_lal_spin_evolution.py#L158-L211
train
crossbario/zlmdb
zlmdb/_pmap.py
qual
def qual(obj): """ Return fully qualified name of a class. """ return u'{}.{}'.format(obj.__class__.__module__, obj.__class__.__name__)
python
def qual(obj): """ Return fully qualified name of a class. """ return u'{}.{}'.format(obj.__class__.__module__, obj.__class__.__name__)
[ "def", "qual", "(", "obj", ")", ":", "return", "u'{}.{}'", ".", "format", "(", "obj", ".", "__class__", ".", "__module__", ",", "obj", ".", "__class__", ".", "__name__", ")" ]
Return fully qualified name of a class.
[ "Return", "fully", "qualified", "name", "of", "a", "class", "." ]
577e8ce9314484f1fd5092fb4eef70221bb1d030
https://github.com/crossbario/zlmdb/blob/577e8ce9314484f1fd5092fb4eef70221bb1d030/zlmdb/_pmap.py#L265-L269
train
crossbario/zlmdb
zlmdb/_pmap.py
PersistentMap.count
def count(self, txn, prefix=None): """ Count number of records in the persistent map. When no prefix is given, the total number of records is returned. When a prefix is given, only the number of records with keys that have this prefix are counted. :param txn: The transac...
python
def count(self, txn, prefix=None): """ Count number of records in the persistent map. When no prefix is given, the total number of records is returned. When a prefix is given, only the number of records with keys that have this prefix are counted. :param txn: The transac...
[ "def", "count", "(", "self", ",", "txn", ",", "prefix", "=", "None", ")", ":", "key_from", "=", "struct", ".", "pack", "(", "'>H'", ",", "self", ".", "_slot", ")", "if", "prefix", ":", "key_from", "+=", "self", ".", "_serialize_key", "(", "prefix", ...
Count number of records in the persistent map. When no prefix is given, the total number of records is returned. When a prefix is given, only the number of records with keys that have this prefix are counted. :param txn: The transaction in which to run. :type txn: :class:`zlmdb....
[ "Count", "number", "of", "records", "in", "the", "persistent", "map", ".", "When", "no", "prefix", "is", "given", "the", "total", "number", "of", "records", "is", "returned", ".", "When", "a", "prefix", "is", "given", "only", "the", "number", "of", "reco...
577e8ce9314484f1fd5092fb4eef70221bb1d030
https://github.com/crossbario/zlmdb/blob/577e8ce9314484f1fd5092fb4eef70221bb1d030/zlmdb/_pmap.py#L513-L545
train
crossbario/zlmdb
zlmdb/_pmap.py
PersistentMap.count_range
def count_range(self, txn, from_key, to_key): """ Counter number of records in the perstistent map with keys within the given range. :param txn: The transaction in which to run. :type txn: :class:`zlmdb.Transaction` :param from_key: Count records starting and including ...
python
def count_range(self, txn, from_key, to_key): """ Counter number of records in the perstistent map with keys within the given range. :param txn: The transaction in which to run. :type txn: :class:`zlmdb.Transaction` :param from_key: Count records starting and including ...
[ "def", "count_range", "(", "self", ",", "txn", ",", "from_key", ",", "to_key", ")", ":", "key_from", "=", "struct", ".", "pack", "(", "'>H'", ",", "self", ".", "_slot", ")", "+", "self", ".", "_serialize_key", "(", "from_key", ")", "to_key", "=", "st...
Counter number of records in the perstistent map with keys within the given range. :param txn: The transaction in which to run. :type txn: :class:`zlmdb.Transaction` :param from_key: Count records starting and including from this key. :type from_key: object :param to_k...
[ "Counter", "number", "of", "records", "in", "the", "perstistent", "map", "with", "keys", "within", "the", "given", "range", "." ]
577e8ce9314484f1fd5092fb4eef70221bb1d030
https://github.com/crossbario/zlmdb/blob/577e8ce9314484f1fd5092fb4eef70221bb1d030/zlmdb/_pmap.py#L547-L576
train
vijayvarma392/surfinBH
surfinBH/surfinBH.py
SurFinBH._read_dict
def _read_dict(self, f): """ Converts h5 groups to dictionaries """ d = {} for k, item in f.items(): if type(item) == h5py._hl.dataset.Dataset: v = item.value if type(v) == np.string_: v = str(v) if type(v) =...
python
def _read_dict(self, f): """ Converts h5 groups to dictionaries """ d = {} for k, item in f.items(): if type(item) == h5py._hl.dataset.Dataset: v = item.value if type(v) == np.string_: v = str(v) if type(v) =...
[ "def", "_read_dict", "(", "self", ",", "f", ")", ":", "d", "=", "{", "}", "for", "k", ",", "item", "in", "f", ".", "items", "(", ")", ":", "if", "type", "(", "item", ")", "==", "h5py", ".", "_hl", ".", "dataset", ".", "Dataset", ":", "v", "...
Converts h5 groups to dictionaries
[ "Converts", "h5", "groups", "to", "dictionaries" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/surfinBH.py#L77-L100
train
vijayvarma392/surfinBH
surfinBH/surfinBH.py
SurFinBH._load_scalar_fit
def _load_scalar_fit(self, fit_key=None, h5file=None, fit_data=None): """ Loads a single fit """ if (fit_key is None) ^ (h5file is None): raise ValueError("Either specify both fit_key and h5file, or" " neither") if not ((fit_key is None) ^ (fit_data is None))...
python
def _load_scalar_fit(self, fit_key=None, h5file=None, fit_data=None): """ Loads a single fit """ if (fit_key is None) ^ (h5file is None): raise ValueError("Either specify both fit_key and h5file, or" " neither") if not ((fit_key is None) ^ (fit_data is None))...
[ "def", "_load_scalar_fit", "(", "self", ",", "fit_key", "=", "None", ",", "h5file", "=", "None", ",", "fit_data", "=", "None", ")", ":", "if", "(", "fit_key", "is", "None", ")", "^", "(", "h5file", "is", "None", ")", ":", "raise", "ValueError", "(", ...
Loads a single fit
[ "Loads", "a", "single", "fit" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/surfinBH.py#L103-L121
train
vijayvarma392/surfinBH
surfinBH/surfinBH.py
SurFinBH._load_vector_fit
def _load_vector_fit(self, fit_key, h5file): """ Loads a vector of fits """ vector_fit = [] for i in range(len(h5file[fit_key].keys())): fit_data = self._read_dict(h5file[fit_key]['comp_%d'%i]) vector_fit.append(self._load_scalar_fit(fit_data=fit_data)) re...
python
def _load_vector_fit(self, fit_key, h5file): """ Loads a vector of fits """ vector_fit = [] for i in range(len(h5file[fit_key].keys())): fit_data = self._read_dict(h5file[fit_key]['comp_%d'%i]) vector_fit.append(self._load_scalar_fit(fit_data=fit_data)) re...
[ "def", "_load_vector_fit", "(", "self", ",", "fit_key", ",", "h5file", ")", ":", "vector_fit", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "h5file", "[", "fit_key", "]", ".", "keys", "(", ")", ")", ")", ":", "fit_data", "=", "self", ...
Loads a vector of fits
[ "Loads", "a", "vector", "of", "fits" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/surfinBH.py#L124-L131
train
vijayvarma392/surfinBH
surfinBH/surfinBH.py
SurFinBH._check_unused_kwargs
def _check_unused_kwargs(self, kwargs): """ Call this at the end of call module to check if all the kwargs have been used. Assumes kwargs were extracted using pop. """ if len(kwargs.keys()) != 0: unused = "" for k in kwargs.keys(): unused += "'%s',...
python
def _check_unused_kwargs(self, kwargs): """ Call this at the end of call module to check if all the kwargs have been used. Assumes kwargs were extracted using pop. """ if len(kwargs.keys()) != 0: unused = "" for k in kwargs.keys(): unused += "'%s',...
[ "def", "_check_unused_kwargs", "(", "self", ",", "kwargs", ")", ":", "if", "len", "(", "kwargs", ".", "keys", "(", ")", ")", "!=", "0", ":", "unused", "=", "\"\"", "for", "k", "in", "kwargs", ".", "keys", "(", ")", ":", "unused", "+=", "\"'%s', \""...
Call this at the end of call module to check if all the kwargs have been used. Assumes kwargs were extracted using pop.
[ "Call", "this", "at", "the", "end", "of", "call", "module", "to", "check", "if", "all", "the", "kwargs", "have", "been", "used", ".", "Assumes", "kwargs", "were", "extracted", "using", "pop", "." ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/surfinBH.py#L149-L159
train
vijayvarma392/surfinBH
surfinBH/surfinBH.py
SurFinBH._check_param_limits
def _check_param_limits(self, q, chiA, chiB, allow_extrap): """ Checks that params are within allowed range of paramters. Raises a warning if outside self.soft_param_lims limits and raises an error if outside self.hard_param_lims. If allow_extrap=True, skips these checks. """ ...
python
def _check_param_limits(self, q, chiA, chiB, allow_extrap): """ Checks that params are within allowed range of paramters. Raises a warning if outside self.soft_param_lims limits and raises an error if outside self.hard_param_lims. If allow_extrap=True, skips these checks. """ ...
[ "def", "_check_param_limits", "(", "self", ",", "q", ",", "chiA", ",", "chiB", ",", "allow_extrap", ")", ":", "if", "q", "<", "1", ":", "raise", "ValueError", "(", "'Mass ratio should be >= 1.'", ")", "chiAmag", "=", "np", ".", "sqrt", "(", "np", ".", ...
Checks that params are within allowed range of paramters. Raises a warning if outside self.soft_param_lims limits and raises an error if outside self.hard_param_lims. If allow_extrap=True, skips these checks.
[ "Checks", "that", "params", "are", "within", "allowed", "range", "of", "paramters", ".", "Raises", "a", "warning", "if", "outside", "self", ".", "soft_param_lims", "limits", "and", "raises", "an", "error", "if", "outside", "self", ".", "hard_param_lims", ".", ...
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/surfinBH.py#L162-L202
train
crossbario/zlmdb
zlmdb/_schema.py
Schema.slot
def slot(self, slot_index, marshal=None, unmarshal=None, build=None, cast=None, compress=False): """ Decorator for use on classes derived from zlmdb.PersistentMap. The decorator define slots in a LMDB database schema based on persistent maps, and slot configuration. :param slot_index: ...
python
def slot(self, slot_index, marshal=None, unmarshal=None, build=None, cast=None, compress=False): """ Decorator for use on classes derived from zlmdb.PersistentMap. The decorator define slots in a LMDB database schema based on persistent maps, and slot configuration. :param slot_index: ...
[ "def", "slot", "(", "self", ",", "slot_index", ",", "marshal", "=", "None", ",", "unmarshal", "=", "None", ",", "build", "=", "None", ",", "cast", "=", "None", ",", "compress", "=", "False", ")", ":", "def", "decorate", "(", "o", ")", ":", "assert"...
Decorator for use on classes derived from zlmdb.PersistentMap. The decorator define slots in a LMDB database schema based on persistent maps, and slot configuration. :param slot_index: :param marshal: :param unmarshal: :param build: :param cast: :param compress: ...
[ "Decorator", "for", "use", "on", "classes", "derived", "from", "zlmdb", ".", "PersistentMap", ".", "The", "decorator", "define", "slots", "in", "a", "LMDB", "database", "schema", "based", "on", "persistent", "maps", "and", "slot", "configuration", "." ]
577e8ce9314484f1fd5092fb4eef70221bb1d030
https://github.com/crossbario/zlmdb/blob/577e8ce9314484f1fd5092fb4eef70221bb1d030/zlmdb/_schema.py#L101-L131
train
vijayvarma392/surfinBH
surfinBH/_dataPath.py
DataPath
def DataPath(): """ Return the default path for fit data h5 files""" return os.path.abspath('%s/data'%(os.path.dirname( \ os.path.realpath(__file__))))
python
def DataPath(): """ Return the default path for fit data h5 files""" return os.path.abspath('%s/data'%(os.path.dirname( \ os.path.realpath(__file__))))
[ "def", "DataPath", "(", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "'%s/data'", "%", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", ")", ")" ]
Return the default path for fit data h5 files
[ "Return", "the", "default", "path", "for", "fit", "data", "h5", "files" ]
9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_dataPath.py#L4-L7
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
init_services
def init_services(service_definitions, service_context, state_db, client_authn_factory=None): """ Initiates a set of services :param service_definitions: A dictionary cotaining service definitions :param service_context: A reference to the service context, this is the same for...
python
def init_services(service_definitions, service_context, state_db, client_authn_factory=None): """ Initiates a set of services :param service_definitions: A dictionary cotaining service definitions :param service_context: A reference to the service context, this is the same for...
[ "def", "init_services", "(", "service_definitions", ",", "service_context", ",", "state_db", ",", "client_authn_factory", "=", "None", ")", ":", "service", "=", "{", "}", "for", "service_name", ",", "service_configuration", "in", "service_definitions", ".", "items",...
Initiates a set of services :param service_definitions: A dictionary cotaining service definitions :param service_context: A reference to the service context, this is the same for all service instances. :param state_db: A reference to the state database. Shared by all the services. :par...
[ "Initiates", "a", "set", "of", "services" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L514-L550
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.gather_request_args
def gather_request_args(self, **kwargs): """ Go through the attributes that the message class can contain and add values if they are missing but exists in the client info or when there are default values. :param kwargs: Initial set of attributes. :return: Possibly augmen...
python
def gather_request_args(self, **kwargs): """ Go through the attributes that the message class can contain and add values if they are missing but exists in the client info or when there are default values. :param kwargs: Initial set of attributes. :return: Possibly augmen...
[ "def", "gather_request_args", "(", "self", ",", "**", "kwargs", ")", ":", "ar_args", "=", "kwargs", ".", "copy", "(", ")", "for", "prop", "in", "self", ".", "msg_type", ".", "c_param", ".", "keys", "(", ")", ":", "if", "prop", "in", "ar_args", ":", ...
Go through the attributes that the message class can contain and add values if they are missing but exists in the client info or when there are default values. :param kwargs: Initial set of attributes. :return: Possibly augmented set of attributes
[ "Go", "through", "the", "attributes", "that", "the", "message", "class", "can", "contain", "and", "add", "values", "if", "they", "are", "missing", "but", "exists", "in", "the", "client", "info", "or", "when", "there", "are", "default", "values", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L68-L104
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.method_args
def method_args(self, context, **kwargs): """ Collect the set of arguments that should be used by a set of methods :param context: Which service we're working for :param kwargs: A set of keyword arguments that are added at run-time. :return: A set of keyword arguments ""...
python
def method_args(self, context, **kwargs): """ Collect the set of arguments that should be used by a set of methods :param context: Which service we're working for :param kwargs: A set of keyword arguments that are added at run-time. :return: A set of keyword arguments ""...
[ "def", "method_args", "(", "self", ",", "context", ",", "**", "kwargs", ")", ":", "try", ":", "_args", "=", "self", ".", "conf", "[", "context", "]", ".", "copy", "(", ")", "except", "KeyError", ":", "_args", "=", "kwargs", "else", ":", "_args", "....
Collect the set of arguments that should be used by a set of methods :param context: Which service we're working for :param kwargs: A set of keyword arguments that are added at run-time. :return: A set of keyword arguments
[ "Collect", "the", "set", "of", "arguments", "that", "should", "be", "used", "by", "a", "set", "of", "methods" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L106-L120
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.do_pre_construct
def do_pre_construct(self, request_args, **kwargs): """ Will run the pre_construct methods one by one in the order given. :param request_args: Request arguments :param kwargs: Extra key word arguments :return: A tuple of request_args and post_args. post_args are to be ...
python
def do_pre_construct(self, request_args, **kwargs): """ Will run the pre_construct methods one by one in the order given. :param request_args: Request arguments :param kwargs: Extra key word arguments :return: A tuple of request_args and post_args. post_args are to be ...
[ "def", "do_pre_construct", "(", "self", ",", "request_args", ",", "**", "kwargs", ")", ":", "_args", "=", "self", ".", "method_args", "(", "'pre_construct'", ",", "**", "kwargs", ")", "post_args", "=", "{", "}", "for", "meth", "in", "self", ".", "pre_con...
Will run the pre_construct methods one by one in the order given. :param request_args: Request arguments :param kwargs: Extra key word arguments :return: A tuple of request_args and post_args. post_args are to be used by the post_construct methods.
[ "Will", "run", "the", "pre_construct", "methods", "one", "by", "one", "in", "the", "order", "given", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L122-L138
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.do_post_construct
def do_post_construct(self, request_args, **kwargs): """ Will run the post_construct methods one at the time in order. :param request_args: Request arguments :param kwargs: Arguments used by the post_construct method :return: Possible modified set of request arguments. "...
python
def do_post_construct(self, request_args, **kwargs): """ Will run the post_construct methods one at the time in order. :param request_args: Request arguments :param kwargs: Arguments used by the post_construct method :return: Possible modified set of request arguments. "...
[ "def", "do_post_construct", "(", "self", ",", "request_args", ",", "**", "kwargs", ")", ":", "_args", "=", "self", ".", "method_args", "(", "'post_construct'", ",", "**", "kwargs", ")", "for", "meth", "in", "self", ".", "post_construct", ":", "request_args",...
Will run the post_construct methods one at the time in order. :param request_args: Request arguments :param kwargs: Arguments used by the post_construct method :return: Possible modified set of request arguments.
[ "Will", "run", "the", "post_construct", "methods", "one", "at", "the", "time", "in", "order", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L140-L153
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.construct
def construct(self, request_args=None, **kwargs): """ Instantiate the request as a message class instance with attribute values gathered in a pre_construct method or in the gather_request_args method. :param request_args: :param kwargs: extra keyword arguments :r...
python
def construct(self, request_args=None, **kwargs): """ Instantiate the request as a message class instance with attribute values gathered in a pre_construct method or in the gather_request_args method. :param request_args: :param kwargs: extra keyword arguments :r...
[ "def", "construct", "(", "self", ",", "request_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "request_args", "is", "None", ":", "request_args", "=", "{", "}", "request_args", ",", "post_args", "=", "self", ".", "do_pre_construct", "(", "request_...
Instantiate the request as a message class instance with attribute values gathered in a pre_construct method or in the gather_request_args method. :param request_args: :param kwargs: extra keyword arguments :return: message class instance
[ "Instantiate", "the", "request", "as", "a", "message", "class", "instance", "with", "attribute", "values", "gathered", "in", "a", "pre_construct", "method", "or", "in", "the", "gather_request_args", "method", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L165-L199
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.init_authentication_method
def init_authentication_method(self, request, authn_method, http_args=None, **kwargs): """ Will run the proper client authentication method. Each such method will place the necessary information in the necessary place. A method may modify the request. ...
python
def init_authentication_method(self, request, authn_method, http_args=None, **kwargs): """ Will run the proper client authentication method. Each such method will place the necessary information in the necessary place. A method may modify the request. ...
[ "def", "init_authentication_method", "(", "self", ",", "request", ",", "authn_method", ",", "http_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "http_args", "is", "None", ":", "http_args", "=", "{", "}", "if", "authn_method", ":", "logger", ".",...
Will run the proper client authentication method. Each such method will place the necessary information in the necessary place. A method may modify the request. :param request: The request, a Message class instance :param authn_method: Client authentication method :param http_ar...
[ "Will", "run", "the", "proper", "client", "authentication", "method", ".", "Each", "such", "method", "will", "place", "the", "necessary", "information", "in", "the", "necessary", "place", ".", "A", "method", "may", "modify", "the", "request", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L201-L222
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.construct_request
def construct_request(self, request_args=None, **kwargs): """ The method where everything is setup for sending the request. The request information is gathered and the where and how of sending the request is decided. :param request_args: Initial request arguments :param ...
python
def construct_request(self, request_args=None, **kwargs): """ The method where everything is setup for sending the request. The request information is gathered and the where and how of sending the request is decided. :param request_args: Initial request arguments :param ...
[ "def", "construct_request", "(", "self", ",", "request_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "request_args", "is", "None", ":", "request_args", "=", "{", "}", "return", "self", ".", "construct", "(", "request_args", ",", "**", "kwargs", ...
The method where everything is setup for sending the request. The request information is gathered and the where and how of sending the request is decided. :param request_args: Initial request arguments :param kwargs: Extra keyword arguments :return: A dictionary with the keys 'u...
[ "The", "method", "where", "everything", "is", "setup", "for", "sending", "the", "request", ".", "The", "request", "information", "is", "gathered", "and", "the", "where", "and", "how", "of", "sending", "the", "request", "is", "decided", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L224-L242
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.get_endpoint
def get_endpoint(self): """ Find the service endpoint :return: The service endpoint (a URL) """ if self.endpoint: return self.endpoint else: return self.service_context.provider_info[self.endpoint_name]
python
def get_endpoint(self): """ Find the service endpoint :return: The service endpoint (a URL) """ if self.endpoint: return self.endpoint else: return self.service_context.provider_info[self.endpoint_name]
[ "def", "get_endpoint", "(", "self", ")", ":", "if", "self", ".", "endpoint", ":", "return", "self", ".", "endpoint", "else", ":", "return", "self", ".", "service_context", ".", "provider_info", "[", "self", ".", "endpoint_name", "]" ]
Find the service endpoint :return: The service endpoint (a URL)
[ "Find", "the", "service", "endpoint" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L244-L253
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.get_authn_header
def get_authn_header(self, request, authn_method, **kwargs): """ Construct an authorization specification to be sent in the HTTP header. :param request: The service request :param authn_method: Which authentication/authorization method to use :param kwargs: Extra keyword...
python
def get_authn_header(self, request, authn_method, **kwargs): """ Construct an authorization specification to be sent in the HTTP header. :param request: The service request :param authn_method: Which authentication/authorization method to use :param kwargs: Extra keyword...
[ "def", "get_authn_header", "(", "self", ",", "request", ",", "authn_method", ",", "**", "kwargs", ")", ":", "headers", "=", "{", "}", "if", "authn_method", ":", "h_arg", "=", "self", ".", "init_authentication_method", "(", "request", ",", "authn_method", ","...
Construct an authorization specification to be sent in the HTTP header. :param request: The service request :param authn_method: Which authentication/authorization method to use :param kwargs: Extra keyword arguments :return: A set of keyword arguments to be sent in the HTTP hea...
[ "Construct", "an", "authorization", "specification", "to", "be", "sent", "in", "the", "HTTP", "header", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L255-L275
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.get_request_parameters
def get_request_parameters(self, request_body_type="", method="", authn_method='', request_args=None, http_args=None, **kwargs): """ Builds the request message and constructs the HTTP headers. This is the starting point for a pipelin...
python
def get_request_parameters(self, request_body_type="", method="", authn_method='', request_args=None, http_args=None, **kwargs): """ Builds the request message and constructs the HTTP headers. This is the starting point for a pipelin...
[ "def", "get_request_parameters", "(", "self", ",", "request_body_type", "=", "\"\"", ",", "method", "=", "\"\"", ",", "authn_method", "=", "''", ",", "request_args", "=", "None", ",", "http_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "not", ...
Builds the request message and constructs the HTTP headers. This is the starting point for a pipeline that will: - construct the request message - add/remove information to/from the request message in the way a specific client authentication method requires. - gather a set ...
[ "Builds", "the", "request", "message", "and", "constructs", "the", "HTTP", "headers", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L286-L355
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.get_urlinfo
def get_urlinfo(info): """ Pick out the fragment or query part from a URL. :param info: A URL possibly containing a query or a fragment part :return: the query/fragment part """ # If info is a whole URL pick out the query or fragment part if '?' in info or '#' in...
python
def get_urlinfo(info): """ Pick out the fragment or query part from a URL. :param info: A URL possibly containing a query or a fragment part :return: the query/fragment part """ # If info is a whole URL pick out the query or fragment part if '?' in info or '#' in...
[ "def", "get_urlinfo", "(", "info", ")", ":", "if", "'?'", "in", "info", "or", "'#'", "in", "info", ":", "parts", "=", "urlparse", "(", "info", ")", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "fragment", "=", "parts", "[...
Pick out the fragment or query part from a URL. :param info: A URL possibly containing a query or a fragment part :return: the query/fragment part
[ "Pick", "out", "the", "fragment", "or", "query", "part", "from", "a", "URL", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L360-L376
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
Service.get_conf_attr
def get_conf_attr(self, attr, default=None): """ Get the value of a attribute in the configuration :param attr: The attribute :param default: If the attribute doesn't appear in the configuration return this value :return: The value of attribute in the configuration o...
python
def get_conf_attr(self, attr, default=None): """ Get the value of a attribute in the configuration :param attr: The attribute :param default: If the attribute doesn't appear in the configuration return this value :return: The value of attribute in the configuration o...
[ "def", "get_conf_attr", "(", "self", ",", "attr", ",", "default", "=", "None", ")", ":", "if", "attr", "in", "self", ".", "conf", ":", "return", "self", ".", "conf", "[", "attr", "]", "else", ":", "return", "default" ]
Get the value of a attribute in the configuration :param attr: The attribute :param default: If the attribute doesn't appear in the configuration return this value :return: The value of attribute in the configuration or the default value
[ "Get", "the", "value", "of", "a", "attribute", "in", "the", "configuration" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L498-L511
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oauth2/authorization.py
Authorization.post_parse_response
def post_parse_response(self, response, **kwargs): """ Add scope claim to response, from the request, if not present in the response :param response: The response :param kwargs: Extra Keyword arguments :return: A possibly augmented response """ if "scope...
python
def post_parse_response(self, response, **kwargs): """ Add scope claim to response, from the request, if not present in the response :param response: The response :param kwargs: Extra Keyword arguments :return: A possibly augmented response """ if "scope...
[ "def", "post_parse_response", "(", "self", ",", "response", ",", "**", "kwargs", ")", ":", "if", "\"scope\"", "not", "in", "response", ":", "try", ":", "_key", "=", "kwargs", "[", "'state'", "]", "except", "KeyError", ":", "pass", "else", ":", "if", "_...
Add scope claim to response, from the request, if not present in the response :param response: The response :param kwargs: Extra Keyword arguments :return: A possibly augmented response
[ "Add", "scope", "claim", "to", "response", "from", "the", "request", "if", "not", "present", "in", "the", "response" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oauth2/authorization.py#L54-L77
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oidc/end_session.py
EndSession.get_id_token_hint
def get_id_token_hint(self, request_args=None, **kwargs): """ Add id_token_hint to request :param request_args: :param kwargs: :return: """ request_args = self.multiple_extend_request_args( request_args, kwargs['state'], ['id_token'], ['au...
python
def get_id_token_hint(self, request_args=None, **kwargs): """ Add id_token_hint to request :param request_args: :param kwargs: :return: """ request_args = self.multiple_extend_request_args( request_args, kwargs['state'], ['id_token'], ['au...
[ "def", "get_id_token_hint", "(", "self", ",", "request_args", "=", "None", ",", "**", "kwargs", ")", ":", "request_args", "=", "self", ".", "multiple_extend_request_args", "(", "request_args", ",", "kwargs", "[", "'state'", "]", ",", "[", "'id_token'", "]", ...
Add id_token_hint to request :param request_args: :param kwargs: :return:
[ "Add", "id_token_hint", "to", "request" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oidc/end_session.py#L32-L53
train
openid/JWTConnect-Python-OidcService
src/oidcservice/state_interface.py
StateInterface.get_state
def get_state(self, key): """ Get the state connected to a given key. :param key: Key into the state database :return: A :py:class:´oidcservice.state_interface.State` instance """ _data = self.state_db.get(key) if not _data: raise KeyError(key) ...
python
def get_state(self, key): """ Get the state connected to a given key. :param key: Key into the state database :return: A :py:class:´oidcservice.state_interface.State` instance """ _data = self.state_db.get(key) if not _data: raise KeyError(key) ...
[ "def", "get_state", "(", "self", ",", "key", ")", ":", "_data", "=", "self", ".", "state_db", ".", "get", "(", "key", ")", "if", "not", "_data", ":", "raise", "KeyError", "(", "key", ")", "else", ":", "return", "State", "(", ")", ".", "from_json", ...
Get the state connected to a given key. :param key: Key into the state database :return: A :py:class:´oidcservice.state_interface.State` instance
[ "Get", "the", "state", "connected", "to", "a", "given", "key", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L56-L67
train
openid/JWTConnect-Python-OidcService
src/oidcservice/state_interface.py
StateInterface.store_item
def store_item(self, item, item_type, key): """ Store a service response. :param item: The item as a :py:class:`oidcmsg.message.Message` subclass instance or a JSON document. :param item_type: The type of request or response :param key: The key under which the inform...
python
def store_item(self, item, item_type, key): """ Store a service response. :param item: The item as a :py:class:`oidcmsg.message.Message` subclass instance or a JSON document. :param item_type: The type of request or response :param key: The key under which the inform...
[ "def", "store_item", "(", "self", ",", "item", ",", "item_type", ",", "key", ")", ":", "try", ":", "_state", "=", "self", ".", "get_state", "(", "key", ")", "except", "KeyError", ":", "_state", "=", "State", "(", ")", "try", ":", "_state", "[", "it...
Store a service response. :param item: The item as a :py:class:`oidcmsg.message.Message` subclass instance or a JSON document. :param item_type: The type of request or response :param key: The key under which the information should be stored in the state database
[ "Store", "a", "service", "response", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L69-L89
train
openid/JWTConnect-Python-OidcService
src/oidcservice/state_interface.py
StateInterface.get_iss
def get_iss(self, key): """ Get the Issuer ID :param key: Key to the information in the state database :return: The issuer ID """ _state = self.get_state(key) if not _state: raise KeyError(key) return _state['iss']
python
def get_iss(self, key): """ Get the Issuer ID :param key: Key to the information in the state database :return: The issuer ID """ _state = self.get_state(key) if not _state: raise KeyError(key) return _state['iss']
[ "def", "get_iss", "(", "self", ",", "key", ")", ":", "_state", "=", "self", ".", "get_state", "(", "key", ")", "if", "not", "_state", ":", "raise", "KeyError", "(", "key", ")", "return", "_state", "[", "'iss'", "]" ]
Get the Issuer ID :param key: Key to the information in the state database :return: The issuer ID
[ "Get", "the", "Issuer", "ID" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L91-L101
train
openid/JWTConnect-Python-OidcService
src/oidcservice/state_interface.py
StateInterface.extend_request_args
def extend_request_args(self, args, item_cls, item_type, key, parameters, orig=False): """ Add a set of parameters and their value to a set of request arguments. :param args: A dictionary :param item_cls: The :py:class:`oidcmsg.message.Message` subclass ...
python
def extend_request_args(self, args, item_cls, item_type, key, parameters, orig=False): """ Add a set of parameters and their value to a set of request arguments. :param args: A dictionary :param item_cls: The :py:class:`oidcmsg.message.Message` subclass ...
[ "def", "extend_request_args", "(", "self", ",", "args", ",", "item_cls", ",", "item_type", ",", "key", ",", "parameters", ",", "orig", "=", "False", ")", ":", "try", ":", "item", "=", "self", ".", "get_item", "(", "item_cls", ",", "item_type", ",", "ke...
Add a set of parameters and their value to a set of request arguments. :param args: A dictionary :param item_cls: The :py:class:`oidcmsg.message.Message` subclass that describes the item :param item_type: The type of item, this is one of the parameter names in the :py:cl...
[ "Add", "a", "set", "of", "parameters", "and", "their", "value", "to", "a", "set", "of", "request", "arguments", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L120-L160
train
openid/JWTConnect-Python-OidcService
src/oidcservice/state_interface.py
StateInterface.get_state_by_X
def get_state_by_X(self, x, xtyp): """ Find the state value by providing the x value. Will raise an exception if the x value is absent from the state data base. :param x: The x value :return: The state value """ _state = self.state_db.get(KEY_PATTERN[xtyp...
python
def get_state_by_X(self, x, xtyp): """ Find the state value by providing the x value. Will raise an exception if the x value is absent from the state data base. :param x: The x value :return: The state value """ _state = self.state_db.get(KEY_PATTERN[xtyp...
[ "def", "get_state_by_X", "(", "self", ",", "x", ",", "xtyp", ")", ":", "_state", "=", "self", ".", "state_db", ".", "get", "(", "KEY_PATTERN", "[", "xtyp", "]", ".", "format", "(", "x", ")", ")", "if", "_state", ":", "return", "_state", "else", ":"...
Find the state value by providing the x value. Will raise an exception if the x value is absent from the state data base. :param x: The x value :return: The state value
[ "Find", "the", "state", "value", "by", "providing", "the", "x", "value", ".", "Will", "raise", "an", "exception", "if", "the", "x", "value", "is", "absent", "from", "the", "state", "data", "base", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/state_interface.py#L226-L239
train
openid/JWTConnect-Python-OidcService
src/oidcservice/service_context.py
ServiceContext.import_keys
def import_keys(self, keyspec): """ The client needs it's own set of keys. It can either dynamically create them or load them from local storage. This method can also fetch other entities keys provided the URL points to a JWKS. :param keyspec: """ for whe...
python
def import_keys(self, keyspec): """ The client needs it's own set of keys. It can either dynamically create them or load them from local storage. This method can also fetch other entities keys provided the URL points to a JWKS. :param keyspec: """ for whe...
[ "def", "import_keys", "(", "self", ",", "keyspec", ")", ":", "for", "where", ",", "spec", "in", "keyspec", ".", "items", "(", ")", ":", "if", "where", "==", "'file'", ":", "for", "typ", ",", "files", "in", "spec", ".", "items", "(", ")", ":", "if...
The client needs it's own set of keys. It can either dynamically create them or load them from local storage. This method can also fetch other entities keys provided the URL points to a JWKS. :param keyspec:
[ "The", "client", "needs", "it", "s", "own", "set", "of", "keys", ".", "It", "can", "either", "dynamically", "create", "them", "or", "load", "them", "from", "local", "storage", ".", "This", "method", "can", "also", "fetch", "other", "entities", "keys", "p...
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service_context.py#L200-L223
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
assertion_jwt
def assertion_jwt(client_id, keys, audience, algorithm, lifetime=600): """ Create a signed Json Web Token containing some information. :param client_id: The Client ID :param keys: Signing keys :param audience: Who is the receivers for this assertion :param algorithm: Signing algorithm :para...
python
def assertion_jwt(client_id, keys, audience, algorithm, lifetime=600): """ Create a signed Json Web Token containing some information. :param client_id: The Client ID :param keys: Signing keys :param audience: Who is the receivers for this assertion :param algorithm: Signing algorithm :para...
[ "def", "assertion_jwt", "(", "client_id", ",", "keys", ",", "audience", ",", "algorithm", ",", "lifetime", "=", "600", ")", ":", "_now", "=", "utc_time_sans_frac", "(", ")", "at", "=", "AuthnToken", "(", "iss", "=", "client_id", ",", "sub", "=", "client_...
Create a signed Json Web Token containing some information. :param client_id: The Client ID :param keys: Signing keys :param audience: Who is the receivers for this assertion :param algorithm: Signing algorithm :param lifetime: The lifetime of the signed Json Web Token :return: A Signed Json We...
[ "Create", "a", "signed", "Json", "Web", "Token", "containing", "some", "information", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L36-L53
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
valid_service_context
def valid_service_context(service_context, when=0): """ Check if the client_secret has expired :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :param when: A time stamp against which the expiration time is to be checked :return: True if the client_s...
python
def valid_service_context(service_context, when=0): """ Check if the client_secret has expired :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :param when: A time stamp against which the expiration time is to be checked :return: True if the client_s...
[ "def", "valid_service_context", "(", "service_context", ",", "when", "=", "0", ")", ":", "eta", "=", "getattr", "(", "service_context", ",", "'client_secret_expires_at'", ",", "0", ")", "now", "=", "when", "or", "utc_time_sans_frac", "(", ")", "if", "eta", "...
Check if the client_secret has expired :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :param when: A time stamp against which the expiration time is to be checked :return: True if the client_secret is still valid
[ "Check", "if", "the", "client_secret", "has", "expired" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L491-L504
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
ClientSecretBasic.construct
def construct(self, request, service=None, http_args=None, **kwargs): """ Construct a dictionary to be added to the HTTP request headers :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments ...
python
def construct(self, request, service=None, http_args=None, **kwargs): """ Construct a dictionary to be added to the HTTP request headers :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments ...
[ "def", "construct", "(", "self", ",", "request", ",", "service", "=", "None", ",", "http_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "http_args", "is", "None", ":", "http_args", "=", "{", "}", "if", "\"headers\"", "not", "in", "http_args",...
Construct a dictionary to be added to the HTTP request headers :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :return: dictionary of HTTP arguments
[ "Construct", "a", "dictionary", "to", "be", "added", "to", "the", "HTTP", "request", "headers" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L82-L151
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
BearerBody.construct
def construct(self, request, service=None, http_args=None, **kwargs): """ Will add a token to the request if not present :param request: The request :param service_context: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :p...
python
def construct(self, request, service=None, http_args=None, **kwargs): """ Will add a token to the request if not present :param request: The request :param service_context: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :p...
[ "def", "construct", "(", "self", ",", "request", ",", "service", "=", "None", ",", "http_args", "=", "None", ",", "**", "kwargs", ")", ":", "_acc_token", "=", "''", "for", "_token_type", "in", "[", "'access_token'", ",", "'refresh_token'", "]", ":", "_ac...
Will add a token to the request if not present :param request: The request :param service_context: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :param kwargs: extra keyword arguments :return: A possibly modified dictionary with ...
[ "Will", "add", "a", "token", "to", "the", "request", "if", "not", "present" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L264-L287
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
JWSAuthnMethod.choose_algorithm
def choose_algorithm(self, context, **kwargs): """ Pick signing algorithm :param context: Signing context :param kwargs: extra keyword arguments :return: Name of a signing algorithm """ try: algorithm = kwargs["algorithm"] except KeyError: ...
python
def choose_algorithm(self, context, **kwargs): """ Pick signing algorithm :param context: Signing context :param kwargs: extra keyword arguments :return: Name of a signing algorithm """ try: algorithm = kwargs["algorithm"] except KeyError: ...
[ "def", "choose_algorithm", "(", "self", ",", "context", ",", "**", "kwargs", ")", ":", "try", ":", "algorithm", "=", "kwargs", "[", "\"algorithm\"", "]", "except", "KeyError", ":", "algorithm", "=", "DEF_SIGN_ALG", "[", "context", "]", "if", "not", "algori...
Pick signing algorithm :param context: Signing context :param kwargs: extra keyword arguments :return: Name of a signing algorithm
[ "Pick", "signing", "algorithm" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L314-L329
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
JWSAuthnMethod.get_signing_key
def get_signing_key(self, algorithm, service_context): """ Pick signing key based on signing algorithm to be used :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :return: A key """ ...
python
def get_signing_key(self, algorithm, service_context): """ Pick signing key based on signing algorithm to be used :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :return: A key """ ...
[ "def", "get_signing_key", "(", "self", ",", "algorithm", ",", "service_context", ")", ":", "return", "service_context", ".", "keyjar", ".", "get_signing_key", "(", "alg2keytype", "(", "algorithm", ")", ",", "alg", "=", "algorithm", ")" ]
Pick signing key based on signing algorithm to be used :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :return: A key
[ "Pick", "signing", "key", "based", "on", "signing", "algorithm", "to", "be", "used" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L331-L341
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
JWSAuthnMethod.get_key_by_kid
def get_key_by_kid(self, kid, algorithm, service_context): """ Pick a key that matches a given key ID and signing algorithm. :param kid: Key ID :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instan...
python
def get_key_by_kid(self, kid, algorithm, service_context): """ Pick a key that matches a given key ID and signing algorithm. :param kid: Key ID :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instan...
[ "def", "get_key_by_kid", "(", "self", ",", "kid", ",", "algorithm", ",", "service_context", ")", ":", "_key", "=", "service_context", ".", "keyjar", ".", "get_key_by_kid", "(", "kid", ")", "if", "_key", ":", "ktype", "=", "alg2keytype", "(", "algorithm", "...
Pick a key that matches a given key ID and signing algorithm. :param kid: Key ID :param algorithm: Signing algorithm :param service_context: A :py:class:`oidcservice.service_context.ServiceContext` instance :return: A matching key
[ "Pick", "a", "key", "that", "matches", "a", "given", "key", "ID", "and", "signing", "algorithm", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L343-L361
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
JWSAuthnMethod.construct
def construct(self, request, service=None, http_args=None, **kwargs): """ Constructs a client assertion and signs it with a key. The request is modified as a side effect. :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :para...
python
def construct(self, request, service=None, http_args=None, **kwargs): """ Constructs a client assertion and signs it with a key. The request is modified as a side effect. :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :para...
[ "def", "construct", "(", "self", ",", "request", ",", "service", "=", "None", ",", "http_args", "=", "None", ",", "**", "kwargs", ")", ":", "if", "'client_assertion'", "in", "kwargs", ":", "request", "[", "\"client_assertion\"", "]", "=", "kwargs", "[", ...
Constructs a client assertion and signs it with a key. The request is modified as a side effect. :param request: The request :param service: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :param kwargs: Extra arguments :return: Constr...
[ "Constructs", "a", "client", "assertion", "and", "signs", "it", "with", "a", "key", ".", "The", "request", "is", "modified", "as", "a", "side", "effect", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L363-L445
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oauth2/provider_info_discovery.py
ProviderInfoDiscovery.get_endpoint
def get_endpoint(self): """ Find the issuer ID and from it construct the service endpoint :return: Service endpoint """ try: _iss = self.service_context.issuer except AttributeError: _iss = self.endpoint if _iss.endswith('/'): ...
python
def get_endpoint(self): """ Find the issuer ID and from it construct the service endpoint :return: Service endpoint """ try: _iss = self.service_context.issuer except AttributeError: _iss = self.endpoint if _iss.endswith('/'): ...
[ "def", "get_endpoint", "(", "self", ")", ":", "try", ":", "_iss", "=", "self", ".", "service_context", ".", "issuer", "except", "AttributeError", ":", "_iss", "=", "self", ".", "endpoint", "if", "_iss", ".", "endswith", "(", "'/'", ")", ":", "return", ...
Find the issuer ID and from it construct the service endpoint :return: Service endpoint
[ "Find", "the", "issuer", "ID", "and", "from", "it", "construct", "the", "service", "endpoint" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oauth2/provider_info_discovery.py#L28-L42
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oauth2/provider_info_discovery.py
ProviderInfoDiscovery._update_service_context
def _update_service_context(self, resp, **kwargs): """ Deal with Provider Config Response. Based on the provider info response a set of parameters in different places needs to be set. :param resp: The provider info response :param service_context: Information collected/used by s...
python
def _update_service_context(self, resp, **kwargs): """ Deal with Provider Config Response. Based on the provider info response a set of parameters in different places needs to be set. :param resp: The provider info response :param service_context: Information collected/used by s...
[ "def", "_update_service_context", "(", "self", ",", "resp", ",", "**", "kwargs", ")", ":", "issuer", "=", "self", ".", "service_context", ".", "issuer", "if", "\"issuer\"", "in", "resp", ":", "_pcr_issuer", "=", "resp", "[", "\"issuer\"", "]", "if", "resp"...
Deal with Provider Config Response. Based on the provider info response a set of parameters in different places needs to be set. :param resp: The provider info response :param service_context: Information collected/used by services
[ "Deal", "with", "Provider", "Config", "Response", ".", "Based", "on", "the", "provider", "info", "response", "a", "set", "of", "parameters", "in", "different", "places", "needs", "to", "be", "set", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oauth2/provider_info_discovery.py#L54-L129
train
openid/JWTConnect-Python-OidcService
src/oidcservice/util.py
get_http_url
def get_http_url(url, req, method='GET'): """ Add a query part representing the request to a url that may already contain a query part. Only done if the HTTP method used is 'GET' or 'DELETE'. :param url: The URL :param req: The request as a :py:class:`oidcmsg.message.Message` instance :param me...
python
def get_http_url(url, req, method='GET'): """ Add a query part representing the request to a url that may already contain a query part. Only done if the HTTP method used is 'GET' or 'DELETE'. :param url: The URL :param req: The request as a :py:class:`oidcmsg.message.Message` instance :param me...
[ "def", "get_http_url", "(", "url", ",", "req", ",", "method", "=", "'GET'", ")", ":", "if", "method", "in", "[", "\"GET\"", ",", "\"DELETE\"", "]", ":", "if", "req", ".", "keys", "(", ")", ":", "_req", "=", "req", ".", "copy", "(", ")", "comp", ...
Add a query part representing the request to a url that may already contain a query part. Only done if the HTTP method used is 'GET' or 'DELETE'. :param url: The URL :param req: The request as a :py:class:`oidcmsg.message.Message` instance :param method: The HTTP method :return: A possibly modified...
[ "Add", "a", "query", "part", "representing", "the", "request", "to", "a", "url", "that", "may", "already", "contain", "a", "query", "part", ".", "Only", "done", "if", "the", "HTTP", "method", "used", "is", "GET", "or", "DELETE", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/util.py#L19-L42
train
openid/JWTConnect-Python-OidcService
src/oidcservice/util.py
get_http_body
def get_http_body(req, content_type=URL_ENCODED): """ Get the message into the format that should be places in the body part of a HTTP request. :param req: The service request as a :py:class:`oidcmsg.message.Message` instance :param content_type: The format of the body part. :return: T...
python
def get_http_body(req, content_type=URL_ENCODED): """ Get the message into the format that should be places in the body part of a HTTP request. :param req: The service request as a :py:class:`oidcmsg.message.Message` instance :param content_type: The format of the body part. :return: T...
[ "def", "get_http_body", "(", "req", ",", "content_type", "=", "URL_ENCODED", ")", ":", "if", "URL_ENCODED", "in", "content_type", ":", "return", "req", ".", "to_urlencoded", "(", ")", "elif", "JSON_ENCODED", "in", "content_type", ":", "return", "req", ".", "...
Get the message into the format that should be places in the body part of a HTTP request. :param req: The service request as a :py:class:`oidcmsg.message.Message` instance :param content_type: The format of the body part. :return: The correctly formatet service request.
[ "Get", "the", "message", "into", "the", "format", "that", "should", "be", "places", "in", "the", "body", "part", "of", "a", "HTTP", "request", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/util.py#L45-L63
train
openid/JWTConnect-Python-OidcService
src/oidcservice/util.py
importer
def importer(name): """Import by name""" c1, c2 = modsplit(name) module = importlib.import_module(c1) return getattr(module, c2)
python
def importer(name): """Import by name""" c1, c2 = modsplit(name) module = importlib.import_module(c1) return getattr(module, c2)
[ "def", "importer", "(", "name", ")", ":", "c1", ",", "c2", "=", "modsplit", "(", "name", ")", "module", "=", "importlib", ".", "import_module", "(", "c1", ")", "return", "getattr", "(", "module", ",", "c2", ")" ]
Import by name
[ "Import", "by", "name" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/util.py#L86-L90
train
openid/JWTConnect-Python-OidcService
src/oidcservice/__init__.py
rndstr
def rndstr(size=16): """ Returns a string of random ascii characters or digits :param size: The length of the string :return: string """ _basech = string.ascii_letters + string.digits return "".join([rnd.choice(_basech) for _ in range(size)])
python
def rndstr(size=16): """ Returns a string of random ascii characters or digits :param size: The length of the string :return: string """ _basech = string.ascii_letters + string.digits return "".join([rnd.choice(_basech) for _ in range(size)])
[ "def", "rndstr", "(", "size", "=", "16", ")", ":", "_basech", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "return", "\"\"", ".", "join", "(", "[", "rnd", ".", "choice", "(", "_basech", ")", "for", "_", "in", "range", "(", "si...
Returns a string of random ascii characters or digits :param size: The length of the string :return: string
[ "Returns", "a", "string", "of", "random", "ascii", "characters", "or", "digits" ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/__init__.py#L35-L43
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oidc/provider_info_discovery.py
add_redirect_uris
def add_redirect_uris(request_args, service=None, **kwargs): """ Add redirect_uris to the request arguments. :param request_args: Incomming request arguments :param service: A link to the service :param kwargs: Possible extra keyword arguments :return: A possibly augmented set of request argume...
python
def add_redirect_uris(request_args, service=None, **kwargs): """ Add redirect_uris to the request arguments. :param request_args: Incomming request arguments :param service: A link to the service :param kwargs: Possible extra keyword arguments :return: A possibly augmented set of request argume...
[ "def", "add_redirect_uris", "(", "request_args", ",", "service", "=", "None", ",", "**", "kwargs", ")", ":", "_context", "=", "service", ".", "service_context", "if", "\"redirect_uris\"", "not", "in", "request_args", ":", "try", ":", "_cbs", "=", "_context", ...
Add redirect_uris to the request arguments. :param request_args: Incomming request arguments :param service: A link to the service :param kwargs: Possible extra keyword arguments :return: A possibly augmented set of request arguments.
[ "Add", "redirect_uris", "to", "the", "request", "arguments", "." ]
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oidc/provider_info_discovery.py#L48-L70
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oidc/provider_info_discovery.py
ProviderInfoDiscovery.match_preferences
def match_preferences(self, pcr=None, issuer=None): """ Match the clients preferences against what the provider can do. This is to prepare for later client registration and or what functionality the client actually will use. In the client configuration the client preferences are ...
python
def match_preferences(self, pcr=None, issuer=None): """ Match the clients preferences against what the provider can do. This is to prepare for later client registration and or what functionality the client actually will use. In the client configuration the client preferences are ...
[ "def", "match_preferences", "(", "self", ",", "pcr", "=", "None", ",", "issuer", "=", "None", ")", ":", "if", "not", "pcr", ":", "pcr", "=", "self", ".", "service_context", ".", "provider_info", "regreq", "=", "oidc", ".", "RegistrationRequest", "for", "...
Match the clients preferences against what the provider can do. This is to prepare for later client registration and or what functionality the client actually will use. In the client configuration the client preferences are expressed. These are then compared with the Provider Configurati...
[ "Match", "the", "clients", "preferences", "against", "what", "the", "provider", "can", "do", ".", "This", "is", "to", "prepare", "for", "later", "client", "registration", "and", "or", "what", "functionality", "the", "client", "actually", "will", "use", ".", ...
759ab7adef30a7e3b9d75475e2971433b9613788
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oidc/provider_info_discovery.py#L93-L178
train
libindic/soundex
libindic/soundex/__init__.py
Soundex.soundexCode
def soundexCode(self, char): '''Return the soundex code for given character :param char: Character whose soundex code is needed :return: Returns soundex code if character is found in charmap else returns 0 ''' lang = get_languag...
python
def soundexCode(self, char): '''Return the soundex code for given character :param char: Character whose soundex code is needed :return: Returns soundex code if character is found in charmap else returns 0 ''' lang = get_languag...
[ "def", "soundexCode", "(", "self", ",", "char", ")", ":", "lang", "=", "get_language", "(", "char", ")", "try", ":", "if", "lang", "==", "\"en_US\"", ":", "return", "_soundex_map", "[", "\"soundex_en\"", "]", "[", "charmap", "[", "lang", "]", ".", "ind...
Return the soundex code for given character :param char: Character whose soundex code is needed :return: Returns soundex code if character is found in charmap else returns 0
[ "Return", "the", "soundex", "code", "for", "given", "character" ]
5d41126b9a017ecee0ae71902388c7bf47722907
https://github.com/libindic/soundex/blob/5d41126b9a017ecee0ae71902388c7bf47722907/libindic/soundex/__init__.py#L45-L65
train
libindic/soundex
libindic/soundex/__init__.py
Soundex.soundex
def soundex(self, name, length=8): '''Calculate soundex of given string This function calculates soundex for Indian language string as well as English string. This function is exposed as service method for JSONRPC in SILPA framework. :param name: String ...
python
def soundex(self, name, length=8): '''Calculate soundex of given string This function calculates soundex for Indian language string as well as English string. This function is exposed as service method for JSONRPC in SILPA framework. :param name: String ...
[ "def", "soundex", "(", "self", ",", "name", ",", "length", "=", "8", ")", ":", "sndx", "=", "[", "]", "fc", "=", "name", "[", "0", "]", "for", "c", "in", "name", "[", "1", ":", "]", ".", "lower", "(", ")", ":", "d", "=", "str", "(", "self...
Calculate soundex of given string This function calculates soundex for Indian language string as well as English string. This function is exposed as service method for JSONRPC in SILPA framework. :param name: String whose Soundex value to be calculated ...
[ "Calculate", "soundex", "of", "given", "string" ]
5d41126b9a017ecee0ae71902388c7bf47722907
https://github.com/libindic/soundex/blob/5d41126b9a017ecee0ae71902388c7bf47722907/libindic/soundex/__init__.py#L68-L111
train
libindic/soundex
libindic/soundex/__init__.py
Soundex.compare
def compare(self, string1, string2): '''Compare soundex of given strings This function checks if 2 given strings are phonetically sounds same by doing soundex code comparison :param string1: First string for comparison :param string2: Second string for comparison ...
python
def compare(self, string1, string2): '''Compare soundex of given strings This function checks if 2 given strings are phonetically sounds same by doing soundex code comparison :param string1: First string for comparison :param string2: Second string for comparison ...
[ "def", "compare", "(", "self", ",", "string1", ",", "string2", ")", ":", "if", "string1", "==", "string2", ":", "return", "0", "string1_lang", "=", "get_language", "(", "string1", "[", "0", "]", ")", "string2_lang", "=", "get_language", "(", "string2", "...
Compare soundex of given strings This function checks if 2 given strings are phonetically sounds same by doing soundex code comparison :param string1: First string for comparison :param string2: Second string for comparison :return: Returns 0 if both strings are...
[ "Compare", "soundex", "of", "given", "strings" ]
5d41126b9a017ecee0ae71902388c7bf47722907
https://github.com/libindic/soundex/blob/5d41126b9a017ecee0ae71902388c7bf47722907/libindic/soundex/__init__.py#L114-L155
train
skoczen/django-seo-js
django_seo_js/backends/prerender.py
PrerenderIO.get_response_for_url
def get_response_for_url(self, url): """ Accepts a fully-qualified url. Returns an HttpResponse, passing through all headers and the status code. """ if not url or "//" not in url: raise ValueError("Missing or invalid url: %s" % url) render_url = self.BASE_U...
python
def get_response_for_url(self, url): """ Accepts a fully-qualified url. Returns an HttpResponse, passing through all headers and the status code. """ if not url or "//" not in url: raise ValueError("Missing or invalid url: %s" % url) render_url = self.BASE_U...
[ "def", "get_response_for_url", "(", "self", ",", "url", ")", ":", "if", "not", "url", "or", "\"//\"", "not", "in", "url", ":", "raise", "ValueError", "(", "\"Missing or invalid url: %s\"", "%", "url", ")", "render_url", "=", "self", ".", "BASE_URL", "+", "...
Accepts a fully-qualified url. Returns an HttpResponse, passing through all headers and the status code.
[ "Accepts", "a", "fully", "-", "qualified", "url", ".", "Returns", "an", "HttpResponse", "passing", "through", "all", "headers", "and", "the", "status", "code", "." ]
7613a168deec9e7f11e5d845176d85a3e2c5cc55
https://github.com/skoczen/django-seo-js/blob/7613a168deec9e7f11e5d845176d85a3e2c5cc55/django_seo_js/backends/prerender.py#L19-L35
train
skoczen/django-seo-js
django_seo_js/backends/prerender.py
PrerenderIO.update_url
def update_url(self, url=None, regex=None): """ Accepts a fully-qualified url, or regex. Returns True if successful, False if not successful. """ if not url and not regex: raise ValueError("Neither a url or regex was provided to update_url.") headers = { ...
python
def update_url(self, url=None, regex=None): """ Accepts a fully-qualified url, or regex. Returns True if successful, False if not successful. """ if not url and not regex: raise ValueError("Neither a url or regex was provided to update_url.") headers = { ...
[ "def", "update_url", "(", "self", ",", "url", "=", "None", ",", "regex", "=", "None", ")", ":", "if", "not", "url", "and", "not", "regex", ":", "raise", "ValueError", "(", "\"Neither a url or regex was provided to update_url.\"", ")", "headers", "=", "{", "'...
Accepts a fully-qualified url, or regex. Returns True if successful, False if not successful.
[ "Accepts", "a", "fully", "-", "qualified", "url", "or", "regex", ".", "Returns", "True", "if", "successful", "False", "if", "not", "successful", "." ]
7613a168deec9e7f11e5d845176d85a3e2c5cc55
https://github.com/skoczen/django-seo-js/blob/7613a168deec9e7f11e5d845176d85a3e2c5cc55/django_seo_js/backends/prerender.py#L37-L59
train
skoczen/django-seo-js
django_seo_js/backends/prerender.py
PrerenderHosted.update_url
def update_url(self, url=None): """ Accepts a fully-qualified url. Returns True if successful, False if not successful. """ if not url: raise ValueError("Neither a url or regex was provided to update_url.") post_url = "%s%s" % (self.BASE_URL, url) r = ...
python
def update_url(self, url=None): """ Accepts a fully-qualified url. Returns True if successful, False if not successful. """ if not url: raise ValueError("Neither a url or regex was provided to update_url.") post_url = "%s%s" % (self.BASE_URL, url) r = ...
[ "def", "update_url", "(", "self", ",", "url", "=", "None", ")", ":", "if", "not", "url", ":", "raise", "ValueError", "(", "\"Neither a url or regex was provided to update_url.\"", ")", "post_url", "=", "\"%s%s\"", "%", "(", "self", ".", "BASE_URL", ",", "url",...
Accepts a fully-qualified url. Returns True if successful, False if not successful.
[ "Accepts", "a", "fully", "-", "qualified", "url", ".", "Returns", "True", "if", "successful", "False", "if", "not", "successful", "." ]
7613a168deec9e7f11e5d845176d85a3e2c5cc55
https://github.com/skoczen/django-seo-js/blob/7613a168deec9e7f11e5d845176d85a3e2c5cc55/django_seo_js/backends/prerender.py#L80-L89
train
lock8/django-rest-framework-jwt-refresh-token
refreshtoken/serializers.py
RefreshTokenSerializer.create
def create(self, validated_data): """Override ``create`` to provide a user via request.user by default. This is required since the read_only ``user`` field is not included by default anymore since https://github.com/encode/django-rest-framework/pull/5886. """ if 'user' n...
python
def create(self, validated_data): """Override ``create`` to provide a user via request.user by default. This is required since the read_only ``user`` field is not included by default anymore since https://github.com/encode/django-rest-framework/pull/5886. """ if 'user' n...
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "if", "'user'", "not", "in", "validated_data", ":", "validated_data", "[", "'user'", "]", "=", "self", ".", "context", "[", "'request'", "]", ".", "user", "return", "super", "(", "RefreshTokenS...
Override ``create`` to provide a user via request.user by default. This is required since the read_only ``user`` field is not included by default anymore since https://github.com/encode/django-rest-framework/pull/5886.
[ "Override", "create", "to", "provide", "a", "user", "via", "request", ".", "user", "by", "default", "." ]
9d46478ac1536982e4dc9dec7599fbce30fef91a
https://github.com/lock8/django-rest-framework-jwt-refresh-token/blob/9d46478ac1536982e4dc9dec7599fbce30fef91a/refreshtoken/serializers.py#L22-L31
train
lock8/django-rest-framework-jwt-refresh-token
refreshtoken/permissions.py
IsOwnerOrAdmin.has_object_permission
def has_object_permission(self, request, view, obj): """ Allow staff or superusers, and the owner of the object itself. """ user = request.user if not user.is_authenticated: return False elif user.is_staff or user.is_superuser: return True ...
python
def has_object_permission(self, request, view, obj): """ Allow staff or superusers, and the owner of the object itself. """ user = request.user if not user.is_authenticated: return False elif user.is_staff or user.is_superuser: return True ...
[ "def", "has_object_permission", "(", "self", ",", "request", ",", "view", ",", "obj", ")", ":", "user", "=", "request", ".", "user", "if", "not", "user", ".", "is_authenticated", ":", "return", "False", "elif", "user", ".", "is_staff", "or", "user", ".",...
Allow staff or superusers, and the owner of the object itself.
[ "Allow", "staff", "or", "superusers", "and", "the", "owner", "of", "the", "object", "itself", "." ]
9d46478ac1536982e4dc9dec7599fbce30fef91a
https://github.com/lock8/django-rest-framework-jwt-refresh-token/blob/9d46478ac1536982e4dc9dec7599fbce30fef91a/refreshtoken/permissions.py#L12-L21
train
Aula13/poloniex
poloniex/concurrency.py
Semaphore.clear
def clear(self): """Release the semaphore of all of its bounds, setting the internal counter back to its original bind limit. Notify an equivalent amount of threads that they can run.""" with self._cond: to_notify = self._initial - self._value self._value = self._...
python
def clear(self): """Release the semaphore of all of its bounds, setting the internal counter back to its original bind limit. Notify an equivalent amount of threads that they can run.""" with self._cond: to_notify = self._initial - self._value self._value = self._...
[ "def", "clear", "(", "self", ")", ":", "with", "self", ".", "_cond", ":", "to_notify", "=", "self", ".", "_initial", "-", "self", ".", "_value", "self", ".", "_value", "=", "self", ".", "_initial", "self", ".", "_cond", ".", "notify", "(", "to_notify...
Release the semaphore of all of its bounds, setting the internal counter back to its original bind limit. Notify an equivalent amount of threads that they can run.
[ "Release", "the", "semaphore", "of", "all", "of", "its", "bounds", "setting", "the", "internal", "counter", "back", "to", "its", "original", "bind", "limit", ".", "Notify", "an", "equivalent", "amount", "of", "threads", "that", "they", "can", "run", "." ]
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/concurrency.py#L96-L103
train
Aula13/poloniex
poloniex/poloniex.py
_api_wrapper
def _api_wrapper(fn): """API function decorator that performs rate limiting and error checking.""" def _convert(value): if isinstance(value, _datetime.date): return value.strftime('%s') return value @_six.wraps(fn) def _fn(self, command, **params): # sanitize the pa...
python
def _api_wrapper(fn): """API function decorator that performs rate limiting and error checking.""" def _convert(value): if isinstance(value, _datetime.date): return value.strftime('%s') return value @_six.wraps(fn) def _fn(self, command, **params): # sanitize the pa...
[ "def", "_api_wrapper", "(", "fn", ")", ":", "def", "_convert", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_datetime", ".", "date", ")", ":", "return", "value", ".", "strftime", "(", "'%s'", ")", "return", "value", "@", "_six", "....
API function decorator that performs rate limiting and error checking.
[ "API", "function", "decorator", "that", "performs", "rate", "limiting", "and", "error", "checking", "." ]
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L20-L55
train
Aula13/poloniex
poloniex/poloniex.py
PoloniexPublic.returnOrderBook
def returnOrderBook(self, currencyPair='all', depth='50'): """Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen. You may set currencyPair to "all" to get the order books of all market...
python
def returnOrderBook(self, currencyPair='all', depth='50'): """Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen. You may set currencyPair to "all" to get the order books of all market...
[ "def", "returnOrderBook", "(", "self", ",", "currencyPair", "=", "'all'", ",", "depth", "=", "'50'", ")", ":", "return", "self", ".", "_public", "(", "'returnOrderBook'", ",", "currencyPair", "=", "currencyPair", ",", "depth", "=", "depth", ")" ]
Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen. You may set currencyPair to "all" to get the order books of all markets.
[ "Returns", "the", "order", "book", "for", "a", "given", "market", "as", "well", "as", "a", "sequence", "number", "for", "use", "with", "the", "Push", "API", "and", "an", "indicator", "specifying", "whether", "the", "market", "is", "frozen", ".", "You", "...
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L95-L101
train
Aula13/poloniex
poloniex/poloniex.py
Poloniex.returnDepositsWithdrawals
def returnDepositsWithdrawals(self, start=0, end=2**32-1): """Returns your deposit and withdrawal history within a range, specified by the "start" and "end" POST parameters, both of which should be given as UNIX timestamps.""" return self._private('returnDepositsWithdrawals', start=start...
python
def returnDepositsWithdrawals(self, start=0, end=2**32-1): """Returns your deposit and withdrawal history within a range, specified by the "start" and "end" POST parameters, both of which should be given as UNIX timestamps.""" return self._private('returnDepositsWithdrawals', start=start...
[ "def", "returnDepositsWithdrawals", "(", "self", ",", "start", "=", "0", ",", "end", "=", "2", "**", "32", "-", "1", ")", ":", "return", "self", ".", "_private", "(", "'returnDepositsWithdrawals'", ",", "start", "=", "start", ",", "end", "=", "end", ")...
Returns your deposit and withdrawal history within a range, specified by the "start" and "end" POST parameters, both of which should be given as UNIX timestamps.
[ "Returns", "your", "deposit", "and", "withdrawal", "history", "within", "a", "range", "specified", "by", "the", "start", "and", "end", "POST", "parameters", "both", "of", "which", "should", "be", "given", "as", "UNIX", "timestamps", "." ]
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L203-L207
train
Aula13/poloniex
poloniex/poloniex.py
Poloniex.buy
def buy(self, currencyPair, rate, amount, fillOrKill=None, immediateOrCancel=None, postOnly=None): """Places a limit buy order in a given market. Required POST parameters are "currencyPair", "rate", and "amount". If successful, the method will return the order number. You may...
python
def buy(self, currencyPair, rate, amount, fillOrKill=None, immediateOrCancel=None, postOnly=None): """Places a limit buy order in a given market. Required POST parameters are "currencyPair", "rate", and "amount". If successful, the method will return the order number. You may...
[ "def", "buy", "(", "self", ",", "currencyPair", ",", "rate", ",", "amount", ",", "fillOrKill", "=", "None", ",", "immediateOrCancel", "=", "None", ",", "postOnly", "=", "None", ")", ":", "return", "self", ".", "_private", "(", "'buy'", ",", "currencyPair...
Places a limit buy order in a given market. Required POST parameters are "currencyPair", "rate", and "amount". If successful, the method will return the order number. You may optionally set "fillOrKill", "immediateOrCancel", "postOnly" to 1. A fill-or-kill order will either fill in its e...
[ "Places", "a", "limit", "buy", "order", "in", "a", "given", "market", ".", "Required", "POST", "parameters", "are", "currencyPair", "rate", "and", "amount", ".", "If", "successful", "the", "method", "will", "return", "the", "order", "number", ".", "You", "...
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L250-L266
train
Aula13/poloniex
poloniex/poloniex.py
Poloniex.moveOrder
def moveOrder(self, orderNumber, rate, amount=None, postOnly=None, immediateOrCancel=None): """Cancels an order and places a new one of the same type in a single atomic transaction, meaning either both operations will succeed or both will fail. Required POST parameters are "or...
python
def moveOrder(self, orderNumber, rate, amount=None, postOnly=None, immediateOrCancel=None): """Cancels an order and places a new one of the same type in a single atomic transaction, meaning either both operations will succeed or both will fail. Required POST parameters are "or...
[ "def", "moveOrder", "(", "self", ",", "orderNumber", ",", "rate", ",", "amount", "=", "None", ",", "postOnly", "=", "None", ",", "immediateOrCancel", "=", "None", ")", ":", "return", "self", ".", "_private", "(", "'moveOrder'", ",", "orderNumber", "=", "...
Cancels an order and places a new one of the same type in a single atomic transaction, meaning either both operations will succeed or both will fail. Required POST parameters are "orderNumber" and "rate"; you may optionally specify "amount" if you wish to change the amount of the new ...
[ "Cancels", "an", "order", "and", "places", "a", "new", "one", "of", "the", "same", "type", "in", "a", "single", "atomic", "transaction", "meaning", "either", "both", "operations", "will", "succeed", "or", "both", "will", "fail", ".", "Required", "POST", "p...
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L282-L292
train
Aula13/poloniex
poloniex/poloniex.py
Poloniex.withdraw
def withdraw(self, currency, amount, address, paymentId=None): """Immediately places a withdrawal for a given currency, with no email confirmation. In order to use this method, the withdrawal privilege must be enabled for your API key. Required POST parameters are "currency", "amount", a...
python
def withdraw(self, currency, amount, address, paymentId=None): """Immediately places a withdrawal for a given currency, with no email confirmation. In order to use this method, the withdrawal privilege must be enabled for your API key. Required POST parameters are "currency", "amount", a...
[ "def", "withdraw", "(", "self", ",", "currency", ",", "amount", ",", "address", ",", "paymentId", "=", "None", ")", ":", "return", "self", ".", "_private", "(", "'withdraw'", ",", "currency", "=", "currency", ",", "amount", "=", "amount", ",", "address",...
Immediately places a withdrawal for a given currency, with no email confirmation. In order to use this method, the withdrawal privilege must be enabled for your API key. Required POST parameters are "currency", "amount", and "address". For XMR withdrawals, you may optionally specify "pay...
[ "Immediately", "places", "a", "withdrawal", "for", "a", "given", "currency", "with", "no", "email", "confirmation", ".", "In", "order", "to", "use", "this", "method", "the", "withdrawal", "privilege", "must", "be", "enabled", "for", "your", "API", "key", "."...
a5bfc91e766e220bf77f5e3a1b131f095913e714
https://github.com/Aula13/poloniex/blob/a5bfc91e766e220bf77f5e3a1b131f095913e714/poloniex/poloniex.py#L294-L301
train