Comments (2)
@ElliotJH Yes, this came up during testing. In fact, in the original version of the code six
wasn't being used, as any dict has itervalues
. You can do the following
tiv_elements = tuple(sorted(
[v for v in cep.itervalues() if v.get('FieldName') and v['FieldName'] == 'TIV'],
key=lambda v: v['FMTermGroupID']
))
The sort is required because the point is to extract an list of TIV elements/fields (these are dict values in cep
describing TIV elements which correspond to TIV fields, and these TIV fields describe column names in a CSV exposures file). The point is that the output of this line should be a list of TIV element dicts ordered element names, so for PiWInd the element for WSCV1VAL
should be listed before the one for WSCV4VAL
, etc.
from oasislmf.
@ElliotJH It appears I was wrong - Python 3.6 dicts don't have itervalues
, instead have values
which appear to be generators. I mainly develop in Python 2.7, and am less familiar with 3+. So the issue you pointed out is still valid. In fact the solution is as follows
tiv_elements = tuple(
sorted(
[v for v in canonical_exposures_profile.values() if v.get('FieldName') == 'TIV'],
key=lambda v: v['FMTermGroupID']
)
)
So filter
in Python 3 produces a generator not a list as in Python 2, so your solution wouldn't work.Tthe common solution is to replace the filter with a plain list, and loop over <dict>.values()
not <dict>.itervalues()
.
This will be fixed in the next release.
from oasislmf.
Related Issues (20)
- Support for AccParticipation
- Index file never used when loading vulnerability.bin
- Add an example of the vulnerability file selection to PiWind. HOT 1
- Adjust log levels separately for modules
- Customise specific vulnerabilities (without providing full replacement data)
- FM acceptance tests failing with pandas==2.2.0
- Provide documentation on existing metrics naming convention & keep publishing it ahead of time for the future metrics HOT 3
- fm test: add sc18 and sc19 to insurance_conditions
- fm test: add acc101 - acc104 to insurance_account
- OasisDataManager Refactor
- Platform API needs to check RUN_MODE to detect workflow
- Footprint_set option not working with parquet format
- Update docs/financial_terms_supported
- Policy and account validation occurs after the keys lookup stage
- RI Scope file filters HOT 4
- Occurrence file not found when requesting output from ktools component aalcalcmeanonly
- Replace `complex_lookup_config` with `analysis_settings` in Keys server
- Pandas 2.2.0 and up generates inconsistent results
- loss output at intermediate inuring priorities - new features HOT 2
- number_of_samples = 0 not working in oasislmf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oasislmf.