Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
735 views
�
�F�Ve�
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZddlmZddlmZddlZddlZddlZddlTddlZddlTdd	d
ddd
dddddddg
ejejZGdd�dej�Zddd�Zdd�Zddd�ZdZdZdd�ZdS)�N)�Options�Store)�pyplot)�display)�interact)�display_html)�*�np�
matplotlib�kwant�	holoviews�
init_notebookrr�plt�pf�SimpleNamespace�
pprint_matrix�scientific_number�pretty_fmt_complexc@seZdZdd�ZdS)rcKs|jj|�|S)N)�__dict__�update)�self�kwargs�r�../code/init_mooc_nb.pyrszSimpleNamespace.updateN)�__name__�
__module__�__qualname__rrrrrrs�cCs�d}|j�dd�}|jdd�}|jdd�}tjdd|�}tjdd	|�}tjtj|jd
|���dS)
z&Print a numpy array as a latex matrix.z#\begin{{pmatrix}}{d}\end{{pmatrix}}��]��
z\\z *\[ *z +z & �dN�����)�__str__�replace�re�subr�
display_latex�Latex�format)�data�digits�headerr"rrrr$scCsS|s
dSttjt|��tjd��d}|d|}d||fS)Nz$0$g$@r�
z$%1.1f \cdot 10^{%1.0f}$)�intr	�log�abs)�xZpot�facrrrr0s
,�cCs�dd�}tj||�dkr(dStj|j|�dkr_|tt|j|���Stj|j|�dkr�|tt|j|���dSt|j�d|jdkt|j�dS)z:Return a human-readable string representation of a number.cSs|jd�jd�S)N�0�.)�rstrip)Znum_strrrr�strip_trailing:sz*pretty_fmt_complex.<locals>.strip_trailingrr5�i�+)r	�round�imag�str�realr)�numr,r8rrrr8s a�
<script type=text/javascript>
/* Add a button for showing or hiding input */
on = "Show input";
off = "Hide input";
function onoff(){
  currentvalue = document.getElementById('onoff').value;
  if(currentvalue == off){
    document.getElementById("onoff").value=on;
      $('div.input').hide();
  }else{
    document.getElementById("onoff").value=off;
      $('div.input').show();
  }
}

/* Launch first notebook cell on start */
function launch_first_cell (evt) {
  if (!launch_first_cell.executed
      && Jupyter.notebook.kernel
  ) {
    Jupyter.notebook.get_cells()[0].execute();
    launch_first_cell.executed = true;
  }
}

$([Jupyter.events]).on('status_started.Kernel notebook_loaded.Notebook', launch_first_cell);
</script>

<p>Press this button to show/hide the code used in the notebook:
<input type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Hide input" id="onoff" onclick="onoff();"></p>
zl<script type=text/javascript>
$(document).ready(function (){if(!("IPython" in window)){onoff();}})
</script>cCs�yt�jdd�Wntk
r+YnXtddjt��tjd�tj	dd�}t
ddd	d
d�|_t
dd
d�|_t
dddd
ddd	�|_t
dddd
ddd	�|_
t
ddd�|_t
ddd�|_t
dddd
d�|_t
dd
ddd�|_t
ddd	d
d�|_t
dd
ddd�|_t
ddddd�|_t
ddd�|_t
ddddddddd�|_t
ddd d!d"�|_tjd#d$�tjjt�}tjtjj|d%��tjd&d	d'd(d)itd*6�tjjtjj|tjj d+��}t!t"j#t$|rt%nd,��d-d.l&m'}|�dS)/N�gui�inlinezPopulated the namespace with:
z, r
�backend�style�	linewidthr4�color�k�plot�aspect�square�	linestylez--�b�r�cmapZRdBu_rZtitle_formatz{label}g333333�?Zshow_legendFZrstriderZcstride�lwg�������?Zazimuth��	elevation��ignorez All-NaN (slice|axis) encountered�matplotlibrc�	precision�suppressT�	formatter�complexfloat�scriptsr r)�	patch_all)(�get_ipython�enable_matplotlib�	NameError�print�join�__all__rZnotebook_extensionr�optionsrZContours�HLineZVLine�Image�Path�CurveZOverlayZLayoutZSurface�warnings�filterwarnings�os�path�dirname�__file__r
�rc_filer	�set_printoptionsr�exists�pardirrr�HTML�nb_html_header�hide_outside_ipythonZpatch_holoviewsrY)r`�
module_dirZ	developerrYrrrr
rs@

!!'
) �sysrgr&�typesre�numpyr	r
rrrrr�IPythonr�
ipywidgetsr�IPython.displayrrZpfaffianrZedx_components�	functionsr_rrrrrprqr
rrrr�<module>s4

;3