Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions GridPythonModule/GridPyM.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from sympy.combinatorics import Permutation
from random import randrange
from matplotlib import pyplot as plt
import numpy as np

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Expand Down Expand Up @@ -1772,6 +1773,53 @@ def thurston_bennequin(input_grid):

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

def turning_number(input_grid):
r"""
Calculates the turning number of a knot grid diagram, using
the orientation O ----> X horizontally.

OUTPUT:

An integer.

EXAMPLES::

>> G = generate_torus_link(3,2)
>> print(turning_number(G))
2
>> K = load_knot('5_2')
>> print(turning_number(K))
0

"""
turning = 0
XX = np.array(input_grid[0])
OO = np.array(input_grid[1])
for t in range(grid_number(input_grid)):
if OO[t] < XX[t]:
if np.where(OO==XX[t])[0][0] < t:
turning -= 1
else:
turning += 1
if np.where(XX==OO[t])[0][0] < t:
turning -= 1
else:
turning += 1
if OO[t] > XX[t]:
if np.where(OO==XX[t])[0][0] < t:
turning += 1
else:
turning -= 1
if np.where(XX==OO[t])[0][0] < t:
turning += 1
else:
turning -= 1
if turning%4 != 0:
print('There is something fishy going on here!')
return turning/4

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

def uncoherent_bs(input_grid, where, which = 'rows'):
r"""
Performs a uncoherent band attachment on the grid. Can choose between a row/column
Expand Down Expand Up @@ -2149,8 +2197,4 @@ def _can_simplify(input_grid):
else:
return False

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
packages=['GridPythonModule'],
install_requires=['simpy',
'random2',
'matplotlib'
'matplotlib',
'numpy'
],

classifiers=[
Expand Down