Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding:utf-8 -*- | |
| """ | |
| Created Date: Saturday December 11th 2021 | |
| Author: Dmitry Kislov | |
| E-mail: [email protected] | |
| ----- | |
| Last Modified: Wednesday, December 15th 2021, 2:32:54 pm | |
| Modified By: Dmitry Kislov | |
| ----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| import re | |
| with open('specifications.txt', 'rt') as file: | |
| specifications = file.read() | |
| specs = namedtuple('specs', 'range regex') | |
| #specs range builtin module | |
| #specs regex from re.compile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from functools import wraps | |
| def arg_checker(*arg_types): | |
| '''An argument checker decorator that checks both: | |
| - The number of variables that you use for a function | |
| - The type of each variable. | |
| Raises a TypeError if either of these fail''' | |
| def wrapper(func): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| with open('olympics.txt', 'rt', encoding='utf-8') as file: | |
| olympics = file.read() | |
| medal = namedtuple('medal', ['City', 'Edition', 'Sport', 'Discipline', 'Athlete', 'NOC', 'Gender', | |
| 'Event', 'Event_gender', 'Medal']) | |
| medals = [medal(*line.split(';')) for line in olympics.split('\n')[1:] if line] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Calculator: | |
| def __init__(self, *excps): | |
| self.exceptions = excps | |
| self.error = '' | |
| def __enter__(self): | |
| return self | |
| def __exit__(self, exc_type, exc_val, traceback): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Source of data: https://www.arrs.run/ | |
| # This dataset has race times for women 10k runners from the Association of Road Racing Statisticians | |
| # Assume a year has 365.25 days | |
| from datetime import datetime | |
| def prefil_globals(): | |
| global T_INDX, AT_INDX, RD_INDX, DB_INDX, LOC_INDX | |
| with open('10k_racetimes.txt', 'rt') as file: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pairwise_offset(sequence, fillvalue='*', offset=0): | |
| sequence = list(sequence) | |
| a = sequence + [fillvalue] * offset if offset > 0 else [fillvalue] * offset + sequence | |
| b = [fillvalue] * offset + sequence if offset > 0 else sequence + [fillvalue] * offset | |
| return list(map(tuple, zip(a, b))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Source of data: https://www.arrs.run/ | |
| # This dataset has race times for women 10k runners from the Association of Road Racing Statisticians | |
| import re | |
| import datetime | |
| def get_data(): | |
| """Return content from the 10k_racetimes.txt file""" | |
| with open('10k_racetimes.txt', 'rt') as file: | |
| content = file.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Sun Jun 7 07:07:17 2020 | |
| @author: dmitry | |
| """ | |
| from osgeo import gdal | |
| import numpy as np | |
| def get_area(filename='',maskfile='', third=None, threshold=0.8): |
NewerOlder