Warning with ineffectual and invalid collapses
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu từ điểm vào Field.collapse được trình bày trong các ví dụ và theo dõi cách các trục có kích thước một được xử lý đối với maximum, variance và sum_of_squares. Quyết định và ghi lại phản hồi cho các phép collapse có hiệu lực, no-op và không hợp lệ, sau đó bổ sung coverage cho ba trường hợp được minh họa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
If a user tries to perform a collapse on an axes which is already singular, depending on the nature of the collapse method this may change the data and metadata as expected e.g. for 'sum_of_squares', but for most (at least, unweighted) collapse methods it, very reasonably, does not change anything, including not adding a call method indicating the collapse type, because the operation would not have an effect or be invalid (see examples below).
I think we should provide feedback to indicate to the user if a collapse has not had effect, since (say if they attempt such a collapse when not realising the axis/es size(s) is/are already one) they may be relying on metadata changes that would be made if the collapse had in fact been applied, such as the fact the units have changed appropriately, or an appropriate cell method has been added, etc. It certainly has the potential to cause confusion when collapses promise to make such changes.
The reason I am not implementing such feedback off the bat, as I doubt that is controversial, is that I am not sure of the best form of feedback, notably:
- should we always use a logging message, or could it even warrant an exception for the 'invalid' case (number 3 below)?
- what level of logging message would be most appropriate (one of 'info' or 'warning' I would think), and should this differ based on case (as below)?
Illustrative cases & examples
As far as I can see there are three cases for a size-one collapse, where case (1) is perfectly fine, but cases (2) and (3) warrant some form of user feedback and (3) may warrant a stronger form of warning, or even an Exception of some sort:
(All example code snippets operating on the following field f:
>>> import cf
>>> f=cf.read('~/Downloads/cfplot_data/ggap.nc')[1]
>>> f
<CF Field: eastward_wind(time(1), pressure(23), latitude(160), longitude(320)) m s**-1>
>>> print(f.data)
[[[[-13.383878707885742, ..., 1.6122403144836426]]]] m s**-1
)
-
It has an effect as with a collapse of axes with non-singular size, e.g. 'sum_of_squares':
>>> i = f.collapse('sum_of_squares', axes='T') >>> print(i.cell_methods) Constructs: {'cellmethod0': <CF CellMethod: domainaxis0: sum_of_squares>} >>> print(i.data) [[[[179.12820926739732, ..., 2.5993188316463147]]]] Gy -
It has no effect because it would make no difference to the field, e.g. 'maximum' (note no cell methods are added):
>>> j = f.collapse('maximum', axes='T') >>> print(j.cell_methods) Constructs: {} >>> print(j.data) [[[[-13.383878707885742, ..., 1.6122403144836426]]]] m s**-1 -
It has no effect because it is not possible, e.g. an unweighted unbiased variance collapse, given that the denominator of the corresponding calculation becomes
(1 - 1) = 0:>>> k = f.collapse('variance', axes='T') >>> print(k.cell_methods) Constructs: {} >>> print(k.data) [[[[-13.383878707885742, ..., 1.6122403144836426]]]] m s**-1
- Ngôn ngữ chính
- Python
- Star
- 150
- Fork
- 23
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NCAS-CMS/cf-python
-
code tidy
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
bug?
-
release
-
enhancement
-
error from netCDF in cf.write Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Tất cả issue của NCAS-CMS/cf-python
Issue tương tự
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
bancolombia/sentinel#23 ·
-
test md Đang mởCI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100