# TypeError in comparison when using pm.Data

**URL:** <https://discourse.pymc.io/t/typeerror-in-comparison-when-using-pm-data/7596>\
**Category:** Questions\
**Created:** [June 13, 2021, 5:28pm UTC](https://discourse.pymc.io/t/typeerror-in-comparison-when-using-pm-data/7596 "2021-06-13T17:28:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendan](https://avatars.discourse-cdn.com/v4/letter/b/50afbb/32.png) [@brendan](https://discourse.pymc.io/u/brendan)\
**Post date:** [June 13, 2021, 5:28pm UTC](https://discourse.pymc.io/t/typeerror-in-comparison-when-using-pm-data/7596/1 "2021-06-13T17:28:56Z")

</div>

Hi all,

I have been reading through the documentation, trying to figure out how to correctly use pm.Data so I can pass in data for training. I keep having the following issue.

Code:

```auto
with pm.Model() as model:
    Site_prior = pm.Dirichlet("Site_prior", a=np.array([1,1,1,1,1]))
    Site_obs = pm.Data("Site_obs", X_train["Site_Code"]) # X_train["Site_Code"] takes on values 0,1,2,3,4
    Site = pm.Categorical("Site", p=Site_prior, observed=Site_obs)
    v = pm.math.switch(pm.math.eq(Site, 0), 0, 10)
    y = pm.Normal("y", mu=v, sigma=1, observed=y_train)
    pm.sample(10)

```

Error:

```auto
The error when converting the test value to that variable type:
TensorType(int32, vector) cannot store a value of dtype int64 without risking loss of precision. If you do not mind this loss, you can: 1) explicitly cast your data to int32, or 2) set "allow_input_downcast=True" when calling "function".

```

I do not understand what is causing this, because the code works fine if I pass the data to observed directly instead of using pm.Data. I’m sure I’m making some very basic mistake with this, as I am new to pymc3. If anyone could help, I would be very appreciative!

---

<div class="post-metadata">

**Author:** ![ckrapu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ckrapu/32/1366_2.png) [@ckrapu](https://discourse.pymc.io/u/ckrapu)\
**Post date:** [June 17, 2021, 2:42pm UTC](https://discourse.pymc.io/t/typeerror-in-comparison-when-using-pm-data/7596/2 "2021-06-17T14:42:13Z")

</div>

There’s likely a processing step involved with `observed` that automatically casts the data or manages its type before the type of error you’ve seen can come up. Can you work around this by doing `Site_obs = pm.Data("Site_obs", X_train["Site_Code"].astype('int32')`?
