Skip to content

Commit

Permalink
docs: Avoid suggesting support for numpy types
Browse files Browse the repository at this point in the history
Remove the suggestion that the `Data` type accepts
`ndarray`s. (These are still unofficially supported.)

This simplifies the type, making it easier to read. This may help users
avoid assuming that arbitrary numpy types will be accepted as data.

PyStan barely depends on numpy. In the future, the dependency may be
removed. (NumPy is a serious dependency, wheel is ~16MB.) In the
meantime, users should be encouraged to interact with PyStan as if it
the package did not know about the existence of numpy.
  • Loading branch information
riddell-stan committed Sep 27, 2021
1 parent 0171b94 commit 1ffd41a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import stan.fit
import stan.plugins

Data = Dict[str, Union[int, float, Sequence[Union[int, float]], np.ndarray]]
Data = Dict[str, Union[int, float, Sequence[Union[int, float]]]]


class DataJSONEncoder(json.JSONEncoder):
def default(self, obj):
# numpy.ndarray is *unofficially* supported as there is no easy way to
# construct tabular data using the Python standard library.
if isinstance(obj, np.ndarray):
return obj.tolist()
# unofficially support np.int64, np.int32, etc.
Expand Down

0 comments on commit 1ffd41a

Please sign in to comment.