Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic API for Column-level attributes (issue #821) #893

Merged
merged 49 commits into from May 31, 2023

Conversation

jondoesntgit
Copy link
Contributor

The column-level attributes are only accessible once the table and the columns are instantiated. There's currently no support for adding attributes on creation (e.g., something like pt.Float32Col(dflt=0.0, shape=(3,2), attrs=dict(foo='bar', description='some string'))

Copy link
Member

@avalentino avalentino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the PR looks good but there are few things to address.
Also there are two important things missing:

  • unit tests
  • documentation update

tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/table.py Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
tables/attributeset.py Outdated Show resolved Hide resolved
@mennthor
Copy link
Contributor

Hi :)
What is missing / needs to be done to make this merged?

I'm creating IsDescription classes by wrapper functions to set column lengths for 1 Bit serialised bool arrays, so they take less space with np.packbits and tables.StrCol(int(np.ceil(NBITS / 8.)).
It would be great to store the number of Bits directly in the method where I'm creating the table IsDescription subclass, because I rely on that information to be present in the table attrs to properly truncate the array when deserialising after reading the table back in.

Copy link
Member

@avalentino avalentino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good to me.
Please add

  • at least basic unit tests
  • basic documentation
  • a changelog entry

tables/table.py Outdated Show resolved Hide resolved
tables/table.py Outdated Show resolved Hide resolved
@avalentino
Copy link
Member

avalentino commented Dec 15, 2021

Sorry @jondoesntgit for the long delay to provide a feedback.
The PR seems to be almost ready for merge.

zequihg50 and others added 21 commits December 16, 2021 23:15
One call to H5*ARRAYmake() used completely different indentation style.
hdf5 doesn't like that:
h5py/h5py#1948
HDFGroup/hdf5@16349c5

> The 'not suitable for filters' message does seem to have been added
> in 1.12.1 From the code, it looks like it will refuse to apply any
> filters to vlen strings.

This patch is based on the assumption that the hdf5 code is *correct*, and
indeed fletcher32 shouldn't be used in that vlarrays. But if hdf5 is wrong,
then the fix should be their side. It might make sense to apply this to
get the tests passing again, even if ultimately hdf5 is adjusted too.

Fixes PyTables#845.
Add python3.10 classifier
xmatthias and others added 6 commits December 16, 2021 23:15
This enables to attach attributes during the assembly of a IsDescription
class. Example:
```
class TableLayout(tables.IsDescription):
    freq = tables.Float32Col(
        attrs={"val": 13.3, "unit": "Hz", "description": "Ref. freq"})
```
…l_attrs

This registers the Col._v_col_attrs in the ColumnAttributeSet and stores them
as table attributes. This way column attributes set in the IsDescription
assembly are propagated to the Column attributes.
Otherwise the attributes are only build when the column is used directly
for attribute assignment. This then does not store the attributes inserted
in the IsDescription class.
@jondoesntgit
Copy link
Contributor Author

jondoesntgit commented Dec 17, 2021 via email

@avalentino avalentino added this to the Next Tasks milestone Dec 28, 2021
@Zybulon
Copy link

Zybulon commented Dec 17, 2022

Hi,
This feature is a great idea, I am very interesting in it to store units and description (like you did I guess).
Is there still a lot a work to do ? The requested changes still need to be done ?

@mennthor
Copy link
Contributor

@Zybulon I adressed the original leftover tasks quite a while ago, but I'm not sure where this currently stands

@avalentino
Copy link
Member

Could you please push new changes in this PR?
I hope that @jondoesntgit doesn't mind it.

@Zybulon
Copy link

Zybulon commented Jan 3, 2023

I am not very familiar with Github so I might misunderstand some things. @jondoesntgit does not seems very active, so I guess we can't push code in this PR, am I wrong ? Maybe @mennthor can create a new PR to push its modifications ?
Edit : sorry I confused your names

@jondoesntgit
Copy link
Contributor Author

jondoesntgit commented Jan 3, 2023 via email

@Zybulon
Copy link

Zybulon commented Jan 8, 2023

@jondoesntgit I think you can accept menthor's commit in your fork, can you do it ? It should be immediate since there is not conflict.

Requested updates to merge PyTables PR PyTables#893
@jondoesntgit
Copy link
Contributor Author

Is git rebase the right move at this point?

@avalentino
Copy link
Member

Is git rebase the right move at this point?

you can re-base or merge master into your branch

@jondoesntgit
Copy link
Contributor Author

Back in January, I did a rebase, and then I just did a merge a few minutes ago. I'm sorry that this has taken so long.

Let me know if there's any issues with merging this into master. I'm needing to factory-reset my laptop, and this is the last thing I'm waiting for before I factory reset.

@avalentino
Copy link
Member

Dear @jondoesntgit, thanks a lot for you effort.
Could you please just remove the appveyor.yml file?
I think that ir was removed in master after your initial PR.

@jondoesntgit
Copy link
Contributor Author

@avalentino Done

@avalentino avalentino merged commit f8ad2f1 into PyTables:master May 31, 2023
15 checks passed
@avalentino
Copy link
Member

Thanks again @jondoesntgit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet