Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
ebf19906
Commit
ebf19906
authored
12 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Removed some unused functions.
parent
2e2ab526
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/node.py
+2
-65
2 additions, 65 deletions
src/node.py
with
2 additions
and
65 deletions
src/node.py
+
2
−
65
View file @
ebf19906
...
@@ -320,69 +320,6 @@ class ExpressionNode(Node, ExpressionBase):
...
@@ -320,69 +320,6 @@ class ExpressionNode(Node, ExpressionBase):
self
.
value
=
OP_VALUE_MAP
[
op
]
self
.
value
=
OP_VALUE_MAP
[
op
]
self
.
op
=
op
self
.
op
=
op
def
construct_integral
(
self
,
children
):
# Make sure that any needed parentheses around f(x) are generated,
# and append ' dx' to it (result 'f(x) dx')
fx
,
x
=
self
[:
2
]
operand
=
re
.
sub
(
r
'
(\s*\*)?\s*d$
'
,
'
d
'
+
x
.
value
,
str
(
fx
*
'
d
'
))
op
=
'
int
'
# Add bounds
if
len
(
self
)
>
2
:
op
+=
self
.
construct_bounds
(
*
self
[
2
:])
# int x ^ 2 -> int x ^ 2 dx
# int x + 1 -> int (x + 1) dx
# int_a^b x ^ 2 -> int_a^b x ^ 2 dx
return
op
+
'
'
+
operand
def
construct_bounds
(
self
,
lbnd
,
ubnd
):
# FIXME: temporary fix: add parentheses around negated bounds to
# prevent a syntax error (solving the syntax error is better, but
# harder)
if
lbnd
.
negated
:
lbnds
=
'
%s(%s)
'
%
(
OP_VALUE_MAP
[
OP_SUBSCRIPT
],
lbnd
)
else
:
lbnds
=
str
(
ExpressionNode
(
OP_SUBSCRIPT
,
lbnd
))
if
ubnd
.
negated
:
ubnds
=
'
%s(%s)
'
%
(
OP_VALUE_MAP
[
OP_POW
],
ubnd
)
else
:
ubnds
=
str
(
ExpressionNode
(
OP_POW
,
ubnd
))
return
lbnds
+
ubnds
def
construct_indef_integral
(
self
,
children
):
# [x ^ 2]_a^b
F
,
lbnd
,
ubnd
=
self
#lbnd = str(ExpressionNode(OP_SUBSCRIPT, lbnd))
#ubnd = str(ExpressionNode(OP_POW, ubnd))
return
'
[%s]%s
'
%
(
F
,
self
.
construct_bounds
(
lbnd
,
ubnd
))
def
construct_function
(
self
,
children
):
if
self
.
op
==
OP_ABS
:
return
'
|%s|
'
%
children
[
0
]
constructors
=
{
#OP_DER: self.construct_derivative,
#OP_LOG: self.construct_logarithm,
OP_INT
:
self
.
construct_integral
,
OP_INT_INDEF
:
self
.
construct_indef_integral
}
if
self
.
op
in
constructors
:
result
=
constructors
[
self
.
op
](
children
)
if
result
!=
None
:
return
result
# Function with absolute value as only parameter does not need
# parentheses
if
self
.
op
in
TOKEN_MAP
and
TOKEN_MAP
[
self
.
op
]
==
'
FUNCTION
'
\
and
len
(
self
)
==
1
and
self
[
0
].
is_op
(
OP_ABS
):
return
self
.
title
()
+
children
[
0
]
def
arity
(
self
):
def
arity
(
self
):
if
self
.
op
in
UNARY_FUNCTIONS
:
if
self
.
op
in
UNARY_FUNCTIONS
:
return
1
return
1
...
@@ -666,12 +603,12 @@ class Scope(object):
...
@@ -666,12 +603,12 @@ class Scope(object):
def
replace
(
self
,
node
,
replacement
):
def
replace
(
self
,
node
,
replacement
):
self
.
remove
(
node
,
replacement
=
replacement
)
self
.
remove
(
node
,
replacement
=
replacement
)
#def as_nary_node(self):
#
FIXME:
def as_nary_node(self):
def
as_real_nary_node
(
self
):
def
as_real_nary_node
(
self
):
return
ExpressionNode
(
self
.
node
.
op
,
*
self
.
nodes
)
\
return
ExpressionNode
(
self
.
node
.
op
,
*
self
.
nodes
)
\
.
negate
(
self
.
node
.
negated
,
clone
=
False
)
.
negate
(
self
.
node
.
negated
,
clone
=
False
)
#def as_binary_node(self):
#
FIXME:
def as_binary_node(self):
def
as_nary_node
(
self
):
def
as_nary_node
(
self
):
return
nary_node
(
self
.
node
.
op
,
self
.
nodes
)
\
return
nary_node
(
self
.
node
.
op
,
self
.
nodes
)
\
.
negate
(
self
.
node
.
negated
,
clone
=
False
)
.
negate
(
self
.
node
.
negated
,
clone
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment