Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 9cde996

Browse files
committed
30352: installation via PyPI
1 parent 66a555b commit 9cde996

File tree

12 files changed

+100
-255
lines changed

12 files changed

+100
-255
lines changed
Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,18 @@
1-
database_knotinfo: Tables of Knots and Links from the KnotInfo Databases
2-
========================================================================
1+
database_knotinfo: Content of the KnotInfo and LinkInfo databases as lists of dictionaries
2+
==========================================================================================
33

44
Description
55
-----------
66

7-
Database for named knots and links provided at
7+
Content of the KnotInfo and LinkInfo databases as lists of dictionaries
88

9-
https://knotinfo.math.indiana.edu/
10-
11-
and
12-
13-
https://linkinfo.sitehost.iu.edu'
14-
15-
Dependencies
16-
------------
17-
18-
- Sage library
9+
License
10+
-------
1911

12+
GPL
2013

2114
Upstream Contact
2215
----------------
2316

24-
- Charles Livingston <[email protected]>
25-
- Allison H. Moore <[email protected]>
26-
27-
Update Instructions
28-
-------------------
29-
30-
- See the Python script ``create_knotinfo_tarball.py`` in the current directory.
31-
32-
Changelog
33-
---------
34-
35-
- 20200713 (Sebastian Oehms, 13 Juli 2020, :trac:`30352`, initial version)
36-
37-
The tarball has been created from the both download files at the
38-
given date:
39-
40-
``knotinfo_data_complete.xls``
41-
``linkinfo_data_complete.xlsx``
42-
43-
exporting them to CSV via LibreOffice.
44-
45-
The second file has been changed manually deleting one character:
46-
a trailing "}" occuring in the homfly_polynomial column of the last
47-
link ``L11n459{1,1,1}``.
48-
49-
- 20210201 (Sebastian Oehms, 1 February 2021, :trac:`30352`, upgrade)
50-
51-
Three new columns have been added to ``knotinfo_data_complete.xls``
52-
(``montesinos_notation``, ``boundary_slopes`` and ``pretzel_notation``).
53-
``linkinfo_data_complete.xlsx`` remains unchanged.
17+
https://pypi.org/project/database-knotinfo/
5418

55-
The tarball has been created using ``create_knotinfo_tarball.py``.
56-
The fix concerning the misplaced character for ``L11n459{1,1,1}``
57-
is performed in :meth:`KnotInfoBase.homfly_polynomial`, now.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tarball=knotinfo-20210201.tar.bz2
2-
sha1=a8a69dacd1f61f19a921d8e5b90d6cfdea85d859
3-
md5=5f53bd7e3a672648d41460c4d22d52b3
4-
cksum=1608275975
5-
upstream_url=https://github.com/soehms/sagemath_knotinfo/blob/main/knotinfo-20210201.tar.bz2?raw=true
1+
tarball=database_knotinfo-VERSION.tar.gz
2+
sha1=2d758c5f8bf346162d13bec1d5bccfec9d27baa1
3+
md5=ec20d43af0c4ecf59dfd281c6ccc4ef0
4+
cksum=2792610748
5+
upstream_url=https://pypi.io/packages/source/d/database_knotinfo/database_knotinfo-VERSION.tar.gz

build/pkgs/database_knotinfo/create_knotinfo_tarball.py

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
| $(SAGERUNTIME)
1+
$(PYTHON) | $(PYTHON_TOOLCHAIN)
22

33
----------
44
All lines of this file are ignored except the first.
5-
It is copied by SAGE_ROOT/build/make/install into SAGE_ROOT/build/make/Makefile.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
database-knotinfo
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20210201
1+
0.7
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
INSTALL="yes"
2-
TARGET="${SAGE_SHARE}/knotinfo"
3-
VERSION=`cat package-version.txt`
4-
if [ -d $TARGET ]
5-
then
6-
diff package-version.txt $TARGET > /dev/null 2>&1
7-
if [ $? -eq 0 ]
8-
then
9-
INSTALL="no"
10-
echo "Version $VERSION of knotinfo already installed"
11-
else
12-
OLD_VERSION=`cat $TARGET/package-version.txt`
13-
echo "Removing former version $OLD_VERSION of knotinfo"
14-
rm -rf $TARGET
15-
fi
16-
fi
1+
cd src
2+
sdh_pip_install .
173

18-
if [ "$INSTALL" = "yes" ]
4+
FILECACHE="${SAGE_SHARE}/knotinfo"
5+
if [ -d $FILECACHE ]
196
then
20-
exec python3 spkg-install.py
7+
echo "Clearing former filecache of knotinfo"
8+
rm -rf $FILECACHE
219
fi

build/pkgs/database_knotinfo/spkg-install.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/sage/databases/knotinfo_db.py

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727

2828
import os
29-
import csv
3029
from enum import Enum
3130

3231
from sage.structure.sage_object import SageObject
@@ -227,6 +226,20 @@ def csv(self):
227226
"""
228227
return '%s.csv' %(self.value[1])
229228

229+
def num_knots(self):
230+
r"""
231+
Return the file name under which the number of knots is stored
232+
in an sobj-file.
233+
234+
Examples::
235+
236+
sage: from sage.databases.knotinfo_db import KnotInfoDataBase
237+
sage: ki_db = KnotInfoDataBase()
238+
sage: ki_db.filename.knots.num_knots()
239+
'num_knots.sobj'
240+
"""
241+
return 'num_knots.sobj'
242+
230243
def sobj_row(self):
231244
r"""
232245
Return the file name under which the row-data of the csv-File
@@ -347,10 +360,9 @@ def __init__(self, install=False):
347360
'linkinfo_data_complete']>
348361
"""
349362
# some constants
350-
self._delimiter = '|'
351-
self._names_column = 'name'
363+
self._names_column = 'name'
352364
self._components_column = 'components'
353-
self._knot_prefix = 'K'
365+
self._knot_prefix = 'K'
354366

355367
self._knot_list = None
356368
self._link_list = None
@@ -359,16 +371,34 @@ def __init__(self, install=False):
359371

360372
from sage.features.databases import DatabaseKnotInfo
361373
self._feature = DatabaseKnotInfo()
362-
self._sobj_path = self._feature.search_path[0]
374+
self._sobj_path = self._feature._sobj_path
375+
376+
def reset_filecache(self):
377+
r"""
378+
Reset the internal files containing the database.
379+
380+
EXAMPLES::
381+
382+
sage: from sage.databases.knotinfo_db import KnotInfoDataBase
383+
sage: ki_db = KnotInfoDataBase()
384+
sage: ki_db.reset_filecache() # optional - database_knotinfo
385+
"""
386+
if not self._feature.is_present():
387+
return
388+
sobj_path = self._sobj_path
389+
os.system('rm -rf %s' %sobj_path)
390+
from sage.misc.misc import sage_makedirs
391+
sage_makedirs(sobj_path)
392+
393+
num_knots_file = os.path.join(sobj_path, self.filename.knots.num_knots())
394+
knot_list = self.knot_list()
395+
num_knots = len(knot_list) - 1
396+
save(num_knots, num_knots_file)
397+
self._num_knots = num_knots
398+
self._create_col_dict_sobj()
399+
self._create_data_sobj()
400+
return
363401

364-
if install:
365-
knot_list = self.knot_list()
366-
num_knots = len(knot_list) - 1
367-
print('Setting the number of Knots: %s!' %num_knots)
368-
save(num_knots, '%s/%s' %(self._sobj_path, self._feature.filename))
369-
self._feature._cache_is_present = None # must be reset for package installation
370-
self._create_col_dict_sobj()
371-
self._create_data_sobj()
372402

373403
def demo_version(self):
374404
r"""
@@ -382,9 +412,14 @@ def demo_version(self):
382412
sage: ki_db.demo_version() # optional - database_knotinfo
383413
False
384414
"""
385-
if not self._demo:
415+
if self._demo is None:
386416
if self._feature.is_present():
387-
self._num_knots = load(self._feature.absolute_path())
417+
num_knots_file = os.path.join(self._sobj_path, self.filename.knots.num_knots())
418+
from builtins import FileNotFoundError
419+
try:
420+
self._num_knots = load(num_knots_file)
421+
except FileNotFoundError:
422+
self.reset_filecache()
388423
self._demo = False
389424
else:
390425
self._demo = True
@@ -404,12 +439,8 @@ def knot_list(self):
404439
if self._knot_list:
405440
return self._knot_list
406441

407-
print('Importing KnotInfo database from SPKG!')
408-
os.system('pwd')
409-
knot_csv = open('src/%s' %self.filename.knots.csv())
410-
knot_dict = csv.DictReader(knot_csv, delimiter=self._delimiter)
411-
self._knot_list = list(knot_dict)
412-
knot_csv.close()
442+
from database_knotinfo import link_list
443+
self._knot_list = link_list()
413444
return self._knot_list
414445

415446

@@ -426,11 +457,8 @@ def link_list(self):
426457
if self._link_list:
427458
return self._link_list
428459

429-
print('Importing LinkInfo database from SPKG!')
430-
link_csv = open('src/%s' %self.filename.links.csv())
431-
link_dict = csv.DictReader(link_csv, delimiter=self._delimiter)
432-
self._link_list = list(link_dict)
433-
link_csv.close()
460+
from database_knotinfo import link_list
461+
self._link_list = link_list(proper_links=True)
434462
return self._link_list
435463

436464
def _create_col_dict_sobj(self):
@@ -786,6 +814,7 @@ def _test_database(self, **options):
786814
db = KnotInfoDataBase()
787815
dc = db.columns()
788816

817+
789818
data_demo_sample = {
790819
dc.name: ['0_1', '3_1', '4_1', '5_1', '5_2', '6_1', '6_2', '6_3', '7_1', '7_2',
791820
'L2a1{0}', 'L2a1{1}', 'L4a1{0}', 'L4a1{1}', 'L5a1{0}', 'L5a1{1}',

0 commit comments

Comments
 (0)