eclipse-cdt-cloud / eclipse-cdt-cloud/tsp-python-client
"Set" classes are not iterable
- 主要語言
- Python
- 星號
- 6
- 分支
- 16
- PR 合併指標
- 30 天內沒有已合併 PR
描述
The Set classes, `ExperimentSet`, `TraceSet`, `ConfigurationParameterDescriptorSet`, `ConfigurationSet`, `ConfigurationSourceSet` and `OutputDescriptorSet` are not usable by themselves as collections.
This gives you access patterns like:
```python3
from tsp.trace_set import TraceSet
traces = TraceSet([{"name": "trace0"}, {"name": "trace1"}])
for trace in traces.traces:
print(t.name)
# trace0
# trace1
print(len(traces.traces))
# 2
```
This is especially inconvenient when working with experiments, since to loop over traces, you must do:
```python3
for t in experiment.traces.traces
```
We could make the classes easier to work with by making them implement collection interfaces.
This would give you the following access patterns instead:
```python3
from tsp.trace_set import TraceSet
traces = TraceSet([{"name": "trace0"}, {"name": "trace1"}])
for trace in traces:
print(t.name)
# trace0
# trace1
print(len(traces))
# 2
```
See example in this [commit](https://github.com/awendelin-work/tsp-python-client/commit/025576dccb9c7239e343c872153fe160973c9425).
`__getitem__` could be implemented as well to allow indexing with integers (`traces[0]`), but it is not implemented for Python sets, so it would make the "Set" classes look less like sets.
If this kind of functionality is wanted, I can help provide patches.
貢獻指南
研究方向
從 Set 類別開始,包括 tsp.trace_set.TraceSet,並找出 ExperimentSet、TraceSet、ConfigurationParameterDescriptorSet、ConfigurationSet、ConfigurationSourceSet 和 OutputDescriptorSet 的實作。將它們目前作為集合的行為與 issue 和連結的範例 commit 中的存取模式進行比較。完成的標準是每個類別都可以直接迭代,並透過 len() 回報其大小,同時索引存取仍為選用項目。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- api
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100