Skip to content

Commit

Permalink
Merge pull request #202 from PowerGridModel/feature/more-code-sonar
Browse files Browse the repository at this point in the history
Feature/more code sonar
  • Loading branch information
petersalemink95 authored Oct 10, 2023
2 parents d3b97cb + 88b52c1 commit 01f3ba0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <dynam
SPDX-License-Identifier: MPL-2.0
-->

[![PyPI version](https://badge.fury.io/py/power-grid-model-io.svg)](https://badge.fury.io/py/power-grid-model-io)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/power-grid-model-io/badges/version.svg)](https://anaconda.org/conda-forge/power-grid-model-io)
[![PyPI version](https://badge.fury.io/py/power-grid-model-io.svg?no-cache)](https://badge.fury.io/py/power-grid-model-io)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/power-grid-model-io/badges/version.svg?no-cache)](https://anaconda.org/conda-forge/power-grid-model-io)
[![License: MIT](https://img.shields.io/badge/License-MPL2.0-informational.svg)](https://github.com/PowerGridModel/power-grid-model-io/blob/main/LICENSE)
[![Build and Test Python](https://github.com/PowerGridModel/power-grid-model-io/actions/workflows/build-test-and-sonar.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model-io/actions/workflows/build-test-and-sonar.yml)
[![Check Code Quality](https://github.com/PowerGridModel/power-grid-model-io/actions/workflows/check-code-quality.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model-io/actions/workflows/check-code-quality.yml)
Expand Down
3 changes: 2 additions & 1 deletion src/power_grid_model_io/mappings/unit_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from numbers import Number
from typing import Dict, Optional, Set, Tuple

import numpy as np
import structlog

# si-unit unit factor
Expand Down Expand Up @@ -58,7 +59,7 @@ def set_mapping(self, mapping: Units):
)
self._mapping[unit] = (multiplier, si_unit)
if unit == si_unit:
if multiplier != 1.0:
if not np.isclose(multiplier, 1.0, rtol=1.0e-9, atol=0.0):
raise ValueError(
f"Invalid unit definition for '{unit}': 1{unit} cannot be {multiplier}{si_unit}"
)
Expand Down
5 changes: 2 additions & 3 deletions src/power_grid_model_io/utils/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def extract(src_file_path: Path, dst_dir_path: Optional[Path] = None, skip_if_ex

log = _log.bind(src_file_path=src_file_path, dst_dir_path=dst_dir_path)

if dst_dir_path.exists():
if not dst_dir_path.is_dir():
raise NotADirectoryError(f"Destination dir {dst_dir_path} exists and is not a directory")
if dst_dir_path.exists() and not dst_dir_path.is_dir():
raise NotADirectoryError(f"Destination dir {dst_dir_path} exists and is not a directory")

# Create the destination directory
dst_dir_path.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 01f3ba0

Please sign in to comment.