repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
sonyxperiadev/pygerrit
pygerrit/stream.py
GerritStream.run
def run(self): """ Listen to the stream and send events to the client. """ channel = self._ssh_client.get_transport().open_session() self._channel = channel channel.exec_command("gerrit stream-events") stdout = channel.makefile() stderr = channel.makefile_stderr() ...
python
def run(self): """ Listen to the stream and send events to the client. """ channel = self._ssh_client.get_transport().open_session() self._channel = channel channel.exec_command("gerrit stream-events") stdout = channel.makefile() stderr = channel.makefile_stderr() ...
[ "def", "run", "(", "self", ")", ":", "channel", "=", "self", ".", "_ssh_client", ".", "get_transport", "(", ")", ".", "open_session", "(", ")", "self", ".", "_channel", "=", "channel", "channel", ".", "exec_command", "(", "\"gerrit stream-events\"", ")", "...
Listen to the stream and send events to the client.
[ "Listen", "to", "the", "stream", "and", "send", "events", "to", "the", "client", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/stream.py#L56-L77
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.run_command
def run_command(self, command): """ Run a command. :arg str command: The command to run. :Return: The result as a string. :Raises: `ValueError` if `command` is not a string. """ if not isinstance(command, basestring): raise ValueError("command must be a st...
python
def run_command(self, command): """ Run a command. :arg str command: The command to run. :Return: The result as a string. :Raises: `ValueError` if `command` is not a string. """ if not isinstance(command, basestring): raise ValueError("command must be a st...
[ "def", "run_command", "(", "self", ",", "command", ")", ":", "if", "not", "isinstance", "(", "command", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"command must be a string\"", ")", "return", "self", ".", "_ssh_client", ".", "run_gerrit_command",...
Run a command. :arg str command: The command to run. :Return: The result as a string. :Raises: `ValueError` if `command` is not a string.
[ "Run", "a", "command", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L79-L91
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.query
def query(self, term): """ Run a query. :arg str term: The query term to run. :Returns: A list of results as :class:`pygerrit.models.Change` objects. :Raises: `ValueError` if `term` is not a string. """ results = [] command = ["query", "--current-patch-set", "...
python
def query(self, term): """ Run a query. :arg str term: The query term to run. :Returns: A list of results as :class:`pygerrit.models.Change` objects. :Raises: `ValueError` if `term` is not a string. """ results = [] command = ["query", "--current-patch-set", "...
[ "def", "query", "(", "self", ",", "term", ")", ":", "results", "=", "[", "]", "command", "=", "[", "\"query\"", ",", "\"--current-patch-set\"", ",", "\"--all-approvals\"", ",", "\"--format JSON\"", ",", "\"--commit-message\"", "]", "if", "not", "isinstance", "...
Run a query. :arg str term: The query term to run. :Returns: A list of results as :class:`pygerrit.models.Change` objects. :Raises: `ValueError` if `term` is not a string.
[ "Run", "a", "query", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L93-L129
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.start_event_stream
def start_event_stream(self): """ Start streaming events from `gerrit stream-events`. """ if not self._stream: self._stream = GerritStream(self, ssh_client=self._ssh_client) self._stream.start()
python
def start_event_stream(self): """ Start streaming events from `gerrit stream-events`. """ if not self._stream: self._stream = GerritStream(self, ssh_client=self._ssh_client) self._stream.start()
[ "def", "start_event_stream", "(", "self", ")", ":", "if", "not", "self", ".", "_stream", ":", "self", ".", "_stream", "=", "GerritStream", "(", "self", ",", "ssh_client", "=", "self", ".", "_ssh_client", ")", "self", ".", "_stream", ".", "start", "(", ...
Start streaming events from `gerrit stream-events`.
[ "Start", "streaming", "events", "from", "gerrit", "stream", "-", "events", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L131-L135
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.stop_event_stream
def stop_event_stream(self): """ Stop streaming events from `gerrit stream-events`.""" if self._stream: self._stream.stop() self._stream.join() self._stream = None with self._events.mutex: self._events.queue.clear()
python
def stop_event_stream(self): """ Stop streaming events from `gerrit stream-events`.""" if self._stream: self._stream.stop() self._stream.join() self._stream = None with self._events.mutex: self._events.queue.clear()
[ "def", "stop_event_stream", "(", "self", ")", ":", "if", "self", ".", "_stream", ":", "self", ".", "_stream", ".", "stop", "(", ")", "self", ".", "_stream", ".", "join", "(", ")", "self", ".", "_stream", "=", "None", "with", "self", ".", "_events", ...
Stop streaming events from `gerrit stream-events`.
[ "Stop", "streaming", "events", "from", "gerrit", "stream", "-", "events", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L137-L144
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.get_event
def get_event(self, block=True, timeout=None): """ Get the next event from the queue. :arg boolean block: Set to True to block if no event is available. :arg seconds timeout: Timeout to wait if no event is available. :Returns: The next event as a :class:`pygerrit.events.GerritEvent` ...
python
def get_event(self, block=True, timeout=None): """ Get the next event from the queue. :arg boolean block: Set to True to block if no event is available. :arg seconds timeout: Timeout to wait if no event is available. :Returns: The next event as a :class:`pygerrit.events.GerritEvent` ...
[ "def", "get_event", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "try", ":", "return", "self", ".", "_events", ".", "get", "(", "block", ",", "timeout", ")", "except", "Empty", ":", "return", "None" ]
Get the next event from the queue. :arg boolean block: Set to True to block if no event is available. :arg seconds timeout: Timeout to wait if no event is available. :Returns: The next event as a :class:`pygerrit.events.GerritEvent` instance, or `None` if: - `block` is...
[ "Get", "the", "next", "event", "from", "the", "queue", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L146-L162
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.put_event
def put_event(self, data): """ Create event from `data` and add it to the queue. :arg json data: The JSON data from which to create the event. :Raises: :class:`pygerrit.error.GerritError` if the queue is full, or the factory could not create the event. """ try: ...
python
def put_event(self, data): """ Create event from `data` and add it to the queue. :arg json data: The JSON data from which to create the event. :Raises: :class:`pygerrit.error.GerritError` if the queue is full, or the factory could not create the event. """ try: ...
[ "def", "put_event", "(", "self", ",", "data", ")", ":", "try", ":", "event", "=", "self", ".", "_factory", ".", "create", "(", "data", ")", "self", ".", "_events", ".", "put", "(", "event", ")", "except", "Full", ":", "raise", "GerritError", "(", "...
Create event from `data` and add it to the queue. :arg json data: The JSON data from which to create the event. :Raises: :class:`pygerrit.error.GerritError` if the queue is full, or the factory could not create the event.
[ "Create", "event", "from", "data", "and", "add", "it", "to", "the", "queue", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L164-L177
sonyxperiadev/pygerrit
pygerrit/ssh.py
_extract_version
def _extract_version(version_string, pattern): """ Extract the version from `version_string` using `pattern`. Return the version as a string, with leading/trailing whitespace stripped. """ if version_string: match = pattern.match(version_string.strip()) if match: return...
python
def _extract_version(version_string, pattern): """ Extract the version from `version_string` using `pattern`. Return the version as a string, with leading/trailing whitespace stripped. """ if version_string: match = pattern.match(version_string.strip()) if match: return...
[ "def", "_extract_version", "(", "version_string", ",", "pattern", ")", ":", "if", "version_string", ":", "match", "=", "pattern", ".", "match", "(", "version_string", ".", "strip", "(", ")", ")", "if", "match", ":", "return", "match", ".", "group", "(", ...
Extract the version from `version_string` using `pattern`. Return the version as a string, with leading/trailing whitespace stripped.
[ "Extract", "the", "version", "from", "version_string", "using", "pattern", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L36-L47
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._configure
def _configure(self): """ Configure the ssh parameters from the config file. """ configfile = expanduser("~/.ssh/config") if not isfile(configfile): raise GerritError("ssh config file '%s' does not exist" % configfile) config = SSHConfig() ...
python
def _configure(self): """ Configure the ssh parameters from the config file. """ configfile = expanduser("~/.ssh/config") if not isfile(configfile): raise GerritError("ssh config file '%s' does not exist" % configfile) config = SSHConfig() ...
[ "def", "_configure", "(", "self", ")", ":", "configfile", "=", "expanduser", "(", "\"~/.ssh/config\"", ")", "if", "not", "isfile", "(", "configfile", ")", ":", "raise", "GerritError", "(", "\"ssh config file '%s' does not exist\"", "%", "configfile", ")", "config"...
Configure the ssh parameters from the config file.
[ "Configure", "the", "ssh", "parameters", "from", "the", "config", "file", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L84-L111
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._do_connect
def _do_connect(self): """ Connect to the remote. """ self.load_system_host_keys() if self.username is None or self.port is None: self._configure() try: self.connect(hostname=self.hostname, port=self.port, username...
python
def _do_connect(self): """ Connect to the remote. """ self.load_system_host_keys() if self.username is None or self.port is None: self._configure() try: self.connect(hostname=self.hostname, port=self.port, username...
[ "def", "_do_connect", "(", "self", ")", ":", "self", ".", "load_system_host_keys", "(", ")", "if", "self", ".", "username", "is", "None", "or", "self", ".", "port", "is", "None", ":", "self", ".", "_configure", "(", ")", "try", ":", "self", ".", "con...
Connect to the remote.
[ "Connect", "to", "the", "remote", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L113-L132
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._connect
def _connect(self): """ Connect to the remote if not already connected. """ if not self.connected.is_set(): try: self.lock.acquire() # Another thread may have connected while we were # waiting to acquire the lock if not self.con...
python
def _connect(self): """ Connect to the remote if not already connected. """ if not self.connected.is_set(): try: self.lock.acquire() # Another thread may have connected while we were # waiting to acquire the lock if not self.con...
[ "def", "_connect", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ".", "is_set", "(", ")", ":", "try", ":", "self", ".", "lock", ".", "acquire", "(", ")", "# Another thread may have connected while we were", "# waiting to acquire the lock", "if", ...
Connect to the remote if not already connected.
[ "Connect", "to", "the", "remote", "if", "not", "already", "connected", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L134-L149
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient.get_remote_version
def get_remote_version(self): """ Return the version of the remote Gerrit server. """ if self.remote_version is None: result = self.run_gerrit_command("version") version_string = result.stdout.read() pattern = re.compile(r'^gerrit version (.*)$') self.remo...
python
def get_remote_version(self): """ Return the version of the remote Gerrit server. """ if self.remote_version is None: result = self.run_gerrit_command("version") version_string = result.stdout.read() pattern = re.compile(r'^gerrit version (.*)$') self.remo...
[ "def", "get_remote_version", "(", "self", ")", ":", "if", "self", ".", "remote_version", "is", "None", ":", "result", "=", "self", ".", "run_gerrit_command", "(", "\"version\"", ")", "version_string", "=", "result", ".", "stdout", ".", "read", "(", ")", "p...
Return the version of the remote Gerrit server.
[ "Return", "the", "version", "of", "the", "remote", "Gerrit", "server", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L151-L158
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient.run_gerrit_command
def run_gerrit_command(self, command): """ Run the given command. Make sure we're connected to the remote server, and run `command`. Return the results as a `GerritSSHCommandResult`. Raise `ValueError` if `command` is not a string, or `GerritError` if command execution fails. ...
python
def run_gerrit_command(self, command): """ Run the given command. Make sure we're connected to the remote server, and run `command`. Return the results as a `GerritSSHCommandResult`. Raise `ValueError` if `command` is not a string, or `GerritError` if command execution fails. ...
[ "def", "run_gerrit_command", "(", "self", ",", "command", ")", ":", "if", "not", "isinstance", "(", "command", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"command must be a string\"", ")", "gerrit_command", "=", "\"gerrit \"", "+", "command", "# ...
Run the given command. Make sure we're connected to the remote server, and run `command`. Return the results as a `GerritSSHCommandResult`. Raise `ValueError` if `command` is not a string, or `GerritError` if command execution fails.
[ "Run", "the", "given", "command", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L165-L194
sonyxperiadev/pygerrit
pygerrit/events.py
GerritEventFactory.register
def register(cls, name): """ Decorator to register the event identified by `name`. Return the decorated class. Raise GerritError if the event is already registered. """ def decorate(klazz): """ Decorator. """ if name in cls._events: rai...
python
def register(cls, name): """ Decorator to register the event identified by `name`. Return the decorated class. Raise GerritError if the event is already registered. """ def decorate(klazz): """ Decorator. """ if name in cls._events: rai...
[ "def", "register", "(", "cls", ",", "name", ")", ":", "def", "decorate", "(", "klazz", ")", ":", "\"\"\" Decorator. \"\"\"", "if", "name", "in", "cls", ".", "_events", ":", "raise", "GerritError", "(", "\"Duplicate event: %s\"", "%", "name", ")", "cls", "....
Decorator to register the event identified by `name`. Return the decorated class. Raise GerritError if the event is already registered.
[ "Decorator", "to", "register", "the", "event", "identified", "by", "name", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L40-L56
sonyxperiadev/pygerrit
pygerrit/events.py
GerritEventFactory.create
def create(cls, data): """ Create a new event instance. Return an instance of the `GerritEvent` subclass after converting `data` to json. Raise GerritError if json parsed from `data` does not contain a `type` key. """ try: json_data = json.loads(dat...
python
def create(cls, data): """ Create a new event instance. Return an instance of the `GerritEvent` subclass after converting `data` to json. Raise GerritError if json parsed from `data` does not contain a `type` key. """ try: json_data = json.loads(dat...
[ "def", "create", "(", "cls", ",", "data", ")", ":", "try", ":", "json_data", "=", "json", ".", "loads", "(", "data", ")", "except", "ValueError", "as", "err", ":", "logging", ".", "debug", "(", "\"Failed to load json data: %s: [%s]\"", ",", "str", "(", "...
Create a new event instance. Return an instance of the `GerritEvent` subclass after converting `data` to json. Raise GerritError if json parsed from `data` does not contain a `type` key.
[ "Create", "a", "new", "event", "instance", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L59-L85
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
_decode_response
def _decode_response(response): """ Strip off Gerrit's magic prefix and decode a response. :returns: Decoded JSON content as a dict, or raw text if content could not be decoded as JSON. :raises: requests.HTTPError if the response contains an HTTP error status code. """ con...
python
def _decode_response(response): """ Strip off Gerrit's magic prefix and decode a response. :returns: Decoded JSON content as a dict, or raw text if content could not be decoded as JSON. :raises: requests.HTTPError if the response contains an HTTP error status code. """ con...
[ "def", "_decode_response", "(", "response", ")", ":", "content", "=", "response", ".", "content", ".", "strip", "(", ")", "logging", ".", "debug", "(", "content", "[", ":", "512", "]", ")", "response", ".", "raise_for_status", "(", ")", "if", "content", ...
Strip off Gerrit's magic prefix and decode a response. :returns: Decoded JSON content as a dict, or raw text if content could not be decoded as JSON. :raises: requests.HTTPError if the response contains an HTTP error status code.
[ "Strip", "off", "Gerrit", "s", "magic", "prefix", "and", "decode", "a", "response", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L33-L53
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.put
def put(self, endpoint, **kwargs): """ Send HTTP PUT to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error. """ kwargs.update(self.kwargs.co...
python
def put(self, endpoint, **kwargs): """ Send HTTP PUT to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error. """ kwargs.update(self.kwargs.co...
[ "def", "put", "(", "self", ",", "endpoint", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "kwargs", ".", "copy", "(", ")", ")", "if", "\"data\"", "in", "kwargs", ":", "kwargs", "[", "\"headers\"", "]", ".", "update",...
Send HTTP PUT to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error.
[ "Send", "HTTP", "PUT", "to", "the", "endpoint", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L121-L138
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.delete
def delete(self, endpoint, **kwargs): """ Send HTTP DELETE to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error. """ kwargs.update(self.kwa...
python
def delete(self, endpoint, **kwargs): """ Send HTTP DELETE to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error. """ kwargs.update(self.kwa...
[ "def", "delete", "(", "self", ",", "endpoint", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "kwargs", ".", "copy", "(", ")", ")", "response", "=", "requests", ".", "delete", "(", "self", ".", "make_url", "(", "endpo...
Send HTTP DELETE to the endpoint. :arg str endpoint: The endpoint to send to. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error.
[ "Send", "HTTP", "DELETE", "to", "the", "endpoint", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L159-L173
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.review
def review(self, change_id, revision, review): """ Submit a review. :arg str change_id: The change ID. :arg str revision: The revision. :arg str review: The review details as a :class:`GerritReview`. :returns: JSON decoded result. :raises: reque...
python
def review(self, change_id, revision, review): """ Submit a review. :arg str change_id: The change ID. :arg str revision: The revision. :arg str review: The review details as a :class:`GerritReview`. :returns: JSON decoded result. :raises: reque...
[ "def", "review", "(", "self", ",", "change_id", ",", "revision", ",", "review", ")", ":", "endpoint", "=", "\"changes/%s/revisions/%s/review\"", "%", "(", "change_id", ",", "revision", ")", "self", ".", "post", "(", "endpoint", ",", "data", "=", "str", "("...
Submit a review. :arg str change_id: The change ID. :arg str revision: The revision. :arg str review: The review details as a :class:`GerritReview`. :returns: JSON decoded result. :raises: requests.RequestException on timeout or connection error.
[ "Submit", "a", "review", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L175-L191
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritReview.add_comments
def add_comments(self, comments): """ Add inline comments. :arg dict comments: Comments to add. Usage:: add_comments([{'filename': 'Makefile', 'line': 10, 'message': 'inline message'}]) add_comments([{'filename': '...
python
def add_comments(self, comments): """ Add inline comments. :arg dict comments: Comments to add. Usage:: add_comments([{'filename': 'Makefile', 'line': 10, 'message': 'inline message'}]) add_comments([{'filename': '...
[ "def", "add_comments", "(", "self", ",", "comments", ")", ":", "for", "comment", "in", "comments", ":", "if", "'filename'", "and", "'message'", "in", "comment", ".", "keys", "(", ")", ":", "msg", "=", "{", "}", "if", "'range'", "in", "comment", ".", ...
Add inline comments. :arg dict comments: Comments to add. Usage:: add_comments([{'filename': 'Makefile', 'line': 10, 'message': 'inline message'}]) add_comments([{'filename': 'Makefile', 'range':...
[ "Add", "inline", "comments", "." ]
train
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L241-L278
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBProtocol.connection_made
def connection_made(self, transport): ''' override asyncio.Protocol ''' self._connected = True self.transport = transport self.remote_ip, self.port = transport.get_extra_info('peername')[:2] logging.debug( 'Connection made (address: {} port: {})' ...
python
def connection_made(self, transport): ''' override asyncio.Protocol ''' self._connected = True self.transport = transport self.remote_ip, self.port = transport.get_extra_info('peername')[:2] logging.debug( 'Connection made (address: {} port: {})' ...
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "self", ".", "_connected", "=", "True", "self", ".", "transport", "=", "transport", "self", ".", "remote_ip", ",", "self", ".", "port", "=", "transport", ".", "get_extra_info", "(", "'peern...
override asyncio.Protocol
[ "override", "asyncio", ".", "Protocol" ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L85-L106
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBProtocol.connection_lost
def connection_lost(self, exc): ''' override asyncio.Protocol ''' self._connected = False logging.debug( 'Connection lost (address: {} port: {})' .format(self.remote_ip, self.port)) for pid, (future, task) in self._requests.items(): t...
python
def connection_lost(self, exc): ''' override asyncio.Protocol ''' self._connected = False logging.debug( 'Connection lost (address: {} port: {})' .format(self.remote_ip, self.port)) for pid, (future, task) in self._requests.items(): t...
[ "def", "connection_lost", "(", "self", ",", "exc", ")", ":", "self", ".", "_connected", "=", "False", "logging", ".", "debug", "(", "'Connection lost (address: {} port: {})'", ".", "format", "(", "self", ".", "remote_ip", ",", "self", ".", "port", ")", ")", ...
override asyncio.Protocol
[ "override", "asyncio", ".", "Protocol" ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L108-L126
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBProtocol.data_received
def data_received(self, data): ''' override asyncio.Protocol ''' self._buffered_data.extend(data) while self._buffered_data: size = len(self._buffered_data) if self._data_package is None: if size < DataPackage.struct_datapackage.size: ...
python
def data_received(self, data): ''' override asyncio.Protocol ''' self._buffered_data.extend(data) while self._buffered_data: size = len(self._buffered_data) if self._data_package is None: if size < DataPackage.struct_datapackage.size: ...
[ "def", "data_received", "(", "self", ",", "data", ")", ":", "self", ".", "_buffered_data", ".", "extend", "(", "data", ")", "while", "self", ".", "_buffered_data", ":", "size", "=", "len", "(", "self", ".", "_buffered_data", ")", "if", "self", ".", "_d...
override asyncio.Protocol
[ "override", "asyncio", ".", "Protocol" ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L128-L151
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBInfoProtocol.connection_made
def connection_made(self, transport): ''' override _SiriDBProtocol ''' self.transport = transport self.remote_ip, self.port = transport.get_extra_info('peername')[:2] logging.debug( 'Connection made (address: {} port: {})' .format(self.remote_ip,...
python
def connection_made(self, transport): ''' override _SiriDBProtocol ''' self.transport = transport self.remote_ip, self.port = transport.get_extra_info('peername')[:2] logging.debug( 'Connection made (address: {} port: {})' .format(self.remote_ip,...
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "self", ".", "transport", "=", "transport", "self", ".", "remote_ip", ",", "self", ".", "port", "=", "transport", ".", "get_extra_info", "(", "'peername'", ")", "[", ":", "2", "]", "loggi...
override _SiriDBProtocol
[ "override", "_SiriDBProtocol" ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L234-L249
SiriDB/siridb-connector
siridb/connector/lib/connection.py
SiriDBConnection._register_server
def _register_server(self, server, timeout=30): '''Register a new SiriDB Server. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' result = self._loop.run_until_complete( self._protoc...
python
def _register_server(self, server, timeout=30): '''Register a new SiriDB Server. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' result = self._loop.run_until_complete( self._protoc...
[ "def", "_register_server", "(", "self", ",", "server", ",", "timeout", "=", "30", ")", ":", "result", "=", "self", ".", "_loop", ".", "run_until_complete", "(", "self", ".", "_protocol", ".", "send_package", "(", "CPROTO_REQ_REGISTER_SERVER", ",", "data", "=...
Register a new SiriDB Server. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request.
[ "Register", "a", "new", "SiriDB", "Server", "." ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/connection.py#L65-L75
SiriDB/siridb-connector
siridb/connector/lib/connection.py
SiriDBConnection._get_file
def _get_file(self, fn, timeout=30): '''Request a SiriDB configuration file. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' msg = FILE_MAP.get(fn, None) if msg is None: rai...
python
def _get_file(self, fn, timeout=30): '''Request a SiriDB configuration file. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' msg = FILE_MAP.get(fn, None) if msg is None: rai...
[ "def", "_get_file", "(", "self", ",", "fn", ",", "timeout", "=", "30", ")", ":", "msg", "=", "FILE_MAP", ".", "get", "(", "fn", ",", "None", ")", "if", "msg", "is", "None", ":", "raise", "FileNotFoundError", "(", "'Cannot get file {!r}. Available file '", ...
Request a SiriDB configuration file. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request.
[ "Request", "a", "SiriDB", "configuration", "file", "." ]
train
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/connection.py#L77-L90
transitland/mapzen-geohash
mzgeohash/geohash.py
_bits_to_float
def _bits_to_float(bits, lower=-90.0, middle=0.0, upper=90.0): """Convert GeoHash bits to a float.""" for i in bits: if i: lower = middle else: upper = middle middle = (upper + lower) / 2 return middle
python
def _bits_to_float(bits, lower=-90.0, middle=0.0, upper=90.0): """Convert GeoHash bits to a float.""" for i in bits: if i: lower = middle else: upper = middle middle = (upper + lower) / 2 return middle
[ "def", "_bits_to_float", "(", "bits", ",", "lower", "=", "-", "90.0", ",", "middle", "=", "0.0", ",", "upper", "=", "90.0", ")", ":", "for", "i", "in", "bits", ":", "if", "i", ":", "lower", "=", "middle", "else", ":", "upper", "=", "middle", "mid...
Convert GeoHash bits to a float.
[ "Convert", "GeoHash", "bits", "to", "a", "float", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L8-L16
transitland/mapzen-geohash
mzgeohash/geohash.py
_float_to_bits
def _float_to_bits(value, lower=-90.0, middle=0.0, upper=90.0, length=15): """Convert a float to a list of GeoHash bits.""" ret = [] for i in range(length): if value >= middle: lower = middle ret.append(1) else: upper = middle ret.append(0) middle = (upper + lower) / 2 return...
python
def _float_to_bits(value, lower=-90.0, middle=0.0, upper=90.0, length=15): """Convert a float to a list of GeoHash bits.""" ret = [] for i in range(length): if value >= middle: lower = middle ret.append(1) else: upper = middle ret.append(0) middle = (upper + lower) / 2 return...
[ "def", "_float_to_bits", "(", "value", ",", "lower", "=", "-", "90.0", ",", "middle", "=", "0.0", ",", "upper", "=", "90.0", ",", "length", "=", "15", ")", ":", "ret", "=", "[", "]", "for", "i", "in", "range", "(", "length", ")", ":", "if", "va...
Convert a float to a list of GeoHash bits.
[ "Convert", "a", "float", "to", "a", "list", "of", "GeoHash", "bits", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L18-L29
transitland/mapzen-geohash
mzgeohash/geohash.py
_geohash_to_bits
def _geohash_to_bits(value): """Convert a GeoHash to a list of GeoHash bits.""" b = map(BASE32MAP.get, value) ret = [] for i in b: out = [] for z in range(5): out.append(i & 0b1) i = i >> 1 ret += out[::-1] return ret
python
def _geohash_to_bits(value): """Convert a GeoHash to a list of GeoHash bits.""" b = map(BASE32MAP.get, value) ret = [] for i in b: out = [] for z in range(5): out.append(i & 0b1) i = i >> 1 ret += out[::-1] return ret
[ "def", "_geohash_to_bits", "(", "value", ")", ":", "b", "=", "map", "(", "BASE32MAP", ".", "get", ",", "value", ")", "ret", "=", "[", "]", "for", "i", "in", "b", ":", "out", "=", "[", "]", "for", "z", "in", "range", "(", "5", ")", ":", "out",...
Convert a GeoHash to a list of GeoHash bits.
[ "Convert", "a", "GeoHash", "to", "a", "list", "of", "GeoHash", "bits", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L31-L41
transitland/mapzen-geohash
mzgeohash/geohash.py
_bits_to_geohash
def _bits_to_geohash(value): """Convert a list of GeoHash bits to a GeoHash.""" ret = [] # Get 5 bits at a time for i in (value[i:i+5] for i in xrange(0, len(value), 5)): # Convert binary to integer # Note: reverse here, the slice above doesn't work quite right in reverse. total = sum([(bit*2**count...
python
def _bits_to_geohash(value): """Convert a list of GeoHash bits to a GeoHash.""" ret = [] # Get 5 bits at a time for i in (value[i:i+5] for i in xrange(0, len(value), 5)): # Convert binary to integer # Note: reverse here, the slice above doesn't work quite right in reverse. total = sum([(bit*2**count...
[ "def", "_bits_to_geohash", "(", "value", ")", ":", "ret", "=", "[", "]", "# Get 5 bits at a time", "for", "i", "in", "(", "value", "[", "i", ":", "i", "+", "5", "]", "for", "i", "in", "xrange", "(", "0", ",", "len", "(", "value", ")", ",", "5", ...
Convert a list of GeoHash bits to a GeoHash.
[ "Convert", "a", "list", "of", "GeoHash", "bits", "to", "a", "GeoHash", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L43-L53
transitland/mapzen-geohash
mzgeohash/geohash.py
decode
def decode(value): """Decode a geohash. Returns a (lon,lat) pair.""" assert value, "Invalid geohash: %s"%value # Get the GeoHash bits bits = _geohash_to_bits(value) # Unzip the GeoHash bits. lon = bits[0::2] lat = bits[1::2] # Convert to lat/lon return ( _bits_to_float(lon, lower=-180.0, upper=180...
python
def decode(value): """Decode a geohash. Returns a (lon,lat) pair.""" assert value, "Invalid geohash: %s"%value # Get the GeoHash bits bits = _geohash_to_bits(value) # Unzip the GeoHash bits. lon = bits[0::2] lat = bits[1::2] # Convert to lat/lon return ( _bits_to_float(lon, lower=-180.0, upper=180...
[ "def", "decode", "(", "value", ")", ":", "assert", "value", ",", "\"Invalid geohash: %s\"", "%", "value", "# Get the GeoHash bits", "bits", "=", "_geohash_to_bits", "(", "value", ")", "# Unzip the GeoHash bits.", "lon", "=", "bits", "[", "0", ":", ":", "2", "]...
Decode a geohash. Returns a (lon,lat) pair.
[ "Decode", "a", "geohash", ".", "Returns", "a", "(", "lon", "lat", ")", "pair", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L56-L68
transitland/mapzen-geohash
mzgeohash/geohash.py
encode
def encode(lonlat, length=12): """Encode a (lon,lat) pair to a GeoHash.""" assert len(lonlat) == 2, "Invalid lon/lat: %s"%lonlat # Half the length for each component. length /= 2 lon = _float_to_bits(lonlat[0], lower=-180.0, upper=180.0, length=length*5) lat = _float_to_bits(lonlat[1], lower=-90.0, upper=90...
python
def encode(lonlat, length=12): """Encode a (lon,lat) pair to a GeoHash.""" assert len(lonlat) == 2, "Invalid lon/lat: %s"%lonlat # Half the length for each component. length /= 2 lon = _float_to_bits(lonlat[0], lower=-180.0, upper=180.0, length=length*5) lat = _float_to_bits(lonlat[1], lower=-90.0, upper=90...
[ "def", "encode", "(", "lonlat", ",", "length", "=", "12", ")", ":", "assert", "len", "(", "lonlat", ")", "==", "2", ",", "\"Invalid lon/lat: %s\"", "%", "lonlat", "# Half the length for each component.", "length", "/=", "2", "lon", "=", "_float_to_bits", "(", ...
Encode a (lon,lat) pair to a GeoHash.
[ "Encode", "a", "(", "lon", "lat", ")", "pair", "to", "a", "GeoHash", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L70-L82
transitland/mapzen-geohash
mzgeohash/geohash.py
adjacent
def adjacent(geohash, direction): """Return the adjacent geohash for a given direction.""" # Based on an MIT licensed implementation by Chris Veness from: # http://www.movable-type.co.uk/scripts/geohash.html assert direction in 'nsew', "Invalid direction: %s"%direction assert geohash, "Invalid geohash: %s"%...
python
def adjacent(geohash, direction): """Return the adjacent geohash for a given direction.""" # Based on an MIT licensed implementation by Chris Veness from: # http://www.movable-type.co.uk/scripts/geohash.html assert direction in 'nsew', "Invalid direction: %s"%direction assert geohash, "Invalid geohash: %s"%...
[ "def", "adjacent", "(", "geohash", ",", "direction", ")", ":", "# Based on an MIT licensed implementation by Chris Veness from:", "# http://www.movable-type.co.uk/scripts/geohash.html", "assert", "direction", "in", "'nsew'", ",", "\"Invalid direction: %s\"", "%", "direction", "...
Return the adjacent geohash for a given direction.
[ "Return", "the", "adjacent", "geohash", "for", "a", "given", "direction", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L84-L108
transitland/mapzen-geohash
mzgeohash/geohash.py
neighbors
def neighbors(geohash): """Return all neighboring geohashes.""" return { 'n': adjacent(geohash, 'n'), 'ne': adjacent(adjacent(geohash, 'n'), 'e'), 'e': adjacent(geohash, 'e'), 'se': adjacent(adjacent(geohash, 's'), 'e'), 's': adjacent(geohash, 's'), 'sw': adjacent(adjacent(geohash, 's'), ...
python
def neighbors(geohash): """Return all neighboring geohashes.""" return { 'n': adjacent(geohash, 'n'), 'ne': adjacent(adjacent(geohash, 'n'), 'e'), 'e': adjacent(geohash, 'e'), 'se': adjacent(adjacent(geohash, 's'), 'e'), 's': adjacent(geohash, 's'), 'sw': adjacent(adjacent(geohash, 's'), ...
[ "def", "neighbors", "(", "geohash", ")", ":", "return", "{", "'n'", ":", "adjacent", "(", "geohash", ",", "'n'", ")", ",", "'ne'", ":", "adjacent", "(", "adjacent", "(", "geohash", ",", "'n'", ")", ",", "'e'", ")", ",", "'e'", ":", "adjacent", "(",...
Return all neighboring geohashes.
[ "Return", "all", "neighboring", "geohashes", "." ]
train
https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L110-L122
SiLab-Bonn/pyBAR
pybar/run_manager.py
thunkify
def thunkify(thread_name=None, daemon=True, default_func=None): '''Make a function immediately return a function of no args which, when called, waits for the result, which will start being processed in another thread. Taken from https://wiki.python.org/moin/PythonDecoratorLibrary. ''' def actual_dec...
python
def thunkify(thread_name=None, daemon=True, default_func=None): '''Make a function immediately return a function of no args which, when called, waits for the result, which will start being processed in another thread. Taken from https://wiki.python.org/moin/PythonDecoratorLibrary. ''' def actual_dec...
[ "def", "thunkify", "(", "thread_name", "=", "None", ",", "daemon", "=", "True", ",", "default_func", "=", "None", ")", ":", "def", "actual_decorator", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "thunked", "(", "*", "arg...
Make a function immediately return a function of no args which, when called, waits for the result, which will start being processed in another thread. Taken from https://wiki.python.org/moin/PythonDecoratorLibrary.
[ "Make", "a", "function", "immediately", "return", "a", "function", "of", "no", "args", "which", "when", "called", "waits", "for", "the", "result", "which", "will", "start", "being", "processed", "in", "another", "thread", ".", "Taken", "from", "https", ":", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L362-L410
SiLab-Bonn/pyBAR
pybar/run_manager.py
set_event_when_keyboard_interrupt
def set_event_when_keyboard_interrupt(_lambda): '''Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised Parameters ---------- _lambda : function Lambda function that points to Threading.Event() object Returns ------- wrapper : function Exa...
python
def set_event_when_keyboard_interrupt(_lambda): '''Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised Parameters ---------- _lambda : function Lambda function that points to Threading.Event() object Returns ------- wrapper : function Exa...
[ "def", "set_event_when_keyboard_interrupt", "(", "_lambda", ")", ":", "def", "wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped_f", "(", "self", ",", "*", "f_args", ",", "*", "*", "f_kwargs", ")", ":", "try", ":", "f", "(", ...
Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised Parameters ---------- _lambda : function Lambda function that points to Threading.Event() object Returns ------- wrapper : function Examples -------- @set_event_when_keyboard_interru...
[ "Decorator", "function", "that", "sets", "Threading", ".", "Event", "()", "when", "keyboard", "interrupt", "(", "Ctrl", "+", "C", ")", "was", "raised" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L655-L686
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.run_id
def run_id(self): '''Run name without whitespace ''' s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', self.__class__.__name__) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
python
def run_id(self): '''Run name without whitespace ''' s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', self.__class__.__name__) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
[ "def", "run_id", "(", "self", ")", ":", "s1", "=", "re", ".", "sub", "(", "'(.)([A-Z][a-z]+)'", ",", "r'\\1_\\2'", ",", "self", ".", "__class__", ".", "__name__", ")", "return", "re", ".", "sub", "(", "'([a-z0-9])([A-Z])'", ",", "r'\\1_\\2'", ",", "s1", ...
Run name without whitespace
[ "Run", "name", "without", "whitespace" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L83-L87
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.conf
def conf(self): '''Configuration (namedtuple) ''' conf = namedtuple('conf', field_names=self._conf.keys()) return conf(**self._conf)
python
def conf(self): '''Configuration (namedtuple) ''' conf = namedtuple('conf', field_names=self._conf.keys()) return conf(**self._conf)
[ "def", "conf", "(", "self", ")", ":", "conf", "=", "namedtuple", "(", "'conf'", ",", "field_names", "=", "self", ".", "_conf", ".", "keys", "(", ")", ")", "return", "conf", "(", "*", "*", "self", ".", "_conf", ")" ]
Configuration (namedtuple)
[ "Configuration", "(", "namedtuple", ")" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L90-L94
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.run_conf
def run_conf(self): '''Run configuration (namedtuple) ''' run_conf = namedtuple('run_conf', field_names=self._run_conf.keys()) return run_conf(**self._run_conf)
python
def run_conf(self): '''Run configuration (namedtuple) ''' run_conf = namedtuple('run_conf', field_names=self._run_conf.keys()) return run_conf(**self._run_conf)
[ "def", "run_conf", "(", "self", ")", ":", "run_conf", "=", "namedtuple", "(", "'run_conf'", ",", "field_names", "=", "self", ".", "_run_conf", ".", "keys", "(", ")", ")", "return", "run_conf", "(", "*", "*", "self", ".", "_run_conf", ")" ]
Run configuration (namedtuple)
[ "Run", "configuration", "(", "namedtuple", ")" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L97-L101
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.default_run_conf
def default_run_conf(self): '''Default run configuration (namedtuple) ''' default_run_conf = namedtuple('default_run_conf', field_names=self._default_run_conf.keys()) return default_run_conf(**self._default_run_conf)
python
def default_run_conf(self): '''Default run configuration (namedtuple) ''' default_run_conf = namedtuple('default_run_conf', field_names=self._default_run_conf.keys()) return default_run_conf(**self._default_run_conf)
[ "def", "default_run_conf", "(", "self", ")", ":", "default_run_conf", "=", "namedtuple", "(", "'default_run_conf'", ",", "field_names", "=", "self", ".", "_default_run_conf", ".", "keys", "(", ")", ")", "return", "default_run_conf", "(", "*", "*", "self", ".",...
Default run configuration (namedtuple)
[ "Default", "run", "configuration", "(", "namedtuple", ")" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L110-L114
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase._init
def _init(self, run_conf, run_number=None): '''Initialization before a new run. ''' self.stop_run.clear() self.abort_run.clear() self._run_status = run_status.running self._write_run_number(run_number) self._init_run_conf(run_conf)
python
def _init(self, run_conf, run_number=None): '''Initialization before a new run. ''' self.stop_run.clear() self.abort_run.clear() self._run_status = run_status.running self._write_run_number(run_number) self._init_run_conf(run_conf)
[ "def", "_init", "(", "self", ",", "run_conf", ",", "run_number", "=", "None", ")", ":", "self", ".", "stop_run", ".", "clear", "(", ")", "self", ".", "abort_run", ".", "clear", "(", ")", "self", ".", "_run_status", "=", "run_status", ".", "running", ...
Initialization before a new run.
[ "Initialization", "before", "a", "new", "run", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L188-L195
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.connect_cancel
def connect_cancel(self, functions): '''Run given functions when a run is cancelled. ''' self._cancel_functions = [] for func in functions: if isinstance(func, basestring) and hasattr(self, func) and callable(getattr(self, func)): self._cancel_functions.append...
python
def connect_cancel(self, functions): '''Run given functions when a run is cancelled. ''' self._cancel_functions = [] for func in functions: if isinstance(func, basestring) and hasattr(self, func) and callable(getattr(self, func)): self._cancel_functions.append...
[ "def", "connect_cancel", "(", "self", ",", "functions", ")", ":", "self", ".", "_cancel_functions", "=", "[", "]", "for", "func", "in", "functions", ":", "if", "isinstance", "(", "func", ",", "basestring", ")", "and", "hasattr", "(", "self", ",", "func",...
Run given functions when a run is cancelled.
[ "Run", "given", "functions", "when", "a", "run", "is", "cancelled", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L248-L258
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.handle_cancel
def handle_cancel(self, **kwargs): '''Cancelling a run. ''' for func in self._cancel_functions: f_args = getargspec(func)[0] f_kwargs = {key: kwargs[key] for key in f_args if key in kwargs} func(**f_kwargs)
python
def handle_cancel(self, **kwargs): '''Cancelling a run. ''' for func in self._cancel_functions: f_args = getargspec(func)[0] f_kwargs = {key: kwargs[key] for key in f_args if key in kwargs} func(**f_kwargs)
[ "def", "handle_cancel", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "func", "in", "self", ".", "_cancel_functions", ":", "f_args", "=", "getargspec", "(", "func", ")", "[", "0", "]", "f_kwargs", "=", "{", "key", ":", "kwargs", "[", "key", ...
Cancelling a run.
[ "Cancelling", "a", "run", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L260-L266
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.stop
def stop(self, msg=None): '''Stopping a run. Control for loops. Gentle stop/abort. This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete. ''' if not self.stop_run.is_set(): if msg: logging.info('%s%s ...
python
def stop(self, msg=None): '''Stopping a run. Control for loops. Gentle stop/abort. This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete. ''' if not self.stop_run.is_set(): if msg: logging.info('%s%s ...
[ "def", "stop", "(", "self", ",", "msg", "=", "None", ")", ":", "if", "not", "self", ".", "stop_run", ".", "is_set", "(", ")", ":", "if", "msg", ":", "logging", ".", "info", "(", "'%s%s Stopping run...'", ",", "msg", ",", "(", "''", "if", "msg", "...
Stopping a run. Control for loops. Gentle stop/abort. This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete.
[ "Stopping", "a", "run", ".", "Control", "for", "loops", ".", "Gentle", "stop", "/", "abort", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L268-L278
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunBase.abort
def abort(self, msg=None): '''Aborting a run. Control for loops. Immediate stop/abort. The implementation should stop a run ASAP when this event is set. The run is considered incomplete. ''' if not self.abort_run.is_set(): if msg: logging.error('%s%s Aborting...
python
def abort(self, msg=None): '''Aborting a run. Control for loops. Immediate stop/abort. The implementation should stop a run ASAP when this event is set. The run is considered incomplete. ''' if not self.abort_run.is_set(): if msg: logging.error('%s%s Aborting...
[ "def", "abort", "(", "self", ",", "msg", "=", "None", ")", ":", "if", "not", "self", ".", "abort_run", ".", "is_set", "(", ")", ":", "if", "msg", ":", "logging", ".", "error", "(", "'%s%s Aborting run...'", ",", "msg", ",", "(", "''", "if", "msg", ...
Aborting a run. Control for loops. Immediate stop/abort. The implementation should stop a run ASAP when this event is set. The run is considered incomplete.
[ "Aborting", "a", "run", ".", "Control", "for", "loops", ".", "Immediate", "stop", "/", "abort", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L280-L291
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunManager.run_run
def run_run(self, run, conf=None, run_conf=None, use_thread=False, catch_exception=True): '''Runs a run in another thread. Non-blocking. Parameters ---------- run : class, object Run class or object. run_conf : str, dict, file Specific configuration for t...
python
def run_run(self, run, conf=None, run_conf=None, use_thread=False, catch_exception=True): '''Runs a run in another thread. Non-blocking. Parameters ---------- run : class, object Run class or object. run_conf : str, dict, file Specific configuration for t...
[ "def", "run_run", "(", "self", ",", "run", ",", "conf", "=", "None", ",", "run_conf", "=", "None", ",", "use_thread", "=", "False", ",", "catch_exception", "=", "True", ")", ":", "if", "isinstance", "(", "conf", ",", "basestring", ")", "and", "os", "...
Runs a run in another thread. Non-blocking. Parameters ---------- run : class, object Run class or object. run_conf : str, dict, file Specific configuration for the run. use_thread : bool If True, run run in thread and returns blocking functio...
[ "Runs", "a", "run", "in", "another", "thread", ".", "Non", "-", "blocking", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L513-L578
SiLab-Bonn/pyBAR
pybar/run_manager.py
RunManager.run_primlist
def run_primlist(self, primlist, skip_remaining=False): '''Runs runs from a primlist. Parameters ---------- primlist : string Filename of primlist. skip_remaining : bool If True, skip remaining runs, if a run does not exit with status FINISHED. N...
python
def run_primlist(self, primlist, skip_remaining=False): '''Runs runs from a primlist. Parameters ---------- primlist : string Filename of primlist. skip_remaining : bool If True, skip remaining runs, if a run does not exit with status FINISHED. N...
[ "def", "run_primlist", "(", "self", ",", "primlist", ",", "skip_remaining", "=", "False", ")", ":", "runlist", "=", "self", ".", "open_primlist", "(", "primlist", ")", "for", "index", ",", "run", "in", "enumerate", "(", "runlist", ")", ":", "logging", "....
Runs runs from a primlist. Parameters ---------- primlist : string Filename of primlist. skip_remaining : bool If True, skip remaining runs, if a run does not exit with status FINISHED. Note ---- Primlist is a text file of the following f...
[ "Runs", "runs", "from", "a", "primlist", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L580-L602
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
analyze_beam_spot
def analyze_beam_spot(scan_base, combine_n_readouts=1000, chunk_size=10000000, plot_occupancy_hists=False, output_pdf=None, output_file=None): ''' Determines the mean x and y beam spot position as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The occupanc...
python
def analyze_beam_spot(scan_base, combine_n_readouts=1000, chunk_size=10000000, plot_occupancy_hists=False, output_pdf=None, output_file=None): ''' Determines the mean x and y beam spot position as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The occupanc...
[ "def", "analyze_beam_spot", "(", "scan_base", ",", "combine_n_readouts", "=", "1000", ",", "chunk_size", "=", "10000000", ",", "plot_occupancy_hists", "=", "False", ",", "output_pdf", "=", "None", ",", "output_file", "=", "None", ")", ":", "time_stamp", "=", "...
Determines the mean x and y beam spot position as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The occupancy is determined for the given combined events and stored into a pdf file. At the end the beam x and y is plotted into a scatter plot with absolute ...
[ "Determines", "the", "mean", "x", "and", "y", "beam", "spot", "position", "as", "a", "function", "of", "time", ".", "Therefore", "the", "data", "of", "a", "fixed", "number", "of", "read", "outs", "are", "combined", "(", "combine_n_readouts", ")", ".", "T...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L23-L99
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
analyze_event_rate
def analyze_event_rate(scan_base, combine_n_readouts=1000, time_line_absolute=True, output_pdf=None, output_file=None): ''' Determines the number of events as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The number of events is taken from the meta data i...
python
def analyze_event_rate(scan_base, combine_n_readouts=1000, time_line_absolute=True, output_pdf=None, output_file=None): ''' Determines the number of events as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The number of events is taken from the meta data i...
[ "def", "analyze_event_rate", "(", "scan_base", ",", "combine_n_readouts", "=", "1000", ",", "time_line_absolute", "=", "True", ",", "output_pdf", "=", "None", ",", "output_file", "=", "None", ")", ":", "time_stamp", "=", "[", "]", "rate", "=", "[", "]", "s...
Determines the number of events as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). The number of events is taken from the meta data info and stored into a pdf file. Parameters ---------- scan_base: list of str scan base names (e.g.: ['...
[ "Determines", "the", "number", "of", "events", "as", "a", "function", "of", "time", ".", "Therefore", "the", "data", "of", "a", "fixed", "number", "of", "read", "outs", "are", "combined", "(", "combine_n_readouts", ")", ".", "The", "number", "of", "events"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L102-L147
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
analyse_n_cluster_per_event
def analyse_n_cluster_per_event(scan_base, include_no_cluster=False, time_line_absolute=True, combine_n_readouts=1000, chunk_size=10000000, plot_n_cluster_hists=False, output_pdf=None, output_file=None): ''' Determines the number of cluster per event as a function of time. Therefore the data of a fixed number of re...
python
def analyse_n_cluster_per_event(scan_base, include_no_cluster=False, time_line_absolute=True, combine_n_readouts=1000, chunk_size=10000000, plot_n_cluster_hists=False, output_pdf=None, output_file=None): ''' Determines the number of cluster per event as a function of time. Therefore the data of a fixed number of re...
[ "def", "analyse_n_cluster_per_event", "(", "scan_base", ",", "include_no_cluster", "=", "False", ",", "time_line_absolute", "=", "True", ",", "combine_n_readouts", "=", "1000", ",", "chunk_size", "=", "10000000", ",", "plot_n_cluster_hists", "=", "False", ",", "outp...
Determines the number of cluster per event as a function of time. Therefore the data of a fixed number of read outs are combined ('combine_n_readouts'). Parameters ---------- scan_base: list of str scan base names (e.g.: ['//data//SCC_50_fei4_self_trigger_scan_390', ] include_no_cluster: bool ...
[ "Determines", "the", "number", "of", "cluster", "per", "event", "as", "a", "function", "of", "time", ".", "Therefore", "the", "data", "of", "a", "fixed", "number", "of", "read", "outs", "are", "combined", "(", "combine_n_readouts", ")", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L150-L248
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
select_hits_from_cluster_info
def select_hits_from_cluster_info(input_file_hits, output_file_hits, cluster_size_condition, n_cluster_condition, chunk_size=4000000): ''' Takes a hit table and stores only selected hits into a new table. The selection is done on an event base and events are selected if they have a certain number of cluster or clus...
python
def select_hits_from_cluster_info(input_file_hits, output_file_hits, cluster_size_condition, n_cluster_condition, chunk_size=4000000): ''' Takes a hit table and stores only selected hits into a new table. The selection is done on an event base and events are selected if they have a certain number of cluster or clus...
[ "def", "select_hits_from_cluster_info", "(", "input_file_hits", ",", "output_file_hits", ",", "cluster_size_condition", ",", "n_cluster_condition", ",", "chunk_size", "=", "4000000", ")", ":", "logging", ".", "info", "(", "'Write hits of events from '", "+", "str", "(",...
Takes a hit table and stores only selected hits into a new table. The selection is done on an event base and events are selected if they have a certain number of cluster or cluster size. To increase the analysis speed a event index for the input hit file is created first. Since a cluster hit table can be created to...
[ "Takes", "a", "hit", "table", "and", "stores", "only", "selected", "hits", "into", "a", "new", "table", ".", "The", "selection", "is", "done", "on", "an", "event", "base", "and", "events", "are", "selected", "if", "they", "have", "a", "certain", "number"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L251-L285
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
select_hits
def select_hits(input_file_hits, output_file_hits, condition=None, cluster_size_condition=None, n_cluster_condition=None, chunk_size=5000000): ''' Takes a hit table and stores only selected hits into a new table. The selection of hits is done with a numexp string. Only if this expression evaluates to true the h...
python
def select_hits(input_file_hits, output_file_hits, condition=None, cluster_size_condition=None, n_cluster_condition=None, chunk_size=5000000): ''' Takes a hit table and stores only selected hits into a new table. The selection of hits is done with a numexp string. Only if this expression evaluates to true the h...
[ "def", "select_hits", "(", "input_file_hits", ",", "output_file_hits", ",", "condition", "=", "None", ",", "cluster_size_condition", "=", "None", ",", "n_cluster_condition", "=", "None", ",", "chunk_size", "=", "5000000", ")", ":", "logging", ".", "info", "(", ...
Takes a hit table and stores only selected hits into a new table. The selection of hits is done with a numexp string. Only if this expression evaluates to true the hit is taken. One can also select hits from cluster conditions. This selection is done on an event basis, meaning events are selected where the clus...
[ "Takes", "a", "hit", "table", "and", "stores", "only", "selected", "hits", "into", "a", "new", "table", ".", "The", "selection", "of", "hits", "is", "done", "with", "a", "numexp", "string", ".", "Only", "if", "this", "expression", "evaluates", "to", "tru...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L288-L338
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
analyze_cluster_size_per_scan_parameter
def analyze_cluster_size_per_scan_parameter(input_file_hits, output_file_cluster_size, parameter='GDAC', max_chunk_size=10000000, overwrite_output_files=False, output_pdf=None): ''' This method takes multiple hit files and determines the cluster size for different scan parameter values of Parameters -----...
python
def analyze_cluster_size_per_scan_parameter(input_file_hits, output_file_cluster_size, parameter='GDAC', max_chunk_size=10000000, overwrite_output_files=False, output_pdf=None): ''' This method takes multiple hit files and determines the cluster size for different scan parameter values of Parameters -----...
[ "def", "analyze_cluster_size_per_scan_parameter", "(", "input_file_hits", ",", "output_file_cluster_size", ",", "parameter", "=", "'GDAC'", ",", "max_chunk_size", "=", "10000000", ",", "overwrite_output_files", "=", "False", ",", "output_pdf", "=", "None", ")", ":", "...
This method takes multiple hit files and determines the cluster size for different scan parameter values of Parameters ---------- input_files_hits: string output_file_cluster_size: string The data file with the results parameter: string The name of the parameter to separate the dat...
[ "This", "method", "takes", "multiple", "hit", "files", "and", "determines", "the", "cluster", "size", "for", "different", "scan", "parameter", "values", "of" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L341-L425
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
histogram_cluster_table
def histogram_cluster_table(analyzed_data_file, output_file, chunk_size=10000000): '''Reads in the cluster info table in chunks and histograms the seed pixels into one occupancy array. The 3rd dimension of the occupancy array is the number of different scan parameters used Parameters ---------- ana...
python
def histogram_cluster_table(analyzed_data_file, output_file, chunk_size=10000000): '''Reads in the cluster info table in chunks and histograms the seed pixels into one occupancy array. The 3rd dimension of the occupancy array is the number of different scan parameters used Parameters ---------- ana...
[ "def", "histogram_cluster_table", "(", "analyzed_data_file", ",", "output_file", ",", "chunk_size", "=", "10000000", ")", ":", "with", "tb", ".", "open_file", "(", "analyzed_data_file", ",", "mode", "=", "\"r\"", ")", "as", "in_file_h5", ":", "with", "tb", "."...
Reads in the cluster info table in chunks and histograms the seed pixels into one occupancy array. The 3rd dimension of the occupancy array is the number of different scan parameters used Parameters ---------- analyzed_data_file : string HDF5 filename of the file containing the cluster table. I...
[ "Reads", "in", "the", "cluster", "info", "table", "in", "chunks", "and", "histograms", "the", "seed", "pixels", "into", "one", "occupancy", "array", ".", "The", "3rd", "dimension", "of", "the", "occupancy", "array", "is", "the", "number", "of", "different", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L428-L482
SiLab-Bonn/pyBAR
pybar/analysis/analysis.py
analyze_hits_per_scan_parameter
def analyze_hits_per_scan_parameter(analyze_data, scan_parameters=None, chunk_size=50000): '''Takes the hit table and analyzes the hits per scan parameter Parameters ---------- analyze_data : analysis.analyze_raw_data.AnalyzeRawData object with an opened hit file (AnalyzeRawData.out_file_h5) or a f...
python
def analyze_hits_per_scan_parameter(analyze_data, scan_parameters=None, chunk_size=50000): '''Takes the hit table and analyzes the hits per scan parameter Parameters ---------- analyze_data : analysis.analyze_raw_data.AnalyzeRawData object with an opened hit file (AnalyzeRawData.out_file_h5) or a f...
[ "def", "analyze_hits_per_scan_parameter", "(", "analyze_data", ",", "scan_parameters", "=", "None", ",", "chunk_size", "=", "50000", ")", ":", "if", "analyze_data", ".", "out_file_h5", "is", "None", "or", "analyze_data", ".", "out_file_h5", ".", "isopen", "==", ...
Takes the hit table and analyzes the hits per scan parameter Parameters ---------- analyze_data : analysis.analyze_raw_data.AnalyzeRawData object with an opened hit file (AnalyzeRawData.out_file_h5) or a file name with the hit data given (AnalyzeRawData._analyzed_data_file) scan_parameters : list o...
[ "Takes", "the", "hit", "table", "and", "analyzes", "the", "hits", "per", "scan", "parameter" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis.py#L485-L541
SiLab-Bonn/pyBAR
pybar/scans/calibrate_plsr_dac_transient.py
interpret_data_from_tektronix
def interpret_data_from_tektronix(preamble, data): ''' Interprets raw data from Tektronix returns: lists of x, y values in seconds/volt''' # Y mode ("WFMPRE:PT_FMT"): # Xn = XZEro + XINcr (n - PT_Off) # Yn = YZEro + YMUlt (yn - YOFf) voltage = np.array(data, dtype=np.float) meta_data = pream...
python
def interpret_data_from_tektronix(preamble, data): ''' Interprets raw data from Tektronix returns: lists of x, y values in seconds/volt''' # Y mode ("WFMPRE:PT_FMT"): # Xn = XZEro + XINcr (n - PT_Off) # Yn = YZEro + YMUlt (yn - YOFf) voltage = np.array(data, dtype=np.float) meta_data = pream...
[ "def", "interpret_data_from_tektronix", "(", "preamble", ",", "data", ")", ":", "# Y mode (\"WFMPRE:PT_FMT\"):", "# Xn = XZEro + XINcr (n - PT_Off)", "# Yn = YZEro + YMUlt (yn - YOFf)", "voltage", "=", "np", ".", "array", "(", "data", ",", "dtype", "=", "np", ".", "floa...
Interprets raw data from Tektronix returns: lists of x, y values in seconds/volt
[ "Interprets", "raw", "data", "from", "Tektronix", "returns", ":", "lists", "of", "x", "y", "values", "in", "seconds", "/", "volt" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/calibrate_plsr_dac_transient.py#L24-L42
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
read_chip_sn
def read_chip_sn(self): '''Reading Chip S/N Note ---- Bits [MSB-LSB] | [15] | [14-6] | [5-0] Content | reserved | wafer number | chip number ''' commands = [] commands.extend(self.register.get_commands("ConfMode")) self.register_utils.send_commands(com...
python
def read_chip_sn(self): '''Reading Chip S/N Note ---- Bits [MSB-LSB] | [15] | [14-6] | [5-0] Content | reserved | wafer number | chip number ''' commands = [] commands.extend(self.register.get_commands("ConfMode")) self.register_utils.send_commands(com...
[ "def", "read_chip_sn", "(", "self", ")", ":", "commands", "=", "[", "]", "commands", ".", "extend", "(", "self", ".", "register", ".", "get_commands", "(", "\"ConfMode\"", ")", ")", "self", ".", "register_utils", ".", "send_commands", "(", "commands", ")",...
Reading Chip S/N Note ---- Bits [MSB-LSB] | [15] | [14-6] | [5-0] Content | reserved | wafer number | chip number
[ "Reading", "Chip", "S", "/", "N", "Note", "----", "Bits", "[", "MSB", "-", "LSB", "]", "|", "[", "15", "]", "|", "[", "14", "-", "6", "]", "|", "[", "5", "-", "0", "]", "Content", "|", "reserved", "|", "wafer", "number", "|", "chip", "number"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L264-L313
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
read_global_register
def read_global_register(self, name, overwrite_config=False): '''The function reads the global register, interprets the data and returns the register value. Parameters ---------- name : register name overwrite_config : bool The read values overwrite the config in RAM if true. ...
python
def read_global_register(self, name, overwrite_config=False): '''The function reads the global register, interprets the data and returns the register value. Parameters ---------- name : register name overwrite_config : bool The read values overwrite the config in RAM if true. ...
[ "def", "read_global_register", "(", "self", ",", "name", ",", "overwrite_config", "=", "False", ")", ":", "self", ".", "register_utils", ".", "send_commands", "(", "self", ".", "register", ".", "get_commands", "(", "\"ConfMode\"", ")", ")", "with", "self", "...
The function reads the global register, interprets the data and returns the register value. Parameters ---------- name : register name overwrite_config : bool The read values overwrite the config in RAM if true. Returns ------- register value
[ "The", "function", "reads", "the", "global", "register", "interprets", "the", "data", "and", "returns", "the", "register", "value", ".", "Parameters", "----------", "name", ":", "register", "name", "overwrite_config", ":", "bool", "The", "read", "values", "overw...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L540-L586
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
read_pixel_register
def read_pixel_register(self, pix_regs=None, dcs=range(40), overwrite_config=False): '''The function reads the pixel register, interprets the data and returns a masked numpy arrays with the data for the chosen pixel register. Pixels without any data are masked. Parameters ---------- pix_regs ...
python
def read_pixel_register(self, pix_regs=None, dcs=range(40), overwrite_config=False): '''The function reads the pixel register, interprets the data and returns a masked numpy arrays with the data for the chosen pixel register. Pixels without any data are masked. Parameters ---------- pix_regs ...
[ "def", "read_pixel_register", "(", "self", ",", "pix_regs", "=", "None", ",", "dcs", "=", "range", "(", "40", ")", ",", "overwrite_config", "=", "False", ")", ":", "if", "pix_regs", "is", "None", ":", "pix_regs", "=", "[", "\"EnableDigInj\"", ",", "\"Imo...
The function reads the pixel register, interprets the data and returns a masked numpy arrays with the data for the chosen pixel register. Pixels without any data are masked. Parameters ---------- pix_regs : iterable, string List of pixel register to read (e.g. Enable, C_High, ...). ...
[ "The", "function", "reads", "the", "pixel", "register", "interprets", "the", "data", "and", "returns", "a", "masked", "numpy", "arrays", "with", "the", "data", "for", "the", "chosen", "pixel", "register", ".", "Pixels", "without", "any", "data", "are", "mask...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L598-L633
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
is_fe_ready
def is_fe_ready(self): '''Get FEI4 status of module. If FEI4 is not ready, resetting service records is necessary to bring the FEI4 to a defined state. Returns ------- value : bool True if FEI4 is ready, False if the FEI4 was powered up recently and is not ready. ''' with...
python
def is_fe_ready(self): '''Get FEI4 status of module. If FEI4 is not ready, resetting service records is necessary to bring the FEI4 to a defined state. Returns ------- value : bool True if FEI4 is ready, False if the FEI4 was powered up recently and is not ready. ''' with...
[ "def", "is_fe_ready", "(", "self", ")", ":", "with", "self", ".", "readout", "(", "fill_buffer", "=", "True", ",", "callback", "=", "None", ",", "errback", "=", "None", ")", ":", "commands", "=", "[", "]", "commands", ".", "extend", "(", "self", ".",...
Get FEI4 status of module. If FEI4 is not ready, resetting service records is necessary to bring the FEI4 to a defined state. Returns ------- value : bool True if FEI4 is ready, False if the FEI4 was powered up recently and is not ready.
[ "Get", "FEI4", "status", "of", "module", ".", "If", "FEI4", "is", "not", "ready", "resetting", "service", "records", "is", "necessary", "to", "bring", "the", "FEI4", "to", "a", "defined", "state", ".", "Returns", "-------", "value", ":", "bool", "True", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L636-L657
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
invert_pixel_mask
def invert_pixel_mask(mask): '''Invert pixel mask (0->1, 1(and greater)->0). Parameters ---------- mask : array-like Mask. Returns ------- inverted_mask : array-like Inverted Mask. ''' inverted_mask = np.ones(shape=(80, 336), dtype=np.dtype('>u1')) ...
python
def invert_pixel_mask(mask): '''Invert pixel mask (0->1, 1(and greater)->0). Parameters ---------- mask : array-like Mask. Returns ------- inverted_mask : array-like Inverted Mask. ''' inverted_mask = np.ones(shape=(80, 336), dtype=np.dtype('>u1')) ...
[ "def", "invert_pixel_mask", "(", "mask", ")", ":", "inverted_mask", "=", "np", ".", "ones", "(", "shape", "=", "(", "80", ",", "336", ")", ",", "dtype", "=", "np", ".", "dtype", "(", "'>u1'", ")", ")", "inverted_mask", "[", "mask", ">=", "1", "]", ...
Invert pixel mask (0->1, 1(and greater)->0). Parameters ---------- mask : array-like Mask. Returns ------- inverted_mask : array-like Inverted Mask.
[ "Invert", "pixel", "mask", "(", "0", "-", ">", "1", "1", "(", "and", "greater", ")", "-", ">", "0", ")", ".", "Parameters", "----------", "mask", ":", "array", "-", "like", "Mask", ".", "Returns", "-------", "inverted_mask", ":", "array", "-", "like"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L660-L675
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
make_pixel_mask
def make_pixel_mask(steps, shift, default=0, value=1, enable_columns=None, mask=None): '''Generate pixel mask. Parameters ---------- steps : int Number of mask steps, e.g. steps=3 (every third pixel is enabled), steps=336 (one pixel per column), steps=672 (one pixel per double column). ...
python
def make_pixel_mask(steps, shift, default=0, value=1, enable_columns=None, mask=None): '''Generate pixel mask. Parameters ---------- steps : int Number of mask steps, e.g. steps=3 (every third pixel is enabled), steps=336 (one pixel per column), steps=672 (one pixel per double column). ...
[ "def", "make_pixel_mask", "(", "steps", ",", "shift", ",", "default", "=", "0", ",", "value", "=", "1", ",", "enable_columns", "=", "None", ",", "mask", "=", "None", ")", ":", "shape", "=", "(", "80", ",", "336", ")", "# value = np.zeros(dimension, dtype...
Generate pixel mask. Parameters ---------- steps : int Number of mask steps, e.g. steps=3 (every third pixel is enabled), steps=336 (one pixel per column), steps=672 (one pixel per double column). shift : int Shift mask by given value to the bottom (towards higher row numbers). F...
[ "Generate", "pixel", "mask", ".", "Parameters", "----------", "steps", ":", "int", "Number", "of", "mask", "steps", "e", ".", "g", ".", "steps", "=", "3", "(", "every", "third", "pixel", "is", "enabled", ")", "steps", "=", "336", "(", "one", "pixel", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L678-L738
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
make_pixel_mask_from_col_row
def make_pixel_mask_from_col_row(column, row, default=0, value=1): '''Generate mask from column and row lists Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of row values. default : int Value of pixels that are not ...
python
def make_pixel_mask_from_col_row(column, row, default=0, value=1): '''Generate mask from column and row lists Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of row values. default : int Value of pixels that are not ...
[ "def", "make_pixel_mask_from_col_row", "(", "column", ",", "row", ",", "default", "=", "0", ",", "value", "=", "1", ")", ":", "# FE columns and rows start from 1\r", "col_array", "=", "np", ".", "array", "(", "column", ")", "-", "1", "row_array", "=", "np", ...
Generate mask from column and row lists Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of row values. default : int Value of pixels that are not selected by the mask. value : int Value of pixels that are se...
[ "Generate", "mask", "from", "column", "and", "row", "lists", "Parameters", "----------", "column", ":", "iterable", "int", "List", "of", "colums", "values", ".", "row", ":", "iterable", "int", "List", "of", "row", "values", ".", "default", ":", "int", "Val...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L741-L767
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
make_box_pixel_mask_from_col_row
def make_box_pixel_mask_from_col_row(column, row, default=0, value=1): '''Generate box shaped mask from column and row lists. Takes the minimum and maximum value from each list. Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of r...
python
def make_box_pixel_mask_from_col_row(column, row, default=0, value=1): '''Generate box shaped mask from column and row lists. Takes the minimum and maximum value from each list. Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of r...
[ "def", "make_box_pixel_mask_from_col_row", "(", "column", ",", "row", ",", "default", "=", "0", ",", "value", "=", "1", ")", ":", "# FE columns and rows start from 1\r", "col_array", "=", "np", ".", "array", "(", "column", ")", "-", "1", "row_array", "=", "n...
Generate box shaped mask from column and row lists. Takes the minimum and maximum value from each list. Parameters ---------- column : iterable, int List of colums values. row : iterable, int List of row values. default : int Value of pixels that are not selected by...
[ "Generate", "box", "shaped", "mask", "from", "column", "and", "row", "lists", ".", "Takes", "the", "minimum", "and", "maximum", "value", "from", "each", "list", ".", "Parameters", "----------", "column", ":", "iterable", "int", "List", "of", "colums", "value...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L770-L797
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
make_xtalk_mask
def make_xtalk_mask(mask): """ Generate xtalk mask (row - 1, row + 1) from pixel mask. Parameters ---------- mask : ndarray Pixel mask. Returns ------- ndarray Xtalk mask. Example ------- Input: [[1 0 0 0 0 0 1 0 0 0 ... 0 0 0 0 1 0 0 0...
python
def make_xtalk_mask(mask): """ Generate xtalk mask (row - 1, row + 1) from pixel mask. Parameters ---------- mask : ndarray Pixel mask. Returns ------- ndarray Xtalk mask. Example ------- Input: [[1 0 0 0 0 0 1 0 0 0 ... 0 0 0 0 1 0 0 0...
[ "def", "make_xtalk_mask", "(", "mask", ")", ":", "col", ",", "row", "=", "mask", ".", "nonzero", "(", ")", "row_plus_one", "=", "row", "+", "1", "del_index", "=", "np", ".", "where", "(", "row_plus_one", ">", "335", ")", "row_plus_one", "=", "np", "....
Generate xtalk mask (row - 1, row + 1) from pixel mask. Parameters ---------- mask : ndarray Pixel mask. Returns ------- ndarray Xtalk mask. Example ------- Input: [[1 0 0 0 0 0 1 0 0 0 ... 0 0 0 0 1 0 0 0 0 0] [0 0 0 1 0 0 0 0 0 1 ... 0 1 ...
[ "Generate", "xtalk", "mask", "(", "row", "-", "1", "row", "+", "1", ")", "from", "pixel", "mask", ".", "Parameters", "----------", "mask", ":", "ndarray", "Pixel", "mask", ".", "Returns", "-------", "ndarray", "Xtalk", "mask", ".", "Example", "-------", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L800-L841
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
make_checkerboard_mask
def make_checkerboard_mask(column_distance, row_distance, column_offset=0, row_offset=0, default=0, value=1): """ Generate chessboard/checkerboard mask. Parameters ---------- column_distance : int Column distance of the enabled pixels. row_distance : int Row distance of...
python
def make_checkerboard_mask(column_distance, row_distance, column_offset=0, row_offset=0, default=0, value=1): """ Generate chessboard/checkerboard mask. Parameters ---------- column_distance : int Column distance of the enabled pixels. row_distance : int Row distance of...
[ "def", "make_checkerboard_mask", "(", "column_distance", ",", "row_distance", ",", "column_offset", "=", "0", ",", "row_offset", "=", "0", ",", "default", "=", "0", ",", "value", "=", "1", ")", ":", "col_shape", "=", "(", "336", ",", ")", "col", "=", "...
Generate chessboard/checkerboard mask. Parameters ---------- column_distance : int Column distance of the enabled pixels. row_distance : int Row distance of the enabled pixels. column_offset : int Additional column offset which shifts the columns by the given amount...
[ "Generate", "chessboard", "/", "checkerboard", "mask", ".", "Parameters", "----------", "column_distance", ":", "int", "Column", "distance", "of", "the", "enabled", "pixels", ".", "row_distance", ":", "int", "Row", "distance", "of", "the", "enabled", "pixels", "...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L844-L886
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
scan_loop
def scan_loop(self, command, repeat_command=100, use_delay=True, additional_delay=0, mask_steps=3, enable_mask_steps=None, enable_double_columns=None, same_mask_for_all_dc=False, fast_dc_loop=True, bol_function=None, eol_function=None, digital_injection=False, enable_shift_masks=None, disable_shift_masks=None, restore_...
python
def scan_loop(self, command, repeat_command=100, use_delay=True, additional_delay=0, mask_steps=3, enable_mask_steps=None, enable_double_columns=None, same_mask_for_all_dc=False, fast_dc_loop=True, bol_function=None, eol_function=None, digital_injection=False, enable_shift_masks=None, disable_shift_masks=None, restore_...
[ "def", "scan_loop", "(", "self", ",", "command", ",", "repeat_command", "=", "100", ",", "use_delay", "=", "True", ",", "additional_delay", "=", "0", ",", "mask_steps", "=", "3", ",", "enable_mask_steps", "=", "None", ",", "enable_double_columns", "=", "None...
Implementation of the scan loops (mask shifting, loop over double columns, repeatedly sending any arbitrary command). Parameters ---------- command : BitVector (FEI4) command that will be sent out serially. repeat_command : int The number of repetitions command will be sent out e...
[ "Implementation", "of", "the", "scan", "loops", "(", "mask", "shifting", "loop", "over", "double", "columns", "repeatedly", "sending", "any", "arbitrary", "command", ")", ".", "Parameters", "----------", "command", ":", "BitVector", "(", "FEI4", ")", "command", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L913-L1252
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
FEI4RegisterUtils.reset_service_records
def reset_service_records(self): '''Resetting Service Records This will reset Service Record counters. This will also bring back alive some FE where the output FIFO is stuck (no data is coming out in run mode). This should be only issued after power up and in the case of a stuck FIFO, other...
python
def reset_service_records(self): '''Resetting Service Records This will reset Service Record counters. This will also bring back alive some FE where the output FIFO is stuck (no data is coming out in run mode). This should be only issued after power up and in the case of a stuck FIFO, other...
[ "def", "reset_service_records", "(", "self", ")", ":", "logging", ".", "info", "(", "'Resetting Service Records'", ")", "commands", "=", "[", "]", "commands", ".", "extend", "(", "self", ".", "register", ".", "get_commands", "(", "\"ConfMode\"", ")", ")", "s...
Resetting Service Records This will reset Service Record counters. This will also bring back alive some FE where the output FIFO is stuck (no data is coming out in run mode). This should be only issued after power up and in the case of a stuck FIFO, otherwise the BCID counter starts jumping.
[ "Resetting", "Service", "Records", "This", "will", "reset", "Service", "Record", "counters", ".", "This", "will", "also", "bring", "back", "alive", "some", "FE", "where", "the", "output", "FIFO", "is", "stuck", "(", "no", "data", "is", "coming", "out", "in...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L164-L180
SiLab-Bonn/pyBAR
pybar/fei4/register_utils.py
FEI4RegisterUtils.reset_bunch_counter
def reset_bunch_counter(self): '''Resetting Bunch Counter ''' logging.info('Resetting Bunch Counter') commands = [] commands.extend(self.register.get_commands("RunMode")) commands.extend(self.register.get_commands("BCR")) self.send_commands(commands) ...
python
def reset_bunch_counter(self): '''Resetting Bunch Counter ''' logging.info('Resetting Bunch Counter') commands = [] commands.extend(self.register.get_commands("RunMode")) commands.extend(self.register.get_commands("BCR")) self.send_commands(commands) ...
[ "def", "reset_bunch_counter", "(", "self", ")", ":", "logging", ".", "info", "(", "'Resetting Bunch Counter'", ")", "commands", "=", "[", "]", "commands", ".", "extend", "(", "self", ".", "register", ".", "get_commands", "(", "\"RunMode\"", ")", ")", "comman...
Resetting Bunch Counter
[ "Resetting", "Bunch", "Counter" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register_utils.py#L182-L193
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
generate_threshold_mask
def generate_threshold_mask(hist): '''Masking array elements when equal 0.0 or greater than 10 times the median Parameters ---------- hist : array_like Input data. Returns ------- masked array Returns copy of the array with masked elements. ''' masked_array = np.ma....
python
def generate_threshold_mask(hist): '''Masking array elements when equal 0.0 or greater than 10 times the median Parameters ---------- hist : array_like Input data. Returns ------- masked array Returns copy of the array with masked elements. ''' masked_array = np.ma....
[ "def", "generate_threshold_mask", "(", "hist", ")", ":", "masked_array", "=", "np", ".", "ma", ".", "masked_values", "(", "hist", ",", "0", ")", "masked_array", "=", "np", ".", "ma", ".", "masked_greater", "(", "masked_array", ",", "10", "*", "np", ".", ...
Masking array elements when equal 0.0 or greater than 10 times the median Parameters ---------- hist : array_like Input data. Returns ------- masked array Returns copy of the array with masked elements.
[ "Masking", "array", "elements", "when", "equal", "0", ".", "0", "or", "greater", "than", "10", "times", "the", "median" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L50-L66
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
unique_row
def unique_row(array, use_columns=None, selected_columns_only=False): '''Takes a numpy array and returns the array reduced to unique rows. If columns are defined only these columns are taken to define a unique row. The returned array can have all columns of the original array or only the columns defined in use_...
python
def unique_row(array, use_columns=None, selected_columns_only=False): '''Takes a numpy array and returns the array reduced to unique rows. If columns are defined only these columns are taken to define a unique row. The returned array can have all columns of the original array or only the columns defined in use_...
[ "def", "unique_row", "(", "array", ",", "use_columns", "=", "None", ",", "selected_columns_only", "=", "False", ")", ":", "if", "array", ".", "dtype", ".", "names", "is", "None", ":", "# normal array has no named dtype", "if", "use_columns", "is", "not", "None...
Takes a numpy array and returns the array reduced to unique rows. If columns are defined only these columns are taken to define a unique row. The returned array can have all columns of the original array or only the columns defined in use_columns. Parameters ---------- array : numpy.ndarray use_colu...
[ "Takes", "a", "numpy", "array", "and", "returns", "the", "array", "reduced", "to", "unique", "rows", ".", "If", "columns", "are", "defined", "only", "these", "columns", "are", "taken", "to", "define", "a", "unique", "row", ".", "The", "returned", "array", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L69-L108
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_ranges_from_array
def get_ranges_from_array(arr, append_last=True): '''Takes an array and calculates ranges [start, stop[. The last range end is none to keep the same length. Parameters ---------- arr : array like append_last: bool If True, append item with a pair of last array item and None. Returns ...
python
def get_ranges_from_array(arr, append_last=True): '''Takes an array and calculates ranges [start, stop[. The last range end is none to keep the same length. Parameters ---------- arr : array like append_last: bool If True, append item with a pair of last array item and None. Returns ...
[ "def", "get_ranges_from_array", "(", "arr", ",", "append_last", "=", "True", ")", ":", "right", "=", "arr", "[", "1", ":", "]", "if", "append_last", ":", "left", "=", "arr", "[", ":", "]", "right", "=", "np", ".", "append", "(", "right", ",", "None...
Takes an array and calculates ranges [start, stop[. The last range end is none to keep the same length. Parameters ---------- arr : array like append_last: bool If True, append item with a pair of last array item and None. Returns ------- numpy.array The array formed by pai...
[ "Takes", "an", "array", "and", "calculates", "ranges", "[", "start", "stop", "[", ".", "The", "last", "range", "end", "is", "none", "to", "keep", "the", "same", "length", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L111-L144
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
in1d_sorted
def in1d_sorted(ar1, ar2): """ Does the same than np.in1d but uses the fact that ar1 and ar2 are sorted. Is therefore much faster. """ if ar1.shape[0] == 0 or ar2.shape[0] == 0: # check for empty arrays to avoid crash return [] inds = ar2.searchsorted(ar1) inds[inds == len(ar2)] = 0 ...
python
def in1d_sorted(ar1, ar2): """ Does the same than np.in1d but uses the fact that ar1 and ar2 are sorted. Is therefore much faster. """ if ar1.shape[0] == 0 or ar2.shape[0] == 0: # check for empty arrays to avoid crash return [] inds = ar2.searchsorted(ar1) inds[inds == len(ar2)] = 0 ...
[ "def", "in1d_sorted", "(", "ar1", ",", "ar2", ")", ":", "if", "ar1", ".", "shape", "[", "0", "]", "==", "0", "or", "ar2", ".", "shape", "[", "0", "]", "==", "0", ":", "# check for empty arrays to avoid crash", "return", "[", "]", "inds", "=", "ar2", ...
Does the same than np.in1d but uses the fact that ar1 and ar2 are sorted. Is therefore much faster.
[ "Does", "the", "same", "than", "np", ".", "in1d", "but", "uses", "the", "fact", "that", "ar1", "and", "ar2", "are", "sorted", ".", "Is", "therefore", "much", "faster", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L159-L168
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
central_difference
def central_difference(x, y): '''Returns the dy/dx(x) via central difference method Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like ''' if (len(x) != len(y)): raise ValueError("x, y must have the same length") z1 = np.hstack((y...
python
def central_difference(x, y): '''Returns the dy/dx(x) via central difference method Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like ''' if (len(x) != len(y)): raise ValueError("x, y must have the same length") z1 = np.hstack((y...
[ "def", "central_difference", "(", "x", ",", "y", ")", ":", "if", "(", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ")", ":", "raise", "ValueError", "(", "\"x, y must have the same length\"", ")", "z1", "=", "np", ".", "hstack", "(", "(", "y", ...
Returns the dy/dx(x) via central difference method Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like
[ "Returns", "the", "dy", "/", "dx", "(", "x", ")", "via", "central", "difference", "method" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L171-L189
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_profile_histogram
def get_profile_histogram(x, y, n_bins=100): '''Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates the y mean for every bin at the bin center and gives the y mean error as error bars. Parameters ---------- x : array like data x positions...
python
def get_profile_histogram(x, y, n_bins=100): '''Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates the y mean for every bin at the bin center and gives the y mean error as error bars. Parameters ---------- x : array like data x positions...
[ "def", "get_profile_histogram", "(", "x", ",", "y", ",", "n_bins", "=", "100", ")", ":", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "raise", "ValueError", "(", "'x and y dimensions have to be the same'", ")", "y", "=", "y", ".", "asty...
Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates the y mean for every bin at the bin center and gives the y mean error as error bars. Parameters ---------- x : array like data x positions y : array like data y positions n_b...
[ "Takes", "2D", "point", "data", "(", "x", "y", ")", "and", "creates", "a", "profile", "histogram", "similar", "to", "the", "TProfile", "in", "ROOT", ".", "It", "calculates", "the", "y", "mean", "for", "every", "bin", "at", "the", "bin", "center", "and"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L192-L217
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_rate_normalization
def get_rate_normalization(hit_file, parameter, reference='event', cluster_file=None, plot=False, chunk_size=500000): ''' Takes different hit files (hit_files), extracts the number of events or the scan time (reference) per scan parameter (parameter) and returns an array with a normalization factor. This normal...
python
def get_rate_normalization(hit_file, parameter, reference='event', cluster_file=None, plot=False, chunk_size=500000): ''' Takes different hit files (hit_files), extracts the number of events or the scan time (reference) per scan parameter (parameter) and returns an array with a normalization factor. This normal...
[ "def", "get_rate_normalization", "(", "hit_file", ",", "parameter", ",", "reference", "=", "'event'", ",", "cluster_file", "=", "None", ",", "plot", "=", "False", ",", "chunk_size", "=", "500000", ")", ":", "logging", ".", "info", "(", "'Calculate the rate nor...
Takes different hit files (hit_files), extracts the number of events or the scan time (reference) per scan parameter (parameter) and returns an array with a normalization factor. This normalization factor has the length of the number of different parameters. If a cluster_file is specified also the number of clu...
[ "Takes", "different", "hit", "files", "(", "hit_files", ")", "extracts", "the", "number", "of", "events", "or", "the", "scan", "time", "(", "reference", ")", "per", "scan", "parameter", "(", "parameter", ")", "and", "returns", "an", "array", "with", "a", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L220-L300
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_parameter_value_from_file_names
def get_parameter_value_from_file_names(files, parameters=None, unique=False, sort=True): """ Takes a list of files, searches for the parameter name in the file name and returns a ordered dict with the file name in the first dimension and the corresponding parameter value in the second. The file names c...
python
def get_parameter_value_from_file_names(files, parameters=None, unique=False, sort=True): """ Takes a list of files, searches for the parameter name in the file name and returns a ordered dict with the file name in the first dimension and the corresponding parameter value in the second. The file names c...
[ "def", "get_parameter_value_from_file_names", "(", "files", ",", "parameters", "=", "None", ",", "unique", "=", "False", ",", "sort", "=", "True", ")", ":", "# unique=False", "logging", ".", "debug", "(", "'Get the parameter: '", "+", "str", "(", "parameters...
Takes a list of files, searches for the parameter name in the file name and returns a ordered dict with the file name in the first dimension and the corresponding parameter value in the second. The file names can be sorted by the parameter value, otherwise the order is kept. If unique is true every parameter is...
[ "Takes", "a", "list", "of", "files", "searches", "for", "the", "parameter", "name", "in", "the", "file", "name", "and", "returns", "a", "ordered", "dict", "with", "the", "file", "name", "in", "the", "first", "dimension", "and", "the", "corresponding", "par...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L361-L404
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_data_file_names_from_scan_base
def get_data_file_names_from_scan_base(scan_base, filter_str=['_analyzed.h5', '_interpreted.h5', '_cut.h5', '_result.h5', '_hists.h5'], sort_by_time=True, meta_data_v2=True): """ Generate a list of .h5 files which have a similar file name. Parameters ---------- scan_base : list, string List...
python
def get_data_file_names_from_scan_base(scan_base, filter_str=['_analyzed.h5', '_interpreted.h5', '_cut.h5', '_result.h5', '_hists.h5'], sort_by_time=True, meta_data_v2=True): """ Generate a list of .h5 files which have a similar file name. Parameters ---------- scan_base : list, string List...
[ "def", "get_data_file_names_from_scan_base", "(", "scan_base", ",", "filter_str", "=", "[", "'_analyzed.h5'", ",", "'_interpreted.h5'", ",", "'_cut.h5'", ",", "'_result.h5'", ",", "'_hists.h5'", "]", ",", "sort_by_time", "=", "True", ",", "meta_data_v2", "=", "True"...
Generate a list of .h5 files which have a similar file name. Parameters ---------- scan_base : list, string List of string or string of the scan base names. The scan_base will be used to search for files containing the string. The .h5 file extension will be added automatically. filter : list, s...
[ "Generate", "a", "list", "of", ".", "h5", "files", "which", "have", "a", "similar", "file", "name", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L407-L462
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_parameter_from_files
def get_parameter_from_files(files, parameters=None, unique=False, sort=True): ''' Takes a list of files, searches for the parameter name in the file name and in the file. Returns a ordered dict with the file name in the first dimension and the corresponding parameter values in the second. If a scan paramet...
python
def get_parameter_from_files(files, parameters=None, unique=False, sort=True): ''' Takes a list of files, searches for the parameter name in the file name and in the file. Returns a ordered dict with the file name in the first dimension and the corresponding parameter values in the second. If a scan paramet...
[ "def", "get_parameter_from_files", "(", "files", ",", "parameters", "=", "None", ",", "unique", "=", "False", ",", "sort", "=", "True", ")", ":", "logging", ".", "debug", "(", "'Get the parameter '", "+", "str", "(", "parameters", ")", "+", "' values from '"...
Takes a list of files, searches for the parameter name in the file name and in the file. Returns a ordered dict with the file name in the first dimension and the corresponding parameter values in the second. If a scan parameter appears in the file name and in the file the first parameter setting has to be in th...
[ "Takes", "a", "list", "of", "files", "searches", "for", "the", "parameter", "name", "in", "the", "file", "name", "and", "in", "the", "file", ".", "Returns", "a", "ordered", "dict", "with", "the", "file", "name", "in", "the", "first", "dimension", "and", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L480-L555
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
check_parameter_similarity
def check_parameter_similarity(files_dict): """ Checks if the parameter names of all files are similar. Takes the dictionary from get_parameter_from_files output as input. """ try: parameter_names = files_dict.itervalues().next().keys() # get the parameter names of the first file, to check if ...
python
def check_parameter_similarity(files_dict): """ Checks if the parameter names of all files are similar. Takes the dictionary from get_parameter_from_files output as input. """ try: parameter_names = files_dict.itervalues().next().keys() # get the parameter names of the first file, to check if ...
[ "def", "check_parameter_similarity", "(", "files_dict", ")", ":", "try", ":", "parameter_names", "=", "files_dict", ".", "itervalues", "(", ")", ".", "next", "(", ")", ".", "keys", "(", ")", "# get the parameter names of the first file, to check if these are the same in...
Checks if the parameter names of all files are similar. Takes the dictionary from get_parameter_from_files output as input.
[ "Checks", "if", "the", "parameter", "names", "of", "all", "files", "are", "similar", ".", "Takes", "the", "dictionary", "from", "get_parameter_from_files", "output", "as", "input", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L558-L572
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
combine_meta_data
def combine_meta_data(files_dict, meta_data_v2=True): """ Takes the dict of hdf5 files and combines their meta data tables into one new numpy record array. Parameters ---------- meta_data_v2 : bool True for new (v2) meta data format, False for the old (v1) format. """ if len(files_d...
python
def combine_meta_data(files_dict, meta_data_v2=True): """ Takes the dict of hdf5 files and combines their meta data tables into one new numpy record array. Parameters ---------- meta_data_v2 : bool True for new (v2) meta data format, False for the old (v1) format. """ if len(files_d...
[ "def", "combine_meta_data", "(", "files_dict", ",", "meta_data_v2", "=", "True", ")", ":", "if", "len", "(", "files_dict", ")", ">", "10", ":", "logging", ".", "info", "(", "\"Combine the meta data from %d files\"", ",", "len", "(", "files_dict", ")", ")", "...
Takes the dict of hdf5 files and combines their meta data tables into one new numpy record array. Parameters ---------- meta_data_v2 : bool True for new (v2) meta data format, False for the old (v1) format.
[ "Takes", "the", "dict", "of", "hdf5", "files", "and", "combines", "their", "meta", "data", "tables", "into", "one", "new", "numpy", "record", "array", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L575-L624
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
smooth_differentiation
def smooth_differentiation(x, y, weigths=None, order=5, smoothness=3, derivation=1): '''Returns the dy/dx(x) with the fit and differentiation of a spline curve Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like ''' if (len(x) != len(y)): ...
python
def smooth_differentiation(x, y, weigths=None, order=5, smoothness=3, derivation=1): '''Returns the dy/dx(x) with the fit and differentiation of a spline curve Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like ''' if (len(x) != len(y)): ...
[ "def", "smooth_differentiation", "(", "x", ",", "y", ",", "weigths", "=", "None", ",", "order", "=", "5", ",", "smoothness", "=", "3", ",", "derivation", "=", "1", ")", ":", "if", "(", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ")", ":",...
Returns the dy/dx(x) with the fit and differentiation of a spline curve Parameters ---------- x : array like y : array like Returns ------- dy/dx : array like
[ "Returns", "the", "dy", "/", "dx", "(", "x", ")", "with", "the", "fit", "and", "differentiation", "of", "a", "spline", "curve" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L627-L642
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
reduce_sorted_to_intersect
def reduce_sorted_to_intersect(ar1, ar2): """ Takes two sorted arrays and return the intersection ar1 in ar2, ar2 in ar1. Parameters ---------- ar1 : (M,) array_like Input array. ar2 : array_like Input array. Returns ------- ar1, ar1 : ndarray, ndarray The ...
python
def reduce_sorted_to_intersect(ar1, ar2): """ Takes two sorted arrays and return the intersection ar1 in ar2, ar2 in ar1. Parameters ---------- ar1 : (M,) array_like Input array. ar2 : array_like Input array. Returns ------- ar1, ar1 : ndarray, ndarray The ...
[ "def", "reduce_sorted_to_intersect", "(", "ar1", ",", "ar2", ")", ":", "# Ravel both arrays, behavior for the first array could be different", "ar1", "=", "np", ".", "asarray", "(", "ar1", ")", ".", "ravel", "(", ")", "ar2", "=", "np", ".", "asarray", "(", "ar2"...
Takes two sorted arrays and return the intersection ar1 in ar2, ar2 in ar1. Parameters ---------- ar1 : (M,) array_like Input array. ar2 : array_like Input array. Returns ------- ar1, ar1 : ndarray, ndarray The intersection values.
[ "Takes", "two", "sorted", "arrays", "and", "return", "the", "intersection", "ar1", "in", "ar2", "ar2", "in", "ar1", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L645-L691
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_not_unique_values
def get_not_unique_values(array): '''Returns the values that appear at least twice in array. Parameters ---------- array : array like Returns ------- numpy.array ''' s = np.sort(array, axis=None) s = s[s[1:] == s[:-1]] return np.unique(s)
python
def get_not_unique_values(array): '''Returns the values that appear at least twice in array. Parameters ---------- array : array like Returns ------- numpy.array ''' s = np.sort(array, axis=None) s = s[s[1:] == s[:-1]] return np.unique(s)
[ "def", "get_not_unique_values", "(", "array", ")", ":", "s", "=", "np", ".", "sort", "(", "array", ",", "axis", "=", "None", ")", "s", "=", "s", "[", "s", "[", "1", ":", "]", "==", "s", "[", ":", "-", "1", "]", "]", "return", "np", ".", "un...
Returns the values that appear at least twice in array. Parameters ---------- array : array like Returns ------- numpy.array
[ "Returns", "the", "values", "that", "appear", "at", "least", "twice", "in", "array", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L694-L707
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_meta_data_index_at_scan_parameter
def get_meta_data_index_at_scan_parameter(meta_data_array, scan_parameter_name): '''Takes the analyzed meta_data table and returns the indices where the scan parameter changes Parameters ---------- meta_data_array : numpy.recordarray scan_parameter_name : string Returns ------- numpy.n...
python
def get_meta_data_index_at_scan_parameter(meta_data_array, scan_parameter_name): '''Takes the analyzed meta_data table and returns the indices where the scan parameter changes Parameters ---------- meta_data_array : numpy.recordarray scan_parameter_name : string Returns ------- numpy.n...
[ "def", "get_meta_data_index_at_scan_parameter", "(", "meta_data_array", ",", "scan_parameter_name", ")", ":", "scan_parameter_values", "=", "meta_data_array", "[", "scan_parameter_name", "]", "diff", "=", "np", ".", "concatenate", "(", "(", "[", "1", "]", ",", "np",...
Takes the analyzed meta_data table and returns the indices where the scan parameter changes Parameters ---------- meta_data_array : numpy.recordarray scan_parameter_name : string Returns ------- numpy.ndarray: first dimension: scan parameter value second dimension: index wh...
[ "Takes", "the", "analyzed", "meta_data", "table", "and", "returns", "the", "indices", "where", "the", "scan", "parameter", "changes" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L710-L730
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
select_hits
def select_hits(hits_array, condition=None): '''Selects the hits with condition. E.g.: condition = 'rel_BCID == 7 & event_number < 1000' Parameters ---------- hits_array : numpy.array condition : string A condition that is applied to the hits in numexpr. Only if the expression evaluates...
python
def select_hits(hits_array, condition=None): '''Selects the hits with condition. E.g.: condition = 'rel_BCID == 7 & event_number < 1000' Parameters ---------- hits_array : numpy.array condition : string A condition that is applied to the hits in numexpr. Only if the expression evaluates...
[ "def", "select_hits", "(", "hits_array", ",", "condition", "=", "None", ")", ":", "if", "condition", "is", "None", ":", "return", "hits_array", "for", "variable", "in", "set", "(", "re", ".", "findall", "(", "r'[a-zA-Z_]+'", ",", "condition", ")", ")", "...
Selects the hits with condition. E.g.: condition = 'rel_BCID == 7 & event_number < 1000' Parameters ---------- hits_array : numpy.array condition : string A condition that is applied to the hits in numexpr. Only if the expression evaluates to True the hit is taken. Returns ------- ...
[ "Selects", "the", "hits", "with", "condition", ".", "E", ".", "g", ".", ":", "condition", "=", "rel_BCID", "==", "7", "&", "event_number", "<", "1000" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L749-L770
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_hits_in_events
def get_hits_in_events(hits_array, events, assume_sorted=True, condition=None): '''Selects the hits that occurred in events and optional selection criterion. If a event range can be defined use the get_data_in_event_range function. It is much faster. Parameters ---------- hits_array : numpy.arr...
python
def get_hits_in_events(hits_array, events, assume_sorted=True, condition=None): '''Selects the hits that occurred in events and optional selection criterion. If a event range can be defined use the get_data_in_event_range function. It is much faster. Parameters ---------- hits_array : numpy.arr...
[ "def", "get_hits_in_events", "(", "hits_array", ",", "events", ",", "assume_sorted", "=", "True", ",", "condition", "=", "None", ")", ":", "logging", ".", "debug", "(", "\"Calculate hits that exists in the given %d events.\"", "%", "len", "(", "events", ")", ")", ...
Selects the hits that occurred in events and optional selection criterion. If a event range can be defined use the get_data_in_event_range function. It is much faster. Parameters ---------- hits_array : numpy.array events : array assume_sorted : bool Is true if the events to select ...
[ "Selects", "the", "hits", "that", "occurred", "in", "events", "and", "optional", "selection", "criterion", ".", "If", "a", "event", "range", "can", "be", "defined", "use", "the", "get_data_in_event_range", "function", ".", "It", "is", "much", "faster", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L773-L814
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_hits_of_scan_parameter
def get_hits_of_scan_parameter(input_file_hits, scan_parameters=None, try_speedup=False, chunk_size=10000000): '''Takes the hit table of a hdf5 file and returns hits in chunks for each unique combination of scan_parameters. Yields the hits in chunks, since they usually do not fit into memory. Parameters ...
python
def get_hits_of_scan_parameter(input_file_hits, scan_parameters=None, try_speedup=False, chunk_size=10000000): '''Takes the hit table of a hdf5 file and returns hits in chunks for each unique combination of scan_parameters. Yields the hits in chunks, since they usually do not fit into memory. Parameters ...
[ "def", "get_hits_of_scan_parameter", "(", "input_file_hits", ",", "scan_parameters", "=", "None", ",", "try_speedup", "=", "False", ",", "chunk_size", "=", "10000000", ")", ":", "with", "tb", ".", "open_file", "(", "input_file_hits", ",", "mode", "=", "\"r+\"", ...
Takes the hit table of a hdf5 file and returns hits in chunks for each unique combination of scan_parameters. Yields the hits in chunks, since they usually do not fit into memory. Parameters ---------- input_file_hits : pytable hdf5 file Has to include a hits node scan_parameters : iterable...
[ "Takes", "the", "hit", "table", "of", "a", "hdf5", "file", "and", "returns", "hits", "in", "chunks", "for", "each", "unique", "combination", "of", "scan_parameters", ".", "Yields", "the", "hits", "in", "chunks", "since", "they", "usually", "do", "not", "fi...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L817-L859
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_data_in_event_range
def get_data_in_event_range(array, event_start=None, event_stop=None, assume_sorted=True): '''Selects the data (rows of a table) that occurred in the given event range [event_start, event_stop[ Parameters ---------- array : numpy.array event_start : int, None event_stop : int, None assume_s...
python
def get_data_in_event_range(array, event_start=None, event_stop=None, assume_sorted=True): '''Selects the data (rows of a table) that occurred in the given event range [event_start, event_stop[ Parameters ---------- array : numpy.array event_start : int, None event_stop : int, None assume_s...
[ "def", "get_data_in_event_range", "(", "array", ",", "event_start", "=", "None", ",", "event_stop", "=", "None", ",", "assume_sorted", "=", "True", ")", ":", "logging", ".", "debug", "(", "\"Calculate data of the the given event range [\"", "+", "str", "(", "event...
Selects the data (rows of a table) that occurred in the given event range [event_start, event_stop[ Parameters ---------- array : numpy.array event_start : int, None event_stop : int, None assume_sorted : bool Set to true if the hits are sorted by the event_number. Increases speed. ...
[ "Selects", "the", "data", "(", "rows", "of", "a", "table", ")", "that", "occurred", "in", "the", "given", "event", "range", "[", "event_start", "event_stop", "[" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L862-L903
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
write_hits_in_events
def write_hits_in_events(hit_table_in, hit_table_out, events, start_hit_word=0, chunk_size=5000000, condition=None): '''Selects the hits that occurred in events and writes them to a pytable. This function reduces the in RAM operations and has to be used if the get_hits_in_events function raises a memory error. ...
python
def write_hits_in_events(hit_table_in, hit_table_out, events, start_hit_word=0, chunk_size=5000000, condition=None): '''Selects the hits that occurred in events and writes them to a pytable. This function reduces the in RAM operations and has to be used if the get_hits_in_events function raises a memory error. ...
[ "def", "write_hits_in_events", "(", "hit_table_in", ",", "hit_table_out", ",", "events", ",", "start_hit_word", "=", "0", ",", "chunk_size", "=", "5000000", ",", "condition", "=", "None", ")", ":", "if", "len", "(", "events", ")", ">", "0", ":", "# needed ...
Selects the hits that occurred in events and writes them to a pytable. This function reduces the in RAM operations and has to be used if the get_hits_in_events function raises a memory error. Also a condition can be set to select hits. Parameters ---------- hit_table_in : pytable.table hit_table_ou...
[ "Selects", "the", "hits", "that", "occurred", "in", "events", "and", "writes", "them", "to", "a", "pytable", ".", "This", "function", "reduces", "the", "in", "RAM", "operations", "and", "has", "to", "be", "used", "if", "the", "get_hits_in_events", "function"...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L906-L941
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
write_hits_in_event_range
def write_hits_in_event_range(hit_table_in, hit_table_out, event_start=None, event_stop=None, start_hit_word=0, chunk_size=5000000, condition=None): '''Selects the hits that occurred in given event range [event_start, event_stop[ and write them to a pytable. This function reduces the in RAM operations and ha...
python
def write_hits_in_event_range(hit_table_in, hit_table_out, event_start=None, event_stop=None, start_hit_word=0, chunk_size=5000000, condition=None): '''Selects the hits that occurred in given event range [event_start, event_stop[ and write them to a pytable. This function reduces the in RAM operations and ha...
[ "def", "write_hits_in_event_range", "(", "hit_table_in", ",", "hit_table_out", ",", "event_start", "=", "None", ",", "event_stop", "=", "None", ",", "start_hit_word", "=", "0", ",", "chunk_size", "=", "5000000", ",", "condition", "=", "None", ")", ":", "loggin...
Selects the hits that occurred in given event range [event_start, event_stop[ and write them to a pytable. This function reduces the in RAM operations and has to be used if the get_data_in_event_range function raises a memory error. Also a condition can be set to select hits. Parameters ---------- h...
[ "Selects", "the", "hits", "that", "occurred", "in", "given", "event", "range", "[", "event_start", "event_stop", "[", "and", "write", "them", "to", "a", "pytable", ".", "This", "function", "reduces", "the", "in", "RAM", "operations", "and", "has", "to", "b...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L944-L979
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_events_with_n_cluster
def get_events_with_n_cluster(event_number, condition='n_cluster==1'): '''Selects the events with a certain number of cluster. Parameters ---------- event_number : numpy.array Returns ------- numpy.array ''' logging.debug("Calculate events with clusters where " + condition) n_...
python
def get_events_with_n_cluster(event_number, condition='n_cluster==1'): '''Selects the events with a certain number of cluster. Parameters ---------- event_number : numpy.array Returns ------- numpy.array ''' logging.debug("Calculate events with clusters where " + condition) n_...
[ "def", "get_events_with_n_cluster", "(", "event_number", ",", "condition", "=", "'n_cluster==1'", ")", ":", "logging", ".", "debug", "(", "\"Calculate events with clusters where \"", "+", "condition", ")", "n_cluster_in_events", "=", "analysis_utils", ".", "get_n_cluster_...
Selects the events with a certain number of cluster. Parameters ---------- event_number : numpy.array Returns ------- numpy.array
[ "Selects", "the", "events", "with", "a", "certain", "number", "of", "cluster", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L982-L998
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_events_with_cluster_size
def get_events_with_cluster_size(event_number, cluster_size, condition='cluster_size==1'): '''Selects the events with cluster of a given cluster size. Parameters ---------- event_number : numpy.array cluster_size : numpy.array condition : string Returns ------- numpy.array ''' ...
python
def get_events_with_cluster_size(event_number, cluster_size, condition='cluster_size==1'): '''Selects the events with cluster of a given cluster size. Parameters ---------- event_number : numpy.array cluster_size : numpy.array condition : string Returns ------- numpy.array ''' ...
[ "def", "get_events_with_cluster_size", "(", "event_number", ",", "cluster_size", ",", "condition", "=", "'cluster_size==1'", ")", ":", "logging", ".", "debug", "(", "\"Calculate events with clusters with \"", "+", "condition", ")", "return", "np", ".", "unique", "(", ...
Selects the events with cluster of a given cluster size. Parameters ---------- event_number : numpy.array cluster_size : numpy.array condition : string Returns ------- numpy.array
[ "Selects", "the", "events", "with", "cluster", "of", "a", "given", "cluster", "size", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1001-L1016
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_events_with_error_code
def get_events_with_error_code(event_number, event_status, select_mask=0b1111111111111111, condition=0b0000000000000000): '''Selects the events with a certain error code. Parameters ---------- event_number : numpy.array event_status : numpy.array select_mask : int The mask that selects ...
python
def get_events_with_error_code(event_number, event_status, select_mask=0b1111111111111111, condition=0b0000000000000000): '''Selects the events with a certain error code. Parameters ---------- event_number : numpy.array event_status : numpy.array select_mask : int The mask that selects ...
[ "def", "get_events_with_error_code", "(", "event_number", ",", "event_status", ",", "select_mask", "=", "0b1111111111111111", ",", "condition", "=", "0b0000000000000000", ")", ":", "logging", ".", "debug", "(", "\"Calculate events with certain error code\"", ")", "return"...
Selects the events with a certain error code. Parameters ---------- event_number : numpy.array event_status : numpy.array select_mask : int The mask that selects the event error code to check. condition : int The value the selected event error code should have. Returns ...
[ "Selects", "the", "events", "with", "a", "certain", "error", "code", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1019-L1037
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_scan_parameter
def get_scan_parameter(meta_data_array, unique=True): '''Takes the numpy meta data array and returns the different scan parameter settings and the name aligned in a dictionary Parameters ---------- meta_data_array : numpy.ndarray unique: boolean If true only unique values for each scan para...
python
def get_scan_parameter(meta_data_array, unique=True): '''Takes the numpy meta data array and returns the different scan parameter settings and the name aligned in a dictionary Parameters ---------- meta_data_array : numpy.ndarray unique: boolean If true only unique values for each scan para...
[ "def", "get_scan_parameter", "(", "meta_data_array", ",", "unique", "=", "True", ")", ":", "try", ":", "last_not_parameter_column", "=", "meta_data_array", ".", "dtype", ".", "names", ".", "index", "(", "'error_code'", ")", "# for interpreted meta_data", "except", ...
Takes the numpy meta data array and returns the different scan parameter settings and the name aligned in a dictionary Parameters ---------- meta_data_array : numpy.ndarray unique: boolean If true only unique values for each scan parameter are returned Returns ------- python.dict{s...
[ "Takes", "the", "numpy", "meta", "data", "array", "and", "returns", "the", "different", "scan", "parameter", "settings", "and", "the", "name", "aligned", "in", "a", "dictionary" ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1040-L1064
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_scan_parameters_table_from_meta_data
def get_scan_parameters_table_from_meta_data(meta_data_array, scan_parameters=None): '''Takes the meta data array and returns the scan parameter values as a view of a numpy array only containing the parameter data . Parameters ---------- meta_data_array : numpy.ndarray The array with the scan pa...
python
def get_scan_parameters_table_from_meta_data(meta_data_array, scan_parameters=None): '''Takes the meta data array and returns the scan parameter values as a view of a numpy array only containing the parameter data . Parameters ---------- meta_data_array : numpy.ndarray The array with the scan pa...
[ "def", "get_scan_parameters_table_from_meta_data", "(", "meta_data_array", ",", "scan_parameters", "=", "None", ")", ":", "if", "scan_parameters", "is", "None", ":", "try", ":", "last_not_parameter_column", "=", "meta_data_array", ".", "dtype", ".", "names", ".", "i...
Takes the meta data array and returns the scan parameter values as a view of a numpy array only containing the parameter data . Parameters ---------- meta_data_array : numpy.ndarray The array with the scan parameters. scan_parameters : list of strings The name of the scan parameters to t...
[ "Takes", "the", "meta", "data", "array", "and", "returns", "the", "scan", "parameter", "values", "as", "a", "view", "of", "a", "numpy", "array", "only", "containing", "the", "parameter", "data", ".", "Parameters", "----------", "meta_data_array", ":", "numpy",...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1067-L1095
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_scan_parameters_index
def get_scan_parameters_index(scan_parameter): '''Takes the scan parameter array and creates a scan parameter index labeling the unique scan parameter combinations. Parameters ---------- scan_parameter : numpy.ndarray The table with the scan parameters. Returns ------- numpy.Histogr...
python
def get_scan_parameters_index(scan_parameter): '''Takes the scan parameter array and creates a scan parameter index labeling the unique scan parameter combinations. Parameters ---------- scan_parameter : numpy.ndarray The table with the scan parameters. Returns ------- numpy.Histogr...
[ "def", "get_scan_parameters_index", "(", "scan_parameter", ")", ":", "_", ",", "index", "=", "np", ".", "unique", "(", "scan_parameter", ",", "return_index", "=", "True", ")", "index", "=", "np", ".", "sort", "(", "index", ")", "values", "=", "np", ".", ...
Takes the scan parameter array and creates a scan parameter index labeling the unique scan parameter combinations. Parameters ---------- scan_parameter : numpy.ndarray The table with the scan parameters. Returns ------- numpy.Histogram
[ "Takes", "the", "scan", "parameter", "array", "and", "creates", "a", "scan", "parameter", "index", "labeling", "the", "unique", "scan", "parameter", "combinations", ".", "Parameters", "----------", "scan_parameter", ":", "numpy", ".", "ndarray", "The", "table", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1098-L1114
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
get_unique_scan_parameter_combinations
def get_unique_scan_parameter_combinations(meta_data_array, scan_parameters=None, scan_parameter_columns_only=False): '''Takes the numpy meta data array and returns the first rows with unique combinations of different scan parameter values for selected scan parameters. If selected columns only is true, the ...
python
def get_unique_scan_parameter_combinations(meta_data_array, scan_parameters=None, scan_parameter_columns_only=False): '''Takes the numpy meta data array and returns the first rows with unique combinations of different scan parameter values for selected scan parameters. If selected columns only is true, the ...
[ "def", "get_unique_scan_parameter_combinations", "(", "meta_data_array", ",", "scan_parameters", "=", "None", ",", "scan_parameter_columns_only", "=", "False", ")", ":", "try", ":", "last_not_parameter_column", "=", "meta_data_array", ".", "dtype", ".", "names", ".", ...
Takes the numpy meta data array and returns the first rows with unique combinations of different scan parameter values for selected scan parameters. If selected columns only is true, the returned histogram only contains the selected columns. Parameters ---------- meta_data_array : numpy.ndarray ...
[ "Takes", "the", "numpy", "meta", "data", "array", "and", "returns", "the", "first", "rows", "with", "unique", "combinations", "of", "different", "scan", "parameter", "values", "for", "selected", "scan", "parameters", ".", "If", "selected", "columns", "only", "...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1117-L1149
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
data_aligned_at_events
def data_aligned_at_events(table, start_event_number=None, stop_event_number=None, start_index=None, stop_index=None, chunk_size=10000000, try_speedup=False, first_event_aligned=True, fail_on_missing_events=True): '''Takes the table with a event_number column and returns chunks with the size up to chunk_size. The c...
python
def data_aligned_at_events(table, start_event_number=None, stop_event_number=None, start_index=None, stop_index=None, chunk_size=10000000, try_speedup=False, first_event_aligned=True, fail_on_missing_events=True): '''Takes the table with a event_number column and returns chunks with the size up to chunk_size. The c...
[ "def", "data_aligned_at_events", "(", "table", ",", "start_event_number", "=", "None", ",", "stop_event_number", "=", "None", ",", "start_index", "=", "None", ",", "stop_index", "=", "None", ",", "chunk_size", "=", "10000000", ",", "try_speedup", "=", "False", ...
Takes the table with a event_number column and returns chunks with the size up to chunk_size. The chunks are chosen in a way that the events are not splitted. Additional parameters can be set to increase the readout speed. Events between a certain range can be selected. Also the start and the stop indices limit...
[ "Takes", "the", "table", "with", "a", "event_number", "column", "and", "returns", "chunks", "with", "the", "size", "up", "to", "chunk_size", ".", "The", "chunks", "are", "chosen", "in", "a", "way", "that", "the", "events", "are", "not", "splitted", ".", ...
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1160-L1320
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
select_good_pixel_region
def select_good_pixel_region(hits, col_span, row_span, min_cut_threshold=0.2, max_cut_threshold=2.0): '''Takes the hit array and masks all pixels with a certain occupancy. Parameters ---------- hits : array like If dim > 2 the additional dimensions are summed up. min_cut_threshold : float ...
python
def select_good_pixel_region(hits, col_span, row_span, min_cut_threshold=0.2, max_cut_threshold=2.0): '''Takes the hit array and masks all pixels with a certain occupancy. Parameters ---------- hits : array like If dim > 2 the additional dimensions are summed up. min_cut_threshold : float ...
[ "def", "select_good_pixel_region", "(", "hits", ",", "col_span", ",", "row_span", ",", "min_cut_threshold", "=", "0.2", ",", "max_cut_threshold", "=", "2.0", ")", ":", "hits", "=", "np", ".", "sum", "(", "hits", ",", "axis", "=", "(", "-", "1", ")", ")...
Takes the hit array and masks all pixels with a certain occupancy. Parameters ---------- hits : array like If dim > 2 the additional dimensions are summed up. min_cut_threshold : float A number to specify the minimum threshold, which pixel to take. Pixels are masked if occupancy...
[ "Takes", "the", "hit", "array", "and", "masks", "all", "pixels", "with", "a", "certain", "occupancy", "." ]
train
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1323-L1353