Skip to content

modernize, increase annotations, document - #1

Open
hunterhogan wants to merge 12 commits into
tasansal:mainfrom
hunterhogan:main
Open

modernize, increase annotations, document#1
hunterhogan wants to merge 12 commits into
tasansal:mainfrom
hunterhogan:main

Conversation

@hunterhogan

Copy link
Copy Markdown

No description provided.

@hunterhogan hunterhogan changed the title ketchup ketchup and modernize. May 4, 2026
- more type annotations.
- replace common functions with torch_einops_kit.
- hunterMakesPy.raiseIfNone for type narrowing. - some formatting.
- change flow to deduplicate.
- change assert to raise and improve messages.
- Remove inline comments from Captain Obvious.
- use class attributes instead of initialization parameters.
- prevent corner-case error with a warning.
- remove unnecessary check.

@hunterhogan hunterhogan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need type annotations and documentation. I wish I had noticed your PR before I had typed the entire module. I plan to publish a typed and documented version because I use it in another package I will soon publish.

On style

So I could match the style of lucidrains in my pull requests, https://github.com/lucidrains/torch-einops-utils/pulls, I anaylzed his repos and created:

ruff.toml à la lucidrains

extend = "pyproject.toml"

line-length = 187

[lint]
select = ["ALL"]
ignore = [
  "C901",
  "COM812",
  "D",
  "E402",
  "E701",
  "E722",
  "E731",
  "E741",
  "FBT001",
  "FBT002",
  "FBT003",
  "FIX",
  "I",
  "N812",
  "PLR0913",
  "Q000",
  "S301",
  "SIM108",
  "SIM300",
  "T201",
  "TC",
  "TD",
]

[lint.per-file-ignores]
"tests/**.py" = [
  "S101",
  "FBT001",
]

[lint.flake8-import-conventions.aliases]
"accelerate.utils.dataclasses" = "accelerate_dataclasses"
"bidirectional_cross_attention.BidirectionalCrossAttentionTransformer" = "BiCrossAttnTransformer"
"einops.layers.torch.EinMix" = "Mix"
"hyper_connections.manifold_constrained_hyper_connections.get_expand_reduce_stream_functions" = "mc_get_expand_reduce_stream_functions"
"jax.numpy" = "jnp"
"kornia.augmentation" = "augs"
"torch.autograd.grad" = "torch_grad"
"torch.nn.functional" = "F"
"torch.nn.parallel.DistributedDataParallel" = "DDP"
"torchvision.transforms" = "T"

[format]
docstring-code-format = true
quote-style = "single"

My style

My style is quite different and idiosyncratic. I've "codified" it in the five configuration files in https://github.com/hunterhogan/hunterMakesPy. ("Codified" is a legal term: I can't think of the programming term right now.)

Our style?

If you want to collaborate on this package, we can pick a style that suits us. I don't think lucidraids will merge your PR "tomorrow", so we may as well code in our own style.

Docstrings are next

I've drafted docstrings. I need to do another round of editing, though.

Coincidentally, I grew up in Houston. I went to high school out by 1960 and 45.

@hunterhogan

Copy link
Copy Markdown
Author

I'm all but certain that the docstrings need revision. I hope, however, they are 1. better than nothing and 2. easier for an expert to fix than for an expert to write from scratch.

@hunterhogan hunterhogan changed the title ketchup and modernize. modernize, increase annotations, document May 4, 2026

@hunterhogan hunterhogan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK what to do with this PR, so I'm not doing anything right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants