[ANN] PrettyPrint.jl: handy and extensible pretty print, also simple

I’m now developing a parser generator library and I’ve found debugging extremely disturbing for the lack of nested datatypes’ pretty print, which motivates me to create a pretty print library.

using PrettyPrint

struct S1
    i :: Int
    f :: Float64
end

struct S2
    s  :: Vector{String}
    s1 :: S1
end

data = S2(
    ["114514", "as we can"],
    S1(42, 9.96)
)
pprint(data) # or print(pformat(data))

=>

S2(
  s=[
    "114514",
    "as we cam",
  ],
  s1=S1(
    i=42,
    f=9.96,
  ),
)

Extension is simple, too…

using PrettyPrint
struct Account
    username :: String
    password :: String
end

@info :before_extension
pprint(
        [Account("van", "gd"), Account("thautwarm", "996icu")]
)
println()
PrettyPrint.pprint_impl(io, account::Account, indent::Int, newline::Bool) = print(io, "Account($(account.username))")

@info :after_extension
pprint(
        [Account("van", "gd"), Account("thautwarm", "996icu")]
)
println()

=>

[ Info: before_extension
[
  Account(
    username="van",
    password="gd",
  ),
  Account(
    username="thautwarm",
    password="996icu",
  ),
]
[ Info: after_extension
[
  Account(van),
  Account(thautwarm),
]
7 Likes

Omg, I’ve just found a package called PrettyPrinting.jl a

4 Likes

Okay, mine is simpler, within fewer features.

Unrelated to pretty printing, I’m interested in your RBNF package, can I find more info about it apart from in the code about what you’re trying to do and, for instance, how it compares to PEG packages like PEG.jl or the older PEGParser.jl or Parsimonious.jl or ParserCombinator (I imagine there may be more such packages too).

Sorry if they’re completely different, I don’t know a lot about parsers, but I’d love to know more about the differences and use-cases. Thanks!

3 Likes

Congratulations on tackling this hard problem. Having pretty printed structures is really important for the development and documentation of works. I’m sure the Julia ecosystem would be very well served with various options to how this problem could be approached. Furthermore, there is always the matter of aesthetics – to each person, some ways just appeal more than others.

PrettyPrinting.jl is based upon the algorithm described by Phillip M. Yelland’s A New Approach to Optimal Code Formatting. I believe the algorithm minimizes ugliness across two dimensions. You can define options for how your custom types could be shown vertically and horizontally, then the core algorithm can pick/choose those options based upon how instances of that type would fit into a broader composition.The hard part is finding an algorithm and implementation that is complex enough to handle the common challenges, but has a simple user interface with the minimum necessary code that it could be maintained and understood.

Kyrylo Simonov wrote Pretty Printing to support our work on DataKnots.jl. We needed to show complex query plans that were optimized to the size of the screen. Probably it won’t scale to very large outputs, but it’s a very nice algorithm for reformatting code, such as the popular gofmt or rfmt. We’ve also found the approach to not support beautifully formatted tables, and have had to write our own code for that. That said, Pretty Printing is especially useful in documentation style test suites, such as NarrativeTest.jl, which we use for DataKnot’s documentation. Readable, informative, and succinct documentation is the cornerstone of accessible open source projects.

Anyway, if you’re looking to help explain, document, provide test cases, and otherwise improve the implementation of pretty printing approaches, you’d be very welcome to contribute to PrettyPrinting. Some of the most important work in an open source project isn’t the initial bootstrap, it’s the ongoing explanations, assistance, documentation, showcases, testing, and what not. Given that you’ve already implemented something similar, this puts you in an even more beloved position as far as other collaborators are concerned. Pretty Printing was written of necessity, could use much more refinement, and is under the MIT Expat license for everyone to enjoy, use, extend, etc. Good luck and have fun!

3 Likes

Pay attention that as we can in the code became as we cam after printing (Both in the opening post and on the GitHub page).

Have you looked at PrettyTables.jl?

2 Likes

Yes, in original post I made this mistake. I think I’ve fixed this and it’s a meme(

Hi. I’ve been in awe of PrettyTables.jl. In fact, being able to use this and import/export to CSV and DataFrame is what prompted me to add support for Tables.jl. When exporting tabular data after a query, having a beautiful format is delicious.

Sadly, our knot structure isn’t really table, it’s a tree (and soon to be a directed graph). So, we pretty much had to write custom layout code. To get an idea of the kinds of outputs we need, you could scan our tutorial – it’s mostly tabular, except when it isn’t: some outputs there are trees that are flattened with undocumented conventions using ; and ,. The eventual visualization in a notebook would be dynamic using HTML, since any tree would necessarily have to be projected as a series of nested tables reflecting particular cross-section of the output.

Perhaps we could have some shared code to visualize trees? The cases include: simple scalars, a singular tuple (not a vector), a vector of scalars, an actual table, and then, nested versions of the above where any cell could be one of those. We have called the projection of a tree onto a set of nested tables a “focus”, since you necessarily have to go down one path or the output would be misleading (ie, parallel, nested tables really confuse users, they see unintended correlations).

2 Likes

Hi, RBNF is invented on my own, which is similar to EBNF but not the same though. I created this to address the complexity of taking advantage of ASTs(abstract syntax trees) that’re given by the generated parser.
I mean what the parser generated by RBNF can produce reasonable and easy-to-use data structures, for instance, following rule defines a grammar for parsing syntaxes like let a = 1 in a + 1, and the parsing output is simply a Let(bind=..., value=..., body=..) instead of a S-Expr/CST like ['let', someIdentifierNode, '=', someExprNode, 'in', someExprNode].

Let := 'let' bind=Identifier '=' value=Expr 'in'  body=Expr 

Also, many other handy features are provided by RBNF, say, auto-generated lexers, you can see in the README I didn’t write lexers like that in YACC/Antlr.

Another I’d say is the context sensitive part, however in RBNF.jl it’s not implemented, but you can check https://github.com/thautwarm/RBNF, which also supports arbitrary left recursions. My friends and I have created a python bytecode compiler written in pure python, whose parser was written in RBNF.py and has benefited from context sensitive parsing.

You might want to check a bunch of mildly context-sensitive parsers, my prospective mentor has told me that RBNF might be one of them, and I’m also planning to make RBNF my first graduate paper.

If you’re interested in this immature technique, we can discuss more about this in Slack. My real name(also Slack name) is Taine Zhao and you can contact me there!

3 Likes

Thanks for your kind words, in fact I didn’t know such a history of pretty print previously. And you’ve referred to the matter of aesthetics, which I think an interesting task to work with. Maybe we can find out a way to customize the style in module level, then the pprint could be more fantastic to each individual.

The hard part is finding an algorithm and implementation that is complex enough to handle the common challenges.

Don’t have an idea about that, but in this domain I know a pretty good practice in F# language, called StructuredFormat. However the documentations of Microsoft are always not that good(but I think in terms of only techniques they are awesome).
I appreciate your works on DataKnots.jl, in fact I do have some experience in writing query plans or SQL parsing and am capable of understanding its value and complexity.

Also, the NarrativeTest.jl is funny, I like it! I think it does help the tests that’re not elaborate enough.

However, I don’t think PrettyPrinting.jl needs more iterations, it has a theoretic basis and has been used for many existing packages. A funny story is, in my local dev, I used to find PrettyPrinting.jl, but at that time I thought I might name my project incorrectly or use PkgTemplates.jl incorrectly, and I didn’t notice that it’s an existing pretty print package! Before I made PrettyPrint.jl I did search in Google about Julia pretty print but, unfortunately, got nothing(only this extremely outdated package: GitHub - samuelcolvin/PrettyPrint.jl: Pretty (ish) debug printing in Julia). If I found there was already PrettyPrinting.jl, I wouldn’t write PrettyPrint.jl.

1 Like

Old thread, I know. But…

I’m trying to find a reasonable way to show measures from MeasureTheory.jl. Two things I think are very important for this are

  • respecting the :compact flag for an IOContext, and
  • allowing a shortening for large arrays.

For example, my startup.jl looks like

atreplinit() do repl
    repl.options.iocontext[:compact] = true
end

So if I make my terminal very short, I can do

julia> rand(20)
20-element Vector{Float64}:
 0.39726
 0.589849
 0.510504
 0.284319
 0.492201
 0.650665
 0.221231
 ⋮
 0.246441
 0.196471
 0.597237
 0.644236
 0.00687201
 0.943697
 0.635658

But using either library discussed here gives

julia> PrettyPrinting.pprint(IOContext(stdout, :compact => true), rand(20))
[0.32307854009810344,
 0.8180342735047795,
 0.24053843715098866,
 0.7954847901467246,
 0.408633820988373,
 0.9419103964185102,
 0.2199964639998675,
 0.5985804609859589,
 0.8055478352343198,
 0.5335080085928902,
 0.22736633059914857,
 0.690141812566719,
 0.2177112390846131,
 0.30775030265864234,
 0.9558744099238402,
 0.18454127438050905,
 0.15231914189412776,
 0.8026990207796599,
 0.10890089602674324,
 0.15042071127179657]

or

julia> PrettyPrint.pprint(IOContext(stdout, :compact => true), rand(20))
[0.14419550871090703, 0.1639364642877562, 
 0.8547105936220037, 0.2867877012253467, 
 0.6745637959310754, 0.07727865780375598, 
 0.7520478475115538, 0.11869915866086267, 
 0.7266109271216247, 0.6988895619747022, 
 0.9477890785831848, 0.19691575460579436, 
 0.4019600678484212, 0.08276266617169015, 
 0.9612818160245404, 0.5183327389345974, 
 0.06252665445609296, 0.30758211069951, 
 0.10493280945369554, 0.0459585958019576]

Neither of these seem to know about the :compact flag or the size of the terminal window (PrettyPrint fits it on the screen, but has the same problem if the array is a bit larger).

It seems difficult to fix this in a composable way. I could add my own functions and call those, but once passed back to the library, control flow would never return to me (when it gets to an array within some structure). I could overload the default methods, but this is type piracy and would impact calls unrelated to MeasureTheory.

I had started with Base.show, but I found it awkward to track line width and indentation, so I had hoped a pretty-printing library might automate this for me. PrettyPrinting.jl seems very nice, but this point is giving me some trouble. And I’ve really enjoyed other libraries from @thautwarm, but given

I wasn’t sure about the future for PrettyPrint.jl.

Any suggestions?

Let me make sure I understand your requirement…

Did you say that you want pprint to aware the compact flag?

Or you need a safe approach(no type piracy), to customize pretty printing data whose type is not defined by you?

If it’s the first one, it’s possible to implement in PrettyPrint.jl. However, if you go for extensibility, for instance, adding safe extensions to types from external packages, the current architecture of PrettyPrint.jl is quite restricted…

I’d like to avoid customizing pretty printing methods for external data types, since there are just too many possibilities. Awareness of the compact flag would help a lot, but also something like the use of .

I had thought this was a Base.show thing, but none of

  • print((randn(100), randn(1000,1000)))
  • show((randn(100), randn(1000,1000)))
  • repr((randn(100), randn(1000,1000)))

are quite right. The one that seems to get closest is

julia> display((randn(100), randn(1000,1000)))
([-0.5896, 0.879209, -0.51636, -1.45705, 1.91899, 0.00938655, -0.501463, -0.396505, -0.146685, 0.629383  …  -1.54764, 0.126381, 0.942928, -0.0262769, -0.213129, 0.668584, -1.09409, -0.146487, -0.0754235, 0.333168], [-0.644568 -0.437927 … 0.213374 0.0849475; 0.54252 0.75829 … 0.612568 0.68246; … ; 0.74551 2.26515 … -0.611506 0.855832; -0.106697 0.422603 … 0.0308461 0.316075])

So I guess what I’m asking for is updating of included methods to be more like this, or maybe even to somehow use display for types where it doesn’t know what else to do.

For reference, here’s the current PrettyPrint.pprint output for this example:

julia> pprint((randn(1000), randn(1000,1000)))
(
  [-0.2835591712611158, 0.12727995777885473, 
   0.39801878019595077, -0.07291629758618459, 
   -0.0010206100249971436, -1.029062077319191, 
   -1.2118188073340033, -0.36248982002724117, 
   -1.0042175010112595, 0.012423800180834044, 
   -1.391071844487439, -0.43779614756853685, 
   1.635979349910138, 0.47913546364770626, 
   0.08697590644883518, -0.34521078526962407, 
   0.41002757383935445, -0.20670558838650227, 
   0.7656470694167938, 0.0505339121633677, 
   1.5201872227403677, 0.6534103799440735, 
   1.838380176810856, -2.2732940195249935, 
   0.7937817745638421, 0.3486700030211566, 
   0.6485538042616453, 1.5206756005779858, 
   -0.024647611937435608, 0.7346168761633698, 
   -0.4091740451812887, -0.6756679445283595, 
   0.4309851322943118, -0.5238540898205972, 
   0.2395110972295308, 0.3484365150391934, 
   0.6777896308028416, 0.11156583004710398, 
   0.1514309152439625, 1.0665422988987916, 
   0.984302447322285, -0.4750341755571866, 
   -1.2403951973063492, 0.36464000387428713, 
   0.0819430588092133, -1.2691118798977172, 
   0.8291608241281083, -0.4323698424962986, 
   0.736656338745749, -0.749481435460557, 
   -0.44749396743902436, -1.8373782205768412, 
   0.36116934071502355, -0.34407997835989185, 
   -1.4839699843393115, -0.9161633966150454, 
   -0.1180487650492344, -0.8763098571316097, 
   0.5194104536180217, -0.11283529813022403, 
   -0.999626998187551, 0.11996425065721937, 
   -0.5558418985794716, -0.7678837213800069, 
   -0.34260840118932895, 0.30747693978396146, 
   2.649478726962324, -1.3771845508056535, 
   -0.32846708171499905, -0.9301157900590415, 
   1.001157465337223, 0.8051962127291438, 
   -1.8984641905439594, -0.4679249169336358, 
   0.41341639811200553, 1.658413758329991, 
   -0.38298021874261584, -1.983836526416969, 
   -0.3287539793288017, -0.8872206688611676, 
   1.13892846802272, 0.9827525836540862, 
   0.7729905101823373, 0.24202530797473762, 
   -1.192695900083, -0.7573001828560425, 
   0.5875820500493651, -1.3729506229924633, 
   1.0657249041207582, -0.8766345134656627, 
   -0.5413707935188865, 0.41956387404672874, 
   0.2626261567413599, -0.12194616177985489, 
   2.3380046878739424, -0.9577203056117204, 
   -1.4893552976006847, -0.6585813800476826, 
   0.48818645675568945, 0.8183350831929648, 
   -0.18809195366247747, 0.03096663969518405, 
   -1.1086725260749377, -1.1273921613431246, 
   -0.4946174457341025, 1.5822639485343375, 
   -0.10538137646299625, -1.8744471437058876, 
   1.1361979520578205, 0.36786112649788655, 
   -1.0712390201800241, 0.14760331960921663, 
   1.2344385100546515, -1.151479853645053, 
   1.8471603804337162, -0.2885349900314878, 
   -1.9092992088675655, 0.39609475275278094, 
   0.36493331728855116, -1.0455573553627948, 
   -0.41083572827022036, -0.18209973681906264, 
   1.185359249029531, -0.6505767777312644, 
   0.3990063044640935, 0.9685091133481237, 
   -1.3833614505380518, 0.9454041585293137, 
   1.5339842669251778, -0.03387684297426253, 
   -0.5566973333753912, 0.6902475510837401, 
   0.6237236169841354, 1.3745207977079674, 
   1.652965405313884, -0.49176572450779027, 
   -2.0474724359204504, 0.6275505345541682, 
   -0.39034959397071844, 0.6546455235633513, 
   1.1610631926877197, 1.4279392952110619, 
   0.9708412949738909, 0.8439887476151319, 
   -0.17483330134695407, 2.8619045435697834, 
   -0.5491635282552148, 0.32932213227624413, 
   0.15987014576469286, 0.06745749151813149, 
   -0.8768691515506031, 0.7557646252609261, 
   -0.35287835636366865, 2.819715468520971, 
   -1.0751887686578843, 0.29255774899218034, 
   -0.009423547118538194, 0.12010219130027232, 
   -0.538716412045549, 0.7563142556002003, 
   -1.2686232501481518, 0.8571619013397085, 
   0.4065221422536133, -1.0427467967401955, 
   -0.8339918146263067, -0.7671049925691962, 
   0.7600555735640696, 1.6528649396765036, 
   -1.4292685083793333, -0.42515638736235845, 
   -0.6375589759285252, -1.4115070587395615, 
   1.5414846018273174, -0.5507344732525604, 
   0.41351930357917793, -2.457308584982528, 
   1.4429866244087894, -0.673116009296837, 
   0.46283104022666316, 0.838082816580472, 
   1.0350349362703062, -0.615717099767367, 
   0.9391310149194528, -0.5107771413086133, 
   0.5463812350388523, -0.6639942777076282, 
   -0.37791371630049064, 0.20762205607350587, 
   0.04344127163853747, -0.06419844665791981, 
   1.9523431831469635, 0.08576738573592502, 
   -0.1498309463228711, -0.7149458660091422, 
   0.5022239671233535, -0.9249172652894891, 
   -1.1020908480214355, 1.5581949624671223, 
   -0.560970857858556, -1.85150243885124, 
   0.3708371184366769, -0.2311680618370196, 
   -0.8513960133888488, 0.9729048143538355, 
   0.3631998330538696, 0.9097199166624202, 
   1.536570390368515, 0.508281742284629, 
   0.09289425139958024, 0.5452034599069672, 
   -2.0682218460011765, 2.227072975280532, 
   -1.9315146113203248, -0.11547994097346735, 
   -0.5016165224298323, -0.32334587585750635, 
   -0.05315345430341035, 1.744498947265209, 
   -0.5676065458775216, 1.0911594454431235, 
   1.1360689152616223, 0.6990366582601554, 
   -0.4243617930717702, 1.58849193931442, 
   0.6831323314548727, 0.21755863147960844, 
   -0.4302911182325818, -1.5321035515629842, 
   -0.21052002423914887, 0.3019233240674683, 
   1.1775677757802678, 0.3038084301732157, 
   0.6991088748177879, 0.8114074961927801, 
   -0.6037289404260372, -0.9235752367589714, 
   -0.7935589157884635, -0.8572558811956094, 
   -0.14229738506109263, 1.4870916424217921, 
   -0.26233266473105604, -0.32146141455590016, 
   0.9029816608506344, -1.17699537730906, 
   -1.101443648866828, 1.5282408149750528, 
   0.4467183475644293, -1.3775989206439767, 
   0.18879193489659574, -0.49566467199790004, 
   -0.1819564570078815, 0.06807783630845597, 
   0.2391535292336196, 0.7201072589549633, 
   2.41868522776604, -1.7096170298415152, 
   -1.6175509102873813, -0.4467652507202873, 
   -0.9949755698476496, 0.04023511746053284, 
   0.7276434784163786, 0.22759559262112242, 
   2.5120332691777185, 0.3074814640286433, 
   1.8354438026935573, 0.8552250794881866, 
   -0.3408035905650194, 1.029732501066855, 
   0.723564680371271, -0.0008916677914341012, 
   0.6051094095856321, 0.4243825082270141, 
   0.517866459195283, -1.6262657522535577, 
   0.12413519247267392, -0.6189790156900493, 
   0.2956055778391092, 0.2849840760640076, 
   1.0057438402111902, -1.1373318035472033, 
   1.1240510481894852, -0.828835100189578, 
   -1.397398765391966, 1.3859950586080958, 
   0.08511060001593385, 0.748544288829754, 
   -0.5033497745821, 0.29670761231959025, 
   -1.110693944579423, 0.15090195943408746, 
   -0.6142219822737636, 0.08649232024911505, 
   -0.7753260859593671, 3.224176660369805, 
   0.2931128493036218, 0.6817852333507839, 
   0.8577434604947747, -0.49538929795642556, 
   -1.560609212918727, -1.407183505084806, 
   0.6326510262472772, 1.1255104537151925, 
   0.7333907422892197, 0.1599325259993327, 
   -0.7531850463804795, -0.9687516182113538, 
   -1.0960241219087214, 1.3629224026159266, 
   -0.06521603937174636, 0.5871904348734309, 
   -0.5029824679989898, -1.378614277252951, 
   0.6038706250108465, -0.09552054451898125, 
   -0.8183613089734135, -0.4192926250652459, 
   -1.2605278700715068, -0.36244785868696927, 
   0.25290311572729346, 0.6897614369684025, 
   -0.8791378485771651, -0.6143003069159488, 
   -0.2579302910336417, 1.3058390749829332, 
   1.339139330823693, 1.5255329673221933, 
   0.024703818935456867, 0.39675878233504214, 
   1.2960745022831084, 0.09870033903609463, 
   0.8103534597813982, -1.1725074196768566, 
   -0.11969533140727943, -2.065165676506686, 
   -0.5028602260247699, -0.618478057465817, 
   0.9396440539773685, 0.1738584644820501, 
   0.7671802973856165, 0.7191575420767194, 
   0.9854575126242153, -0.2206826902606028, 
   -0.35346756464534657, -0.08139975408788393, 
   0.7589792404926614, 0.11865966421424072, 
   -0.7685400334470663, 1.6824171039795668, 
   1.3736836942893758, -0.02758325209469404, 
   -2.2309194497896865, -0.6992317749205151, 
   0.8166472218790283, -0.6958599915081071, 
   1.0204552838310825, -0.47603229866531876, 
   0.759266102372466, 0.3118782861952914, 
   0.2111543002243299, -2.4223998425881765, 
   -0.957665201134612, 1.4485559824440994, 
   -1.3254222213569011, -1.9091312918345884, 
   -0.23687970684571247, 0.8420877490738781, 
   -0.9712440652272465, -0.81745985449041, 
   1.573842740860456, -0.6416785769080451, 
   -1.3264844630075603, -0.9006338645550165, 
   -0.18064321905503755, -0.6511124559735862, 
   0.42346061226724635, 0.018884210106221083, 
   0.549925540706957, 2.488899913553602, 
   0.843274246893059, -2.190338214445313, 
   -0.6973836978321776, -0.9185687522656034, 
   0.7344896704144187, -0.3242851820643189, 
   -0.5204287254785982, 1.4607939664119935, 
   1.4366367369210342, -0.7396201403380012, 
   -0.07340879146815608, -0.48057371908244456, 
   0.01964091673154269, -0.5094814957599668, 
   -0.7093364961234043, -0.3016586748238967, 
   0.4751280478544437, 0.8005613122386795, 
   -1.890028931519131, -0.4221217712086232, 
   0.4041345912705559, -1.6669641482539959, 
   0.820734143873921, -2.0386879584669635, 
   -0.10408146207736373, -0.6888831120002287, 
   0.08678167996851179, -1.1703866542947154, 
   0.7743902474239427, 0.638666624268331, 
   1.5249764081581465, -1.728162078201106, 
   0.7379682562060479, 0.4518466632284025, 
   0.33357271128351595, 1.2377705141444046, 
   -1.0711860503421318, -0.03462006863460388, 
   0.48264034549097834, 0.8635694446078741, 
   -0.49476810503461643, 0.7471354043044541, 
   -0.59961014262136, -2.0856254443491036, 
   2.6501826789852463, 1.683375542243304, 
   0.5796394991120148, -0.18861937842117393, 
   0.05053111591666545, -0.07169935791161475, 
   -1.4519081307715611, 0.06493299561737145, 
   -0.4689447602385458, -1.734684652914275, 
   0.7267314414444878, 0.9643857507182606, 
   -0.5449259506118329, -0.3437968801340948, 
   0.9250484455487255, -2.9923098477687065, 
   0.3104034809662107, 0.977844292674559, 
   -1.0275958252876507, 1.3838818510540072, 
   0.965584438788597, -0.3817949661801486, 
   0.6882251139966614, 0.15130202974295842, 
   0.8402884935771152, 0.2076701185320685, 
   0.9594962953205942, -1.2733022352637078, 
   -1.89757487720967, -0.9235742654165892, 
   -0.6141962872793134, -1.5131068490153563, 
   -0.3077566413746341, 1.0138368718261537, 
   1.0564269920538978, -0.012033543187100612, 
   0.44797339570372996, 0.8532153486753856, 
   -0.2763125299126477, 0.30380601059583623, 
   -0.7499070841120576, -1.1033184275475956, 
   0.3085298427769202, -0.3320547750334536, 
   1.7952451286839872, 0.9019565070180163, 
   0.005872326042458213, 0.00535173154661555, 
   0.0365202548909653, -1.8315279133033273, 
   0.028148244169514194, 0.7205548067977766, 
   -0.9554097337366644, 0.0054458799817679, 
   -0.4747803583401711, 0.9077335470085207, 
   -0.2541509438078664, -0.2665321315283594, 
   0.12970775611187269, -0.24599637130319874, 
   -0.32937896152032997, -1.2069188866621041, 
   0.6399919587410561, 0.4540044391637916, 
   -1.8668574707529633, 0.5132796610347087, 
   -2.07007293006694, 0.525433984085917, 
   1.394987405850034, 0.5128617349366463, 
   0.7386536220194361, -0.3376162502936141, 
   -0.852420393966946, 0.048025871424862, 
   1.1941750788600665, -0.9875618714754917, 
   -0.7723423085814476, -1.5602743394154097, 
   -0.9866823548854508, 0.03798854162641005, 
   -0.9034097451019034, 0.2833413752224078, 
   0.05542311525829476, 1.0166682587494165, 
   -0.3020341478022855, -1.0343351645674899, 
   -1.6102034943812424, -0.8390841126347991, 
   -0.019594244136863285, -0.3303032527872778, 
   0.052189191078848854, 0.06575538797749818, 
   -0.01802838292908464, -1.7835498618033268, 
   0.8882169601391845, 0.8881835116046237, 
   -0.5038776497618538, -0.38455102820392045, 
   0.0013060874439562876, -0.9328424195492112, 
   1.3781709666388942, 0.5023149595107732, 
   -0.7688884363917033, 0.4193350390498185, 
   0.9229084731337597, 0.0360556639934905, 
   -1.8924084811274253, -0.5896383285618203, 
   -0.15125712185358559, -0.6518281198452607, 
   -0.7963841124361021, 0.7845430384933674, 
   -1.0597395482784073, 0.2701251712316602, 
   0.043129572554326014, 0.5163747221507974, 
   -0.19042705484181466, 0.512194416679438, 
   -1.3667078808783089, 0.12368787228781623, 
   -1.3209749662417147, -0.2357505482981011, 
   -0.9082005485496366, -0.4020189982119912, 
   -0.3600742885846379, 1.9150391852402697, 
   -1.440408865653051, -0.5604701043465292, 
   -1.8993653195479505, -0.4328262231550909, 
   -0.5602162617933553, 1.2296014660575183, 
   0.11698598628201425, -1.8005212735691478, 
   1.4682224791955945, -0.6852744827480787, 
   1.7621067092640867, -0.020428393386424167, 
   0.8968270436007844, -1.44290767453441, 
   0.443888626071185, 0.07203724922068197, 
   1.4417404118235257, 1.2100183696071836, 
   1.6128152271203129, 0.8209076061433356, 
   -0.6561950877197582, 0.7103876974318002, 
   2.316389611401717, -0.4973641747833864, 
   0.6341807374037715, -1.142348329466675, 
   -1.5489049641720996, 0.9510246898038941, 
   -1.0971490243548927, 0.06359801777785226, 
   0.6763923077264675, 0.2553079127413939, 
   -1.254575421336729, 1.6464519363739607, 
   0.47471767924239205, 0.32612574663769095, 
   0.48310500295503533, -1.4294362912089649, 
   -0.7235488673243712, -0.37160169435987445, 
   0.9735295899319723, -0.14874145567614538, 
   0.5629664039621187, -0.14917847725400712, 
   0.046070051485920846, 1.2176208151034598, 
   0.09025732082737303, 0.3054721912419086, 
   0.5140616482005834, -1.034565813376988, 
   -1.3678973392995892, -0.2897669360187113, 
   0.6025880997320311, -0.8726459366674995, 
   -0.24915536647629083, 1.5480210902056637, 
   -1.349422273018605, 0.29368658363385436, 
   0.0073119986545787455, -0.34738960600219, 
   0.011099208361404921, 0.7612950011994699, 
   0.25009686155036437, 1.7132560286907517, 
   -0.5917158074542239, 1.211077496750685, 
   -0.42995346989475935, 0.14699387939205097, 
   0.8916280362956371, 0.21964800218932864, 
   -1.1054885986313119, -0.2743163392506564, 
   0.6695110549623906, -0.2965530493365125, 
   0.5000657372930974, -2.1830389586606453, 
   1.4602881310325393, 0.24175877600478016, 
   -0.41588845078207043, -1.4297464120810044, 
   0.21394136934597435, -1.6902247816394746, 
   1.4906419711906087, -0.545200004143394, 
   -0.6000039847459481, 0.8378571509824005, 
   -0.917561037777009, 1.0750783563341006, 
   0.8747611550309784, 1.1935758340281137, 
   1.426093534150089, 0.27183899968667385, 
   -0.8471434850457266, -2.7276916444169808, 
   1.4751014427580014, -0.13906831922144083, 
   -0.9996559340528302, 2.106446752211484, 
   -1.0566756648756928, -0.5011320088030048, 
   0.6265694543912962, -0.3469754881493394, 
   1.1056634022632499, 0.2598184604013764, 
   -0.5467322986419552, 2.550050233579579, 
   -1.7847775246226016, -1.146114057499958, 
   0.8545724364709912, -1.351251730416807, 
   -1.2980792711553184, -0.36548239214782874, 
   1.8459458852263562, -0.6200686781719685, 
   3.2743919468176044, 0.46548919011510764, 
   0.6123629131408135, -1.5262411626410906, 
   0.8480267112195566, -0.05264932028466183, 
   -0.15883470068722225, -0.7522429459638184, 
   0.9593836456903607, 0.1276132155671941, 
   -0.08097136395892736, -0.2252919296839628, 
   0.3886659610331345, -1.542101372029787, 
   0.3102568990602086, 0.4826567339621986, 
   0.7233761185031803, 0.799172279473472, 
   0.7514598456359222, 1.1476111016616029, 
   0.23858875064279256, 0.4305611568468757, 
   0.9366802673380878, -0.7580950756727887, 
   0.7447324876576291, -0.14386025998563406, 
   -0.12827253128302685, 1.4999924350147575, 
   1.2273073758614321, 0.33995451507192487, 
   -0.746712337903545, -0.2753689796284399, 
   0.9545414423803465, 0.4436444256939337, 
   -1.2488731249974874, 0.9779099476280688, 
   -0.18651665692650715, -0.26722309007257683, 
   1.2487930924069235, 0.21068687158272423, 
   -0.26101482950257976, -0.15714168463156145, 
   0.5863088626815105, 0.6586800273653128, 
   0.5988719888912505, -0.08775181767565732, 
   0.04350064794626186, -0.4488181364818301, 
   1.1032620213673174, 1.3323405661525907, 
   1.3119667357214275, 1.1717760141564064, 
   -0.1852968978416724, 0.07616317471522226, 
   -1.615610475752547, 1.4197031775756284, 
   0.18226737672062274, 1.7843011024322257, 
   -0.41224388525489547, -0.37611347950359386, 
   -0.18532799982495246, 0.33927960403512025, 
   -0.046464673182541646, -0.4031374328891227, 
   -0.38801083273393017, -0.06616655249623601, 
   -0.2211306523464023, -0.8060903742841837, 
   0.3212247339078938, -1.5725023718043936, 
   -0.8439552403597532, 1.4628073713882563, 
   0.8129853873031709, -0.02742178641322233, 
   0.5340142805625884, 0.9096531128025371, 
   0.5120888828261597, -0.49978194448778185, 
   0.35977746404185035, 0.9138114023035101, 
   -0.22144685802748834, 0.7522612236330997, 
   0.44237053031898066, -0.17515509154817285, 
   -0.5281719519052747, 1.046876931721963, 
   0.764556080129785, 1.6749562650646257, 
   1.744073873833259, -0.4675144424213454, 
   -0.067549928747493, 0.49033478654027673, 
   1.5864877493658025, 0.4651002369570176, 
   -0.057657232597735524, -0.634964445844008, 
   1.5623145480291412, -0.9337534755158823, 
   1.71935085695263, 1.3507552128261298, 
   0.7718316641318301, 1.8037794093644965, 
   -0.825936653114569, -1.028049162868107, 
   1.2000664277728335, -0.14637323395151597, 
   -2.259537770586388, -0.5660602792008579, 
   1.123529150430362, -0.3810665290212803, 
   0.01195817555756556, 0.6455058076152914, 
   1.1553865892193804, 1.8259408289251322, 
   -1.2688283632783286, 1.908472175748251, 
   0.46450998818615086, 1.9986880279255501, 
   -0.7279761417022761, -0.7709940627079017, 
   -0.00796338333563988, 0.8944070786531547, 
   0.21716855537883217, -1.2984555316724284, 
   0.5419109808837118, 0.3667491784341427, 
   -1.1212271998287329, 1.405227998643342, 
   -0.9132617893824738, -1.8938137055641815, 
   -0.4297506656341305, -0.6421003897567515, 
   -0.36008555818643384, 0.858221756550408, 
   0.2461864915164286, 2.1208241650537047, 
   -0.5216870063879836, 2.5975355311291035, 
   0.4899178852143263, 0.3033109435479667, 
   0.3012922495734282, 0.7010827020423775, 
   -0.2515585109477356, 0.9117610249455381, 
   -1.3273258566421209, -0.4445178832025187, 
   -0.3076942870154854, 0.017368827331339143, 
   2.4056799965493805, -0.8984862532357663, 
   -1.1970976247340102, 1.3635542351626884, 
   -0.26663186726558347, 0.6194153054989314, 
   0.15010692465526762, -0.27857122797633044, 
   0.01552009195811221, -1.9496841557192888, 
   2.2408415196910436, 1.3506071336116983, 
   -2.472790449549925, 0.5505223687987297, 
   0.5337493747150404, 0.7210951361691147, 
   -0.5650070703120768, -0.4373522690294493, 
   1.0433394601153185, -0.09363450136902525, 
   -1.037733809558648, 1.1321375979031385, 
   -0.33061303730471625, -2.039867544525365, 
   -0.902137183623926, 0.4704635085004791, 
   1.1641671181048345, -0.5247621221847278, 
   0.7470159312938492, -1.2622254130958617, 
   1.0029904999566528, 0.3294949239290314, 
   -0.6553983346920782, -0.28202751819679406, 
   -0.8870874132527073, -1.4563846605026118, 
   1.4590952514657585, -1.1108520243837705, 
   0.7665543880354899, -0.510768872958721, 
   0.375852631150856, 0.11230420152376358, 
   0.4445352063509752, 0.24323821902054715, 
   -0.8472450257500788, -0.634873789728584, 
   -0.9198403759292193, 0.752529344607158, 
   -0.005212108682150299, -1.1340529025069153, 
   1.1894767441237153, -2.278078940477562, 
   -0.0833564765016275, -0.5025293602338361, 
   0.8552694284802654, 1.4234465418714162, 
   -0.4786176314553583, 0.07752398069687433, 
   0.891399493509947, -1.0681963905869003, 
   1.8448794548410716, -0.5535988150459454, 
   0.4958416855398955, -0.9442998819733581, 
   0.493649027827312, 1.48225258328621, 
   -2.0506317136696635, -0.010068407072460737, 
   -1.0031908798674145, -0.7131121939826917, 
   -1.0029864462680491, -2.1226343844266635, 
   -1.0999033672117906, 0.9883650850527766, 
   1.6345126563811447, 0.2647314571514357, 
   0.5278822678127645, 1.0095984047967335, 
   -0.9523304668683905, 0.5717380413294999, 
   0.7439482024732975, -1.3975454825805582, 
   0.5062205939744439, -1.4141331984998176, 
   -0.9415899863002472, -0.832517312145214, 
   0.2459274313977557, -0.36564706032853106, 
   0.7184485064694376, 1.2605837152282326, 
   0.49600600505638637, 2.052045955097776, 
   -0.4917272888610034, -0.8813275843258276, 
   0.8550340268510233, 0.1345259561058899, 
   0.11504179455052495, -0.6498007456174104, 
   1.3087138057017567, 0.7659596068204626, 
   -0.46643490134468485, 1.938952141394054, 
   0.01121236493983757, -1.04267098821931, 
   0.12090521092018364, 0.23831013191948547, 
   0.04630977526136672, 1.4918861795783303, 
   0.09718950248184403, -1.3605038353009058, 
   -1.9698988075364126, 0.393187918395254, 
   -1.6368387928942294, 0.5782073767546512, 
   0.4438651781297972, 0.3665340527694612, 
   0.355369502467044, 0.7173729380618854, 
   -0.6740755245242614, 0.5572284224600311, 
   2.41679331112969, 0.03892620371386521, 
   1.5690610536156748, 1.5392588826922688, 
   1.1419621883071944, 0.9052707061237752, 
   0.9586998060922237, 0.3866167181580576, 
   -0.08354495125783248, -1.913176856815956, 
   0.48744061173658804, 4.069539639589706, 
   -1.2567383308453104, -0.613865041048225, 
   -0.18611596649380185, -1.6284103574972932, 
   -0.18746654724948106, -1.4038988396620389, 
   1.3925414979678692, -1.1364896743322601, 
   1.3779440625359032, -0.022732187417538578, 
   -0.2621605094473549, -0.9654001805019304, 
   -0.32574335521184056, 0.2882704792285216, 
   -0.12664729320831541, 0.7725584356425672, 
   -0.17126476864700443, 0.4360504720220881, 
   -0.8738285323706118, -2.9869540808991943, 
   -0.022798083970403987, -0.7762146011460135, 
   2.5839794488818635, 0.9489518770641444, 
   1.7554303689671336, 0.3308962523042306, 
   -0.3577068462507085, 0.6035751719218581, 
   -2.6921986796174324, -1.110890989572115, 
   0.3181611031586598, 0.365937598525055, 
   1.2378243539736313, 0.7668825855745635, 
   -1.2200392051565503, -0.41048300053128545, 
   -0.938288638093673, 0.7652143298880908, 
   -0.062203389518925054, 0.36835973006131567, 
   1.7908904686813751, -0.9126316394374735, 
   -0.20902352845057584, 1.7193315793755872, 
   -1.6521329417389126, -0.9975218957740191, 
   -1.205676081669881, -1.2739236596593646, 
   -0.010900532125829674, -0.6630582269021428, 
   -0.03749923018876707, -1.0868316227501784, 
   0.9526207242920165, -0.06603592552560973, 
   -0.47785384673579884, -0.1402412429846122, 
   1.736498445687587, -0.5854874411386954],
  Matrix{Float64}(),
)

Could there be a way to use some information from Base.show or Base.display to help this? I’m sorry this is vague, I’m not very familiar with the architecture of either of these packages.

Got it, it seems that you need to truncate the output in compact mode.

It’s do-able, by letting all invocations of print and println to aware the current line number and column offset…

https://github.com/thautwarm/PrettyPrint.jl/blob/4613b3f33b8565d938cd792aff923c5cc2374950/src/PrettyPrint.jl#L66 :

print(io, ",") # -> customized_print(io, ",", line=line, col=col)

I can support it by the end of Jan(currently too busy with other stuffs…).

3 Likes

End of Jan would be great! I wasn’t sure how much you’d be extending this, so I’m currently using PrettyPrinting.jl. But I’ve always been impressed with your packages, and I think switching would be pretty easy.

1 Like