Skip to content

Commit

Permalink
#106 add markdown support for decription + add example page (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonatai committed Jan 5, 2024
1 parent 2dd19d6 commit a63939a
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import gswJitpack from './pages/GettingStarted/GettingStartedWithJitpack.md';
import { NeuralNetworksQuickstart } from './pages/GettingStarted/NeuralNetworksQuickstart/NeuralNetworksQuickstart';
import { Home } from './pages/Home/Home';
import { useGetSummary } from './Hooks';
import { LoadingSpinner, MainNav, MarkdownPage, Message } from './components';
import {
CustomPage,
LoadingSpinner,
MainNav,
MarkdownPage,
MarkdownRenderer,
Message,
} from './components';
import example from './pages/example.json';

export const App = (): JSX.Element => {
const { data: summary, isLoading, isError } = useGetSummary();
Expand Down Expand Up @@ -77,6 +85,16 @@ export const App = (): JSX.Element => {
<MarkdownPage filePath={buildingFromSource} />
}
/>
<Route
path="/example"
element={
<CustomPage>
<MarkdownRenderer>
{example.narrative}
</MarkdownRenderer>
</CustomPage>
}
/>
</Routes>
</div>
</main>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Document/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Feature,
Layout,
LoadingSpinner,
MarkdownRenderer,
Message,
} from '../../components';
import { IDocument } from 'spock-react/pages/document-types';
Expand Down Expand Up @@ -40,7 +41,7 @@ export const Document = (props: IDocument): JSX.Element => {
</div>

<h2>Description</h2>
<pre className="whitespace-pre-line">{data.narrative}</pre>
<MarkdownRenderer>{data.narrative}</MarkdownRenderer>

<h2>Features</h2>
{data.features.map((feature, index) => (
Expand Down
119 changes: 119 additions & 0 deletions src/pages/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"className": "ut.ndim.Tensor_Permute_Spec",
"title": "Reshaping Tensors",
"narrative": "Permuting an N-dimensional array means rearranging the dimensions/axes of the N-dimensional array. \nIt produces a new tensor with the same data as the original tensor, \nbut with the specified dimensions rearranged. \n \nThis is very useful for example when you want to \nchange the order of dimensions, for example, if you have a tensor with dimensions (batch_size, channels, height, width), \nyou can use permute() to rearrange the dimensions to (batch_size, height, width, channels). \nAnother useful application of permute() is transposing a matrix. \nFor example, if you have a matrix with dimensions (rows, columns), \nyou can use permute() to rearrange the dimensions to (columns, rows). \n \nPermuting is a very cheap operation because it does not copy any data but merely \ncreates a new view on the same data with a different access pattern.",
"subjects": ["neureka.Tensor"],
"statistics": {
"runs": "2",
"successRate": "100.0%",
"failures": "0",
"errors": "0",
"skipped": "0",
"duration": "0.003 seconds"
},
"headers": [],
"tags": {},
"see": [],
"features": [
{
"id": "We can use the \"permute\" method to rearrange the dimensions of a tensor.",
"result": "PASS",
"duration": "0.002 seconds",
"iterations": {
"tags": {},
"see": [],
"extraInfo": [
"\n In Neureka `Tensor::permute(int...)` rearranges the original tensor according to the desired \n ordering and returns a new multidimensional rotated tensor. \n The size of the returned tensor remains the same as that of the original.\n "
]
},
"blocks": [
{
"kind": "given",
"text": "A tensor with a shape of [2, 4, 6, 8]",
"code": [
"Tensor t = Tensor.ofFloats().withShape(2, 4, 6, 8).andSeed(42)"
]
},

{
"kind": "expect",
"text": "By default, the tensor has a row major layout.",
"code": [
"t.NDConf.layout == NDConfiguration.Layout.ROW_MAJOR",
"t.NDConf.traits == [NDTrait.COMPACT, NDTrait.SIMPLE, NDTrait.ROW_MAJOR, NDTrait.CONTINUOUS_MATRIX]"
]
},

{
"kind": "when",
"text": "We create a new permuted tensor with the shape of [6, 4, 8, 2] and store it as `t2`.",
"code": ["var t2 = t.permute( 2, 1, 3, 0 )"]
},

{
"kind": "then",
"text": "The new tensor has the shape of [6, 4, 8, 2].",
"code": ["t2.shape == [6, 4, 8, 2]"]
},

{
"kind": "and",
"text": "A unspecific layout is assigned to the new tensor.",
"code": [
"t2.NDConf.layout == NDConfiguration.Layout.UNSPECIFIC",
"t2.NDConf.traits == [NDTrait.COMPACT, NDTrait.COL_MAJOR, NDTrait.CONTINUOUS_MATRIX]"
]
},

{
"kind": "and",
"text": "The new tensor has the same size as the original tensor, but it is not the same object.",
"code": ["t2.size == t.size", "t2 !== t"]
}
],
"problems": { "dataValues": [], "errors": [] }
},

{
"id": "When matrices are transpose, they will change their layout type as expected.",
"result": "PASS",
"duration": "0",
"iterations": {
"tags": {},
"see": [],
"extraInfo": []
},
"blocks": [
{
"kind": "given",
"text": "",
"code": [
"Tensor t = Tensor.ofFloats().withShape(3, 4).andSeed(42)"
]
},

{
"kind": "expect",
"text": "",
"code": [
"t.NDConf.layout == NDConfiguration.Layout.ROW_MAJOR",
"t.NDConf.traits == [NDTrait.COMPACT, NDTrait.SIMPLE, NDTrait.ROW_MAJOR, NDTrait.CONTINUOUS_MATRIX]"
]
},

{ "kind": "when", "text": "", "code": ["t = t.T"] },

{
"kind": "then",
"text": "",
"code": [
"t.NDConf.layout == NDConfiguration.Layout.COLUMN_MAJOR",
"t.NDConf.traits == [NDTrait.COMPACT, NDTrait.COL_MAJOR, NDTrait.CONTINUOUS_MATRIX]"
]
}
],
"problems": { "dataValues": [], "errors": [] }
}
],
"generator": "https://github.com/renatoathaydes/spock-reports"
}

0 comments on commit a63939a

Please sign in to comment.