Open ligerzero-ai opened 1 year ago
It's undocumented and highly non-intuitive, but you're not actually supposed to add the pre-defined function manually back into the table. Instead you should do
tab.add.get_energy_pot
tab.add.get_elements
...
just accessing the elements adds the functions to the table. This is not written anywhere and doesn't make sense to the uninitiated. It's knowledge that can only be gleaned by studying the S'urce by oneself. Now having added the functions this way, them returning dictionaries instead of straight values causes the table to create multiple columns from one function (one for each key in the dictionary). If you look at the code doing tab.add['foo'] = bar
will actually add a function lambda j: {'foo': bar(j)}
into the table, inline with this mechanism above.
There's a lot I think that should change, but that I never got around to:
tab.add.energy_pot()
or something to do the additiontable.add['foo', 'bar']
?df['new'] = df.old.map(function)
, but if I could do it in one place it'd make me a bit happier.Okay, I'll leave this issue open as a reminder to look at it at some point to finish the implementation.
I think that it feels better/more elegant to call:
pr.create_table(properties = [job_name, energy_pot, energy_tot, ...])
And the docstring contains an example/usage pointer to:
pr.create_table.prop_list
which returns a list of strings that can be added to the list to generate the table.
So by default we can have pr.create_table(properties = self.prop_list)
.
rather than having a whole bunch of tab.add lines which is the current unfinished implementation.
What do you think?
https://github.com/pyiron/pyiron_atomistics/blob/master/pyiron_atomistics/table/funct.py
I'm wondering why these functions all return a dictionary key-pair? What is the intended form of usage for these functions?
e.g. when I am creating a table, I would use functions that return directly a value/string/list.
Using the inbuilt functions:
df_no_shift now has dictionaries in every column with key-pair values. I would think that this is not the intended use case. What exactly is the intended use case for this? Are we supposed to be using these functions to build dictionaries with key-pair values and just build a dataframe from the concatenated dictionary?
pd.DataFrame(concatenated_dict_list)