Compare commits

..

7 Commits
0.3.1 ... 0.3.4

Author SHA1 Message Date
fa82caa752 chore(release): 0.3.4
All checks were successful
gitea-physics/deepdog/pipeline/tag This commit looks good
gitea-physics/deepdog/pipeline/head This commit looks good
2022-03-06 17:31:47 -06:00
0784cd53d7 feat: Changes chunksize for multiprocessing
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
2022-03-06 17:31:17 -06:00
fb4b012491 chore(release): 0.3.3
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
gitea-physics/deepdog/pipeline/tag This commit looks good
2022-03-06 17:23:15 -06:00
8617e4d274 fix: Fixes count to use cycles as well
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
2022-03-06 17:22:52 -06:00
fe2af1644e chore(release): 0.3.2
All checks were successful
gitea-physics/deepdog/pipeline/tag This commit looks good
gitea-physics/deepdog/pipeline/head This commit looks good
2022-03-06 17:18:42 -06:00
e6d8d33c27 feat: Adds monte carlo cycles to trade off space and cpu 2022-03-06 17:18:24 -06:00
e00dc95f02 docs: readme badges
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
2022-03-06 16:48:49 -06:00
4 changed files with 55 additions and 10 deletions

View File

@@ -2,6 +2,27 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.3.4](https://gitea.deepak.science:2222/physics/deepdog/compare/0.3.3...0.3.4) (2022-03-06)
### Features
* Changes chunksize for multiprocessing ([0784cd5](https://gitea.deepak.science:2222/physics/deepdog/commit/0784cd53d79e00684506604f094b5d820b3994d4))
### [0.3.3](https://gitea.deepak.science:2222/physics/deepdog/compare/0.3.2...0.3.3) (2022-03-06)
### Bug Fixes
* Fixes count to use cycles as well ([8617e4d](https://gitea.deepak.science:2222/physics/deepdog/commit/8617e4d2742b112cc824068150682ce3b2cdd879))
### [0.3.2](https://gitea.deepak.science:2222/physics/deepdog/compare/0.3.1...0.3.2) (2022-03-06)
### Features
* Adds monte carlo cycles to trade off space and cpu ([e6d8d33](https://gitea.deepak.science:2222/physics/deepdog/commit/e6d8d33c27e7922581e91c10de4f5faff2a51f8b))
### [0.3.1](https://gitea.deepak.science:2222/physics/deepdog/compare/v0.3.0...v0.3.1) (2022-03-06) ### [0.3.1](https://gitea.deepak.science:2222/physics/deepdog/compare/v0.3.0...v0.3.1) (2022-03-06)

View File

@@ -1,3 +1,18 @@
# deepdog # deepdog
The dipole diagnostic tool. [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg?style=flat-square)](https://conventionalcommits.org)
[![PyPI](https://img.shields.io/pypi/v/deepdog?style=flat-square)](https://pypi.org/project/deepdog/)
[![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fdeepdog%2Fjob%2Fmaster&style=flat-square)](https://jenkins.deepak.science/job/gitea-physics/job/deepdog/job/master/)
![Jenkins tests](https://img.shields.io/jenkins/tests?compact_message&jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fdeepdog%2Fjob%2Fmaster%2F&style=flat-square)
![Jenkins Coverage](https://img.shields.io/jenkins/coverage/cobertura?jobUrl=https%3A%2F%2Fjenkins.deepak.science%2Fjob%2Fgitea-physics%2Fjob%2Fdeepdog%2Fjob%2Fmaster%2F&style=flat-square)
![Maintenance](https://img.shields.io/maintenance/yes/2022?style=flat-square)
The DiPole DiaGnostic tool.
## Getting started
`poetry install` to start locally
Commit using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), and when commits are on master, release with `doo release`.

View File

@@ -4,13 +4,13 @@ import pdme.util.fast_v_calc
from typing import Sequence, Tuple, List from typing import Sequence, Tuple, List
import datetime import datetime
import csv import csv
import multiprocessing
import logging import logging
import numpy import numpy
# TODO: remove hardcode # TODO: remove hardcode
COST_THRESHOLD = 1e-10 CHUNKSIZE = 20
# TODO: It's garbage to have this here duplicated from pdme. # TODO: It's garbage to have this here duplicated from pdme.
DotInput = Tuple[numpy.typing.ArrayLike, float] DotInput = Tuple[numpy.typing.ArrayLike, float]
@@ -19,6 +19,13 @@ DotInput = Tuple[numpy.typing.ArrayLike, float]
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
def get_a_result(input) -> int:
discretisation, dot_inputs, lows, highs, monte_carlo_count, max_frequency = input
sample_dipoles = discretisation.get_model().get_n_single_dipoles(monte_carlo_count, max_frequency)
vals = pdme.util.fast_v_calc.fast_vs_for_dipoles(dot_inputs, sample_dipoles)
return numpy.count_nonzero(pdme.util.fast_v_calc.between(vals, lows, highs))
class AltBayesRun(): class AltBayesRun():
''' '''
A single Bayes run for a given set of dots. A single Bayes run for a given set of dots.
@@ -36,7 +43,7 @@ class AltBayesRun():
run_count: int run_count: int
The number of runs to do. The number of runs to do.
''' '''
def __init__(self, dot_inputs: Sequence[DotInput], discretisations_with_names: Sequence[Tuple[str, pdme.model.Discretisation]], actual_model: pdme.model.Model, filename_slug: str, run_count: int, low_error: float = 0.9, high_error: float = 1.1, monte_carlo_count: int = 10000, max_frequency: float = 20, end_threshold: float = None) -> None: def __init__(self, dot_inputs: Sequence[DotInput], discretisations_with_names: Sequence[Tuple[str, pdme.model.Discretisation]], actual_model: pdme.model.Model, filename_slug: str, run_count: int, low_error: float = 0.9, high_error: float = 1.1, monte_carlo_count: int = 10000, monte_carlo_cycles: int = 10, max_frequency: float = 20, end_threshold: float = None) -> None:
self.dot_inputs = dot_inputs self.dot_inputs = dot_inputs
self.dot_inputs_array = pdme.measurement.oscillating_dipole.dot_inputs_to_array(dot_inputs) self.dot_inputs_array = pdme.measurement.oscillating_dipole.dot_inputs_to_array(dot_inputs)
self.discretisations = [disc for (_, disc) in discretisations_with_names] self.discretisations = [disc for (_, disc) in discretisations_with_names]
@@ -44,6 +51,7 @@ class AltBayesRun():
self.actual_model = actual_model self.actual_model = actual_model
self.model_count = len(self.discretisations) self.model_count = len(self.discretisations)
self.monte_carlo_count = monte_carlo_count self.monte_carlo_count = monte_carlo_count
self.monte_carlo_cycles = monte_carlo_cycles
self.run_count = run_count self.run_count = run_count
self.low_error = low_error self.low_error = low_error
self.high_error = high_error self.high_error = high_error
@@ -87,9 +95,10 @@ class AltBayesRun():
_logger.debug("Going to iterate over discretisations now") _logger.debug("Going to iterate over discretisations now")
for disc_count, discretisation in enumerate(self.discretisations): for disc_count, discretisation in enumerate(self.discretisations):
_logger.debug(f"Doing discretisation #{disc_count}") _logger.debug(f"Doing discretisation #{disc_count}")
sample_dipoles = discretisation.get_model().get_n_single_dipoles(self.monte_carlo_count, self.max_frequency) with multiprocessing.Pool(multiprocessing.cpu_count() - 1 or 1) as pool:
vals = pdme.util.fast_v_calc.fast_vs_for_dipoles(self.dot_inputs_array, sample_dipoles) results.append(sum(
results.append(numpy.count_nonzero(pdme.util.fast_v_calc.between(vals, lows, highs))) pool.imap_unordered(get_a_result, [(discretisation, self.dot_inputs_array, lows, highs, self.monte_carlo_count, self.max_frequency)] * self.monte_carlo_cycles, CHUNKSIZE)
))
_logger.debug("Done, constructing output now") _logger.debug("Done, constructing output now")
row = { row = {
@@ -102,9 +111,9 @@ class AltBayesRun():
for model_index, (name, result) in enumerate(zip(self.model_names, results)): for model_index, (name, result) in enumerate(zip(self.model_names, results)):
row[f"{name}_success"] = result row[f"{name}_success"] = result
row[f"{name}_count"] = self.monte_carlo_count row[f"{name}_count"] = self.monte_carlo_count * self.monte_carlo_cycles
successes.append(max(result, 0.5)) successes.append(max(result, 0.5))
counts.append(self.monte_carlo_count) counts.append(self.monte_carlo_count * self.monte_carlo_cycles)
success_weight = sum([(succ / count) * prob for succ, count, prob in zip(successes, counts, self.probabilities)]) success_weight = sum([(succ / count) * prob for succ, count, prob in zip(successes, counts, self.probabilities)])
new_probabilities = [(succ / count) * old_prob / success_weight for succ, count, old_prob in zip(successes, counts, self.probabilities)] new_probabilities = [(succ / count) * old_prob / success_weight for succ, count, old_prob in zip(successes, counts, self.probabilities)]

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "deepdog" name = "deepdog"
version = "0.3.1" version = "0.3.4"
description = "" description = ""
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"] authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]