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

Add timedelta, timedelta64 and datetime64 plus respective conversions #509

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
093bdcb
add support for `@py from <module> import`
Feb 21, 2022
c63ab23
Merge branch 'cjdoris:main' into main
hhaensel Jul 5, 2023
5a65a52
Merge branch 'main' of https://github.com/hhaensel/PythonCall.jl
hhaensel Jun 16, 2024
5740b59
support timedelta, timedelta64, datetime64 and respective conversions
hhaensel Jun 16, 2024
f897600
fix week kw in pytimedelta64, typo (space) in builtins
hhaensel Jun 16, 2024
1e8d410
correct handling of count in 64-bit conversion rules
Jun 17, 2024
b3cc79f
Merge remote-tracking branch 'origin/main' into hh-timedelta64
hhaensel Jul 28, 2024
9dfc0dd
Apply suggestions from code review
hhaensel Sep 6, 2024
a3a2b97
Apply suggestions from code review part II
hhaensel Sep 6, 2024
daf9759
reviewers suggestions part III
hhaensel Sep 6, 2024
60e0daa
Merge branch 'JuliaPy:main' into hh-timedelta64
hhaensel Jan 19, 2025
7391b8d
add tests for pytimedelta
Jan 19, 2025
8f28567
fix micro/millisecond in pytimedelta,
Jan 20, 2025
46efe53
add tests for pytimedelta, pytimedelta64 and conversion of pytimedelt…
Jan 20, 2025
d36c113
fix pytimdelta(years/months=0), add pydatetime64(::Union{Date, DateTi…
hhaensel Jan 21, 2025
66459c6
add tests for pytimedelta64, pydatetime64
hhaensel Jan 21, 2025
3c51b54
support unitless timedelta64, keep unit per default, add keyword cano…
Jan 21, 2025
fac1ef8
add tests for timedelta64 canonicalize
Jan 21, 2025
d00a788
Merge branch 'JuliaPy:main' into hh-timedelta64
hhaensel Jan 21, 2025
5abcf1d
add CondaPkg and DataFrames as extras in Project.toml
Jan 21, 2025
34f35ce
fix pandas testing
Jan 20, 2025
9864173
fix compat with julia < 1.8
Jan 21, 2025
3148bae
specialize Base.convert(::<:Period, CompoundPeriod) for julia < 1.8
Jan 21, 2025
94b47df
change CondaPkg environment
Jan 21, 2025
f66f526
fix test/Project.toml, adapt runtests.jl
Jan 21, 2025
e9277ef
change order of args of pytimedelta; add docstrings for pytimedelta, …
Feb 19, 2025
d93e99a
remove `@py`method for python-style imports
Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add support for @py from <module> import
hhaensel committed Feb 21, 2022
commit 093bdcb09b38f60f9b277fd96978bb5628fc933e
16 changes: 16 additions & 0 deletions src/py_macro.jl
Original file line number Diff line number Diff line change
@@ -793,10 +793,26 @@ For example:
- `x.foo` is translated to `pygetattr(x, "foo")`

Compound statements such as `begin`, `if`, `while` and `for` are supported.
Import statements are supported, e.g.
- `import foo, bar`
- `from os.path import join as py_joinpath, exists`

See the online documentation for more details.
"""
macro py(ex)
esc(py_macro(ex, __module__, __source__))
end

macro py(keyword, modulename, ex)
keyword == :from || return :( nothing )

d = Dict(isa(a.args[1], Symbol) ? a.args[1] => a.args[1] : a.args[1].args[1] => a.args[2] for a in ex.args)
vars = Expr(:tuple, values(d)...)
imports = Tuple(keys(d))

esc(quote
$vars = pyimport($(string(modulename)) => $(string.(imports)))
end)
end

export @py