Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
161

I. General I will first try to briefly answer the questions, and then illustrate this with a small but practical application. 1.Speed of insertion / deletion Associations are based on so called Hash Array Mapped Trie persistent data structure. One can think of this as a nested hash table, but it is more than that, because it has the following properties: ...


47

I helped design Association, and I designed and implemented Dataset, so I wanted to comment on question 3: Dataset is designed explicitly for hierarchical data. It supports any 'shape' of data, inferring the shape when the Dataset is first created. It also tracks the shape of the data as transformations are applied to the dataset, using a type-inference ...


44

For me the operator forms of Map and Apply will probably provide the most important benefits in terms of code readability. Often I need to apply a sequence of transformations to some data, and I am fond of infix notation for this purpose. For example I find a ~Position~ 0 ~SortBy~ Last more readable than the "conventional" SortBy[Position[a, 0], Last] ...


38

Update 2: The content and organization of $PlotThemes in versions 10 and 9 are very different. In Version 10 Charting`$PlotThemes gives whereas in Version 9, the content is organized around Charting/Plotting functions (See the picture in original post below.) The color schemes can be obtained using: "Color"/. Charting`$PlotThemes (* BackgroundColor, ...


37

I would have liked to have more experience with the operator forms before this question was asked as I am short on examples, and I'm sure my opinion will evolve over time. Nevertheless I think I have enough familiarity with similar syntax to provide some useful comments. Taliesin Beynon provided some background for this functionality in Chat: Operator ...


36

Theoretically, Dataset supports any number of columns. The behavior you are seeing is actually because the type deduction that Dataset is doing behind the scenes isn't perfect (and indeed in some sense cannot be perfect). Your synthetic example is such that your second list of associations is "most consistent" with a particular type that doesn't typeset as ...


35

Unfortunately I cannot claim the original discovery, but there are additional CodeAssistOptions in M10, the one you want is: SetOptions[EvaluationNotebook[], CodeAssistOptions -> {"FloatingElementEnable" -> False}] You could replace EvaluationNotebook[] with $FrontEnd but I prefer not to change $FrontEnd options.


34

Updated Both Hold and Inactive block evaluation; the key difference is that Inactive is meant to be wrapped around heads rather than a whole expression. Inactivate does this. Inactivate[1 + 2 + 3 * 4 ^ 5 ] // FullForm Inactive[Plus][1, 2, Inactive[Times][3, Inactive[Power][4, 5]]] It is of course possible to use Inactive directly, and it will behave like ...


34

I'm the developer of Dataset. Yes, this is a gross documentation oversight. We planned this functionality but had to push it back to a point release. Somehow no-one caught this piece of legacy documentation. I've filed a bug on the documentation problem right now, it's easy to fix. As for when L-value assignment will be available, I'm hoping 10.0.1 or 10....


24

I find the value of the new operator forms becomes critical when working with datasets. Consider titanic = ExampleData[{"Dataset", "Titanic"}]; titanic[Count[#], "survived"] & /@ {True, False, _Missing} {500, 809, 0} Derive a data set for analyzing the survival of very young passengers. cutoff = 8; youngest = titanic[All, {"age", "survived"}][Select[#...


23

Mathematica still works with Courier by default. Nothing is broken about your copy of Mathematica. It is the case, however, that if you use any sans serif font (or at least any font that properly advertises itself as sans serif...many amateur font designers don't bother setting font metadata bits correctly), you'll see the new MathematicaSans font in use ...


23

First of all, it's not a new data structure, it's a new only in a Wolfram Mathematica. About complexity of a data structure. It's a Wolfram implementation of a hash-map. With a complexity of an operations (worst case in parenthesis): Space O(n) Search O(1) (O(n)) Insert O(1) (O(n)) Delete O(1) (O(n)) This can be easily checked: create custom ...


23

Update: Using MeshFunctions and Mesh in RegionPlot: RegionPlot[Evaluate[Region`RegionProperty[Rationalize /@ blob, {x, y}, "FastDescription"][[1, 2]]], {x, -3, 3}, {y, -3, 3}, Mesh -> 50, MeshFunctions -> {#1 + #2 &, #1 - #2 &}, MeshStyle -> White, PlotStyle -> Directive[{Thick, Blue}]] With settings MeshStyle -> GrayLevel[....


21

From my understanding of what's going on, Mathematica does the following when you hit "Run": Parse the entire test notebook to look for input test cells and get the corresponding cell ids. Run the tests and collect the outcomes (using the cell ids from step 1). Generate test stats (total tests run, successes, failures) and provide links to jump to the next ...


21

Based on Mr.Wizard's answer and comments by Szabolcs and celtschk, I now understand that the code I posted does have undesirable side-effects and it should be avoided. Specifically, the scoping constructs Module and Block are meant to completely localize the variables in their first argument (for more information see this question). However, placing their ...


20

Update: Using Raster3D and a variation of func that returns 4-tuples data3C = RandomReal[1, {10, 6}]; func3C = Nearest[{#, #2, #3} -> {##4, .03} & @@@ data3C]; tbl3C = Table[ First[func3C[{x, y, z}]] // Quiet, {x, 0, 1, .01}, {y, 0, 1, .01}, {z, 0, 1, .01}]; Examples: Row[Labeled[Graphics3D[Raster3D[tbl3C, ColorFunction -> #, Method ...


20

We can push paclet updates out directly, I think PacletManager guarantees that you'll have them within a week (as long as you have an internet connection). This only works for certain functionality that has been written in the paclet form (e.g. Machine Learning, Dataset, SemanticImport). I'm really excited about that, because we can respond quickly to ...


18

One difference is that NDSolve directly supports Inactive. It can be used to specify operators such as divergence ($\nabla\cdot$) without automatically evaluating them to components. This is described here.


18

Association is atomic: <|x -> 1|> // AtomQ True Therefore standard pattern matching inside the structure will not work. You can still match on the implicit head using: MatchQ[<|x -> 1|>, _Association] True There is also AssociationQ: <|x -> 1|> // AssociationQ True MatchQ[<|x -> 1|>, _?AssociationQ] True I ...


18

We may observe that the automatically generated legend limits the number of legend items to the number of available colors in the given color scheme. Using this utility function: plot[scheme_] := Plot[Evaluate[Range[20] + x], {x, -5, 5}, PlotLegends -> "Expressions", PlotStyle -> scheme] Observe the result for indexed color scheme #42 which has ...


17

Although I haven't examined it to see how complete it is, putting Virtual Book into the search bar of the Documentation Center quickly found this: http://reference.wolfram.com/language/tutorial/VirtualBookOverview.html Which can be accessed locally with: tutorial/VirtualBookOverview


17

This is not related to the output cell greying to indicate mismatch with the input cell. You can easily verify this by editing the input cell — it gets further greyed out. The new summarized display that is used for things like SparseArray, Interpolation, etc. has a setting "Interpretable" -> False. If this is the case, the output is showed in a gray ...


17

Intermingling Operator Forms & Linguistic Connections This answer attempts to draw out linguistic connections in understanding why operator forms seem so useful, a process that can perhaps point to further utility. Operator Forms are a type of modularization with the standard re-use and combinatory advantages but IMO the biggest benefit is cognitive - ...


17

Currently in Mathematica v10 you need to be careful joining datasets as the Key[] function doesn't work with a string key for a dataset (it does for an association) . See Taliesin's comment below. Personally I think the help is a bit misleading referring to SQL joins with associations when they are more like "joins" in a NOSQL database. Examples of ...


17

Here are three progressively more intrusive steps to troubleshoot Mathematica. Hold down Shift-Control (Shift-Command on Mac) while starting Mathematica, as described here. If this didn't fix the problem, move to the next step. Evaluate SystemOpen[$UserBaseDirectory]. This will reveal the directory where Mathematica keeps all its settings, packages, ...


16

In lieu of Set, the Query syntax offers various ways to update selective elements of a dataset. For example, we can change the value of the field a in the first row like this: ds[{1 -> (<| #, "a" -> 999|> &)}] or like this: ds[{1 -> Query[{"a" -> (999 &)}]}] Multiple fields can be updated simultaneously: ds[{1 -> (<| #, "...


16

An alternative to @Rahul's suggested fix: Plot3D[Sin[x+y^2],{x,-3,3},{y,-2,2}, PlotTheme->{"Classic","ClassicLights"}] The associated Lighting setting matches the one in Rahul's post: "DefaultLighting"/.(Method /.Charting`ResolvePlotTheme["ClassicLights", Plot3D]) (* {{"Ambient", RGBColor[0.312, 0.188, 0.4]}, {"Directional", RGBColor[0.8, 0, 0], ...


16

One may also call up the old navigator palette with TreeBrowse`DocsNavigatorLookup[False]


16

This is an intentional change to make PlotLegends -> "Expressions" more consistent with PlotLegends -> Automatic. Both now do not produce legends when only one line is present. What you are looking for is PlotLegends -> "AllExpressions" which has the old behavior, e.g. Plot[x, {x, 0, 1}, PlotLegends -> "AllExpressions"] More generally, ...


16

Fonts in version 10.3.1 v1031 = {"Al Bayan", "Al Nile", "Al Tarikh", "American Typewriter", "Andale Mono", "Apple Braille", "Apple Chancery", "Apple Color Emoji", "AppleGothic", "AppleMyungjo", "Apple SD Gothic Neo", "Apple Symbols", "Arial", "Arial Black", "Arial Hebrew", "Arial Hebrew Scholar", "Arial Narrow", "Arial Rounded MT Bold", "...


Only top voted, non community-wiki answers of a minimum length are eligible