Skip to content

Commit

Permalink
Proper way to indicate ColorDistance needs numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed May 19, 2021
1 parent 95f5575 commit ef16eb6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
3 changes: 0 additions & 3 deletions mathics/builtin/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ def __str__(self):
return "-CompiledCode-"

def boxes_to_text(self, leaves=None, **options):
from trepan.api import debug

debug()
if not leaves:
leaves = self._leaves
return "-CompiledCode-"
Expand Down
11 changes: 4 additions & 7 deletions mathics/builtin/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ class ColorDistance(Builtin):
+ "two lists of colors of the same length.",
}

# If numpy is not installed, 100 * c1.to_color_space returns
# a list of 100 x 3 elements, instead of doing elementwise multiplication
requires = ("numpy",)

# the docs say LABColor's colorspace corresponds to the CIE 1976 L^* a^* b^* color space
# with {l,a,b}={L^*,a^*,b^*}/100. Corrections factors are put accordingly.

Expand Down Expand Up @@ -887,13 +891,6 @@ class ColorDistance(Builtin):
def apply(self, c1, c2, evaluation, options):
"ColorDistance[c1_, c2_, OptionsPattern[ColorDistance]]"

# If numpy is not installed, 100 * c1.to_color_space returns
# a list of 100 x 3 elements, instead of doing elementwise multiplication
try:
import numpy as np
except:
raise RuntimeError("NumPy needs to be installed for ColorDistance")

distance_function = options.get("System`DistanceFunction")
compute = None
if isinstance(distance_function, String):
Expand Down
1 change: 0 additions & 1 deletion mathics/formatter/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

class _SVGTransform:
def __init__(self):
from trepan.api import debug; debug()
self.transforms = []

def matrix(self, a, b, c, d, e, f):
Expand Down

0 comments on commit ef16eb6

Please sign in to comment.