AcademySoftwareFoundation / AcademySoftwareFoundation/OpenColorIO
[python][feature-request]`GradingPrimary` change set GradingStyle behavior
- 主要言語
- C++
- スター
- 2.1k
- フォーク
- 505
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hello,
When looking at the `GradingPrimary` class, I have a hard time understanding why do we need to specify the _GradingStyle_ in the `__init__` of the class ? I do understand it's kind of needed for its `validate()` method, but then if we ask the _GradingStyle_ in the validate method, why asking it at `__init__` ?
Furthermore we can't get back this value _GradingStyle_ value from the instance so we have to track it before in the code. Which is annoying when we then need in `GradingPrimaryTransform` to specify the _GradingStyle_ AND a `GradingPrimary` instance which already specify a _GradingStyle_.
Consider the following snippet :
```python
gp_lin = ocio.GradingPrimary(ocio.GRADING_LIN)
gp_lin.exposure = 0.5 #need GradingRGBM but let's ignore for the example
gp_log = ocio.GradingPrimary(ocio.GRADING_LOG)
gp_log.brightness = 0.5
gp_list = (gp_lin , gp_log)
for gp in gp_list:
gp_tsfm = ocio.GradingPrimaryTransform(
gp,
gp.?????, # we can't know which style to use
False,
)
...
```
So in my opinion, here is 2 suggestions for how I would see the class behave :
### 1. Style agnostic
you can check compatibility with `validate()`
the user determine at any moment which style the GradingPrimary will be used with,
```python
gp1 = ocio.GradingPrimary()
gp1.exposure = 0.5
gp2 = ocio.GradingPrimary()
gp2.brightness = 0.5
gp2.validate(ocio.GRADING_LOG) # pass fine
gp2.exposure = 0.5
gp2.validate(ocio.GRADING_LOG) # raise a warning/error ?
# the user determine at any moment which style the GradingPrimary will be used with
gp_list = (
(gp1, ocio.GRADING_LIN),
(gp2, ocio.GRADING_LOG)
)
for gpdata in gp_list:
gp_tsfm = ocio.GradingPrimaryTransform(
gpdata[0],
gpdata[1],
False,
)
...
```
### 2. Style bound to instance, flexible
```python
gp1 = ocio.GradingPrimary(ocio.GRADING_LIN)
gp1.exposure = 0.5
gp2 = ocio.GradingPrimary(ocio.GRADING_LOG)
gp2.brightness = 0.5
gp2.validate() # pass fine
gp2.exposure = 0.5
gp2.validate() # raise a warning/error ?
gp_list = (gp1,gp2)
for gp in gp_list:
gp_tsfm = ocio.GradingPrimaryTransform(
gp,
gp.gradingStyle, # new attribute
False,
)
...
```
### 2.2. Style bound to instance, strict
Remove the `validate()` method and perform check on attribute set.
```python
gp1 = ocio.GradingPrimary(ocio.GRADING_LIN)
gp1.exposure = 0.5
gp2 = ocio.GradingPrimary(ocio.GRADING_LOG)
gp2.brightness = 0.5
gp2.exposure = 0.5 # will raise error
gp2.contrast = 0.0 # will raise error
gp_list = (gp1,gp2)
for gp in gp_list:
gp_tsfm = ocio.GradingPrimaryTransform(
gp,
gp.gradingStyle, # new attribute
False,
)
...
```
I don't know if this makes sense or is too subjective.
Cheers.
Liam.
コントリビューションガイド
調査の方向性
GradingPrimary と GradingPrimaryTransform のエントリポイント、特に GradingPrimary.__init__ と validate() から始め、提案されているスタイル非依存の動作とスタイルに依存する動作を比較します。これらのクラス間で GradingStyle の値がどのように渡されるかを確認します。完了の条件は、いずれかの動作について合意し、スタイルを一貫して公開または検証し、選択した動作を既存のプロジェクトテストでカバーすることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100