Created
June 26, 2020 04:54
-
-
Save fovtran/beeed64dd174c2e813e9593f6c49922e to your computer and use it in GitHub Desktop.
IPY autostart1
This file contains 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
#!which python.exe | |
# coding: utf-8 | |
from __future__ import print_function | |
__author__ = "Diego <dcadogan@live.com.ar>" | |
__version__ = '0.1' | |
print('IPython autoconf') | |
import os | |
import platform, sys | |
from math import radians, degrees | |
import pandas as pd | |
pd.options.display.max_columns = 50 | |
pd.options.display.max_rows = 30 | |
import numpy as np | |
np.set_printoptions(precision=17, threshold=40)#np.set_printoptions(suppress=True,linewidth=np.nan,threshold=np.nan). | |
np.set_printoptions(linewidth=230) | |
np.random.seed(9375739) | |
eps = np.finfo(float).eps | |
import scipy as sc | |
from scipy.stats import norm | |
import sympy as sy | |
import matplotlib.pyplot as plt | |
from pathlib import Path | |
from datetime import datetime | |
import re | |
import json | |
import unittest | |
import requests, io | |
import IPython | |
from IPython.core.interactiveshell import InteractiveShell | |
from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic) | |
from IPython import get_ipython | |
import traitlets.config | |
InteractiveShell.ast_node_interactivity = 'all' | |
ipython = get_ipython() | |
c = traitlets.config.get_config() | |
c.InteractiveShell.automagic = True | |
# c.InteractiveShellApp.gui = None | |
c.InteractiveShellApp.extensions.append('Cython') | |
c.TerminalIPythonApp.display_banner = False | |
c.InteractiveShellApp.log_level = 20 | |
#c.InteractiveShellApp.extensions = [ 'myextension' ] | |
#c.InteractiveShellApp.exec_lines = [ 'import numpy', 'import scipy' ] | |
#c.InteractiveShellApp.exec_files = [ 'mycode.py', 'fancy.ipy' ] | |
c.InteractiveShellApp.extensions = ['autoreload'] | |
c.InteractiveShell.colors = 'LightBG' | |
c.InteractiveShell.confirm_exit = False | |
#c.InteractiveShell.editor = 'nano' | |
c.InteractiveShell.xmode = 'Minimal' | |
c.PrefilterManager.multi_line_specials = True | |
c.AliasManager.user_aliases = [ ('la', 'ls -al') ] | |
from shutil import copyfile, copy | |
ipython_config_dir = IPython.paths.get_ipython_dir() # As of IPython v4.0 | |
ipython_profile_dir = IPython.paths.locate_profile() | |
#ipython_current_script = os.path.dirname(os.path.abspath(__file__)) | |
ipython_current_script = os.path.join(os.getcwd(), __file__) | |
print('Exec: ', sys.executable) | |
print('Python ver: ', sys.version_info) | |
print('OS Name: ', os.name) | |
print('Platform: ', platform.system()) | |
print('Platform Release: ', platform.release()) | |
print('Numpy ver: ', np.version.version) | |
print('Scipy ver: ', sc.__version__) | |
print('Pandas ver: ', pd.__version__) | |
print('Sympy ver: ', sy.__version__) | |
print('Requests ver: ', requests.__version__) | |
#ext = 'https://raw.githubusercontent.com/birkenfeld/ipython-physics/master/physics.py' | |
#f = requests.get(ext) | |
#eval(f.text) | |
if os.path.exists(ipython_profile_dir): | |
if __file__ in os.listdir(os.path.join(ipython_profile_dir,'startup')): | |
#print(ipython_config_dir) | |
#print(ipython_profile_dir) | |
#print(ipython_current_script) | |
pass | |
try: | |
os.remove(os.path.join(os.path.join(ipython_profile_dir,'startup'),__file__)) | |
except: | |
pass | |
try: | |
copyfile(ipython_current_script, os.path.join(os.path.join(ipython_profile_dir,'startup'),__file__)) | |
except: | |
pass | |
#%autoreload 2 | |
#%xmode Minimal | |
def load_ipython_extension(ipython): | |
ipython.register_magics(Abracadabra) | |
@magics_class | |
class Abracadabra(Magics): | |
@line_magic | |
def abra(self, line): | |
return line | |
@cell_magic | |
def cadabra(self, line, cell): | |
return line, cell | |
ipython.register_magics(Abracadabra) | |
base_path = Path.cwd() | |
# Data paths | |
data_path = base_path / 'data' | |
raw_data_path = data_path / 'raw' | |
interim_data_path = data_path / 'interim' | |
processed_data_path = data_path / 'processed' | |
external_data_path = data_path / 'external' | |
XVERSION = 1 | |
def my_version(): | |
return XVERSION | |
class Test_My_Code(unittest.TestCase): | |
def __init__(self, methodName='runTest'): | |
super(Test_My_Code, self).__init__(methodName) | |
self.regex_test_mls = """ """ | |
def test_version(self): | |
self.assertTrue(my_version() == 1) | |
def emit_cell(cell_type: str, cell_index: int, text: str): | |
xs = None | |
if True: # state != ParseState.none: | |
# cell_type = 'markdown' if state == ParseState.markdown else 'code' | |
xs = emit_cell_at_index(cell_type, cell_index, text) | |
cell_index += 1 | |
return xs, cell_index | |
def is_regex_match(self, regx, test: str, expected: str): | |
mm = re.match(regx, test) | |
if not mm: | |
return False | |
last_grp = len(mm.groups()) | |
return expected == mm.group(last_grp) | |
#if __name__ == '__main__': | |
#unittest.main(argv=['first-arg-is-ignored'], exit=False) | |
#print (os.environ["PYTHONPATH"]) | |
# print('Done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment