Bridges-Python 3.5.0-dev1
Bridges(Python API)
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | Properties | List of all members
bridges.bridges.Bridges Class Reference

The bridges class is the main class that provides interfaces to datasets, maintains user and assignment information, and connects to the bridges server. More...

Public Member Functions

 __init__ (self, int assignment, str username=None, str appl_id=None)
 Bridges constructor.
 
 set_data_structure (self, ds)
 Set the data structure type.
 
bool get_json_flag (self)
 This method returns the json flag, which controls if the json is to be printed.
 
 set_json_flag (self, bool flag)
 This method controls if the data structure's JSON representation is printed to the console or not.
 
 set_map (self, list map_info)
 This method serializes all the state and county objects in the map_info for sending to the server.
 
 post_visualization_link (self, bool flag)
 This method controls (with a flag) if the visualization url is printed to the console or not.
 
None visualize (self)
 Method for generating the representation of the data structure in the form of JSON and sends the information to the bridges server for generating the visualization.
 
 get_visualize_url (self)
 
 set_assignment (self, int assignment)
 Setter for assignment id (must be positive)
 
str get_assignment (self)
 Getter for the assignment id.
 
None set_title (self, str title)
 Setter for the title of the bridges visualization.
 
None set_description (self, str description)
 Setter for the description of the bridges visualization.
 
 set_map_overlay (self, bool flag)
 Setter for if the visualization will have a map overlay.
 
 set_coord_system_type (self, coord)
 Setter for the coordinate system type to use in the visualization.
 
ColorGrid get_color_grid_from_assignment (self, str user, int assignment, int subassignment=0)
 Reconstruct a ColorGrid from an existing ColorGrid on the bridges server.
 
 set_username (self, username)
 Setter for username (must be a string)
 
 get_username (self)
 Getter for the assignment user name (BRIDGES credentials)
 
 get_assignment_id (self)
 Getter for the assignment number.
 
 set_key (self, apikey)
 Setter for API Key (BRIDGES Credentials)
 
 get_key (self)
 Getter for the API key (BRIDGES credentials)
 
None set_server_url (self, str server_url)
 Sets url for the output of the visualize method.
 

Public Attributes

 connector
 
 map
 
 ds_handle
 
 vis_type
 

Protected Attributes

 _window
 
 _debug
 
 _assignment_part
 
 _assignment
 
 _username
 
 _key
 
 _title
 
 _description
 
 _coord_system_type
 
 _json_flag
 
 _element_label_flag
 
 _link_label_flag
 
 _post_url_flag
 
 _map_overlay
 
 _MaxTitleSize
 
 _MaxDescSize
 

Static Protected Attributes

int _MaxTitleSize
 
int _MaxDescSize
 
dict _projection_options
 
bool _debug
 

Properties

 window = property
 This function returns the current window size.
 
 debug = property
 
 element_label_flag = property
 
 link_label_flag = property
 

Detailed Description

The bridges class is the main class that provides interfaces to datasets, maintains user and assignment information, and connects to the bridges server.

The bridges class is responsible for initializing the bridges system, specifying parameters (user id, assignment id, title, description, data structure type, etc) for the student assignment, generating the data structure representation and transmission to the bridges server. In addition, it provides interfaces to a number of real-world datasets, that makes it easy to access the data for use algorithms/data structure assignments.

Datasets. The datasets that are currently supported through the BRIDGES API include USGS Earthquake Data, IMDB Actor/Movie Data (2 versions), Gutenberg Book Collection Meta Data, a Video Game Dataset, Shakespeare Dataset, OpenStreetMap and Elevation map data. More information is found in the respective methods (below) and at https://bridgesuncc.github.io/datasets.html

A typical bridges program includes creating the bridges object, followed by creation of the data structure by the user, assigning visual attributes to elements of the data structure, followed by specification of teh data structure type and the call to visualize the data structure (bridges::setDataStructure() and visualize() methods).

Author
Sean Gallagher, Kalpathi Subramanaian, Mihai Mehedint, David Burlinson, Matthew Mcquaigue, Erik Saule, Jamie Payton
Date
2015, 2016, 2017, 2018, 2019, 2020, 2021

Constructor & Destructor Documentation

◆ __init__()

bridges.bridges.Bridges.__init__ (   self,
int  assignment,
str  username = None,
str  appl_id = None 
)

Bridges constructor.

       (int) assignment: the number your bridges assignment will have
       (str) username: your bridges username, optional if BRIDGES_USER_NAME in env
       (str) appl_id: your appl authentication key from bridges acc, optional if BRIDGES_API_KEY in env
Returns
None

Member Function Documentation

◆ get_assignment()

str bridges.bridges.Bridges.get_assignment (   self)

Getter for the assignment id.

Returns
str representing the full assignment id including subassignment aspect

◆ get_assignment_id()

bridges.bridges.Bridges.get_assignment_id (   self)

Getter for the assignment number.

Returns
int assignment number

◆ get_color_grid_from_assignment()

ColorGrid bridges.bridges.Bridges.get_color_grid_from_assignment (   self,
str  user,
int  assignment,
int   subassignment = 0 
)

Reconstruct a ColorGrid from an existing ColorGrid on the bridges server.

Parameters
userthe name of the user who uploaded the assignment
assignmentthe ID of the assignment to get
subassignmentthe ID of the subassignment to get (default 0)
Returns
ColorGrid the ColorGrid stored in the bridges server

◆ get_json_flag()

bool bridges.bridges.Bridges.get_json_flag (   self)

This method returns the json flag, which controls if the json is to be printed.

◆ get_key()

bridges.bridges.Bridges.get_key (   self)

Getter for the API key (BRIDGES credentials)

Returns
str user's API key

◆ get_username()

bridges.bridges.Bridges.get_username (   self)

Getter for the assignment user name (BRIDGES credentials)

Returns
str user name

◆ get_visualize_url()

bridges.bridges.Bridges.get_visualize_url (   self)

◆ post_visualization_link()

bridges.bridges.Bridges.post_visualization_link (   self,
bool  flag 
)

This method controls (with a flag) if the visualization url is printed to the console or not.

Parameters
flagflag that controls if the url to the visualization is output to console

◆ set_assignment()

bridges.bridges.Bridges.set_assignment (   self,
int  assignment 
)

Setter for assignment id (must be positive)

Parameters
assignmentassignment number to be set
Returns
None

◆ set_coord_system_type()

bridges.bridges.Bridges.set_coord_system_type (   self,
  coord 
)

Setter for the coordinate system type to use in the visualization.

Parameters
coordcoordinate system type (used in map overlays (can be "cartesian", "albersusa", "equirectangular")

◆ set_data_structure()

bridges.bridges.Bridges.set_data_structure (   self,
  ds 
)

Set the data structure type.

This method sets the handle to the current data structure; this can be an array, the head of a linked list, root of a tree structure, a graph Arrays of upto 3 dimensions are suppported. It can be any of the data structures supported by BRIDGES. Polymorphism and type casting is used to determine the actual data structure and extract its representtion.

Parameters
dsthe data structure to visualize
Returns
None
Exceptions
ValueErrorif it is not a BRIDGES data structure

◆ set_description()

None bridges.bridges.Bridges.set_description (   self,
str  description 
)

Setter for the description of the bridges visualization.

       (str) description: representing the assignment description
Returns
None

◆ set_json_flag()

bridges.bridges.Bridges.set_json_flag (   self,
bool  flag 
)

This method controls if the data structure's JSON representation is printed to the console or not.

Parameters
flagflag that controls if the JSON of the data structure representation is output to console
Returns
None

◆ set_key()

bridges.bridges.Bridges.set_key (   self,
  apikey 
)

Setter for API Key (BRIDGES Credentials)

Parameters
apikeyapi key to be set
Returns
None

◆ set_map()

bridges.bridges.Bridges.set_map (   self,
list  map_info 
)

This method serializes all the state and county objects in the map_info for sending to the server.

   See tutorial at https://bridgesuncc.github.io/tutorials/Map.html
Parameters
map_infois a list of state objects with their counties
Returns
none

◆ set_map_overlay()

bridges.bridges.Bridges.set_map_overlay (   self,
bool  flag 
)

Setter for if the visualization will have a map overlay.

       (bool) flag: boolean for if map overlay
Returns
None

◆ set_server_url()

None bridges.bridges.Bridges.set_server_url (   self,
str  server_url 
)

Sets url for the output of the visualize method.

Parameters
server_urlstring, must be one of {live, clone, local, games}
Returns
None

◆ set_title()

None bridges.bridges.Bridges.set_title (   self,
str  title 
)

Setter for the title of the bridges visualization.

       (str) title: representing the title
Returns
None

◆ set_username()

bridges.bridges.Bridges.set_username (   self,
  username 
)

Setter for username (must be a string)

Parameters
usernameusername to be set
Returns
None

◆ visualize()

None bridges.bridges.Bridges.visualize (   self)

Method for generating the representation of the data structure in the form of JSON and sends the information to the bridges server for generating the visualization.

Returns
None

Member Data Documentation

◆ _assignment

bridges.bridges.Bridges._assignment
protected

◆ _assignment_part

bridges.bridges.Bridges._assignment_part
protected

◆ _coord_system_type

bridges.bridges.Bridges._coord_system_type
protected

◆ _debug [1/2]

bridges.bridges.Bridges._debug
staticprotected

◆ _debug [2/2]

bridges.bridges.Bridges._debug
protected

◆ _description

bridges.bridges.Bridges._description
protected

◆ _element_label_flag

bridges.bridges.Bridges._element_label_flag
protected

◆ _json_flag

bridges.bridges.Bridges._json_flag
protected

◆ _key

bridges.bridges.Bridges._key
protected

◆ _link_label_flag

bridges.bridges.Bridges._link_label_flag
protected

◆ _map_overlay

bridges.bridges.Bridges._map_overlay
protected

◆ _MaxDescSize [1/2]

bridges.bridges.Bridges._MaxDescSize
staticprotected

◆ _MaxDescSize [2/2]

bridges.bridges.Bridges._MaxDescSize
protected

◆ _MaxTitleSize [1/2]

bridges.bridges.Bridges._MaxTitleSize
staticprotected

◆ _MaxTitleSize [2/2]

bridges.bridges.Bridges._MaxTitleSize
protected

◆ _post_url_flag

bridges.bridges.Bridges._post_url_flag
protected

◆ _projection_options

bridges.bridges.Bridges._projection_options
staticprotected

◆ _title

bridges.bridges.Bridges._title
protected

◆ _username

bridges.bridges.Bridges._username
protected

◆ _window

bridges.bridges.Bridges._window
protected

◆ connector

bridges.bridges.Bridges.connector

◆ ds_handle

bridges.bridges.Bridges.ds_handle

◆ map

bridges.bridges.Bridges.map

◆ vis_type

bridges.bridges.Bridges.vis_type

Property Documentation

◆ debug

bridges.bridges.Bridges.debug = property
static

◆ element_label_flag

bridges.bridges.Bridges.element_label_flag = property
static

◆ link_label_flag

bridges.bridges.Bridges.link_label_flag = property
static

◆ window

bridges.bridges.Bridges.window = property
static

This function returns the current window size.

This only works for graph data types. And the coordinate system need to be set to "window" using set_coord_system_type(), setting this value will set "window" for you.

Returns
return a list of 4 floats [x1, x2, y1, y2]

The documentation for this class was generated from the following file: