MCPcopy Create free account
hub / github.com/Open-Quant/openquant / _sample_weight

Function _sample_weight

python/openquant/feature_diagnostics.py:51–59  ·  view source on GitHub ↗
(weights: Sequence[float] | None, n_rows: int)

Source from the content-addressed store, hash-verified

49 continue
50 if (
51 isinstance(value, (complex, np.complexfloating))
52 or (isinstance(value, Decimal) and not value.is_finite())
53 or (isinstance(value, (Decimal, Real, np.integer, np.floating)) and value not in (0, 1))
54 ):
55 raise ValueError(message)
56 converted = float(value)
57 if converted not in (0.0, 1.0):
58 raise ValueError(message)
59 out.append(converted)
60 if len(out) != n_rows:
61 raise ValueError(f"y/X length mismatch: {len(out)} vs {n_rows}")
62 return out

Callers 4

mdi_importanceFunction · 0.85
mda_importanceFunction · 0.85
sfi_importanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected