Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Numpy Beginner's Guide (Update)
  • Toc
  • feedback
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

By : Ivan Idris
2 (1)
close
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

2 (1)
By: Ivan Idris

Overview of this book

This book is for the scientists, engineers, programmers, or analysts looking for a high-quality, open source mathematical library. Knowledge of Python is assumed. Also, some affinity, or at least interest, in mathematics and statistics is required. However, I have provided brief explanations and pointers to learning resources.
Table of Contents (16 chapters)
close
14
C. NumPy Functions' References
15
Index

Time for action – decorating tests

We will apply the @setastest decorator directly to test functions. Then we will apply the same decorator to a method to disable it. Also, we will skip one of the tests and fail another. First, install nose in case you don't have it yet.

  1. Install nose with setuptools:
    $ [sudo] easy_install nose
    

    Or pip:

    $ [sudo] pip install nose
    
  2. Apply one function as being a test and another as not being a test:
    @setastest(False)
    def test_false():
       pass
    
    @setastest(True)
    def test_true():
       pass
  3. Skip tests with the @skipif decorator. Let's use a condition that always leads to a test being skipped:
    @skipif(True)
    def test_skip():
       pass
  4. Add a test function that always passes. Then, decorate it with the @knownfailureif decorator so that the test always fails:
    @knownfailureif(True)
    def test_alwaysfail():
         pass
  5. Define some test classes with methods that normally should be executed by nose:
    class TestClass():
       def test_true2(self):
          pass
    
    class TestClass2(...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete