Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
pymdptoolbox
Commits
852347f8
Commit
852347f8
authored
Mar 10, 2014
by
Steven Cordwell
Browse files
remove unnecessary list generator notation from tuple creation
parent
bfb2d6cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/mdptoolbox/mdp.py
View file @
852347f8
...
...
@@ -205,7 +205,7 @@ class MDP(object):
except
AttributeError
:
self
.
S
=
P
[
0
].
shape
[
0
]
# convert P to a tuple of numpy arrays
self
.
P
=
tuple
(
[
P
[
aa
]
for
aa
in
range
(
self
.
A
)
]
)
self
.
P
=
tuple
(
P
[
aa
]
for
aa
in
range
(
self
.
A
))
def
_computePR
(
self
,
P
,
R
):
# Compute the reward for the system in one state chosing an action.
...
...
@@ -233,20 +233,20 @@ class MDP(object):
try
:
if
R
.
ndim
==
1
:
r
=
array
(
R
).
reshape
(
self
.
S
)
self
.
R
=
tuple
(
[
r
for
aa
in
range
(
self
.
A
)
]
)
self
.
R
=
tuple
(
r
for
aa
in
range
(
self
.
A
))
elif
R
.
ndim
==
2
:
self
.
R
=
tuple
(
[
array
(
R
[:,
aa
]).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)
]
)
self
.
R
=
tuple
(
array
(
R
[:,
aa
]).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
))
else
:
self
.
R
=
tuple
(
[
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)
]
)
self
.
R
=
tuple
(
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
))
except
AttributeError
:
if
len
(
R
)
==
self
.
A
:
self
.
R
=
tuple
(
[
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)
]
)
self
.
R
=
tuple
(
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
))
else
:
r
=
array
(
R
).
reshape
(
self
.
S
)
self
.
R
=
tuple
(
[
r
for
aa
in
range
(
self
.
A
)
]
)
self
.
R
=
tuple
(
r
for
aa
in
range
(
self
.
A
))
def
run
(
self
):
# Raise error because child classes should implement this function.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment