Skip to content

Commit 7254d3e

Browse files
committed
Give Data model-relative names.
Use Model.name_for() to relativize pm.Data names.
1 parent 446557c commit 7254d3e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Diff for: pymc3/data.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,6 @@ class Data:
479479
https://docs.pymc.io/notebooks/data_container.html
480480
"""
481481
def __new__(self, name, value):
482-
# `pm.model.pandas_to_array` takes care of parameter `value` and
483-
# transforms it to something digestible for pymc3
484-
shared_object = theano.shared(pm.model.pandas_to_array(value), name)
485-
486-
# To draw the node for this variable in the graphviz Digraph we need
487-
# its shape.
488-
shared_object.dshape = tuple(shared_object.shape.eval())
489482

490483
# Add data container to the named variables of the model.
491484
try:
@@ -494,6 +487,18 @@ def __new__(self, name, value):
494487
raise TypeError("No model on context stack, which is needed to "
495488
"instantiate a data container. Add variable "
496489
"inside a 'with model:' block.")
490+
491+
name = model.name_for(name)
492+
493+
# `pm.model.pandas_to_array` takes care of parameter `value` and
494+
# transforms it to something digestible for pymc3
495+
shared_object = theano.shared(pm.model.pandas_to_array(value), name)
496+
497+
# To draw the node for this variable in the graphviz Digraph we need
498+
# its shape.
499+
shared_object.dshape = tuple(shared_object.shape.eval())
500+
501+
497502
model.add_random_variable(shared_object)
498503

499504
return shared_object

0 commit comments

Comments
 (0)