Sorry, in looking over my other code I had called publish_display_data twice but thought it was only once. So, I haven't found a bug.<br><br><div class="gmail_quote">On Wed, Jun 13, 2012 at 6:56 PM, MinRK <span dir="ltr"><<a href="mailto:benjaminrk@gmail.com" target="_blank">benjaminrk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div class="im">On Wed, Jun 13, 2012 at 6:51 PM, Jonathan Taylor <span dir="ltr"><<a href="mailto:jonathan.taylor@stanford.edu" target="_blank">jonathan.taylor@stanford.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I was a little confused because sometimes it displays several things. </blockquote><div><br></div></div><div>When have you seen multiple displays from one display call?  This would be a bug.</div><div class="im"><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The idea with having several values in the dict is that they might be different representations of the same output?</blockquote><div><br></div></div><div>Precisely. One call == one thing to display.</div><div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><br><br><div class="gmail_quote">On Wed, Jun 13, 2012 at 4:08 PM, MinRK <span dir="ltr"><<a href="mailto:benjaminrk@gmail.com" target="_blank">benjaminrk@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div><div>On Wed, Jun 13, 2012 at 3:52 PM, Jonathan Taylor <span dir="ltr"><<a href="mailto:jonathan.taylor@stanford.edu" target="_blank">jonathan.taylor@stanford.edu</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

On the master branch, I am getting some unexpected behaviour when I try the following<div><br></div><div><div>import numpy as np</div><div>from IPython.core.displaypub import publish_display_data</div><div><br></div><div>





class NormalMean(object):</div>
<div>    """</div><div>    Sample from N(mean, sd) independently n times </div><div>    """</div><div>    tol = 5.e-2</div><div>    checkable = True</div><div>    </div><div>    def __init__(self, mean, sd, n, identifier):</div>






<div>        self.mean = mean</div><div>        self.identifier = identifier</div><div>        <a href="http://self.sd" target="_blank">self.sd</a> = sd</div><div>        self.n = n</div><div>        self.sequence = self.generate()</div>






<div>        self.correct_answer = np.mean(self.sequence)</div><div>        </div><div>    def generate(self):</div><div>        return np.round(np.random.standard_normal(self.n), 1) * <a href="http://self.sd" target="_blank">self.sd</a> + self.mean</div>






<div>        </div><div>    @property</div><div>    def answer(self):</div><div>        return np.mean(self.sequence)</div><div>    </div><div>    def publish(self, return_data=False):</div><div><br></div><div>        data = {'text/latex': r"What is the sample mean, $\bar{X}$ of this sequence: %s ?" % `["%0.1f" % s for s in self.sequence]`,</div>






<div>                'text/html': ''}</div><div>        </div><div>        data['text/html'] += '<form method="post" name=%s ><p><input type="text" ></p></form>' % self.identifier</div>






<div>        data['application/json'] = {'constructor_info': ('normal_mean', [self.mean, <a href="http://self.sd" target="_blank">self.sd</a>, self.n], {})}</div><div>        publish_display_data("NormalMean", data)</div>






<div>        if return_data:</div><div>            return data</div><div>        </div><div>    def check_answer(self, answer):</div><div>        if np.fabs(answer - self.correct_answer) / np.std(self.sequence) < self.tol:</div>






<div>            data = self.publish(return_data=True)</div><div>            data['text/html'] += '\n<p><h2>Good job!</h2></p>\n'</div><div>        else:</div><div>            self.sequence = self.generate()</div>






<div>            data = self.publish(return_data=True)</div><div>            data['text/html'] += '\n<p><h2>Try Again!</h2></p>\n' </div><div>  </div><div><br></div><div>NormalMean(10, 3, 6, 'mean_10_sd_3_n_6').publish()</div>






<div><br></div><div><br></div><div>I expect to see a latex rendering of the question with a textbox below it but I am only getting a text box.</div><div><br></div><div>By the way, if I want to see these things in order, I suppose it is best to use several calls to publish_display_data? Is that right, if so the outputs are in the order I want them to be rather than</div>






<div>the order of the dict keys (which I cannot control).</div></div></blockquote><div><br></div></div></div><div>Right - one call to "publish_display_data" should always result in exactly one thing being displayed.  The idea being "I have a thing I want to display, and I can display in all these different ways". It is up to the frontends to pick their favorite (HTML in the notebook).  If you want to display multiple things, then you should use multiple calls.</div>





<div><br></div><div>-MinRK</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div><br></div><div>Thanks,</div><div><br></div><div>
Jonathan</div><span><font color="#888888"><div>

<br></div><div><br></div>-- <br>Jonathan Taylor                          <br>Dept. of Statistics                      <br>
Sequoia Hall, 137                          <br>390 Serra Mall<br>Stanford, CA 94305<br>Tel:   <a href="tel:650.723.9230" value="+16507239230" target="_blank">650.723.9230</a><br>Fax:   <a href="tel:650.725.8977" value="+16507258977" target="_blank">650.725.8977</a><br>





Web: <a href="http://www-stat.stanford.edu/%7Ejtaylo" target="_blank">http://www-stat.stanford.edu/~jtaylo</a><br>

</font></span></div>
<br></div>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Jonathan Taylor                          <br>Dept. of Statistics                      <br>Sequoia Hall, 137                          <br>390 Serra Mall<br>Stanford, CA 94305<br>



Tel:   <a href="tel:650.723.9230" value="+16507239230" target="_blank">650.723.9230</a><br>Fax:   <a href="tel:650.725.8977" value="+16507258977" target="_blank">650.725.8977</a><br>Web: <a href="http://www-stat.stanford.edu/%7Ejtaylo" target="_blank">http://www-stat.stanford.edu/~jtaylo</a><br>



</div></div><br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Jonathan Taylor                          <br>Dept. of Statistics                      <br>Sequoia Hall, 137                          <br>390 Serra Mall<br>Stanford, CA 94305<br>
Tel:   650.723.9230<br>Fax:   650.725.8977<br>Web: <a href="http://www-stat.stanford.edu/~jtaylo">http://www-stat.stanford.edu/~jtaylo</a><br>