AcademySoftwareFoundation / AcademySoftwareFoundation/OpenColorIO

[python][feature-request]`GradingPrimary` change set GradingStyle behavior

Aperta
#1,644 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Needs Discussion
Lingua principale
C++
Stelle
2.1k
Fork
503
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dagli entry point GradingPrimary e GradingPrimaryTransform, in particolare GradingPrimary.__init__ e validate(), per confrontare i comportamenti proposti indipendenti dallo stile e vincolati allo stile. Esamina come il valore GradingStyle viene passato tra queste classi; il lavoro è completato quando si concorda un comportamento, lo stile viene esposto o validato in modo coerente e il comportamento scelto è coperto dai test esistenti del progetto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.