« first day (2150 days earlier)      last day (373 days later) » 

3:13 PM
I packaged up my code for solving eigenvalue BVPs, and put it on GitHub with a paclet installer. Any feedback on anything that I should do differently would be appreciated, this is my first time both making a package and using GitHub. Package is at: github.com/KraZug/CompoundMatrixMethod
 
3:52 PM
posted on December 07, 2017 by Jon McLoone

Computation is no longer the preserve of science and engineering, so I thought I would share a simple computational literary analysis that I did with my daughter. Hannah’s favorite book is Lord of the Flies by William Golding, and as part of a project she was doing, she wanted to find some quantitative information to [...]

 
@KraZug Here's some (very superficial) feedback:
The "Download the latest release" link in your readme is broken.
The paclet file should be hosted on GitHub's releases page, not in the repo itself. Create a tag for the repo (e.g. v0.1), then go to the releases page, click draft release, select the tag, upload the corresponding paclet.
If you want v9-compatibility, then the PacletInfo.m file should use MathematicaVersion, not WolframVersion.
The source code is not indented/formatted, therefore it is very hard to read, and it is easy to miss errors in it. There are immediately noticeable minor errors, such as e.g. lena, lenb not being localized in the Module.
I strongly suggest using halirutan's IDEA plugin: wlplugin.halirutan.de It'll make it easier to write code, easier to format code, and easier to spot many basic mistakes such as not localizing variables, forgetting a semicolon/comma, etc.
Instead of Print, it's nicer to use Message. This way warnings can be individually disabled.
Abort is ugly: it stops the kernel completely. It doesn't give your package's users the option to catch and handle errors automatically. Please don't do this. There are several techniques for handling errors. I suggest reading this:
79
Q: What are the best practices / most common / idiomatic ways to report errors in Mathematica?

SzabolcsIn particular, what are the best ways to report errors about incorrect arguments to a function? Checking for the correct arguments is relatively easy using patterns, but how to report an informative error message specific to the situation is not obvious. Most built-in functions will return unev...

And I suggest simply returning $Failed in case of an error (along with issuing a Message) because this is the easiest to implement.
Don't use $Aborted for this, use $Failed, or if you like, use Failure. That was introduced in v10.0, so it's not an option if you need 9.0-compatibility.
Easy way: Return[$Failed]. More complicated, but more flexible way: Catch[...; Throw[$Failed, myTag]; ..., myTag]. The advantage of Throw/Catch: it works even if you throw from one function and catch from another (Return doesn't).
I hope this helps!
 
4:14 PM
Thanks @Szabolcs, that's great feedback
 
@KraZug Just tried the example form the README, but CompoundMatrixMethod[{k,1},sys] won't evaluate. What am I doing wrong?
 
The L is undefined, let me edit that in the README
Edited the README. Is there any way of writing maths in the README file?
Currently working on the error messages.
 
4:36 PM
@Szabolcs I'm not convinced on this one. Putting it in the repo makes it easier to install than if it's in the releases. One requires just using the raw.... url in PacletInstall while the other requires the GitHub API (unless I'm much mistaken). Unless you makes the user download and then install, but that feels like an unnecessary step.
The issue, of course, is for forking. One interesting thing @CarlWoll did was to pack a paclet server into a repo: github.com/carlwoll/TensorSimplify
 
Is there a way to check what version all the functions I use were introduced at?
For that matter, what version did Paclets start at?
 
But of course that still suffers the forking / cloning issue. Better, I think, to have a stand-alone paclet server that you serve from GitHub.
@KraZug these are undocumented but have been in the language since ~v6 I think. The system is how Wolfram distributes things like its curated data.
And also all of its new features and feature updates. Given how much use it gets internally, I'm fairly confident it won't just get dropped.
If your scroll down to PacletManager here: wolframcloud.com/objects/b3m2a1.docs/main.html
You can see some auto-built documentation for it.
 
I'm happy to use PacletManager, I just wondered if there was any point trying to say that my code works for v6 (say) if the Paclet installer didn't exist.
 
@KraZug They started in 6, but AFAIK big changes were made after v8. Personally I have only tested with v9+.
@KraZug The best way is to test in the earliest version you want to target. The next best way is to use the IDEA plugin I referenced. You can set a minimum version and it'll highlight functions that aren't available in it. It won't tell you about changes to these functions' syntaxes though.
I'm not quite certain if you need to have that minimum version installed to be able to do this, though.
 
4:51 PM
I've just installed IDEA and the plugin. I've used Eclipse before but not that.
What in the IDEA plugin is super useful compared to working directly in Mathematica?
I have v9 and v11 installed, so I know it works on v9.
 
Also, about MathematicaVersion vs WolframVersion in PacletInfo: while "MathematicaVersion" is deprecated, it at least has the advantage that v9 will recognize it and will refuse to install a paclet that's compatible only with v10+. This is why I use it even for v10+ compatible packages.
configurable code indenting (and automatic code formatting), better syntax highlighting, better auto-completion, refactoring (e.g. rename a Module variable without changing symbols with the same name outside the module), some warnings about common mistakes
Watch the video
 
5:28 PM
Do I just give up on using greek letters (one of my favourite things about Mathematica) in package?
 
@KraZug in a package no, in a package in external editor, yes.
 
5:45 PM
@b3m2a1 Of course, I just used your idea and method.
 
 
2 hours later…
7:16 PM
@b3m2a1 You are mistaken
And the repo is not the right place for the finished product.
 
@KraZug You do not need to use the IDE. You can just use the Mathematica front end if you wish. There are tradeoffs, and we need to decide what features are important and what we're willing to give up.
Actually it is possible to use Greek letters with an IDE. I have a Greek keyboard set up and can type αβγ with minimal fuss. In principle I could use these in a Mathematica package.
The problem is that then a specific encoding needs to be selected for the .m file. Most editors use UTF8. Mathematica interprets the file as UTF8 on OS X and probably on Linux. But not on Windows!
So the package may not properly load on Windows, depending on $CharacterEncoding
I do use non-ASCII characters in strings and comments only in my packages, and to deal with this issue I post-process the .m files before building a paclet, like this:
8
Q: Re-encode text file to use Mathematica's character name, like \[Alpha]

SzabolcsHow can I re-encode a text file (or string) so that non-ASCII characters will be represented using Mathematica's standard names? For example, if the original contents of the file was xαy then the re-encoded file should contain x\[Alpha]y Using the CharacterEncoding "Mathematica7" comes ...

 
7:31 PM
@halirutan I agree with that. How do you PacletInstall from a release?
 
@b3m2a1 You use Mathematica 11.2 or later :-)
PacletInstall["https://github.com/szhorvat/IGraphM/releases/download/v0.3.94/IG‌​raphM-0.3.94.paclet"]
 
@Szabolcs Ha. Okay. I think I'm gonna stick with the paclet server approach for now, though.
 
Yes, of course I know what you mean. I do not think it is a good idea to put the release in the repo, but sometimes hacks like this are convenient or even necessary. I would still use separate GitHub repos for a paclet server, and for development.
 
@b3m2a1 The paclet server thing is another one of Wolfram's infamous "we need to re-invent the wheel" feature. Completely blind to what's going on in the rest of the tech-world.
 
@halirutan I find it convenient. How would you go about distributing paclets from a common source?
 
7:44 PM
@b3m2a1 The problem is not that it exists, the problem is that there is zero support for existing open source solutions. If you look how other languages distribute their packages (again, look at Julia) then you see that the support for GitHub works out of the box.
However, the amount of package developers is very very small compared to Mathematica users.
 
@halirutan Ahhh. Yes I agree with that.
 
The problem is that many Mathematica users will stumble even on something as basic as downloading a paclet file and typing in the correct path for PacletInstall. Being able to give them a single line of code to install a package is valuable.
 
They could very easily add paclet-based support for GitHub, too.
 
The only way I know is the paclet server approach. That you may host anywhere you like.
I tried to have an auto-install script for MaTeX, but it's way too long:
 
@Szabolcs Yeah that's what I like about the paclet servers. I also built a general GitHub-based paclet installer that worked like that.
 
7:47 PM
There are projects like Kuba's MPM, but it takes time to maintain them, and no current project supports everything back to M10.0.
 
Mhmm. I think someone needs to convince Todd Gayley to convince SW to let him add GitHub support...
 
I tried to suggest to Wolfram to at least help the community standardize on a solution if they won't make their own, but they don't seem terribly interested.
 
Or just document and expose the paclet manager in general
 
@b3m2a1 11.2 came with lots of fixes for it, thanks to Kuba sending detailed problem reports
There were rumours that Wolfram wants to set up an "app marketplace". I don't know the details. I haven't been to any WTCs and I assume that those people who have had to sign NDAs.
@b3m2a1 Actually that's not good enough for me. I want something that works all the way back to v10.0. I'd much rather see some sort of openly implementable standard.
 
@Szabolcs I've heard those rumors too. I assumed with their data-repository and neural-net-repository and stuff a a package-repository was in the works.
 
7:51 PM
@Szabolcs My personal feeling is that WRI will exploit everything that is currently done to make money. I expect that more things like an App-Store-like stuff appears.
 
That's also why I think that a proper package manager is so urgent. It'll take several years before packages that support older versions will start using it
 
@Szabolcs what else would WRI need to do for that? I feel like they have 80% of the stuff they need for it.
 
Several people worked in this direction, first Leonid, much later Kuba and you. No solutions really caught on. WRI needs to show public support. How about patching up an existing project like @Kuba's MPM, hosting it under their own account and accepting pull requests form the community?
 
@Szabolcs What would a "proper package manager" support outside of the standard paclet system? Is it mostly dependency handling?
 
I mean if they really really don't have the resources to do it entirely on their own.
WRI has next to zero support for package developers or package dvelopment. They don't seem to care much.
@b3m2a1 Something that gives me a one-line command to install from open sites like GitHub.
And which is also robust and trusted.
 
7:58 PM
@Szabolcs yeah that's definitely something that WRI would need to get in-on too. I think a centralized system would be important too... like python's pip or Atom's apm.
 
They do give prizes to people for industry who are said to have developed amazing packages, but the packages never even get publicly released.
Actually this goes back many years. It's so typical to find presentations about interesting sounding packages on the Wolfram Library Archive, but there is often no trace of the package files.
 
Honestly I think SW causes much of this. I feel like his focus is not on the open-source community at all.
 
@b3m2a1 Of course not. His focus is on SW. Just go to Glassdoor and read one of the many reports.
 
8:18 PM
@Szabolcs @b3m2a1 yeah, I feel sorry for abandoning MPM but I have less time now and I wasn't motivated by minimal usability as everything gets complicated if you need to inject several multifile packages into a cdf because your client is not able to Shift+Enter one line. To get MPM to that stage is beyond my imagination so I do custom packing anyway.
 
9:08 PM
Does anyone know what precisely is causing Hyperlinks to turn black (instead of blue) when printing? Is it simply that this is the style they have in the Printout environment, or is there something more to it? Adding a new style for them for the Printout environment does work.
 
@Szabolcs CurrentValue[{StyleDefinitions, "Hyperlink", FontColor}] returns different colors when evaluated in Printput and Working
@Szabolcs and it seems to come from "Link" style.
 
10:14 PM
Does OptionsPattern[] include RuleDelayed options?
f[x_,y_,x_:2,opts:OptionsPattern[]]
but f[1,2,StepMonitor:>((a=#)&)] seems to take the RuleDelayed option as x_.
 
10:27 PM
@Edmund I'm guessing you need to Clear. That shouldn't work at all...
It does take RuleDelayed.
And that pattern is faulty unless I am much mistaken.
 
10:58 PM
@Edmund Yes, it works for rule delayed.
But your pattern doesn't really make sense to me.
In[3]:= Options[f] = {
   opt :> Automatic
   };
f[x_, y_, x_: 2, opts : OptionsPattern[]] := {x, y, OptionValue[opt]}

In[8]:= f[2, 1, opt :> "Boing"]

Out[8]= {2, 1, "Boing"}
 
11:29 PM
@Edmund make x_ more specific, e.g. x_?NumericQ mathematica.stackexchange.com/a/124208/12
@Edmund Check the 4-argument form of OptionValue, documented under Details. It's for RuleDelayed.
 

« first day (2150 days earlier)      last day (373 days later) »