Skip to content

Commit

Permalink
Merge pull request #32 from EzequielPuerta/31-filter-nan-values-from-…
Browse files Browse the repository at this point in the history
…global-min-and-max

🐛 Filter nan values from global min and max
  • Loading branch information
EzequielPuerta committed Jun 30, 2024
2 parents c235511 + cae7b9a commit 8fd3313
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ jobs:
command: |
export GITHUB_HOSTNAME="github.com"
set -- "$@" --notes-file "./CHANGELOG.md"
set -- "$@" --title "simulab v0.0.15"
set -- "$@" --title "simulab v0.0.16"
set -- "$@" --repo "$(git config --get remote.origin.url)"
gh release create "0.0.15" "$@"
gh release create "0.0.16" "$@"
workflows:
build_test_publish:
jobs:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.0.16] - 2024-06-30

### Fixed

Filter Nan values from global min and max

## [0.0.15] - 2024-06-29

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "simulab"
version = "0.0.15"
version = "0.0.16"
description = "Simple simulation framework, created during a course of the Discrete Events Simulation Laboratory, from the University of Buenos Aires (https://modsimu.exp.dc.uba.ar/sed/)"
authors = ["Armando Ezequiel Puerta <armando.ezequiel.puerta@gmail.com>"]
license = "MIT License"
Expand Down
16 changes: 11 additions & 5 deletions simulab/simulation/plotters/animated_lattice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any, Dict, List, Tuple

import numpy as np
import plotly.graph_objs as go

from simulab.simulation.core.runner import Runner
Expand Down Expand Up @@ -159,9 +160,14 @@ def heatmap(

@classmethod
def calculate_global_min_max(cls, series: List[List[List[float]]]) -> Tuple[float, float]:
_min = _max = 0.0
iterations = [sum(lattice, []) for lattice in series]
maxs_mins = [(min(iteration), max(iteration)) for iteration in iterations]
_min = min(map(lambda each: each[0], maxs_mins))
_max = max(map(lambda each: each[1], maxs_mins))
current_min = current_max = 0.0
for iteration in series:
lattice = sum(iteration, [])
try:
_min = np.nanmin(lattice)
_max = np.nanmax(lattice)
current_min = min(current_min, _min)
current_max = max(current_max, _max)
except RuntimeWarning:
pass
return _min, _max
18 changes: 10 additions & 8 deletions simulab/simulation/plotters/categorical_animated_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ def frame_args(cls, duration: int) -> Dict[str, Any]:
def calculate_global_min_max(
cls, series: List[List[List[Tuple[float, int]]]]
) -> Tuple[float, float]:
_min = _max = 0.0
iterations = [sum(lattice, []) for lattice in series]
maxs_mins = [
(min(map(lambda x: x[0], iteration)), max(map(lambda x: x[0], iteration)))
for iteration in iterations
]
_min = min(map(lambda each: each[0], maxs_mins))
_max = max(map(lambda each: each[1], maxs_mins))
current_min = current_max = 0.0
for iteration in series:
lattice = [cell[0] for cell in sum(iteration, [])]
try:
_min = np.nanmin(lattice)
_max = np.nanmax(lattice)
current_min = min(current_min, _min)
current_max = max(current_max, _max)
except RuntimeWarning:
pass
return _min, _max

0 comments on commit 8fd3313

Please sign in to comment.