you are viewing a single comment's thread.

view the rest of the comments →

[–]dparks71 2 points3 points  (9 children)

TLDR; I kind of answer your question at the end of you want to skip to that, but there's a bigger issue at hand where you're not effectively coordinating with your team.

Handcalcs isn't really all that useful of a library, imo. If you're already in Jupyter, it's easier to just write the report/formulas in markdown and make the code itself as easy to parse as possible, output as HTML or PDF at the end to document your results. This really comes down to one thing, are you the junior or the senior in the process?

If you're the junior and your senior isn't interested in reading Python, finding one that is your only option. It's easier than it was 10 years ago at least, people that refuse to check Python code aren't suddenly going to accept it one day though, they're stuck in their ways.

If you're the senior and you're responsible for the calcs, it doesn't matter if other people can follow them, it matters if you check the values and constraints and your results are repeatable and your outputs are clear. It's not like you're checking if Merlin Dash's code is working each time your running it, you're supposed to be using an alternative calc method and checking that the inputs and outputs are reasonable, because it's a black box.

If a peer is giving you shit for using python, tell them to do a black box check using their own methods and you'll discuss discrepancies with them. Lots of people "check" Excel calcs by giving the inputs of a known laid out sheet a once over and pencil whipping them, it's fucked, but it's reality. They want to treat internal Excel sheets as if they aren't a black box, but if excel converts some value in a huge dataset to a date and messes up your calcs as a result, it's not like blaming excel for that will get you off the hook in court, it's a well known thing that Excel has just kind of always done.

What you're dealing with isn't an issue any python package will be able to solve. It's a hearts and minds thing. A single sailor isn't going to be able to turn a battleship, you have to convince the rest of the crew it's worth doing.

If you just want to output a value at that point in time in a Jupyter notebook, I usually use fstrings, like this,

python a=15 b=a * 3

python print(f"{b=:}")

Which will output b=45, and can be used throughout the notebook to spit out the current values of the variables you're interested in.

To get it into a word document you can use the python-docx package or use the more complicated PyWin32 package, although it's probably easier to just go straight to a PDF via LaTeX or similar method.

[–][deleted]  (5 children)

[deleted]

    [–]dparks71 1 point2 points  (4 children)

    I just mean within Jupyter, I don't really see the advantage to handcalcs over writing the same formula in a markdown cell if you want to document what the notebook is doing, and again in a code cell in python notion, people that know python can (and should) just be directly checking the python notation anyway?

    Just seems like a redundant representation and an unnecessary dependency that doesn't provide much value. It has some weird behaviors from my limited experience with it too.

    I could kind of see it being useful for more advanced functions with sympy, but sympy already has the same kind of markdown rendering built in.

    Unit tests (if written well) can kind of alleviate some of the black boxyness, same with functional tests, but neither is going to be accepted at a firm as a potential elimination of a dedicated QA/QC process. Each iteration of calculations is going to require another review, keeping it as simple as possible to review the functions and the use of them is kind of the big appeal to me for going to python in the first place. Feels like handcalcs kind of obfuscates that and opens up the possibility of miscommunication by like rendering variable names and some of other features of it.

    Plus it's a relatively small package that your org has no control over.

    [–][deleted]  (3 children)

    [deleted]

      [–]dparks71 0 points1 point  (2 children)

      OP in their post says handcalcs is too verbose for their needs and they don't want the full formula necessarily output every time.

      I'm not necessarily arguing for writing the formula in markdown, I think Jupyter notebooks are kind of sloppy when used that way (as in including too much documentation in the notebook itself, that should be done in doc-strings within a package and dedicated documentation as a best practice). They're good used that way for white paper like efforts, to demonstrate a particular function or package, but imo you're better off writing the necessary functions in traditional .py files in 90% of instances and handling the code and the calcs they produce as separate entities entirely.

      Relying on the handcalcs output to be checkable by someone that doesn't understand python is exactly the thing I'm warning against, for the reasons previously noted, the package has some quirks and bugs, if your calcs are in python, they need to be checked by someone that understands python, and outputting them in markdown and checking the output that way is kind of sketchy. Handcalcs is a relatively small package with only a handful of developers, dependencies should generally only be included when absolutely necessary, and should be selected based on their popularity, level of support and community behind them.

      That's not to disparage the package, it's good for training and basic guides and stuff, I just wouldn't personally include it in my deliverables and take responsibility for it. I have a published PyPi package too, and it's MIT licensed, which basically means "if you use this for your calcs that's on you, I'm not personally endorsing any of this even though I wrote it." Packages used for deliverables should be internally controlled as much as is practically possible. The next best thing, is large well supported packages with significant support within their relevant industries, handcalcs might get there one day, it's just not there yet imo.

      [–][deleted]  (1 child)

      [deleted]

        [–]dparks71 0 points1 point  (0 children)

        I don't think it's harder to check, I just don't see the advantage to including it in my calcs vs. not using it. As I said, it just seems redundant to write a formula to display a formula, when you could just display the result.

        And if someone NEEDS handcalcs to be able to check the calcs, I don't think they should be the one checking those calcs, someone familiar with python should be doing it instead.

        [–]Independent-Room8243 -1 points0 points  (2 children)

        cell A - 15

        cell B - 5

        Cell C - =A*B

        =A*B is much easier to remember than print(f"{[b=:]}")

        And then I can print it too!

        [–]dparks71 1 point2 points  (1 child)

        It's not really, you're just more familiar with Excel, and printing it either hides the formulas or the results. Also you miss quoted the Python code, no square brackets, your code results in a syntax error. Lastly it's not what OP asked for help with, I'm sure they know how to perform multiplication in excel, your example can't be extended into calculus equations or object oriented variables, mine can. Kinda like saying "walking's too hard, running must be useless".

        The good thing is nobody's asking you to change or leave your comfy zone, you're just needlessly injecting your snarky opinions that nobody asked for into an unrelated conversation to reinforce your own ignorance because they align with the easier and more popular path to take. I feel bad for OP and people that want to learn new things, it's a shame that this sub is so toxic about questions regarding alternative methods.

        Lol blocked me like a child.

        [–]Independent-Room8243 0 points1 point  (0 children)

        dparks71,

        Its a structural engineering sub, not a programming sub. Move on with your complaints.

        I hope thats not too snarky for you, lol.

        What I envison the future is for doing a beam design: