This week we welcome Connor Ferster as our PyDev of the Week! Connor is the author of handcalcs which was recently featured on the PythonBytes Podcast. You can see more of Connor’s work on Github.
Let’s spend some time getting to know Connor now!
Can you tell us a little about yourself (hobbies, education, etc):
I am 38 years old and went back to school at 31 to pursue civil technology and then civil engineering. Civil engineering is the discipline of building anything to do with “civilization”: water resources and pipes, roads and transportation, buildings and bridges. I currently work as a structural design engineer-in-training in Canada where I work on buildings. My education involved a special transfer year between college and university where I learned, among other things, programming in Matlab. It was during that year that I got really into programming, primarily as a creative outlet. I would have to say that programming in Python is probably my biggest hobby right now but I also enjoy cooking, making bread, and reading. I have been reading everything by Ursula K. LeGuin recently.
Prior to going back to college, I was also a headhunter, business owner, sales person, and music school drop-out (in that reverse chronological order).
Why did you start using Python?
I first heard of Python when I was at a house party in about 2009. At that time, I had my online wallet business and I had hired my friend’s company to build the website. He was a big fan of Ruby on Rails and he had gotten me interested in learning it. When I was at this house party, I met some other web developer guys and I was telling them about my interest in learning Ruby on Rails. They said, “Pfffft! Forget Ruby. Learn Python!” They were showing me some of their projects in Python and talking about how great Python is (I don’t remember what they said, though!). Since then, I have been aware of “Python”, just as a name, but not much else.
In 2018, I saw that the university offered a course called “Introduction to Systematic Program Design”, a kind of computer science course for non-computer science majors. The course was to teach people in other disciplines how to write programs for their own disciplines. When I saw the course would be taught in Python, I signed up, even though it didn’t give me credits for my degree. That course changed my life. I believe I got an A+ on that final exam which was all hand-written Python code.
Since then, I have fallen in love with Python. I love Python so much.
What projects are you working on now?
I have two open source projects that I am building, called “handcalcs” and “forallpeople”. Handcalcs was a library developed for a simple, single purpose: calculations written in Python code can be displayed as though you wrote them by hand. Forallpeople is another units library for Python but designed for fast and casual calculations following a “convention over configuration” approach.
In addition to these projects, I work on proprietary projects internally for my company that have to do with work-flow automation and how it relates to the structural design process. I am grateful that my company has allowed me to work on handcalcs and forallpeople as open source projects in my free time.
Which Python libraries are your favorite (core or 3rd party)?
Like many Pythonistas, I love pathlib. It just handles everything related to paths so beautifully.
In the standard library, I really value collections. Not only for the containers it provides but also the way the code is written. I opened up the source one day and learned so much about Python in just 15 minutes of reading the source.
I think shapely is fantastic. Being able to perform 2D geometric queries and comparisons is really powerful.
Handcalcs is built on pyparsing, which is an incredibly beautiful and useful library.
For plotting, I really appreciate plotly but I am keeping an eye on ipyvolume and hope to use it more in the future (I am waiting for custom pop-ups when hovering over a glyph).
I just started using a new library called sxl for lazy loading of single tables and table ranges within really large Excel files. It’s a simple library but it works really well! You do not have to load the whole workbook into memory to iterate over a range or sheet within the file.
I have been on the streamlit bandwagon for a few months now. I think it can be a revolutionary library for some Python users: the ability to create simple and fast web interfaces for one’s Python script feels like magic.
I don’t know if I am allowed to say this here but I really love my own modules: handcalcs and forallpeople. I rely on them everyday to be productive at work and I don’t want to imagine my work life without them! They are just so important to me.
What is the origin story for your handcalcs package?
I spent a summer as a student programming design calculation spreadsheets for my current company. It was a great experience but, knowing how to use Python, I grew to become very frustrated at working in Excel. In the engineering world, a hand-written calculation is still a kind of “gold standard” for design notes that typically become a part of a project’s legal history. Excel is often used to make the process more efficient however it is not transparent: you type a formula in a cell and 1) the formula only contains cell references (unless you define cell names) and 2) the formula is hidden. For accountability, you have to separately type the formula in an adjacent cell so you can print your sheet out as a report or calc sheet. However, the formula you typed is just text: the resulting value has no relationship with the formatted formula you typed out and you have to change both to update. This makes maintenance cumbersome.
I wanted the formula I typed to be the same as the formatted representation of the formula I typed — change the representation and the result changes. Software packages like SMathStudio and MathCAD do this but you have to manually lay out formulas on the sheet and, most importantly, none of these software packages show the numerical substitution. This is how we are taught in school: first you write out the formula, then you write the numerical substitution of values, then you write the answer. This allows for fast verification of the calculation. Additionally, I wanted the calculations and notes to format themselves: I don’t have time to fuss with formatting.
However, there is no software (that I have seen) that can actually do all of this, which is why I wrote handcalcs.
Handcalcs is a library intended to be used with Jupyter Lab/Notebooks with a simple premise: type a calculation into your Python cell and have it be automatically rendered out in Latex as though you wrote it by hand. Jupyter handles the formatting for you. Print to PDF using your browser (via an HTML export) or through Latex (if you have it installed). Additionally, use handcalcs with any other library that enhances your workflow with Jupyter, such as with papermill that allows you to run parameterized notebooks.
The primary handcalcs interface is through the “%%render” Jupyter cell magic but I have also written a decorator interface that you can put on any calculation function to render the function source to Jupyter or Streamlit. This decorator interface is so powerful because it allows you to write small “library modules” of commonly-used calculations that you can import into your Juptyer Notebook without re-typing them. I am still figuring out all the ways I can use the decorator interface!
Why should people use your package instead of something like LaTex?
Ah! When you are using handcalcs you are actually using LaTex! Handcalcs will render out your calculations for you so you do not need to know LaTex. However, using the %%tex cell magic, you can also use handcalcs to spit out the raw LaTex code that you can use in your own .tex documents. LaTex, but more specifically Mathjax and Katex, is what makes handcalcs possible. In this way, LaTex is like the flux capacitor.
But if we are comparing handcalcs to Excel and SMathStudio (which is excellent) and MathCAD, then in addition to all of the reasons I provided earlier, I would say that it’s really important to have and use Free Software. Python is Free Software, Jupyter is Free Software; LaTex, Mathjax, and Katex are Free Software; and handcalcs is Free Software. I think that the Free Software realm represents a kind of microcosm of the larger world that I hope we can create where people’s creative gifts are given to enhance all people, everywhere. When people in the future use and build upon your work, it can be a kind of way to live forever.
Thanks for doing the interview, Connor!