Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit daacc99

Browse filesBrowse files
committed
Convert some dates.py docstrings to numpydoc
1 parent 54adb36 commit daacc99
Copy full SHA for daacc99

File tree

Expand file treeCollapse file tree

1 file changed

+57
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+57
-18
lines changed

‎lib/matplotlib/dates.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dates.py
+57-18Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def tzname(self, dt):
164164
def dst(self, dt):
165165
return datetime.timedelta(0)
166166

167+
167168
UTC = _UTC()
168169

169170

@@ -327,8 +328,8 @@ def datestr2num(d, default=None):
327328
d : string or sequence of strings
328329
The dates to convert.
329330
330-
default : datetime instance
331-
The default date to use when fields are missing in `d`.
331+
default : datetime instance, optional
332+
The default date to use when fields are missing in *d*.
332333
"""
333334
if isinstance(d, six.string_types):
334335
dt = dateutil.parser.parse(d, default=default)
@@ -344,14 +345,23 @@ def datestr2num(d, default=None):
344345

345346
def date2num(d):
346347
"""
347-
*d* is either a :class:`datetime` instance or a sequence of datetimes.
348+
Converts datetime objects to Matplotlib dates.
349+
350+
Parameters
351+
----------
352+
d: :class:`datetime` or sequence of :class:`datetime`
348353
349-
Return value is a floating point number (or sequence of floats)
350-
which gives the number of days (fraction part represents hours,
351-
minutes, seconds) since 0001-01-01 00:00:00 UTC, *plus* *one*.
352-
The addition of one here is a historical artifact. Also, note
353-
that the Gregorian calendar is assumed; this is not universal
354-
practice. For details, see the module docstring.
354+
Returns
355+
-------
356+
float or sequence of floats
357+
Number of days (fraction part represents hours, minutes, seconds)
358+
since 0001-01-01 00:00:00 UTC, plus one.
359+
360+
Notes
361+
-----
362+
The addition of one here is a historical artifact. Also, note that the
363+
Gregorian calendar is assumed; this is not universal practice.
364+
For details see the module docstring.
355365
"""
356366
if not cbook.iterable(d):
357367
return _to_ordinalf(d)
@@ -365,6 +375,16 @@ def date2num(d):
365375
def julian2num(j):
366376
"""
367377
Convert a Julian date (or sequence) to a matplotlib date (or sequence).
378+
379+
Parameters
380+
----------
381+
k: float or sequence of floats
382+
Julian date(s)
383+
384+
Returns
385+
-------
386+
float or sequency of floats
387+
Matplotlib date(s)
368388
"""
369389
if cbook.iterable(j):
370390
j = np.asarray(j)
@@ -373,7 +393,17 @@ def julian2num(j):
373393

374394
def num2julian(n):
375395
"""
376-
Convert a matplotlib date (or sequence) to a Julian date (or sequence).
396+
Convert a Matplotlib date (or sequence) to a Julian date (or sequence).
397+
398+
Parameters
399+
----------
400+
n: float or sequence of floats
401+
Matplotlib date(s)
402+
403+
Returns
404+
-------
405+
float or sequency of floats
406+
Julian date(s)
377407
"""
378408
if cbook.iterable(n):
379409
n = np.asarray(n)
@@ -382,18 +412,27 @@ def num2julian(n):
382412

383413
def num2date(x, tz=None):
384414
"""
385-
*x* is a float value which gives the number of days
386-
(fraction part represents hours, minutes, seconds) since
387-
0001-01-01 00:00:00 UTC *plus* *one*.
388-
The addition of one here is a historical artifact. Also, note
389-
that the Gregorian calendar is assumed; this is not universal
390-
practice. For details, see the module docstring.
415+
Parameters
416+
----------
417+
x: float
418+
Number of days (fraction part represents hours, minutes, seconds)
419+
since 0001-01-01 00:00:00 UTC, plus one.
420+
tz: string, optional
421+
Timezone of *x* (defaults to rcparams TZ value).
391422
392-
Return value is a :class:`datetime` instance in timezone *tz* (default to
393-
rcparams TZ value).
423+
Returns
424+
-------
425+
:class:`datetime` or sequence of :class:`datetime`
426+
Dates are returned in timezone *tz*
394427
395428
If *x* is a sequence, a sequence of :class:`datetime` objects will
396429
be returned.
430+
431+
Notes
432+
-----
433+
The addition of one here is a historical artifact. Also, note that the
434+
Gregorian calendar is assumed; this is not universal practice.
435+
For details, see the module docstring.
397436
"""
398437
if tz is None:
399438
tz = _get_rc_timezone()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.