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
file = "blablabab.pdf" | |
import PyPDF2 | |
all_comments = "" | |
# %% | |
# Open the PDF file | |
with open(file, 'rb') as pdf_file: | |
# Create a PDF reader object | |
pdf_reader = PyPDF2.PdfReader(pdf_file) |
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
# %% | |
base = r"\Downloads\NL_Surrogate_Data\NL_Surrogate_Data" | |
import random | |
import matplotlib.pyplot as plt | |
from collections import OrderedDict | |
import os | |
import numpy as np | |
from typing import List | |
from dataclasses import dataclass |
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
def check_duplicate_columns(df): | |
# Identify duplicate columns | |
duplicate_columns = df.columns[df.columns.duplicated(keep=False)] | |
if len(duplicate_columns) == 0: | |
print("No duplicate columns found.") | |
return [] | |
else: | |
print(f"Duplicates found. {duplicate_columns.to_list()} ") | |
col_idxs_to_drop =[] |
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
import numpy as np | |
class Accum_List(list): | |
cnt_in_epoch = 0 | |
accum_fn = np.mean | |
def __init__(self): | |
super().__init__() | |
self.internal_epoch_list = [] |
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
using Gridap | |
using Gridap.Geometry | |
const E = 70.0e9 | |
const ν = 0.33 | |
const λ = (E * ν) / ((1 + ν) * (1 - 2 * ν)) | |
const μ = E / (2 * (1 + ν)) | |
const density = 2710 # kg/m^3 | |
σ(ε) = λ * tr(ε) * one(ε) + 2 * μ * ε | |
# for making the FEA grid. |
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
from pathlib import Path | |
from fpdf import FPDF | |
from PIL import Image | |
# Define directory to search for images | |
img_dir = Path("viz") | |
class MyPDF(FPDF): | |
pass |
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
#!/usr/bin/env python | |
import json,fire,re | |
from pathlib import Path | |
output_folder = 'rom' | |
output_folder_jl = output_folder+"_jl" | |
package_version = "0.1.0" | |
def is_export(cell): |
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
""" | |
Script provides functional interface for Mish activation function. | |
""" | |
# import pytorch | |
import torch | |
import torch.nn.functional as F | |
# @torch.jit.script |
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
import torch.nn as nn | |
class MLP(nn.Module): | |
def __init__(self, input_dims = 1, out_dims = 1, hidden_size = 100, layers = 5): | |
super(MLP, self).__init__() | |
self.hidden_layer_size = hidden_size | |
self.hidden_layers = layers | |
layers = [] | |
input_size = input_dims | |
for i in range(self.hidden_layers): |
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
class Tracker: | |
def __init__(self, names_of_things_to_track): | |
self.names_of_things_to_track = names_of_things_to_track | |
self.data = [] | |
def __call__(self, *values): | |
self.add(*values) | |
def add(self, *values): | |
values = [try_detach(v) for v in values] |
NewerOlder