Skip to content

Commit

Permalink
BUG: replace np.unicode_ with np.str_ (closes #168)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Dec 6, 2024
1 parent 96b1452 commit 6807be9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyblp/configurations/formulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ def eval(self, string: str, **_: Any) -> Array:
# parse the SymPy expression, preserving the function that marks variables as categorical
expression = parse_expression(string, mark_categorical=True)

# replace categorical variables with unicode objects and explicitly mark them as categorical so that labels are
# replace categorical variables with string objects and explicitly mark them as categorical so that labels are
# unique and so that all categorical variables are treated the same
C = sp.Function('C')
for symbol in expression.free_symbols:
if not np.issubdtype(data[symbol.name].dtype, getattr(np, 'number')):
expression = expression.replace(symbol, C(symbol))
data[symbol.name] = data[symbol.name].astype(np.unicode_).astype(np.object_)
data[symbol.name] = data[symbol.name].astype(np.str_).astype(np.object_)

# evaluate the expression and handle universally-marked categorical variables with a non-default coding class
evaluated = evaluate_expression(expression, self._namespaces[0], function_mapping={
Expand Down

0 comments on commit 6807be9

Please sign in to comment.