-
Notifications
You must be signed in to change notification settings - Fork 190
feat(DRAFT): Add get_supertype
#3396
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
Draft
dangotbanned
wants to merge
127
commits into
main
Choose a base branch
from
dtypes/supertyping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 99 commits
Commits
Show all changes
127 commits
Select commit
Hold shift + click to select a range
0f5905d
WIP
FBruzzesi bd7d0d9
chore: Appease `ruff`
dangotbanned dcd6d79
chore: Appease `mypy`
dangotbanned 560d577
test: xfail a todo
dangotbanned b40a6a9
refactor: Split out supertyping from `dtypes`
dangotbanned dade8f2
chore: Define integer bits in the class def
dangotbanned 5892f7a
start adding typing
dangotbanned 36ce6ea
fix: wow
dangotbanned 46c21a2
refactor: Use `IntegerType._bits`
dangotbanned ea6b143
skip using `DTypes` for `IntegerType`s
dangotbanned 3743462
a bit more typing-friendly
dangotbanned 37ba753
`None` can't return here
dangotbanned c2d9ddf
refactor: No versioning needed for `Float64`
dangotbanned 48c952d
test: Add ids for tests
dangotbanned 34c8088
change the problem to be which function
dangotbanned 3f4706d
Generate a (cached) `IntegerType` search space instead
dangotbanned 1a0f193
docs: Add links for `Enum`
dangotbanned 9a19344
cheaper float compare
dangotbanned 1e64d47
cheaper int, float compare
dangotbanned 2fd8800
add `DType.__eq__` todo
dangotbanned 7425ecc
avoid repeating binary checks
dangotbanned 69949f0
perf: Use `min(..., key=...)` and move cache for `_min_time_unit`
dangotbanned 9b58520
why not do the same for `FloatType`?
dangotbanned 433e439
test(DRAFT): Try to get more cov
dangotbanned 63a1764
test: Almost full cov
dangotbanned f5b65ef
test: And yet more coverage
dangotbanned b5521e4
docs: Add todos for temporal -> numeric
dangotbanned 0074caa
perf: Don't lookup the type you have already!
dangotbanned 9488191
refactor: Generalize `_max_float`
dangotbanned 89043d1
Make `(Date, Datetime)` preferable to Numeric
dangotbanned 1ecdee1
more useful `Struct` todo
dangotbanned 1482572
test: Prepare `(Temporal, Numeric)` cases
dangotbanned b375a16
test: more test id fiddling
dangotbanned 476e71e
Note a funky idea
dangotbanned 09a8000
getting started on `Struct`
dangotbanned edb5ede
feat: Add `Struct` supertyping
dangotbanned 7e8b5f6
test: Cover more `Struct`
dangotbanned 15f9c9c
test: Add more `Struct` cases
dangotbanned 131e9ed
rename, reuse `IntoDType -> DType` helpers
dangotbanned 4420d37
oops typo
dangotbanned bdbb1c5
feat(DRAFT): `DType.__call__` experiment
dangotbanned b291324
refactor: Tighten-up integer supertyping
dangotbanned d109a86
Merge remote-tracking branch 'upstream/HEAD' into dtypes/supertyping
dangotbanned f742054
fix: Require `Enum` categories to match
dangotbanned 9c4e650
chore: Write some todo essays
dangotbanned 08525ef
refactor: Make `dtypes` a package
dangotbanned ac4286d
perf: Make all *visible* imports module-level
dangotbanned c251707
perf: Use direct instance checks
dangotbanned a84dd60
perf: Avoid using `DTypes` when it refs an alias export
dangotbanned d36fd7d
docs: todo -> note
dangotbanned 7b142cd
Absolutely giant refactor!
dangotbanned 2825970
refactor: use `frozen_dtypes` more
dangotbanned 8448858
refactor: Move things back into `_integer_supertyping`
dangotbanned 6a1a461
fix: TypeError: type 'operator.attrgetter' is not subscriptable
dangotbanned c7bfd9f
test: Prep some `v1` tests
dangotbanned 85b3938
feat: Impl `_get_supertype_v1`
dangotbanned cc40d52
test: Cover nested `v1` dtypes
dangotbanned 72173fb
test: `@parametrize` over `Version`
dangotbanned 5542ca8
chore(typing): Widen `list` -> `Collection`
dangotbanned 244537d
test: Fix parameterized `Version` `slow` reuse
dangotbanned 2f2cda9
why are you like this mypy
dangotbanned c8d1cff
Fix (Decimal, FloatX) case
FBruzzesi 55a7de3
clean up Float dtypes, add issue link
FBruzzesi 443d9cc
split up tests
FBruzzesi d719bcc
test: Fix more test ids
dangotbanned da29e9a
Merge branch 'main' into dtypes/supertyping
dangotbanned 36f2a4e
test: Move, rename `dtype_ids`
dangotbanned 6d30302
rename _intersect to _has_intersection
FBruzzesi 2c3b145
test mixed version return None
FBruzzesi 1f38f37
test: fix always true
dangotbanned 84468ea
Merge branch 'dtypes/supertyping' of https://github.com/narwhals-dev/…
dangotbanned af92d34
check symmetrical, add versions, rm comment
FBruzzesi 42c96ab
merge head
FBruzzesi 6269876
test: Add `numeric_dtype` fixture
dangotbanned 0e9d51b
test: Add `naive_temporal_dtype` fixture
dangotbanned 6cc3d91
cov
dangotbanned d2c96fe
refactor: Rename `narwhals.dtypes.classes` -> `narwhals.dtypes._classes`
dangotbanned 2eaf88d
refactor: `narwhals.stable.v1._dtypes` -> `narwhals.dtypes._classes_v1`
dangotbanned e71bc47
perf: Avoid inline imports for `v1` dtypes
dangotbanned fc9134d
docs: Explain `has_nested` heavy-lifting
dangotbanned fae966b
flip left,right for test_numeric_promotion
FBruzzesi 085fc4d
refactor: Factor-out `version: Version`
dangotbanned 4b8eed2
I can't believe you've done this
dangotbanned d681c10
chore: Add a bound to `downcast_time_unit`
dangotbanned 9b67280
docs: Convert `_mixed_supertype` comments
dangotbanned 7670022
docs: Convert `_numeric_supertype` comments
dangotbanned 65faf13
docs: Some attempt at explaining `Struct`
dangotbanned b3121ea
refactor: merge dispatch tables, add docs
dangotbanned 3f98168
test: Remove `slow` marker
dangotbanned 7d7531f
remove comment
dangotbanned 0309bde
Merge remote-tracking branch 'upstream/main' into dtypes/supertyping
dangotbanned 9ab5748
fix(typing): Ensure all dispatch functions return `DType`
dangotbanned ff1933d
fix(typing): Mostly get scoping working
dangotbanned a0bad9d
perf: Reuse cached `DType.__eq__`
dangotbanned ca45998
chore: Renames, remove unused
dangotbanned 933750a
test: More de-duplicating
dangotbanned 48b51eb
revert: woops, how did those vanish?
dangotbanned b1221f4
chore: Add `promotion-rules.md` script
dangotbanned 91697b6
docs: Manually generate `promotion-rules.md`
dangotbanned a272b21
Add promotion rules explainations, move to jinja template
FBruzzesi 9382b84
Feedback adjustment in promotion-rules.md, add mkdocs hook, fix script
FBruzzesi 2924433
duh!
FBruzzesi f72cd11
duh! part 2
FBruzzesi e0f8ce5
refactor: Use self-documenting constants instead of index in `time_unit`
dangotbanned fc66091
Merge branch 'main' into dtypes/supertyping
dangotbanned d84afa2
promotion-rules.md.jinja feedback adjustments
FBruzzesi 39adca4
fix english
FBruzzesi fd7dbe4
docs: Template the template for templating
dangotbanned ed1b614
docs: Remove repeat inline supertype docs (#3411)
dangotbanned d66d07f
refactor: Deduplicate `v1` dtypes imports
dangotbanned fdd1bc3
merge main and solve conflicts
FBruzzesi 42caf17
WIP: Add support for (Decimal, Decimal)
FBruzzesi ec0401f
{Decimal, IntegerType} case
FBruzzesi b5ae62a
simplify a bit
FBruzzesi 8dbd2ef
fix typing issue + function renaming
FBruzzesi 69b07f3
merge main
FBruzzesi 3ad1639
add support for {List, Array} -> List
FBruzzesi 8d9e053
add support for {String, X} -> String, for X not Binary
FBruzzesi ef2c7db
update docs for {String, X} and {List, Array} cases
FBruzzesi 88683e0
Merge branch 'main' into dtypes/supertyping
FBruzzesi 8ecb636
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] eeb822d
Merge remote-tracking branch 'upstream/main' into dtypes/supertyping
dangotbanned 9ed0d17
fiddle with `(Array, List) -> List`
dangotbanned 548e5b8
refactor: Reduce `String` branching
dangotbanned bb2846f
Merge branch 'main' into dtypes/supertyping
dangotbanned 8757b4f
refactor: Replace ad-hoc dispatch with custom `@singledispatch` (#3410)
dangotbanned dd14fd1
Merge branch 'main' into dtypes/supertyping
dangotbanned File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| | | Array | Binary | Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int8 | List | Object | String | Struct | Time | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 | Unknown | | ||
| |-------------|---------|---------|---------|-------------|----------|----------|---------|----------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------| | ||
| | Array | Array | | | | | | | | | | | | | | | | | | | | | | | | | | Unknown | | ||
| | Binary | | Binary | | | | | | | | | | | | | | | | | Binary | | | | | | | | Unknown | | ||
| | Boolean | | | Boolean | | | | Decimal | | | Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int8 | | | | | | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 | Unknown | | ||
| | Categorical | | | | Categorical | | | | | | | | | | | | | | | String | | | | | | | | Unknown | | ||
| | Date | | | | | Date | Datetime | | | | | | | | | | | | | | | | | | | | | Unknown | | ||
| | Datetime | | | | | Datetime | Datetime | | | | | | | | | | | | | | | | | | | | | Unknown | | ||
| | Decimal | | | Decimal | | | | Decimal | | | Float64 | Float64 | Decimal | Decimal | Decimal | Decimal | Decimal | | | | | | Decimal | Decimal | Decimal | Decimal | Decimal | Unknown | | ||
| | Duration | | | | | | | | Duration | | | | | | | | | | | | | | | | | | | Unknown | | ||
| | Enum | | | | | | | | | Enum | | | | | | | | | | String | | | | | | | | Unknown | | ||
| | Float32 | | | Float32 | | | | Float64 | | | Float32 | Float64 | Float64 | Float32 | Float64 | Float64 | Float32 | | | | | | Float64 | Float32 | Float64 | Float64 | Float32 | Unknown | | ||
| | Float64 | | | Float64 | | | | Float64 | | | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | | | | | | Float64 | Float64 | Float64 | Float64 | Float64 | Unknown | | ||
| | Int128 | | | Int128 | | | | Decimal | | | Float64 | Float64 | Int128 | Int128 | Int128 | Int128 | Int128 | | | | | | Float64 | Int128 | Int128 | Int128 | Int128 | Unknown | | ||
| | Int16 | | | Int16 | | | | Decimal | | | Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int16 | | | | | | Float64 | Int32 | Int64 | Float64 | Int16 | Unknown | | ||
| | Int32 | | | Int32 | | | | Decimal | | | Float64 | Float64 | Int128 | Int32 | Int32 | Int64 | Int32 | | | | | | Float64 | Int32 | Int64 | Float64 | Int32 | Unknown | | ||
| | Int64 | | | Int64 | | | | Decimal | | | Float64 | Float64 | Int128 | Int64 | Int64 | Int64 | Int64 | | | | | | Float64 | Int64 | Int64 | Float64 | Int64 | Unknown | | ||
| | Int8 | | | Int8 | | | | Decimal | | | Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int8 | | | | | | Float64 | Int32 | Int64 | Float64 | Int16 | Unknown | | ||
| | List | | | | | | | | | | | | | | | | | List | | | | | | | | | | Unknown | | ||
| | Object | | | | | | | | | | | | | | | | | | Object | | | | | | | | | Unknown | | ||
| | String | | Binary | | String | | | | | String | | | | | | | | | | String | | | | | | | | Unknown | | ||
| | Struct | | | | | | | | | | | | | | | | | | | | Struct | | | | | | | Unknown | | ||
| | Time | | | | | | | | | | | | | | | | | | | | | Time | | | | | | Unknown | | ||
| | UInt128 | | | UInt128 | | | | Decimal | | | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | | | | | | UInt128 | UInt128 | UInt128 | UInt128 | UInt128 | Unknown | | ||
| | UInt16 | | | UInt16 | | | | Decimal | | | Float32 | Float64 | Int128 | Int32 | Int32 | Int64 | Int32 | | | | | | UInt128 | UInt16 | UInt32 | UInt64 | UInt16 | Unknown | | ||
| | UInt32 | | | UInt32 | | | | Decimal | | | Float64 | Float64 | Int128 | Int64 | Int64 | Int64 | Int64 | | | | | | UInt128 | UInt32 | UInt32 | UInt64 | UInt32 | Unknown | | ||
| | UInt64 | | | UInt64 | | | | Decimal | | | Float64 | Float64 | Int128 | Float64 | Float64 | Float64 | Float64 | | | | | | UInt128 | UInt64 | UInt64 | UInt64 | UInt64 | Unknown | | ||
| | UInt8 | | | UInt8 | | | | Decimal | | | Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int16 | | | | | | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 | Unknown | | ||
| | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | Unknown | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from narwhals.dtypes._classes import ( | ||
| Array, | ||
| Binary, | ||
| Boolean, | ||
| Categorical, | ||
| Date, | ||
| Datetime, | ||
| Decimal, | ||
| DType, | ||
| Duration, | ||
| Enum, | ||
| Field, | ||
| Float32, | ||
| Float64, | ||
| FloatType, | ||
| Int8, | ||
| Int16, | ||
| Int32, | ||
| Int64, | ||
| Int128, | ||
| IntegerType, | ||
| List, | ||
| NestedType, | ||
| NumericType, | ||
| Object, | ||
| SignedIntegerType, | ||
| String, | ||
| Struct, | ||
| TemporalType, | ||
| Time, | ||
| UInt8, | ||
| UInt16, | ||
| UInt32, | ||
| UInt64, | ||
| UInt128, | ||
| Unknown, | ||
| UnsignedIntegerType, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "Array", | ||
| "Binary", | ||
| "Boolean", | ||
| "Categorical", | ||
| "DType", | ||
| "Date", | ||
| "Datetime", | ||
| "Decimal", | ||
| "Duration", | ||
| "Enum", | ||
| "Field", | ||
| "Float32", | ||
| "Float64", | ||
| "FloatType", | ||
| "Int8", | ||
| "Int16", | ||
| "Int32", | ||
| "Int64", | ||
| "Int128", | ||
| "IntegerType", | ||
| "List", | ||
| "NestedType", | ||
| "NumericType", | ||
| "Object", | ||
| "SignedIntegerType", | ||
| "String", | ||
| "Struct", | ||
| "TemporalType", | ||
| "Time", | ||
| "UInt8", | ||
| "UInt16", | ||
| "UInt32", | ||
| "UInt64", | ||
| "UInt128", | ||
| "Unknown", | ||
| "UnsignedIntegerType", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.