Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Steinlechner
pykat
Commits
2afa43d4
Commit
2afa43d4
authored
10 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
adding example on how to remove and add components
parent
017c399f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/remove_add_components.py
+54
-0
54 additions, 0 deletions
examples/remove_add_components.py
with
54 additions
and
0 deletions
examples/remove_add_components.py
0 → 100644
+
54
−
0
View file @
2afa43d4
# Example showing how to remove and add components with Pykat.
# Commands that get parsed into a pykat object can be interacted
# with in a object orientated manner. So you can call kat.component.remove()
# to remove it for example.
#
# This example shows how a kat object can be manipulated when pykat objects
# are available.
#
# If the a Finesse command hasn't been implemented as a pykat object yet
# the command will be added as an "extra line", these can still be removed
# and added to using the kat.removeLine and kat.addLine commands.
#
# Daniel Brown 17/12/14
import
pykat
from
pykat.components
import
*
kat
=
pykat
.
finesse
.
kat
()
kat
.
parseCommands
(
"""
m m1 0.9 0.1 0 n1 n2
s s1 1 n2 n3
m m2 0.9 0.1 0 n3 n4
"""
)
print
"
Before...
"
print
""
.
join
(
kat
.
generateKatScript
())
kat
.
s1
.
remove
()
print
"
After remove...
"
print
""
.
join
(
kat
.
generateKatScript
())
# Adding in with commands
kat
.
parseCommands
(
"""
s s2 1 n2 n2a
m m3 0.9 0.1 0 n2a n3a
s s3 1 n3a n3
"""
)
print
"
After add with commands...
"
print
""
.
join
(
kat
.
generateKatScript
())
kat
.
s2
.
remove
()
kat
.
s3
.
remove
()
kat
.
m3
.
remove
()
# Adding in with objects
kat
.
add
(
space
(
"
s2
"
,
"
n2
"
,
"
n2a
"
,
L
=
1
))
kat
.
add
(
space
(
"
s3
"
,
"
n3
"
,
"
n3a
"
,
L
=
1
))
kat
.
add
(
mirror
(
"
m3
"
,
"
n2a
"
,
"
n3a
"
,
R
=
0.9
,
T
=
0.1
,
phi
=
0
))
print
"
After add with objects...
"
print
""
.
join
(
kat
.
generateKatScript
())
\ No newline at end of file
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