axon_sdk.visualization package

Submodules

axon_sdk.visualization.chronogram module

axon_sdk.visualization.chronogram.build_array(length, entry_points, fill_method='ffil')[source]

Build an array of specified length using the provided entry points.

Parameters:
  • length (int) – Desired length of the output array

  • entry_points (list) – List of tuples (x, t) where x is a value and t is an index

  • fill_method (str) – Method to fill missing values. Options are ‘zero’ or ‘ffill’ (forward fill)

Returns:

An array of the specified length with values at entry points and filled values elsewhere

Return type:

list

axon_sdk.visualization.chronogram.plot_chronogram(timesteps: list[float], voltage_log: dict[str, list[tuple]], spike_log: dict[str, list[float]])[source]

axon_sdk.visualization.server module

class axon_sdk.visualization.server.Handler(*args, **kwargs)[source]

Bases: SimpleHTTPRequestHandler

MessageClass

alias of HTTPMessage

address_string()

Return the client address.

copyfile(source, outputfile)

Copy all data between two file objects.

The SOURCE argument is a file object open for reading (or anything with a read() method) and the DESTINATION argument is a file object open for writing (or anything with a write() method).

The only reason for overriding this would be to change the block size or perhaps to replace newlines by CRLF – note however that this the default server uses this to copy binary data as well.

date_time_string(timestamp=None)

Return the current date and time formatted for a message header.

default_request_version = 'HTTP/0.9'
disable_nagle_algorithm = False
do_GET()[source]

Serve a GET request.

do_HEAD()

Serve a HEAD request.

end_headers()

Send the blank line ending the MIME headers.

error_content_type = 'text/html;charset=utf-8'
error_message_format = '<!DOCTYPE HTML>\n<html lang="en">\n    <head>\n        <meta charset="utf-8">\n        <title>Error response</title>\n    </head>\n    <body>\n        <h1>Error response</h1>\n        <p>Error code: %(code)d</p>\n        <p>Message: %(message)s.</p>\n        <p>Error code explanation: %(code)s - %(explain)s.</p>\n    </body>\n</html>\n'
extensions_map = {'.Z': 'application/octet-stream', '.bz2': 'application/x-bzip2', '.gz': 'application/gzip', '.xz': 'application/x-xz'}
finish()
flush_headers()
guess_type(path)

Guess the type of a file.

Argument is a PATH (a filename).

Return value is a string of the form type/subtype, usable for a MIME Content-type header.

The default implementation looks the file’s extension up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess.

handle()

Handle multiple requests if necessary.

handle_expect_100()

Decide what to do with an “Expect: 100-continue” header.

If the client is expecting a 100 Continue response, we must respond with either a 100 Continue or a final response before waiting for the request body. The default is to always respond with a 100 Continue. You can behave differently (for example, reject unauthorized requests) by overriding this method.

This method should either return True (possibly after sending a 100 Continue response) or send an error response and return False.

handle_one_request()

Handle a single HTTP request.

You normally don’t need to override this method; see the class __doc__ string for information on how to handle specific HTTP commands such as GET and POST.

list_directory(path)

Helper to produce a directory listing (absent index.html).

Return value is either a file object, or None (indicating an error). In either case, the headers are sent, making the interface the same as for send_head().

log_date_time_string()

Return the current time formatted for logging.

log_error(format, *args)

Log an error.

This is called when a request cannot be fulfilled. By default it passes the message on to log_message().

Arguments are the same as for log_message().

XXX This should go to the separate error log.

log_message(format, *args)

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

Unicode control characters are replaced with escaped hex before writing the output to stderr.

log_request(code='-', size='-')

Log an accepted request.

This is called by send_response().

monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
parse_request()

Parse a request (internal).

The request should be stored in self.raw_requestline; the results are in self.command, self.path, self.request_version and self.headers.

Return True for success, False for failure; on failure, any relevant error response has already been sent back.

protocol_version = 'HTTP/1.0'
rbufsize = -1
responses = {HTTPStatus.CONTINUE: ('Continue', 'Request received, please continue'), HTTPStatus.SWITCHING_PROTOCOLS: ('Switching Protocols', 'Switching to new protocol; obey Upgrade header'), HTTPStatus.PROCESSING: ('Processing', ''), HTTPStatus.EARLY_HINTS: ('Early Hints', ''), HTTPStatus.OK: ('OK', 'Request fulfilled, document follows'), HTTPStatus.CREATED: ('Created', 'Document created, URL follows'), HTTPStatus.ACCEPTED: ('Accepted', 'Request accepted, processing continues off-line'), HTTPStatus.NON_AUTHORITATIVE_INFORMATION: ('Non-Authoritative Information', 'Request fulfilled from cache'), HTTPStatus.NO_CONTENT: ('No Content', 'Request fulfilled, nothing follows'), HTTPStatus.RESET_CONTENT: ('Reset Content', 'Clear input form for further input'), HTTPStatus.PARTIAL_CONTENT: ('Partial Content', 'Partial content follows'), HTTPStatus.MULTI_STATUS: ('Multi-Status', ''), HTTPStatus.ALREADY_REPORTED: ('Already Reported', ''), HTTPStatus.IM_USED: ('IM Used', ''), HTTPStatus.MULTIPLE_CHOICES: ('Multiple Choices', 'Object has several resources -- see URI list'), HTTPStatus.MOVED_PERMANENTLY: ('Moved Permanently', 'Object moved permanently -- see URI list'), HTTPStatus.FOUND: ('Found', 'Object moved temporarily -- see URI list'), HTTPStatus.SEE_OTHER: ('See Other', 'Object moved -- see Method and URL list'), HTTPStatus.NOT_MODIFIED: ('Not Modified', 'Document has not changed since given time'), HTTPStatus.USE_PROXY: ('Use Proxy', 'You must use proxy specified in Location to access this resource'), HTTPStatus.TEMPORARY_REDIRECT: ('Temporary Redirect', 'Object moved temporarily -- see URI list'), HTTPStatus.PERMANENT_REDIRECT: ('Permanent Redirect', 'Object moved permanently -- see URI list'), HTTPStatus.BAD_REQUEST: ('Bad Request', 'Bad request syntax or unsupported method'), HTTPStatus.UNAUTHORIZED: ('Unauthorized', 'No permission -- see authorization schemes'), HTTPStatus.PAYMENT_REQUIRED: ('Payment Required', 'No payment -- see charging schemes'), HTTPStatus.FORBIDDEN: ('Forbidden', 'Request forbidden -- authorization will not help'), HTTPStatus.NOT_FOUND: ('Not Found', 'Nothing matches the given URI'), HTTPStatus.METHOD_NOT_ALLOWED: ('Method Not Allowed', 'Specified method is invalid for this resource'), HTTPStatus.NOT_ACCEPTABLE: ('Not Acceptable', 'URI not available in preferred format'), HTTPStatus.PROXY_AUTHENTICATION_REQUIRED: ('Proxy Authentication Required', 'You must authenticate with this proxy before proceeding'), HTTPStatus.REQUEST_TIMEOUT: ('Request Timeout', 'Request timed out; try again later'), HTTPStatus.CONFLICT: ('Conflict', 'Request conflict'), HTTPStatus.GONE: ('Gone', 'URI no longer exists and has been permanently removed'), HTTPStatus.LENGTH_REQUIRED: ('Length Required', 'Client must specify Content-Length'), HTTPStatus.PRECONDITION_FAILED: ('Precondition Failed', 'Precondition in headers is false'), HTTPStatus.REQUEST_ENTITY_TOO_LARGE: ('Request Entity Too Large', 'Entity is too large'), HTTPStatus.REQUEST_URI_TOO_LONG: ('Request-URI Too Long', 'URI is too long'), HTTPStatus.UNSUPPORTED_MEDIA_TYPE: ('Unsupported Media Type', 'Entity body in unsupported format'), HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE: ('Requested Range Not Satisfiable', 'Cannot satisfy request range'), HTTPStatus.EXPECTATION_FAILED: ('Expectation Failed', 'Expect condition could not be satisfied'), HTTPStatus.IM_A_TEAPOT: ("I'm a Teapot", 'Server refuses to brew coffee because it is a teapot.'), HTTPStatus.MISDIRECTED_REQUEST: ('Misdirected Request', 'Server is not able to produce a response'), HTTPStatus.UNPROCESSABLE_ENTITY: ('Unprocessable Entity', ''), HTTPStatus.LOCKED: ('Locked', ''), HTTPStatus.FAILED_DEPENDENCY: ('Failed Dependency', ''), HTTPStatus.TOO_EARLY: ('Too Early', ''), HTTPStatus.UPGRADE_REQUIRED: ('Upgrade Required', ''), HTTPStatus.PRECONDITION_REQUIRED: ('Precondition Required', 'The origin server requires the request to be conditional'), HTTPStatus.TOO_MANY_REQUESTS: ('Too Many Requests', 'The user has sent too many requests in a given amount of time ("rate limiting")'), HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE: ('Request Header Fields Too Large', 'The server is unwilling to process the request because its header fields are too large'), HTTPStatus.UNAVAILABLE_FOR_LEGAL_REASONS: ('Unavailable For Legal Reasons', 'The server is denying access to the resource as a consequence of a legal demand'), HTTPStatus.INTERNAL_SERVER_ERROR: ('Internal Server Error', 'Server got itself in trouble'), HTTPStatus.NOT_IMPLEMENTED: ('Not Implemented', 'Server does not support this operation'), HTTPStatus.BAD_GATEWAY: ('Bad Gateway', 'Invalid responses from another server/proxy'), HTTPStatus.SERVICE_UNAVAILABLE: ('Service Unavailable', 'The server cannot process the request due to a high load'), HTTPStatus.GATEWAY_TIMEOUT: ('Gateway Timeout', 'The gateway server did not receive a timely response'), HTTPStatus.HTTP_VERSION_NOT_SUPPORTED: ('HTTP Version Not Supported', 'Cannot fulfill request'), HTTPStatus.VARIANT_ALSO_NEGOTIATES: ('Variant Also Negotiates', ''), HTTPStatus.INSUFFICIENT_STORAGE: ('Insufficient Storage', ''), HTTPStatus.LOOP_DETECTED: ('Loop Detected', ''), HTTPStatus.NOT_EXTENDED: ('Not Extended', ''), HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED: ('Network Authentication Required', 'The client needs to authenticate to gain network access')}
send_error(code, message=None, explain=None)

Send and log an error reply.

Arguments are * code: an HTTP error code

3 digits

  • message: a simple optional 1 line reason phrase.

    *( HTAB / SP / VCHAR / %x80-FF ) defaults to short entry matching the response code

  • explain: a detailed message defaults to the long entry

    matching the response code.

This sends an error response (so it must be called before any output has been generated), logs the error, and finally sends a piece of HTML explaining the error to the user.

send_head()

Common code for GET and HEAD commands.

This sends the response code and MIME headers.

Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.

send_header(keyword, value)

Send a MIME header to the headers buffer.

send_response(code, message=None)

Add the response header to the headers buffer and log the response code.

Also send two standard headers with the server software version and the current date.

send_response_only(code, message=None)

Send the response header only.

server_version = 'SimpleHTTP/0.6'
setup()
sys_version = 'Python/3.11.13'
timeout = None
translate_path(path)

Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

version_string()

Return the server software version string.

wbufsize = 0
weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
axon_sdk.visualization.server.find_available_port(initial_port)[source]
axon_sdk.visualization.server.is_port_available(port)[source]
axon_sdk.visualization.server.open_browser(port)[source]
axon_sdk.visualization.server.start_server(graph_data)[source]

The server will only stay open for a fixed amount of time, enough to load the visualization. Afterwards, the simulator execution will continue. To achieve so, the server is run on a different thread with a timeout.

axon_sdk.visualization.server.start_server_on_port(graph_data, port)[source]

axon_sdk.visualization.topovis module

axon_sdk.visualization.topovis.color_for_synapse(synapse_type: str) str[source]
axon_sdk.visualization.topovis.format_edges(synapses: list[Synapse]) list[dict[str, str]][source]
axon_sdk.visualization.topovis.format_groups(groups: list[tuple[ExplicitNeuron, str]]) list[dict[str, str]][source]

The input groups contain a list of tuples, where each component contains a neuron and the uid of their immediately superior module

axon_sdk.visualization.topovis.format_nodes(neurons: list[ExplicitNeuron]) list[dict[str, str]][source]
axon_sdk.visualization.topovis.generate_mapping_neuron_to_net(net: SpikingNetworkModule) dict[ExplicitNeuron, str][source]

Generates a dictionary that maps each neuron to a net uid.

Neurons in the top module will be assinged the uid of the top module; Neurons in submodules of the top module will be assigned the uid of the first submodule.

IMP: neurons in submodules within submodules will NOT be given the uid of the direct submodule that contains them BUT rather of the submodule of net that contains them.

axon_sdk.visualization.topovis.get_groups_to_display(net: SpikingNetworkModule, neurons_to_display: list[ExplicitNeuron]) list[tuple[ExplicitNeuron, str]][source]

Submodules of net will be displayed as boxes in the visualization. To do so, the displayed neurons are assigned uid of the module they belong to. Only neurons belonging strictly to a submodule of net are assigned to a group (the top module neurons are not given a group)

axon_sdk.visualization.topovis.get_neurons_and_synapses_to_display(net: SpikingNetworkModule) tuple[list[ExplicitNeuron], list[Synapse]][source]
axon_sdk.visualization.topovis.vis_topology(net: SpikingNetworkModule) None[source]

Module contents