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

Relax Table schema constructor #2850

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Relax Table schema constructor #2850

merged 1 commit into from
Nov 15, 2024

Conversation

texodus
Copy link
Member

@texodus texodus commented Nov 15, 2024

This PR adds support for using native Python types as column type specifiers, when creating a Perspective Table from a schema. The available types are based on the types allowed in 2.10.1:

table = perspective.table({
    "integer": int,
    "float": float,
    "string": str,
    "boolean": bool,
    "date": datetime.date,
    "datetime": datetime.datetime,
})

It is worth noting that despite the use of date and datetime python types as schema specifiers for legacy support, 3.x does not support date or datetime values when provided to the table constructor function in a dict or list input type (though you may extend native json parsing to allow this, or use pandas.DataFrame to marshall these to for you, see the 3.x release notes).

This support is a convenience feature for existing integrations with the old API. Unlike the old API, Table::schema and View::schema (and all existing and future APIs that use Perspective visual types) will only return String.

Also fixed, PerspectiveWidget was moved to a sub-module in #2728, but the reference to this class was left in the root __init__.py's __all__ variable. A test for this has been added as well - which may seem a bit ham-fisted, but even perspective's own repo lacked a test-path which included from perspective import * to expose this case beforehand, so ...

@texodus texodus added bug Concrete, reproducible bugs enhancement Feature requests or improvements and removed bug Concrete, reproducible bugs labels Nov 15, 2024
@texodus texodus marked this pull request as ready for review November 15, 2024 09:37
@texodus texodus merged commit d630f0f into master Nov 15, 2024
13 checks passed
@texodus texodus deleted the python-schema-relax branch November 15, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant