Skip to content

Instantly share code, notes, and snippets.

View ashishsinghucd's full-sized avatar

Ashish Singh ashishsinghucd

  • University College Dublin
  • dublin
View GitHub Profile
@ashishsinghucd
ashishsinghucd / segments.py
Created November 17, 2020 14:18
Function to find all the regions in a numpy array greater than a threshold
def get_segments(weights, threshold=80):
marker_list = [True if i >= threshold else False for i in weights]
i = 0
final_pairs = []
while i < len(weights):
if marker_list[i]:
start = i
while i < len(weights) and marker_list[i]:
i = i + 1
end = i - 1
@ashishsinghucd
ashishsinghucd / coding_standard.py
Created July 1, 2020 08:55 — forked from nateGeorge/coding_standard.py
coding standards, originally from enthought
# taken from here: http://web.archive.org/web/20110527163743/https://svn.enthought.com/enthought/browser/sandbox/docs/coding_standard.py
""" This module is an example of the Enthought Python coding standards.
It was adapted from the Python Enhancement Proposal 8 (aka PEP 8) titled
'Style Guide for Python Code' (http://www.python.org/peps/pep-0008.html).
The first item in a module must be a documentation string (docstring). The
first line of the docstring should be a one line summary. If a more
detailed description is required, put an empty line before it.
@ashishsinghucd
ashishsinghucd / logging_example_python
Created June 4, 2020 17:54
How to use logging in python
logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
logging_format = logging.Formatter('%(asctime)s %(name)s %(levelname)s - %(message)s')
handler.setFormatter(logging_format)
logger.setLevel(logging.DEBUG). # Do not use handler.setLevel(logging.DEBUG)
logger.addHandler(handler)