I have a class similar to the example below
class P(param.Parameterized):
a = param.Array()
r = param.Array()
d = param.DataFrame()
def setup(self):
axis_names = [f"Axis_{i+1}" for i in range(5)]
dt = np.dtype([('expected', 'i4'), ('actual', 'i4')])
self.a = np.random.randint(0,100, (10,10))
comp_dt_lst = [(ax, dt) for ax in axis_names]
self.dtype = np.dtype(comp_dt_lst)
self.r = self.a.view(self.dtype, np.recarray)
cnames = []
for axis_name in axis_names:
cnames.extend([i for i in itertools.product((axis_name,), dt.names)])
print(cnames)
# Set the pandas.DataFrame column indexs to the column tuples.
columns = pd.MultiIndex.from_tuples(cnames)
# This makes a MultiIndex which is supported in pandas but is not supported in param and panel libraries for
# dynamic viewing. For that reason the next few lines of code with compress the MultiIndex columns into a single
# set of columns with the form 'AxisName_SampleName'
df = pd.DataFrame(self.a,
columns=columns
)
df.columns = ["_".join(col) for col in df.columns]
# TODO: We can set a flag later to use the MultiIndex columns or the flat columns when param and panel supports
# that tye of indexing.
self.d = df
I’m using this basic example to test the usage pattern where I store a numpy.ndarray once but keep both a numpy recarray and pandas Dataframe view of the same data to allow for different access patterns a viewing with panel without duplicating the large array in memory.
this example works as you can see from the example below
However I have this same basic pattern in a much larger class but when I try to assign a value to the main numpy array I get a ValueError: assignment destination is read-only. I have not declared any of the paramerters in param.Parameterized class as readonly or constant but continue to get this simple ValueError.
Is there a way to track down were the readonly designation is being applied via some other more detailed stack trace? I’m beyond frustrated with trying ot figure out why the main array is being assigned as readonly when I have made no such designation in my code.