{"id":19670773,"url":"https://github.com/terriko/pyknit","last_synced_at":"2025-04-24T00:22:15.321Z","repository":{"id":38274724,"uuid":"319587315","full_name":"terriko/pyknit","owner":"terriko","description":"A set of tools for knitters to create charts and eventually more.","archived":false,"fork":false,"pushed_at":"2024-01-22T23:09:49.000Z","size":14168,"stargazers_count":82,"open_issues_count":12,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-26T03:03:40.996Z","etag":null,"topics":["hacktoberfest","jupyter","knitting","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terriko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-08T09:21:17.000Z","updated_at":"2025-03-19T05:54:21.000Z","dependencies_parsed_at":"2024-01-22T23:58:39.527Z","dependency_job_id":null,"html_url":"https://github.com/terriko/pyknit","commit_stats":{"total_commits":78,"total_committers":15,"mean_commits":5.2,"dds":0.2948717948717948,"last_synced_commit":"c411f0e5a8639243203d194f4909822413221e4d"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terriko%2Fpyknit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terriko%2Fpyknit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terriko%2Fpyknit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terriko%2Fpyknit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terriko","download_url":"https://codeload.github.com/terriko/pyknit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250536239,"owners_count":21446698,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","jupyter","knitting","python"],"created_at":"2024-11-11T17:07:05.907Z","updated_at":"2025-04-24T00:22:15.283Z","avatar_url":"https://github.com/terriko.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyKnit\n\n![pyKnit](https://raw.githubusercontent.com/terriko/pyknit/main/pyknit-logolong.png)\n\nA set of tools for knitters to do math, create charts, and eventually more.\n\n![pyknit](https://github.com/terriko/pyknit/workflows/pyknit/badge.svg?branch=main\u0026event=push)\n[![On PyPI](https://img.shields.io/pypi/v/pyknit)](https://pypi.org/project/pyknit/)\n\n## Installing pyKnit\n\n```\npip install pyknit\n```\n\nIf you want to use the latest and greatest [grab pyknit from github](https://github.com/terriko/pyknit) and use `pip install -e` to install it in [\"editable\" mode](https://pip.pypa.io/en/stable/cli/pip_install/#install-editable).\n\n```\ngit clone https://github.com/terriko/pyknit\npip install -e pyknit/\n```\n\nNote that when you're doing `pip install -e pyknit/` here that `pyknit/` refers to the directory.  (You don't really need the slash but it makes that more clear.) If you get an error about not being able to find `setup.py` you're probably giving it the wrong directory (and may need to `cd ..` to go up one directory).\n\n## Jupyter-lab Usage\n\npyKnit works best in conjunction with [Jupyter](https://jupyter.org/install).\nThis allows you to \"mess around\" with the functions and see the results in your\nbrowser.  I like this especially for the ability to display the charts inline.\n\nMake sure you install Jupyter and pyknit in the same place (e.g. in the same\nvirtualenv if you're using one) so that you can use `import pyknit` and have it\nwork. (You can [read more about how to install a python Package in Jupyter\nhere](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/).)\n\nI prefer to use virtualenv and pip, so I set up my environment as follows:\n\n```console\nvirtualenv -p python3.8 venv-3.8-jupyter\nsource venv-3.8-jupyter/bin/activate\npip install jupyterlab\npip install pyknit\njupyter-lab\n```\n***Developers may prefer to [get pyknit from github](https://github.com/terriko/pyknit) and use `pip install -e $pyknit_directory` in lieu of `pip install pyknit`  Remember to restart the notebook kernel to get any changes you've made in the pyknit directory while you're editing the code!***\n\n\nFrom there, jupyter lab will open in a browser, and you can create a new notebook to play around.  When you're done, you can shut down the notebook server using `^C` in the console and typing `y` when it asks if you want to shut down.  You can deactivate the virtualenv by typing `deactivate` and pressing enter.\n\nIf you want to run it again later, you can do the following:\n\n```console\nsource venv-3.8-jupyter/bin/activate\njupyter-lab\n```\n\n(The virtualenv only needs to be created once, and you don't need to reinstall.)\n\n## Using PyKnit\n\n```python\nimport pyknit\n\n# Sweater fit check math.  My gauge doesn't match the pattern but I like the\n# fabric I got in my swatch and don't want to change the needle I'm using.\n# What size should I knit?\n\npattern_g = pyknit.GaugeSwatch(\n    stitch_count=27.5, stitch_measure=10, row_count=40, row_measure=4, units=\"in\"\n)\nmy_g = pyknit.GaugeSwatch(\n    stitch_count=23.5, stitch_measure=10, row_count=33, row_measure=4, units=\"in\"\n)\n\n# The closest size to my measurements is the 42in chest one, let's convert that\n\nsize3 = pyknit.convert_stitch_measure(42, pattern_g, my_g)\nprint(f\"{size3=}\")\n```\n\nRunning that gives a new size of 49 inches. This sweater was designed for +/- 2 inches (it says so in the pattern), so that's too big unless I love a really baggy sweater.\n\n\n```python\nsize2 = pyknit.convert_stitch_measure(38, pattern_g, my_g)\nsize1 = pyknit.convert_stitch_measure(34, pattern_g, my_g)\nprint(f\"{size2=}\")\nprint(f\"{size1=}\")\n```\n\nThose give me 44.25 inches and 40 inches respectively (rounded to the nearest quarter inch, anyhow)\n\nIf I was aiming for exactly 42 inches chest circumference, I'd have the option\nof either knitting the 44 inch one and having 2 inches positive ease (i.e. the\nsweater would be a little loose) or the 40 inch one with -2 inches positive\nease (i.e. the sweater would stretch to fit me), and I would choose whichever\none I think I'd like better assuming my swatch is sufficiently stretchy.\n\nThis [SweaterFit Example file](https://github.com/terriko/pyknit/blob/main/documentation/SweaterFit.py) is here if you want to sub in your own swatch numbers.\n\n\n[Here's an example of how to calculate sweater sleeve decreases using pyknit](https://github.com/terriko/pyknit/blob/main/documentation/SleeveDecreases.md) to get you started.\n\nFor those using Jupyter, there are also several full interactive notebooks available:\n\n* [Sweater Sleeve Decreases](https://github.com/terriko/pyknit/blob/main/documentation/SleeveDecreases.ipynb)\n* [Triangle Hat interactive hat pattern](https://github.com/terriko/pyknit/blob/main/documentation/TriangleHat.ipynb)\n* [Sweater Fit from gauge swatches](https://github.com/terriko/pyknit/blob/main/documentation/SweaterFit.ipynb)\n\n## Why pyKnit?\n\nThere's lots of great tools for knitters out there, but they're not open\nsource, which means if I don't like the way they work, I'm often stuck with\nweird workarounds.  I thought it would be fun to make some knitting tools that\nwere a bit more flexible.\n\nI knit during conference talks, and every year at PyCon I meet a few folk who\nstop by to ask what I'm knitting and or to show me what they're working on.  So\nI know there's enough of an intersection between the knitting and Python\ncommunities for this to be fun for more than just me.\n\nAnd finally, knitting involves a lot of math.  Not every knitter loves math,\nand even those who do can get tired of calculating and recalculating.  So why\nnot let the computer do that work?  I'd like to imagine a world where I could\npublish a pattern with an interactive notebook and let people fit sweaters\nspecifically to their measurements, or figure out how to adjust a shawl if\nyou want to use all of a pretty gradient skein of yarn, or have the option to\nadd calculated stitch counts to every single row of your pattern so people can\ncheck if they messed something up.\n\nIt's going to be a while before we get to the complicated stuff, but you have\nto start somewhere!\n\n## Contributing\n\nGot an idea for a function you wish we had?  Think you found a bug?  [Let us know via the issues](https://github.com/terriko/pyknit/issues).\n\nKnow open source and want to just get into it?  [Make a pull request here](https://github.com/terriko/pyknit/pulls)\n\nNever contributed to open source before? Not sure what open source is? [Here's a guide on How to contribute to open source](https://opensource.guide/how-to-contribute/) that includes information on why you might want to and how to do it.  I work with new contributors regularly in my day job, so don't be shy!  I'm happy to help you figure it out.\n\nIf you find a security issue and want to contact me privately, [send me an\nemail](https://github.com/terriko/).  It might feel silly to talk about\nsecurity issues in knitting software, but it *does* parse things and display\nthings, so it's possible!\n\n## License\n\npyKnit is licensed under the [GPL-2.0 License](https://github.com/terriko/pyknit/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterriko%2Fpyknit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterriko%2Fpyknit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterriko%2Fpyknit/lists"}