Comments (10)
Thanks @MaJuRG . Coincidentally, I've already rewritten get_stats:
def get_stats(self):
"""
Given a list of Delta objects, return a 'counts' dictionary keyed by
category -- i.e., the keys of the determine_delta() OrderedDict of
Delta objects -- that contains the count as a value for each category.
"""
added, modified, moved, removed, unmodified = 0, 0, 0, 0, 0
# added = len(self.deltas['added'])
# modified = len(self.deltas['modified'])
# moved = len(self.deltas['moved'])
# removed = len(self.deltas['removed'])
# unmodified = len(self.deltas['unmodified'])
added = len([i for i in self.deltas if i.category == 'added'])
modified = len([i for i in self.deltas if i.category == 'modified'])
moved = len([i for i in self.deltas if i.category == 'moved'])
removed = len([i for i in self.deltas if i.category == 'removed'])
unmodified = len([i for i in self.deltas if i.category == 'unmodified'])
from deltacode.
@MaJuRG Making my way through the flattening process. Re DeltaCode.to_dict()
, is it accurate to say that we . . .
- . . . want to convert
DeltaCode.to_dict()
so that it returns a single list ofDelta
objects instead of anOrderedDict
ofDelta
objects keyed byadded
,removed
etc.? - . . . need to change the method name to, e.g.,
DeltaCode.to_list()
? - . . . could sort by
Delta.score
inside this method before returning the list?
from deltacode.
@johnmhoran We do not care about to_dict
or to_list
.
We want to change the Deltacode.deltas field to a list of Delta objects instead of a dictionary as it currently is
from deltacode.
@MaJuRG I've already done that. My question is, what do we want to do with the current method, DeltaCode.to_dict()
?
from deltacode.
It is not needed anymore in that case. We will need to replace code paths that use the old dict structure (few, mostly output related) and all code that calls Deltacode.to_dict()
(many,mostly in tests).
from deltacode.
Thanks.
from deltacode.
@MaJuRG FYI I'm replacing tests that use DeltaCode.to_dict()
with equivalent tests where possible. For example, I've replaced test_DeltaCode_to_dict_simple_file_added() with this:
def test_DeltaCode_counts_simple_file_added(self):
new_scan = self.get_test_loc('deltacode/new_added1.json')
old_scan = self.get_test_loc('deltacode/old_added1.json')
options = OrderedDict([
('--all-delta-types', False)
])
deltacode = DeltaCode(new_scan, old_scan, options)
assert (len([d.to_dict() for d in deltacode.deltas if d.category == 'added']) +
len([d.to_dict() for d in deltacode.deltas if d.category == 'removed']) +
len([d.to_dict() for d in deltacode.deltas if d.category == 'moved']) +
len([d.to_dict() for d in deltacode.deltas if d.category == 'modified']) +
len([d.to_dict() for d in deltacode.deltas if d.category == 'unmodified'])) == 9
assert len([d.to_dict() for d in deltacode.deltas if d.category == 'added']) == 1
assert len([d.to_dict() for d in deltacode.deltas if d.category == 'removed']) == 0
assert len([d.to_dict() for d in deltacode.deltas if d.category == 'moved']) == 0
assert len([d.to_dict() for d in deltacode.deltas if d.category == 'modified']) == 0
assert len([d.to_dict() for d in deltacode.deltas if d.category == 'unmodified']) == 8
from deltacode.
@johnmhoran A better option may be to simply re-write get_stats() and use that for for the tests.
from deltacode.
to avoid massive duplications. Code of similar logic could be used in an updated get_stats()
from deltacode.
#66 Handles this. Closing.
from deltacode.
Related Issues (20)
- Add limited delta stats after running HOT 1
- Upgrade DeltaCode to Python 3 HOT 4
- Create DeltaCode documentation on ReadTheDocs HOT 6
- Linux and MacOs buid is showing some warnings in TravisCI HOT 3
- configure failed,why? HOT 10
- Adding Azure Pipelines HOT 1
- In the output content format ‘[ ’how to understand? HOT 2
- Configure failed with "file setup.py not found" HOT 11
- Azure Piplines seems to be filing for Windows Test Jobs
- Create objects to score scan information HOT 6
- Add function to handle loading 2 codebases. HOT 2
- Remove redundant Scan model HOT 1
- Remove redundant File model
- Add Dockerfile
- Separate csv formatted output in Deltacode
- Merge DeltaCode in ScanCode TK
- Update structure to use the https://github.com/nexB/skeleton
- RFC: DeltaCode next! and roadmap HOT 2
- Update documentation after deltacode gets merge in scancode-toolkit HOT 2
- License detection diffs are incorrect HOT 2
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 deltacode.