Skip to content

Commit

Permalink
remove unused EvaluableConstant
Browse files Browse the repository at this point in the history
  • Loading branch information
joostvanzwieten committed Dec 20, 2023
1 parent f5c34de commit 4b73a78
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
26 changes: 0 additions & 26 deletions nutils/evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,32 +521,6 @@ def _node(self, cache, subgraph, times):
EVALARGS = EVALARGS()


class EvaluableConstant(Evaluable):
'''Evaluate to the given constant value.
Parameters
----------
value
The return value of ``eval``.
'''

def __init__(self, value):
self.value = value
super().__init__(())

def evalf(self):
return self.value

@property
def _node_details(self):
s = repr(self.value)
if '\n' in s:
s = s.split('\n', 1)[0] + '...'
if len(s) > 20:
s = s[:17] + '...'
return s


class Tuple(Evaluable):

def __init__(self, items):
Expand Down
21 changes: 0 additions & 21 deletions tests/test_evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,27 +1146,6 @@ def test_nested_variant(self):
self.assertEqual(actual, desired)


class EvaluableConstant(TestCase):

def test_evalf(self):
self.assertEqual(evaluable.EvaluableConstant(1).evalf(), 1)
self.assertEqual(evaluable.EvaluableConstant('1').evalf(), '1')

def test_node_details(self):

class Test:
def __init__(self, s):
self.s = s

def __repr__(self):
return self.s

self.assertEqual(evaluable.EvaluableConstant(Test('some string'))._node_details, 'some string')
self.assertEqual(evaluable.EvaluableConstant(Test('a very long string that should be abbreviated'))._node_details, 'a very long strin...')
self.assertEqual(evaluable.EvaluableConstant(Test('a string with\nmultiple lines'))._node_details, 'a string with...')
self.assertEqual(evaluable.EvaluableConstant(Test('a very long string with\nmultiple lines'))._node_details, 'a very long strin...')


class Einsum(TestCase):

def test_swapaxes(self):
Expand Down

0 comments on commit 4b73a78

Please sign in to comment.