File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 13
13
Union ,
14
14
)
15
15
16
- try :
17
- from typing import SupportsIndex
18
- except ImportError : # pragma: no cover
19
- from typing_extensions import SupportsIndex
20
-
21
16
import wrapt
22
17
23
18
from formulaic .parser .types import Factor
24
19
from formulaic .utils .sentinels import MISSING , MissingType
25
20
21
+ try :
22
+ from typing import SupportsIndex
23
+ except ImportError : # pragma: no cover
24
+ from typing_extensions import SupportsIndex
25
+
26
26
if TYPE_CHECKING : # pragma: no cover
27
27
from formulaic .model_spec import ModelSpec
28
28
Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ def encoder(
69
69
encoder_state : dict [str , Any ],
70
70
model_spec : ModelSpec ,
71
71
) -> FactorValues :
72
- values = pandas .Series (values )
72
+ # wrapped numpy arrays are problematic
73
+ values = pandas .Series (
74
+ values .__wrapped__ if isinstance (values , FactorValues ) else values
75
+ )
73
76
values = values .drop (index = values .index [drop_rows ])
74
77
return encode_contrasts (
75
78
values ,
@@ -129,6 +132,8 @@ def encode_contrasts( # pylint: disable=dangerous-default-value # always repla
129
132
levels = (
130
133
levels if levels is not None else _state .get ("categories" )
131
134
) # TODO: Is this too early to provide useful feedback to users?
135
+ if isinstance (data , FactorValues ): # wrapped numpy arrays are problematic
136
+ data = data .__wrapped__
132
137
133
138
if contrasts is None :
134
139
contrasts = TreatmentContrasts ()
You can’t perform that action at this time.
0 commit comments