datetime support not working for cf.Data made from a scalar

未關閉
#955 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python
領域
data

研究方向

先重現 issue 中的純量 cf.Data 範例,並追蹤其 year 屬性如何針對給定的 noleap 日期計算。檢查純量專用的 datetime 處理,並驗證結果是整數年份 -1,而不是錯誤的字串。

由索引模型根據 Issue 內容生成。

描述

bug?

I think this should return an integer year, but actually it returns a string (whose contents is incorrect):

>>> cf.Data(-182500.0,units='days since 0001-01-01 00:00:00',calendar='noleap').year               
<CF Data(): -0001-08-20 00:00:00 noleap>

I think it's because it's a scalar.

Maybe this is a bug which has been fixed since I last installed the packages (on jasmin)

>>> cf.environment(paths=False)
Platform: Linux-5.14.0-611.54.1.el9_7.x86_64-x86_64-with-glibc2.34
Python: 3.12.11
packaging: 25.0
numpy: 2.2.6
cfdm.core: 1.12.2.0
udunits2 library: /apps/jasmin/jaspy/miniforge_envs/jaspy3.12/mf3-25.3.0-3/envs/jaspy3.12-mf3-25.3.0-3-v20250704/lib/libudunits2.so.0
HDF5 library: 1.14.3
netcdf library: 4.9.2
netCDF4: 1.7.2
h5netcdf: 1.6.3
h5py: 3.13.0
zarr: 3.0.10
s3fs: 2025.5.1
scipy: 1.15.2
dask: 2025.5.1
cftime: 1.6.4
cfunits: 3.3.7
cfdm: 1.12.2.0
esmpy/ESMF: 8.8.1
psutil: 7.0.0
matplotlib: 3.10.3
cfplot: 3.4.0
cf: 3.18.0

Thanks

Jonathan

主要語言
Python
星號
151
分支
23
平均合併
1 天 2 小時
30 天內合併 PR
1

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NCAS-CMS/cf-python 的其他 Issue

查看 NCAS-CMS/cf-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。