From 60c332e9816cb73a4794edc20c3e9a0866a368e4 Mon Sep 17 00:00:00 2001 From: brent hartshorn Date: Fri, 24 Jan 2025 12:26:55 -0800 Subject: [PATCH 1/3] make vizpy optional --- pyknotid/visualise.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyknotid/visualise.py b/pyknotid/visualise.py index 9843b48..9a0209b 100644 --- a/pyknotid/visualise.py +++ b/pyknotid/visualise.py @@ -20,7 +20,10 @@ from __future__ import division -import vispy +try: + import vispy +except ModuleNotFoundError: + vispy = None # vispy.use('PyQt5') import numpy as n @@ -29,11 +32,11 @@ from pyknotid.utils import ensure_shape_tuple, vprint import random from colorsys import hsv_to_rgb - -try: - from vispy.visuals.transforms import MatrixTransform -except (AttributeError, ImportError): - from vispy.visuals.transforms import AffineTransform as MatrixTransform +if vispy: + try: + from vispy.visuals.transforms import MatrixTransform + except (AttributeError, ImportError): + from vispy.visuals.transforms import AffineTransform as MatrixTransform vispy_canvas = None From 8242e7b403dc62c0109c71cddea111f6dedc78a4 Mon Sep 17 00:00:00 2001 From: brent hartshorn Date: Fri, 24 Jan 2025 12:32:01 -0800 Subject: [PATCH 2/3] no install knotid.py for using knotid from blender made vizpy optional --- knotid.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 knotid.py diff --git a/knotid.py b/knotid.py new file mode 100644 index 0000000..d515ff1 --- /dev/null +++ b/knotid.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import os, sys, subprocess +import numpy, networkx, sympy, appdirs, requests, tqdm +_thisdir = os.path.split(os.path.abspath(__file__))[0] + +try: + import planarity +except ModuleNotFoundError: + pass + +try: + import peewee +except ModuleNotFoundError: + print('peewee not installed') + +try: + import vizpy +except ModuleNotFoundError: + print('vizpy not installed') + +sys.path.append(_thisdir) +import pyknotid +print(pyknotid) +import pyknotid.spacecurves as sp +print(sp) +import pyknotid.make as mk +print(mk) From 2c4a9028a0b3e156f07b85b46867e969ad672124 Mon Sep 17 00:00:00 2001 From: brent hartshorn Date: Fri, 24 Jan 2025 13:31:42 -0800 Subject: [PATCH 3/3] option --test --- knotid.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/knotid.py b/knotid.py index d515ff1..fbca6da 100644 --- a/knotid.py +++ b/knotid.py @@ -25,3 +25,21 @@ print(sp) import pyknotid.make as mk print(mk) + +def test(): + k = sp.SpaceCurve(mk.trefoil()) + print(k) + g2 = k.gauss_code(recalculate=True, try_cython=False) + print(g2) + +def test_random(): + from random import uniform + points = [ [uniform(-1,1),uniform(-1,1),uniform(-1,1)] for i in range(10)] + k = sp.SpaceCurve( points ) + print(k) + g2 = k.gauss_code(recalculate=True, try_cython=False) + print(g2) + +if '--test' in sys.argv: + test() + test_random()