Skip to content

Commit

Permalink
Release 3.0.8 (#75)
Browse files Browse the repository at this point in the history
* Set package to version 3.0.8

* Fix/forex case error (#70)

* fix case to detect the correct column when doing a currency conversion

* add list option to create currency conversion object

* pep8 update

* Fix publish

* Update changelog

---------

Co-authored-by: awsbuild <[email protected]>
Co-authored-by: Stephane Struzik <[email protected]>
  • Loading branch information
3 people authored Nov 9, 2023
1 parent 4f962fc commit 7abca19
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ jobs:
echo "run_status=${{ job.status }}" >> $GITHUB_OUTPUT
slack:
uses: OasisLMF/OasisLMF/.github/workflows/notify.yml@master
uses: OasisLMF/OasisLMF/.github/workflows/notify.yml@main
secrets: inherit
needs: release
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ODS_Tools Changelog
===================

`3.0.8`_
---------
* [#51](https://github.com/OasisLMF/ODS_Tools/pull/51) - Update CI for stable 3.0.x
* [#70](https://github.com/OasisLMF/ODS_Tools/pull/70) - Fix/forex case error
.. _`3.0.8`: https://github.com/OasisLMF/ODS_Tools/compare/3.0.7...3.0.8

`3.0.7`_
---------
* [#42](https://github.com/OasisLMF/ODS_Tools/pull/43) - ods_tools check crashes on empty location file
Expand Down
2 changes: 1 addition & 1 deletion ods_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.0.7'
__version__ = '3.0.8'

import logging

Expand Down
20 changes: 12 additions & 8 deletions ods_tools/oed/forex.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ def get_path(name):
elif currency_conversion.get("source_type") == 'parquet':
return DictBasedCurrencyRates.from_parquet(get_path('file_path'),
**currency_conversion.get("read_parameters", {}))
elif currency_conversion.get("source_type", '').lower() == 'dict':
elif currency_conversion.get("source_type", '').lower() == 'dict': # doesn't work in json as key must be single value
return DictBasedCurrencyRates(currency_conversion['currency_rates'])
elif currency_conversion.get("source_type", '').lower() == 'list': # option to write directly the rate in the json file
return DictBasedCurrencyRates.from_list(currency_conversion['currency_rates'])
else:
raise OdsException(
f"Unsupported currency_conversion source type : {currency_conversion.get('source_type')}")
Expand Down Expand Up @@ -253,21 +255,23 @@ def convert_currency(oed_df, oed_type, reporting_currency, currency_rate, oed_sc
oed_df.loc[orig_cur_rows, 'RateOfExchange'] *= rate
for field, column in field_to_column.items():
field_type = ods_fields[field.lower()].get('Back End DB Field Name', '').lower()
if (field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded',
'maxded']
or field.endswith('tiv')):

if (
field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded', 'maxded']
or field.lower().endswith('tiv')
or field in ['LayerLimit', 'LayerAttachment']):
row_filter = orig_cur_rows
elif field_type == 'ded':
column_type_name = field.replace('ded', 'dedtype')
column_type_name = field.replace('Ded', 'DedType')
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type == 'limit':
column_type_name = field.replace('limit', 'limittype')
column_type_name = field.replace('Limit', 'LimitType')
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type in ['payoutstart', 'payoutend', 'payoutlimit']:
column_type_name = 'payouttype'
column_type_name = 'PayoutType'
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type in ['triggerstart', 'triggerend']:
column_type_name = 'triggertype'
column_type_name = 'TriggerType'
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
else: # not a currency unit column we go to the next one
continue
Expand Down
12 changes: 6 additions & 6 deletions tests/test_ods_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ def test_relative_and_absolute_path(self):
with tempfile.TemporaryDirectory() as tmp_dir:
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()
with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10Currency.csv') as response,\
with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10Currency.csv') as response, \
open(pathlib.Path(tmp_dir, 'SourceLocOEDPiWind10Currency.csv'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)
with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response,\
with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response, \
open(pathlib.Path(abs_dir, 'SourceAccOEDPiWind.csv'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down Expand Up @@ -402,7 +402,7 @@ def test_setting_schema_analysis__is_valid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand All @@ -424,7 +424,7 @@ def test_setting_schema_analysis__is_invalid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down Expand Up @@ -454,7 +454,7 @@ def test_setting_schema_model__is_valid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand All @@ -476,7 +476,7 @@ def test_setting_schema_model__is_invalid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down

0 comments on commit 7abca19

Please sign in to comment.