Skip to content

Commit

Permalink
Merge pull request #656 from silx-kit/prettier
Browse files Browse the repository at this point in the history
Upgrade Prettier and apply new formatting
  • Loading branch information
axelboc authored May 10, 2021
2 parents 107ae60 + 55b5f32 commit 220f6bb
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 54 deletions.
18 changes: 15 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-testing-library": "4.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"prettier": "^2.3.0",
"react-app-polyfill": "^2.0.0",
"react-is": "^17.0.2",
"react-scripts": "^4.0.3",
Expand Down
10 changes: 4 additions & 6 deletions src/h5web/providers/hsds/HsdsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ interface Props {
function HsdsProvider(props: Props) {
const { url, username, password, filepath, children } = props;

const api = useMemo(() => new HsdsApi(url, username, password, filepath), [
filepath,
password,
url,
username,
]);
const api = useMemo(
() => new HsdsApi(url, username, password, filepath),
[filepath, password, url, username]
);

return <Provider api={api}>{children}</Provider>;
}
Expand Down
5 changes: 2 additions & 3 deletions src/h5web/toolbar/controls/ToggleGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ interface ToggleGroupProps {
onChange: (val: string) => void;
}

const ToggleGroupContext = createContext<ToggleGroupProps | undefined>(
undefined
);
const ToggleGroupContext =
createContext<ToggleGroupProps | undefined>(undefined);

function useToggleGroupProps(): ToggleGroupProps {
const context = useContext(ToggleGroupContext);
Expand Down
56 changes: 26 additions & 30 deletions src/h5web/vis-packs/core/complex/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,32 @@ export function usePhaseAmplitude(
amplitudeArray: NdArray;
amplitudeDomain: Domain;
} {
const [
phaseArray,
phaseBounds,
amplitudeArray,
amplitudeBounds,
] = useMemo(() => {
const phaseValues: number[] = [];
const amplitudeValues: number[] = [];

const mappedValues = mappedArray.data as H5WebComplex[];
const [phaseBounds, amplitudeBounds] = mappedValues.reduce(
(acc, [real, imag]) => {
const phase = Math.atan2(imag, real);
phaseValues.push(phase);

const amplitude = Math.sqrt(real ** 2 + imag ** 2);
amplitudeValues.push(amplitude);

return [getNewBounds(acc[0], phase), getNewBounds(acc[1], amplitude)];
},
[INITIAL_BOUNDS, INITIAL_BOUNDS]
);

return [
ndarray(phaseValues, mappedArray.shape),
phaseBounds,
ndarray(amplitudeValues, mappedArray.shape),
amplitudeBounds,
];
}, [mappedArray]);
const [phaseArray, phaseBounds, amplitudeArray, amplitudeBounds] =
useMemo(() => {
const phaseValues: number[] = [];
const amplitudeValues: number[] = [];

const mappedValues = mappedArray.data as H5WebComplex[];
const [phaseBounds, amplitudeBounds] = mappedValues.reduce(
(acc, [real, imag]) => {
const phase = Math.atan2(imag, real);
phaseValues.push(phase);

const amplitude = Math.sqrt(real ** 2 + imag ** 2);
amplitudeValues.push(amplitude);

return [getNewBounds(acc[0], phase), getNewBounds(acc[1], amplitude)];
},
[INITIAL_BOUNDS, INITIAL_BOUNDS]
);

return [
ndarray(phaseValues, mappedArray.shape),
phaseBounds,
ndarray(amplitudeValues, mappedArray.shape),
amplitudeBounds,
];
}, [mappedArray]);

const [phaseDomain, amplitudeDomain] = useMemo(
() => [
Expand Down
8 changes: 4 additions & 4 deletions src/h5web/vis-packs/core/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ export function useMappedArrays(
mapping: DimensionMapping,
autoScale?: boolean
) {
const baseArrays = useMemo(() => values.map((v) => getBaseArray(v, dims)), [
dims,
values,
]);
const baseArrays = useMemo(
() => values.map((v) => getBaseArray(v, dims)),
[dims, values]
);
const mappedArrays = useMemo(
() => baseArrays.map((v) => applyMapping(v, mapping)),
[baseArrays, mapping]
Expand Down
9 changes: 2 additions & 7 deletions src/h5web/vis-packs/core/shared/VisCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ interface Props {
}

function VisCanvas(props: Props) {
const {
abscissaConfig,
ordinateConfig,
aspectRatio,
canvasTitle,
children,
} = props;
const { abscissaConfig, ordinateConfig, aspectRatio, canvasTitle, children } =
props;

const [visAreaRef, visAreaSize] = useMeasure();

Expand Down

0 comments on commit 220f6bb

Please sign in to comment.