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
| import gzip | |
| import urllib.request | |
| from pathlib import Path | |
| from types import SimpleNamespace | |
| from typing import Literal | |
| import numpy as np | |
| def load_dataset(mnist_or_fashionmnist: Literal["mnist", "fashionmnist"]): |
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
| class CallCounter: | |
| def __init__(self) -> None: | |
| self._count = 1 | |
| @property | |
| def count(self) -> int: | |
| return self._count | |
| def __call__(self) -> "CallCounter": | |
| self._count += 1 |
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
| """ | |
| ## Limitations | |
| - Extracted variables are just string representation, not arbitrary Python objects | |
| - Variables defined by substitution (e.g. `a = 1`) would be extracted, but others (e.g. `def func():`) won't | |
| """ | |
| import logging | |
| import time |
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
| import difflib | |
| def diff(a: str, b: str) -> None: | |
| line_color = {"+": 32, "-": 31} | |
| diffs = difflib.ndiff(a.splitlines(keepends=True), b.splitlines(keepends=True)) | |
| diff_list = list(diffs) | |
| styled: list[str] = [] | |
| for prev, next in zip(diff_list, diff_list[1:] + [""]): |
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
| function get_ros2_workspace() { | |
| # Look up environment variables. | |
| # If the value isn't actually a directory, this will create it. | |
| candidate=($ROS2_WS $ROS_WS) | |
| for __value in $candidate; do | |
| if [ ! -z $__value ]; then | |
| echo $__value | |
| [ ! -d $__value ] && mkdir -p $__value | |
| return 0 | |
| fi |
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 | |
| import shutil | |
| import subprocess | |
| import sys | |
| import time | |
| from pathlib import Path | |
| save_dir = Path.home() / "Downloads" / "to_upload" |
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
| __all__ = ["imshow_skewed"] | |
| from typing import Tuple | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from matplotlib.transforms import Affine2D | |
| from mpl_toolkits.axisartist import floating_axes | |
| from mpl_toolkits.axisartist.grid_finder import DictFormatter, FixedLocator |
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
| [tool.poetry] | |
| name = "neclib" | |
| version = "0.3.1" | |
| description = "My package" | |
| authors = ["me"] | |
| [tool.poetry.dependencies] | |
| python = ">=3.6.1, <3.10" | |
| astropy = [ | |
| { version = "^3.0", python = "<3.8" }, |
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
| import functools | |
| import types | |
| import xarray as xr | |
| @xr.register_dataarray_accessor("accessor_name") | |
| class Something(xr.DataArray): | |
| __slots__ = ( | |
| "_cache", |
NewerOlder