KnotInfo database#

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

To use the database, you need to install the optional database_knotinfo package by the Sage command

sage -i database_knotinfo

EXAMPLES:

sage: # optional - database_knotinfo
sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db
<sage.databases.knotinfo_db.KnotInfoDataBase object at ...>

AUTHORS:

  • Sebastian Oehms (2020-08): initial version

class sage.databases.knotinfo_db.KnotInfoColumnTypes(value)#

Bases: 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'>]
OnlyKnots = 'K'#
class sage.databases.knotinfo_db.KnotInfoColumns(value)#

Bases: 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)',
 'Braid Notation',
 'Quasipositive Braid',
 'Multivariable Alexander Polynomial',
 'HOMFLYPT Polynomial',
 'Khovanov 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
property 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: SageObject, 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 database 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)']
create_filecache(force=False)#

Create the internal files containing the database.

INPUT:

  • force – optional boolean. If set to True the existing file-cache is overwritten

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.create_filecache()    # optional - database_knotinfo
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()) > 120       # optional - database_knotinfo
True
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
12966
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]
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'
version()#

Return the version of the database currently installed on the device.

Note

The development of the original databases on the KnotInfo and LinkInfo web-pages is in a continuous flow. The installed version can be behind the current available state of these databases. Every month a cronjob on the GitHub repository searches for differences and creates a new release on PyPI in case of success.

If you note that your version is behind the version on PyPI and would like to have Sage working with that release you should first try to upgrade using sage -i database_knotinfo. If this is not successful even though you are on the latest Sage release please create an issue for that in the GitHub repository.

EXAMPLES:

sage: from sage.databases.knotinfo_db import KnotInfoDataBase
sage: ki_db = KnotInfoDataBase()
sage: ki_db.version()   >= '2021.10.1'   # optional database_knotinfo
True
class sage.databases.knotinfo_db.KnotInfoFilename(value)#

Bases: Enum

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

  • knots – contains the data from KnotInfo

  • links – contains 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'
knots = ['https://knotinfo.math.indiana.edu/', 'knotinfo_data_complete']#
num_knots(version)#

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('21.7')
'num_knots_21.7.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/'
class sage.databases.knotinfo_db.dc(value)#

Bases: KnotInfoColumns

An enumeration.

alexander_polynomial = ['Alexander', KnotInfoColumnTypes.OnlyKnots]#
alternating = ['Alternating', KnotInfoColumnTypes.KnotsAndLinks]#
arc_notation = ['Arc Notation', KnotInfoColumnTypes.OnlyLinks]#
braid_index = ['Braid Index', KnotInfoColumnTypes.OnlyKnots]#
braid_length = ['Braid Length', KnotInfoColumnTypes.OnlyKnots]#
braid_notation = ['Braid Notation', KnotInfoColumnTypes.KnotsAndLinks]#
braid_notation_old = ['Braid Notation', KnotInfoColumnTypes.OnlyLinks]#
conway_polynomial = ['Conway', KnotInfoColumnTypes.KnotsAndLinks]#
crossing_number = ['Crossing Number', KnotInfoColumnTypes.KnotsAndLinks]#
determinant = ['Determinant', KnotInfoColumnTypes.KnotsAndLinks]#
dt_code = ['DT code', KnotInfoColumnTypes.OnlyLinks]#
dt_notation = ['DT Notation', KnotInfoColumnTypes.OnlyKnots]#
fibered = ['Fibered', KnotInfoColumnTypes.OnlyKnots]#
gauss_notation = ['Gauss Notation', KnotInfoColumnTypes.KnotsAndLinks]#
homfly_polynomial = ['HOMFLY', KnotInfoColumnTypes.OnlyKnots]#
homflypt_polynomial = ['HOMFLYPT Polynomial', KnotInfoColumnTypes.OnlyLinks]#
jones_polynomial = ['Jones', KnotInfoColumnTypes.KnotsAndLinks]#
kauffman_polynomial = ['Kauffman', KnotInfoColumnTypes.KnotsAndLinks]#
khovanov_odd_integral_polynomial = ['KH Odd Red Z Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_odd_mod2_polynomial = ['KH Red Odd Mod2 Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_odd_rational_polynomial = ['KH Odd Red Q Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_polynomial = ['Khovanov', KnotInfoColumnTypes.OnlyLinks]#
khovanov_reduced_integral_polynomial = ['KH Red Z Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_reduced_mod2_polynomial = ['KH Red Mod2 Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_reduced_rational_polynomial = ['KH Red Q Poly', KnotInfoColumnTypes.OnlyKnots]#
khovanov_unreduced_integral_polynomial = ['KH Unred Z Poly', KnotInfoColumnTypes.OnlyKnots]#
name = ['Name', KnotInfoColumnTypes.KnotsAndLinks]#
name_unoriented = ['Name - Unoriented', KnotInfoColumnTypes.OnlyLinks]#
pd_notation = ['PD Notation', KnotInfoColumnTypes.OnlyKnots]#
pd_notation_vector = ['PD Notation (vector)', KnotInfoColumnTypes.OnlyLinks]#
positive = ['Positive', KnotInfoColumnTypes.OnlyKnots]#
symmetry_type = ['Symmetry Type', KnotInfoColumnTypes.OnlyKnots]#
unoriented = ['Unoriented', KnotInfoColumnTypes.OnlyLinks]#
width = ['Width', KnotInfoColumnTypes.OnlyKnots]#