Most construct data wiped when unary operator taken of field
まだ誰も着手していません。
評価
調査の方向性
まず、cf.example_fields() とフィールドの単項否定で問題を再現し、-f[0] と -1*f[0] を比較します。Field の単項マイナスのエントリポイントを追跡し、メタデータコンストラクトのデータがクリアされる理由を確認します。コンストラクトがデータを保持し、cf-plot cfp.vect(u=c, v=-g) のケースで AttributeError が発生しなくなれば、修正は完了です。
索引モデルが issue の本文から書いたものです。
説明
Here's a funky one for the end of the working week! When taking the additive inverse i.e. negative of a field, the additive inverse of the (field) data is correctly taken but it results, as an unintended side effect, in all of the data for the metadata constructs being wiped, somehow (no time to investigate until next week, and I won't speculate quite how this even happens!). Note that an operation of -f shows this bug but -1*f does not, which implies it is likely an issue with the setup/logic of the - operator on a field.
Quick examples:
>>> f = cf.example_fields()
>>> print(f[0].data) # all good
[[0.007, ..., 0.013]] 1
>>> print(-f[0].data) # all good
[[-0.007, ..., -0.013]] 1
>>> print(-f[0]) # not all good - see the dim coords
Field: specific_humidity (ncvar%q)
----------------------------------
Data : specific_humidity(latitude(5), longitude(8)) 1
Cell methods : area: mean
Dimension coords: latitude(5) =
: longitude(8) =
: time(1) =
>>> print(-1*f[0]) # also all good
Field: specific_humidity (ncvar%q)
----------------------------------
Data : specific_humidity(latitude(5), longitude(8)) 1
Cell methods : area: mean
Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north
: longitude(8) = [22.5, ..., 337.5] degrees_east
: time(1) = [2019-01-01 00:00:00]
>>>
>>> print(-f[1]) # note from this result that other constructs are affected too
Field: air_temperature (ncvar%ta)
---------------------------------
Data : air_temperature(atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) K
Cell methods : grid_latitude(10): grid_longitude(9): mean where land (interval: 0.1 degrees) time(1): maximum
Field ancils : air_temperature standard_error
Dimension coords: atmosphere_hybrid_height_coordinate(1) =
: grid_latitude(10) =
: grid_longitude(9) =
: time(1) =
Auxiliary coords: latitude
: longitude
: long_name=Grid latitude name
Cell measures : measure:area
Coord references: grid_mapping_name:rotated_latitude_longitude
: standard_name:atmosphere_hybrid_height_coordinate
Domain ancils : atmosphere_hybrid_height_coordinate
: ncvar%b
: surface_altitude
I noticed this during working through issues in the cf-plot basic test suite, whereby a call to cfp.vect(u=c, v=-g) was failing with the error AttributeError: DimensionCoordinate has no data due to the underlying issue whereby the - operation is taken for the field input as the v argument. Which indicates it is more than a representational issue (i.e. the data is missing from the printed output), but I am yet to explore further.
Environment
Using the main branch:
>>> cf.environment()
Platform: Linux-6.5.13-7-MANJARO-x86_64-with-glibc2.39
HDF5 library: 1.14.2
netcdf library: 4.9.2
udunits2 library: /home/slb93/miniconda3/envs/cf-env-312/lib/libudunits2.so.0
esmpy/ESMF: 8.4.2 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/esmpy/__init__.py
Python: 3.12.0 /home/slb93/miniconda3/envs/cf-env-312/bin/python
dask: 2024.7.0 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/dask/__init__.py
netCDF4: 1.6.5 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/netCDF4/__init__.py
psutil: 5.9.5 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/psutil/__init__.py
packaging: 23.2 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/packaging/__init__.py
numpy: 1.26.4 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/numpy/__init__.py
scipy: 1.11.3 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/scipy/__init__.py
matplotlib: 3.8.0 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/matplotlib/__init__.py
cftime: 1.6.2 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/cftime/__init__.py
cfunits: 3.3.7 /home/slb93/miniconda3/envs/cf-env-312/lib/python3.12/site-packages/cfunits/__init__.py
cfplot: 3.3.0 /home/slb93/git-repos/cf-plot/cfplot/__init__.py
cfdm: 1.11.1.0 /home/slb93/git-repos/cfdm/cfdm/__init__.py
cf: 3.16.2 /home/slb93/git-repos/cf-python/cf/__init__.py
- 主要言語
- Python
- スター
- 151
- フォーク
- 23
- 平均マージ
- 21時間 29分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NCAS-CMS/cf-python のほかの issue
-
code tidy
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Attempt at unsupported conservative 3D mesh regridding対応中かも @sadielbartholomew が 22 日前に担当しました。 オープンbug?
-
Release: migrate from deprecated build command対応中かも @sadielbartholomew が 25 日前に担当しました。 オープンrelease
-
Remove support for Python 3.10 (EOL)対応中かも @sadielbartholomew が 25 日前に担当しました。 オープンenhancement
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
NCAS-CMS/cf-python の issue をすべて見る
似ている issue
-
tool-calling
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
vllm-project/vllm#59838 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
raullenchai/Rapid-MLX#4042 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
transitmatters/mbta-slow-zone-bot#70 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
litestar-org/advanced-alchemy#811 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信