Skip to content

Instantly share code, notes, and snippets.

import os
from ctypes import *
from msl.loadlib import Server32
#from comtypes import BSTR
class Heatex32(Server32):
"""
class created by the 32bit process to wrap 32bit DLL which is called from 64bit Python
"""
import pandas as pd
import numpy as np
import visuals as vs
import matplotlib.pyplot as plt
from sklearn.metrics import r2_score
from sklearn import cross_validation
from sklearn.metrics import r2_score
data = pd.read_csv('housing.csv')
prices = data.MEDV
@zhukovgreen
zhukovgreen / conftest.py
Created February 13, 2019 05:46
Using pytest fixtures factories with teardown
import pytest
@pytest.fixture(scope="function")
def fixture_arg():
def _opening_file_with_freecad(file):
# opening a file in freecad
print(f"starting with file is {file}")
file = "opened"
print(f"file is {file}")
@zhukovgreen
zhukovgreen / pyproject.toml
Created July 21, 2020 13:07
Demo from lighting talks Jul 21, 2020
[tool.black]
line-length=79
target-version=["py38"]
[tool.isort]
line_length = 79
use_parentheses = true
balanced_wrapping = true
include_trailing_comma = true
multi_line_output = 3
@zhukovgreen
zhukovgreen / test_rasing_deprecatoins.py
Created August 11, 2020 10:25
Example how to raise DeprecationWarnings in childs classes with proper class name
import warnings
import pytest
def deprecated(since, message):
def do_warn(cls):
warnings.warn(
f"{cls.__name__}: {message}, {since}", DeprecationWarning,
)
@zhukovgreen
zhukovgreen / pyproject.toml
Created June 8, 2021 07:00
/tmp/used-for-poetry-issue
[tool.poetry]
name = "zhukovgreen111"
version = "0.1.0"
description = ""
authors = ["ZhukovGreen <zhukovgreen@icloud.com>"]
[tool.poetry.dependencies]
python = "^3.8"
docker-compose = "^1.25.3"
ipython = {git = "https://github.com/ipython/ipython"}
@zhukovgreen
zhukovgreen / square_root.scala
Created October 11, 2021 14:23
Implementation of the square root in scala
import org.scalatest.wordspec.AnyWordSpec
import scala.math.*
class test_different_samples extends AnyWordSpec {
/**Calculates square root of x*/
def square_root(x: Double, precision: Double = 0.01): Double = {
require(x >= 0)
def inner(min: Double, max: Double): Double = {
val guess = (min + max) / 2
@zhukovgreen
zhukovgreen / test_feature.py
Created June 8, 2022 10:38
Dependency injection for functions
import functools
import inspect
from typing import Any, Callable, Dict
import pytest
class feature:
fixtures: Dict[str, Callable[[], Any]] = {}
@zhukovgreen
zhukovgreen / transformation.py
Created October 11, 2022 12:05
Concept with transformations
class MyTransformation(BaseTransformation):
def implementation(metastore) -> DataFrame:
table_x = metastore.get("table_x")
table_y = metastore.get("table_y")
# do some transformation
return some_result_dataframe
@zhukovgreen
zhukovgreen / longest_chain.py
Created October 27, 2022 19:00
Task with longest chain
import pytest
def longest_chain_of_words(
inputs: tuple[str, ...],
) -> int:
"""Find the longest chain of words within an array matching the rule.
The rule is: