-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
DOC: Add 'now' string to datetime64 documentation #29534
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
base: main
Are you sure you want to change the base?
Conversation
…tions] [skip cirrus]
How are these documentation examples passing the doctests without any hints to doctest to ignore the results? @ev-br are we running doctests on this? |
We don't and I don't know if we ever did :-). Applying $ git diff
diff --git a/.spin/cmds.py b/.spin/cmds.py
index 66885de630..e89f535e5f 100644
--- a/.spin/cmds.py
+++ b/.spin/cmds.py
@@ -242,7 +242,7 @@ def check_tutorials(*, parent_callback, pytest_args, **kwargs):
# - `spin check-tutorials path/to/rst`, and
# - `spin check-tutorials path/to/rst -- --durations=3`
if (not pytest_args) or all(arg.startswith('-') for arg in pytest_args):
- pytest_args = ('doc/source/user',) + pytest_args
+ pytest_args = ('doc/source/user', 'doc/source/reference/') + pytest_args
# make all paths relative to the numpy source folder
pytest_args = tuple( produces on main
Some errors are relatively mild and are easy to fix or work around. Otherwise, there's a list problematic tutorials to skip wholesale: https://github.com/numpy/numpy/blob/main/numpy/conftest.py#L215 |
Summary
This PR adds documentation for the string
"now"
as a valid argument tonp.datetime64
.The string
"now"
returns the current UTC time. By default, it uses second (s
) precision, but you can specify a different unit (e.g.,'M'
,'D'
,'h'
) to truncate the result to that precision. Units finer than seconds (such as'ms'
or'ns'
) are supported but will display fractional parts as zeros, effectively truncating to whole seconds. This behavior is already supported internally but was previously undocumented.✅ Example added
The example is placed immediately before the
"today"
example in the "Basic datetimes" section, so readers can compare their behaviors easily.Context
"now"
and notes its UTC semantics and default second-level precision."now"
with an example, but was closed without merge due to procedural issues."today"
string (merged), adding its explanation and example to this section.This PR documents
"now"
with explicit mention of its default precision, UTC behavior, and unit truncation to address potential user confusion.Thanks for considering this improvement!