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 ...>
>>> from sage.all import *
>>> # optional - database_knotinfo
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db
<sage.databases.knotinfo_db.KnotInfoDataBase object at ...>

AUTHORS:

  • Sebastian Oehms (2020-08): initial version

class sage.databases.knotinfo_db.KnotInfoColumnTypes(value)[source]#

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'>]
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoColumnTypes
>>> [col_type for col_type in KnotInfoColumnTypes]
[<KnotInfoColumnTypes.OnlyKnots: 'K'>,
<KnotInfoColumnTypes.OnlyLinks: 'L'>,
<KnotInfoColumnTypes.KnotsAndLinks: 'B'>]
OnlyKnots = 'K'[source]#
class sage.databases.knotinfo_db.KnotInfoColumns(value)[source]#

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']
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns(); cols
<enum 'Columns'>
>>> from sage.databases.knotinfo_db import KnotInfoColumns
>>> isinstance(cols.name, KnotInfoColumns)
True

>>> def only_links(c):
...     return c.column_type() == c.types.OnlyLinks
>>> [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()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns()
>>> cols.dt_code.column_name()
'DT code'
column_type()[source]#

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'>
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns()
>>> cols.homfly_polynomial.column_type()
<KnotInfoColumnTypes.OnlyKnots: 'K'>
>>> cols.homflypt_polynomial.column_type()
<KnotInfoColumnTypes.OnlyLinks: 'L'>
>>> cols.name.column_type()
<KnotInfoColumnTypes.KnotsAndLinks: 'B'>
description_webpage(new=0, autoraise=True)[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns()
>>> cols.pd_notation.description_webpage()            # not tested
True
>>> 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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns()
>>> cols.dt_code.column_type() == cols.dt_code.types.OnlyLinks
True
class sage.databases.knotinfo_db.KnotInfoDataBase(install=False)[source]#

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']>
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots
<KnotInfoFilename.knots: ['https://knotinfo.math.indiana.edu/',
                          'knotinfo_data_complete']>
columns()[source]#

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)']
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> cols = ki_db.columns()
>>> [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)[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.create_filecache()    # optional - database_knotinfo
demo_version()[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.demo_version()       # optional - database_knotinfo
False
filename[source]#

alias of KnotInfoFilename

knot_list()[source]#

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)
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> 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)
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> len(ki_db.link_list())  # not tested (just used on installation)
read(column)[source]#

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()
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
read_column_dict()[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> len(ki_db.read_column_dict()) > Integer(120)       # optional - database_knotinfo
True
read_num_knots()[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.read_num_knots()              # optional - database_knotinfo
12966
read_row_dict()[source]#

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]
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.read_row_dict()['K7_1']
[8, 1]
row_names()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.row_names()['K7_1']      # optional - database_knotinfo
'7_1'
version()[source]#

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
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.version()   >= '2021.10.1'   # optional database_knotinfo
True
class sage.databases.knotinfo_db.KnotInfoFilename(value)[source]#

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'>
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename
<enum 'KnotInfoFilename'>
csv()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.csv()
'knotinfo_data_complete.csv'
description_url(column)[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> 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)[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.diagram_url('3_1-50.png')
'https://knotinfo.math.indiana.edu/diagram_display.php?3_1-50.png'
>>> ki_db.filename.knots.diagram_url('3_1', single=True)
'https://knotinfo.math.indiana.edu/diagrams/3_1'
excel()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.excel()
'knotinfo_data_complete.xls'
knots = ['https://knotinfo.math.indiana.edu/', 'knotinfo_data_complete'][source]#
num_knots(version)[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.num_knots('21.7')
'num_knots_21.7.sobj'
sobj_column()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.sobj_column()
'column_dict.sobj'
sobj_data(column)[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.sobj_data(ki_db.columns().braid_notation)
'knotinfo_braid_notation'
sobj_row()[source]#

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'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.sobj_row()
'row_dict.sobj'
url()[source]#

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/'
>>> from sage.all import *
>>> from sage.databases.knotinfo_db import KnotInfoDataBase
>>> ki_db = KnotInfoDataBase()
>>> ki_db.filename.knots.url()
'https://knotinfo.math.indiana.edu/'
class sage.databases.knotinfo_db.dc(value)[source]#

Bases: KnotInfoColumns

An enumeration.

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