-
Notifications
You must be signed in to change notification settings - Fork 5
Collection of small fixes and perf. improvements #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| yTicks = ticks1D plotH (yNumTicks cfg) (ymin, ymax) True | ||
| baseLbl = List.replicate plotH pad | ||
|
|
||
| setAt :: [Text] -> Int -> Text -> [Text] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a big deal, but this impl. is less efficient than it could be, because it traverses the input list multiple times:
- length traverses the spine of the list to determine the length
- take, drop and the two calls to
<>repeatedly traverse the initial segment of lengthiof the list to do their job.
So I'm just adding custom recursive function that only traverses the initial segment of length i once.
It DOES change semantics a bit compared to the first implementation of setAt
setAt row i v = take i row <> [v] <> drop (i + 1) row
which "inserts v in all cases" (even if the index is out of bounds of list indices) - which was probably not the indented behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Not the intended behaviour.
| , ("Class D", [65, 70, 72, 68, 75, 80, 73, 71, 69, 74, 77, 76]) | ||
| ] | ||
| defPlot{plotTitle = "Test Score Distribution by Class"} | ||
| defPlot{plotTitle = "Test Score Distribution by Class", xNumTicks = 4} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only showing the default 3 x labels, which makes one of the labels not appear and makes the demo look broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still having trouble with grid axes in general. Was thinking to rewrite parts of this when I get time.
| maximum' [] = 1 | ||
| maximum' xs = maximum xs | ||
|
|
||
| safeHead :: [a] -> Maybe a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced this with equivalent function listToMaybe from base.
|
|
||
| grid8 = setGridChar grid7 xMid minRow '┬' (Just col) | ||
| grid9 = setGridChar grid8 xMid maxRow '┴' (Just col) | ||
| grid8 = setGridChar grid7 xMid minRow '┴' (Just col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These chars were upside down (max should use ┬, min should use ┴)
| , ("Class D", [65, 70, 72, 68, 75, 80, 73, 71, 69, 74, 77, 76]) | ||
| ] | ||
| defPlot{plotTitle = "Test Score Distribution by Class"} | ||
| defPlot{plotTitle = "Test Score Distribution by Class", xNumTicks = 4} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I don't like the box plots. They are still here more as a gimmick.
| ( \acc (row, v) -> | ||
| setAt acc row (justifyRight left (yFormatter cfg (yEnv row) ySlot v)) | ||
| setAt acc row | ||
| . ellipsisize left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thus should be documented somewhere in the haddock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will mention it in the next PR.
| cy = yDot `div` 4 | ||
| rx = xDot - 2 * cx | ||
| ry = yDot - 4 * cy | ||
| let (cx, rx) = xDot `divMod` 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change.
| ( \acc (row, v) -> | ||
| setAt acc row (justifyRight left (yFormatter cfg (yEnv row) ySlot v)) | ||
| setAt acc row | ||
| . ellipsisize left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thus should be documented somewhere in the haddock.
| yTicks = ticks1D plotH (yNumTicks cfg) (ymin, ymax) True | ||
| baseLbl = List.replicate plotH pad | ||
|
|
||
| setAt :: [Text] -> Int -> Text -> [Text] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Not the intended behaviour.
No description provided.