Skip to content
Snippets Groups Projects
Commit b38f00b1 authored by florent's avatar florent
Browse files

Add a function to convert a string to a tuple

    * src/dynamic_graph/signal_base.py: string format should be
    '[n](x_1,...,x_{n-1}'.
parent 68569d6e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,28 @@
Author: Florent Lamiraux
"""
import wrap
import re
def stringToTuple(vector):
"""
Transform a string of format '[n](x_1, x_2, ..., x_{n-1} into a list of
numbers
"""
# Find vector length
a = re.search('[\d]', vector)
size = int(a.group(0))
format = '\('
for i in range(size):
format += '(.*)'
if i != size-1:
format += ','
format += '\)'
a = re.search(format, vector)
res = []
for i in range(1, size+1):
res.append(float(a.group(i)))
return tuple(res)
class SignalBase (object) :
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment