File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import numpy as np
22
22
import numpy .linalg as npl
23
- from typing_extensions import TypeVar # PY312
23
+ from typing_extensions import Self , TypeVar # PY312
24
24
25
25
from . import analyze # module import
26
26
from .arrayproxy import get_obj_dtype
@@ -328,6 +328,12 @@ def __init__(
328
328
self .code = code # type: ignore[assignment]
329
329
self ._content = content
330
330
331
+ @classmethod
332
+ def from_bytes (cls , content : bytes ) -> Self :
333
+ if not hasattr (cls , 'code' ):
334
+ raise NotImplementedError ('from_bytes() requires a class attribute `code`' )
335
+ return cls (cls .code , content )
336
+
331
337
# Handle (de)serialization of extension content
332
338
# Subclasses may implement these methods to provide an alternative
333
339
# view of the extension content. If left unimplemented, the content
@@ -509,6 +515,8 @@ class Nifti1DicomExtension(Nifti1Extension[DicomDataset]):
509
515
header.
510
516
"""
511
517
518
+ code = 2
519
+
512
520
def __init__ (
513
521
self ,
514
522
code : ty .Union [int , str ],
You can’t perform that action at this time.
0 commit comments