Skip to content

Commit eb2fb1b

Browse files
committed
Quick fix for the indexing of high level objects
1 parent d5ec355 commit eb2fb1b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/pymadng/madp_classes.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __setattr__(self, item, value):
3333
# If the attribute is private, set it as a normal attribute
3434
return super(high_level_mad_ref, self).__setattr__(item, value)
3535
# Otherwise, set the item as a variable in the MAD-NG process
36-
self[item] = (value)
36+
self[item] = value
3737

3838
def __setitem__(
3939
self,
@@ -48,7 +48,7 @@ def __setitem__(
4848
raise TypeError(
4949
"Cannot index type of ", type(item), "expected string or int"
5050
)
51-
self._mad.send_vars(**{f"{self._name}[{item+1}]": value})
51+
self._mad.send_vars(**{f"{self._name}[{item}]": value})
5252

5353
def __add__(self, rhs):
5454
return self.__generate_operation__(rhs, "+")
@@ -159,8 +159,8 @@ def __next__(self):
159159
return self[self._iterindex]
160160
except IndexError:
161161
raise StopIteration
162-
163-
def to_df(self, columns: list = None): # For backwards compatibility (jgray 2024)
162+
163+
def to_df(self, columns: list = None): # For backwards compatibility (jgray 2024)
164164
"""See `convert_to_dataframe`"""
165165
return self.convert_to_dataframe(columns)
166166

@@ -175,7 +175,9 @@ def convert_to_dataframe(self, columns: list = None):
175175
Returns:
176176
pandas.DataFrame or tfs.TfsDataFrame: The dataframe containing the object's data.
177177
"""
178-
if not self._mad.protected_variable_retrieval(f"MAD.typeid.is_mtable({self._name})"):
178+
if not self._mad.protected_variable_retrieval(
179+
f"MAD.typeid.is_mtable({self._name})"
180+
):
179181
raise TypeError("Object is not a table, cannot convert to dataframe")
180182

181183
import pandas as pd

0 commit comments

Comments
 (0)