Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample_distribution_collection index bugfix (2.3.55 release) #553

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ To understand how to use PHOEBE, please consult the [tutorials, scripts and manu
CHANGELOG
----------

### 2.3.55 - sample_distribution_collection index bugfix

* fixes handling distributions on array parameters within sample_distribution_collection and run_compute(sample_from).

### 2.3.54 - distribution bugfix

* updates `distl` to convert units with recent changes to astropy. See also the changes in 2.3.51 and 2.3.52.
Expand Down
2 changes: 1 addition & 1 deletion phoebe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""

__version__ = '2.3.54'
__version__ = '2.3.55'

import os as _os
import sys as _sys
Expand Down
8 changes: 7 additions & 1 deletion phoebe/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from phoebe.parameters import dataset as _dataset
from phoebe.parameters import StringParameter, DictParameter, ArrayParameter, ParameterSet
from phoebe.parameters.parameters import _extract_index_from_string
from phoebe import dynamics
from phoebe.backend import universe, etvs, horizon_analytic
from phoebe.atmospheres import passbands
Expand Down Expand Up @@ -633,15 +634,20 @@ def _call_run_single_model(args):
while True:
# print("trying with samples={}".format(samples))
for uniqueid, value in samples.items():
uniqueid, index = _extract_index_from_string(uniqueid)

# TODO: for some reason when redrawing we're getting arrays with length
# one as if we had passed N=1 to sample_distribution_collection. For now, we'll
# just work around the issue.
if isinstance(value, np.ndarray):
value = value[0]
# print("setting uniqueid={}, value={}".format(uniqueid, value))
ref_param = b.get_parameter(uniqueid=uniqueid, **_skip_filter_checks)
try:
b.set_value(uniqueid=uniqueid, value=value, **_skip_filter_checks)
if index is None:
ref_param.set_value(value, unit=unit)
else:
ref_param.set_index_value(index, value, unit=unit)
except Exception as err:
if expose_samples:
msg = _simplify_error_message(err)
Expand Down
15 changes: 12 additions & 3 deletions phoebe/frontend/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8112,16 +8112,25 @@ def sample_distribution_collection(self, twig=None, sample_size=None,
ret = {}
changed_params = []
for sampled_value, uniqueid, unit in zip(sampled_values, uniqueids, [dist.unit for dist in dc.dists]):
uniqueid, index = _extract_index_from_string(uniqueid)
ref_param = self.get_parameter(uniqueid=uniqueid, **_skip_filter_checks)

if set_value:
ref_param.set_value(sampled_value, unit=unit)
if index is None:
ref_param.set_value(sampled_value, unit=unit)
else:
ref_param.set_index_value(index, sampled_value, unit=unit)

changed_params.append(ref_param)
else:
k = getattr(ref_param, keys)
if index is not None:
k += '[{}]'.format(index)
if as_quantity:
ret[getattr(ref_param, keys)] = sampled_value * unit
# this is the actual problem
ret[k] = sampled_value * unit
else:
ret[getattr(ref_param, keys)] = (sampled_value * unit).to(ref_param.default_unit).value
ret[k] = (sampled_value * unit).to(ref_param.default_unit).value


if set_value:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def _env_variable_bool(key, default):
long_description = "\n".join(long_description_s[long_description_s.index("INTRODUCTION"):])

setup (name = 'phoebe',
version = '2.3.54',
description = 'PHOEBE 2.3.54',
version = '2.3.55',
description = 'PHOEBE 2.3.55',
long_description=long_description,
author = 'PHOEBE development team',
author_email = 'phoebe-devel@lists.sourceforge.net',
Expand All @@ -367,7 +367,7 @@ def _env_variable_bool(key, default):
'Programming Language :: Python :: 3 :: Only',
],
python_requires='>=3.6, <4',
download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.3.54',
download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.3.55',
packages = ['phoebe', 'phoebe.parameters', 'phoebe.parameters.solver', 'phoebe.parameters.figure', 'phoebe.frontend', 'phoebe.constraints', 'phoebe.dynamics', 'phoebe.distortions', 'phoebe.algorithms', 'phoebe.atmospheres', 'phoebe.backend', 'phoebe.solverbackends', 'phoebe.solverbackends.ebai', 'phoebe.utils', 'phoebe.helpers', 'phoebe.pool', 'phoebe.dependencies', 'phoebe.dependencies.autofig', 'phoebe.dependencies.nparray', 'phoebe.dependencies.distl', 'phoebe.dependencies.unitsiau2015'],
install_requires=['numpy>=1.12','scipy>=1.2','astropy>=1.0', 'corner', 'pytest', 'requests', 'python-socketio[client]']+['flask', 'flask-cors', 'flask-socketio==4.3.*', 'gevent-websocket'],
package_data={'phoebe.atmospheres':['tables/wd/*', 'tables/passbands/*'],
Expand Down