Skip to content

Commit

Permalink
last commit for v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
enricgrau committed Jul 10, 2023
1 parent f041cb2 commit 7342030
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 86 deletions.
9 changes: 3 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ Ready to contribute? Here's how to set up `pudu` for local development.

$ git clone [email protected]:your_name_here/pudu.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development::
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv pudu
$ cd pudu/
Expand All @@ -67,8 +66,7 @@ your fork for local development::

$ git checkout -b name-of-your-bugfix-or-feature

5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python
versions with tox::
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::

$ flake8 pudu tests
$ pytest
Expand Down Expand Up @@ -97,6 +95,5 @@ Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests. Coverage should not go below 70% with `Codecov`.
2. CodeQL should pass.
3. If the pull request adds functionality, the docs should be updated. Add useful
documentation to your functionality so it is included in the `docs`.
3. If the pull request adds functionality, the docs should be updated. Add useful documentation to your functionality so it is included in the `docs`.
4. The pull request should work for Python 3.6 through 3.10.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022, Institut de Recerca en Energia de Catalunya
Copyright (c) 2023, Institut de Recerca en Energia de Catalunya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Enric Tomas Grau-Luque"""
__email__ = '[email protected]'
__version__ = '0.2.0'
__version__ = '0.3.0'
16 changes: 1 addition & 15 deletions docs/_modules/pudu.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ <h1>Source code for pudu</h1><div class="highlight"><pre>

<span class="n">temp</span><span class="p">,</span> <span class="n">temp2</span> <span class="o">=</span> <span class="n">perturbation</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">x_copy</span><span class="p">,</span> <span class="n">row</span><span class="p">,</span> <span class="n">col</span><span class="p">,</span> <span class="n">window</span><span class="p">,</span> <span class="n">bias</span><span class="p">)</span>

<span class="c1"># print(np.shape(temp[0,:,:,0]), np.shape(self.x[0,:,:,0]))</span>
<span class="c1"># plt.plot(temp[0,0,:,0])</span>
<span class="c1"># plt.plot(self.x[0,0,:,0])</span>
<span class="c1"># plt.show()</span>
<span class="c1"># exit()</span>

<span class="k">if</span> <span class="n">temp2</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">val</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pf</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">-</span> <span class="n">p0</span>
<span class="k">else</span><span class="p">:</span>
Expand Down Expand Up @@ -620,23 +614,15 @@ <h1>Source code for pudu</h1><div class="highlight"><pre>
<span class="n">s_x</span><span class="p">,</span> <span class="n">s_y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span>

<span class="n">master</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># master = np.array()</span>
<span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">s_x</span><span class="p">,</span> <span class="n">s_y</span><span class="p">):</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">expand_dims</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>

<span class="n">feats</span><span class="p">,</span> <span class="n">units</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reactivations</span><span class="p">(</span><span class="n">layer</span><span class="p">,</span> <span class="n">slope</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">window</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">bias</span><span class="p">,</span> <span class="n">padding</span><span class="p">,</span>
<span class="n">perturbation</span><span class="o">=</span><span class="n">perturbation</span><span class="p">,</span> <span class="n">mask</span><span class="o">=</span><span class="n">mask</span><span class="p">)</span>
<span class="n">perturbation</span><span class="p">,</span> <span class="n">mask</span><span class="p">)</span>

<span class="n">master</span><span class="o">.</span><span class="n">extend</span><span class="p">((</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">feats</span><span class="p">,</span> <span class="n">units</span><span class="p">))</span>

<span class="n">feats</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">feats</span><span class="p">)</span>
<span class="n">units</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">units</span><span class="p">)</span>
<span class="n">master</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">column_stack</span><span class="p">((</span><span class="n">feats</span><span class="p">,</span> <span class="n">units</span><span class="p">))</span>

<span class="n">master</span> <span class="o">=</span> <span class="n">master</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>

<span class="n">master</span> <span class="o">=</span> <span class="p">[</span><span class="nb">tuple</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span> <span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="n">master</span><span class="p">]</span>
<span class="n">counts</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">master</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="p">[[</span><span class="n">j</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">),</span> <span class="n">count</span> <span class="ow">in</span> <span class="n">counts</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
Expand Down
20 changes: 13 additions & 7 deletions docs/_sources/examples.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,50 @@ Example 1: PC-LDA with Scikit-learn for classification of spectroscopic data
:linenos:


Examples 2: Regression for predicition of open circuit voltage of solar cells with RBFN
Example 2: Regression for predicition of open circuit voltage of solar cells with RBFN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_rbnf.py
:language: python


Examples 3: Handwritten numbers recognition using CNN with Keras and Mnist
Example 3: Handwritten numbers recognition using CNN with Keras and Mnist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_cnn_mnist.py
:language: python


Examples 4: How to call different masks
Example 4: How to call different masks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_masking.py
:language: python


Examples 5: How to call different perturbations
Example 5: How to call different perturbations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_perturbation.py
:language: python


Examples 6: Re-activations with 1-D CNN
Example 6: Re-activations with 1-D CNN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_activations_1d.py
:language: python


Examples 7: Re-activations with 2-D CNN
Example 7: Re-activations with 2-D CNN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_activations_2d.py
:language: python



Example 8: SEelcting specific sections to evaluate
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../examples/example_specific_sections.py
:language: python
17 changes: 6 additions & 11 deletions docs/contributions.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,25 @@ <h2>Get Started!<a class="headerlink" href="#get-started" title="Permalink to th
</pre></div>
</div>
</li>
</ol>
<p>3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up
your fork for local development:</p>
<li><p>Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mkvirtualenv pudu
$ cd pudu/
$ python setup.py develop
</pre></div>
</div>
<ol class="arabic" start="4">
</li>
<li><p>Create a branch for local development to make changes locally:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git checkout -b name-of-your-bugfix-or-feature
</pre></div>
</div>
</li>
</ol>
<p>5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python
versions with tox:</p>
<li><p>When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ flake8 pudu tests
$ pytest
$ tox
</pre></div>
</div>
<ol class="arabic" start="6">
</li>
<li><p>Run unittest, check the test coverage, and create a coverage report in the <cite>tests</cite> folder:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ coverage run -m unittest test_pudu.py
$ coverage xml
Expand All @@ -185,10 +181,9 @@ <h2>Pull Request Guidelines<a class="headerlink" href="#pull-request-guidelines"
<ol class="arabic simple">
<li><p>The pull request should include tests. Coverage should not go below 70% with <cite>Codecov</cite>.</p></li>
<li><p>CodeQL should pass.</p></li>
<li><p>If the pull request adds functionality, the docs should be updated. Add useful documentation to your functionality so it is included in the <cite>docs</cite>.</p></li>
<li><p>The pull request should work for Python 3.6 through 3.10.</p></li>
</ol>
<p>3. If the pull request adds functionality, the docs should be updated. Add useful
documentation to your functionality so it is included in the <cite>docs</cite>.
4. The pull request should work for Python 3.6 through 3.10.</p>
</section>
</section>

Expand Down
Loading

0 comments on commit 7342030

Please sign in to comment.