File: coding.py

package info (click to toggle)
python-xarray 2025.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,796 kB
  • sloc: python: 115,416; makefile: 258; sh: 47
file content (18 lines) | stat: -rw-r--r-- 520 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import numpy as np

import xarray as xr

from . import parameterized


@parameterized(["calendar"], [("standard", "noleap")])
class EncodeCFDatetime:
    def setup(self, calendar):
        self.units = "days since 2000-01-01"
        self.dtype = np.dtype("int64")
        self.times = xr.date_range(
            "2000", freq="D", periods=10000, calendar=calendar
        ).values

    def time_encode_cf_datetime(self, calendar):
        xr.coding.times.encode_cf_datetime(self.times, self.units, calendar, self.dtype)