KnotInfo Database

This module contains the class KnotInfoDataBase and auxilary classes for it which serves as an interface to the lists of named knots and links provided at the web-pages KnotInfo and LinkInfo.

AUTHORS:

  • Sebastian Oehms August 2020: initial version

class sage.databases.knotinfo_db.KnotInfoColumnTypes

Bases: enum.Enum

Enum class to specify if a column from the table of knots and links provided at the web-pages KnotInfo and LinkInfo. is used for knots only, links only or both.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoColumnTypes
sage: [col_type for col_type in KnotInfoColumnTypes]
[<KnotInfoColumnTypes.OnlyKnots: 'K'>,
<KnotInfoColumnTypes.OnlyLinks: 'L'>,
<KnotInfoColumnTypes.KnotsAndLinks: 'B'>]
class sage.databases.knotinfo_db.KnotInfoColumns

Bases: enum.Enum

Enum class to select a column from the table of knots and links provided at the web-pages KnotInfo and LinkInfo.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns(); cols
<enum 'Columns'>
sage: from sage.databases.knotinfo_db import KnotInfoColumns
sage: isinstance(cols.name, KnotInfoColumns)
True

sage: def only_links(c):
....:     return c.column_type() == c.types.OnlyLinks
sage: [c.column_name() for c in cols if only_links(c)]  # optional - database_knotinfo
['Name - Unoriented',
 'Orientation',
 'Unoriented Rank',
 'PD Notation (vector)',
 'PD Notation (KnotTheory)',
 'Multivariable Alexander Polynomial',
 'HOMFLYPT Polynomial',
 'Unoriented',
 'Arc Notation',
 'Linking Matrix',
 'Rolfsen Name',
 'Components',
 'DT code',
 'Splitting Number',
 'Nullity',
 'Unlinking Number',
 'Weak Splitting Number']
column_name()

Return the name of self displayed on the KnotInfo web-page.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns()
sage: cols.dt_code.column_name()
'DT code'
column_type()

Return the type of self. That is an instance of Enum KnotInfoColumnTypes.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns()
sage: cols.homfly_polynomial.column_type()
<KnotInfoColumnTypes.OnlyKnots: 'K'>
sage: cols.homflypt_polynomial.column_type()
<KnotInfoColumnTypes.OnlyLinks: 'L'>
sage: cols.name.column_type()
<KnotInfoColumnTypes.KnotsAndLinks: 'B'>
description_webpage(new=0, autoraise=True)

Launch the description page of self in the standard web browser.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns()
sage: cols.pd_notation.description_webpage()            # not tested
True
sage: cols.homflypt_polynomial.description_webpage()    # not tested
True
types

Return KnotInfoColumnTypes to be used for checks.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns()
sage: cols.dt_code.column_type() == cols.dt_code.types.OnlyLinks
True
class sage.databases.knotinfo_db.KnotInfoDataBase(install=False)

Bases: sage.structure.sage_object.SageObject, sage.structure.unique_representation.UniqueRepresentation

Database interface to KnotInfo

The original data are obtained from KnotInfo web-page (URL see the example below). In order to have these data installed during the build process as a sage-package they are converted as csv files into a tarball. This tarball has been created using the method create_spkg_tarball().

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots
<KnotInfoFilename.knots: ['https://knotinfo.math.indiana.edu/',
                          'knotinfo_data_complete']>
columns()

Return the columns ot the databese table as instances of enum class KnotInfoColumns.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: cols = ki_db.columns()
sage: [col.column_name() for col in cols if col.name.startswith('pd')]   # optional - database_knotinfo
['PD Notation', 'PD Notation (vector)', 'PD Notation (KnotTheory)']
demo_version()

Return whether the KnotInfo databases are installed completely or just the demo version is used.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.demo_version()       # optional - database_knotinfo
False
filename

alias of KnotInfoFilename

knot_list()

Return the KnotInfo table rows as Python list.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: len(ki_db.knot_list())  # not tested (just used on installation)

Return the LinkInfo table rows as Python list.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: len(ki_db.link_list())  # not tested (just used on installation)
read(column)

Access a column of KnotInfo / LinkInfo

INPUT:

column – instance of enum KnotInfoColumns

to select the data to be read in

OUTPUT:

A python list containing the data corresponding to the column.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
read_column_dict()

Read the dictionary for the column names from the according sobj-file

OUTPUT:

A python dictionary containing the column names and types

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: len(ki_db.read_column_dict())       # optional - database_knotinfo
125
read_num_knots()

Read the number of knots contained in the database (without proper links) from the according sobj-file.

OUTPUT:

Integer

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.read_num_knots()              # optional - database_knotinfo
2978
read_row_dict()

Read the dictionary for the row names that is the knot and link names from the according sobj-file

OUTPUT:

A python dictionary containing the names of the knots and links together with their table index and the corresponding number of components

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.read_row_dict()['K7_1']
[8, 1]
reset_filecache()

Reset the internal files containing the database.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.reset_filecache()    # optional - database_knotinfo
row_names()

Return a dictionary to obtain the original name to a row_dict key

OUTPUT:

A python dictionary containing the names of the knots and links together with their original names from the database,

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.row_names()['K7_1']      # optional - database_knotinfo
'7_1'
class sage.databases.knotinfo_db.KnotInfoFilename

Bases: enum.Enum

Enum for the different data files. The following choices are possible:

  • knots – contains the the data from KnotInfo

  • links – contains the the data for proper links from LinkInfo

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename
<enum 'KnotInfoFilename'>
csv()

Return the file name under which the data from the web-page are stored as csv file.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.csv()
'knotinfo_data_complete.csv'
description_url(column)

Return the url of the description page of the given column.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.description_url(ki_db.columns().braid_notation)
'https://knotinfo.math.indiana.edu/descriptions/braid_notation.html'
diagram_url(fname, single=False)

Return the url of the diagram page of the given link.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.diagram_url('3_1-50.png')
'https://knotinfo.math.indiana.edu/diagram_display.php?3_1-50.png'
sage: ki_db.filename.knots.diagram_url('3_1', single=True)
'https://knotinfo.math.indiana.edu/diagrams/3_1'
excel()

Return the Excel-file name to download the data from the web-page.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.excel()
'knotinfo_data_complete.xls'
num_knots()

Return the file name under which the number of knots is stored in an sobj-file.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.num_knots()
'num_knots.sobj'
sobj_column()

Return the file name under which the column-data of the csv-File is stored as python dictionary in a sobj-file.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.sobj_column()
'column_dict.sobj'
sobj_data(column)

Return the file name under which the data of the given column is stored as python list in a sobj-file.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.sobj_data(ki_db.columns().braid_notation)
'knotinfo_braid_notation'
sobj_row()

Return the file name under which the row-data of the csv-File is stored as python dictionary in a sobj-file.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.sobj_row()
'row_dict.sobj'
url()

Return the URL to download the data from the web-page.

Examples:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.filename.knots.url()
'https://knotinfo.math.indiana.edu/'
sage.databases.knotinfo_db.db = <sage.databases.knotinfo_db.KnotInfoDataBase object>
class sage.databases.knotinfo_db.dc

Bases: sage.databases.knotinfo_db.KnotInfoColumns

An enumeration.