Skip to content

Commit

Permalink
bumped to 0.9.4
Browse files Browse the repository at this point in the history
can read probability distribution from file for uni2many
  • Loading branch information
cosminbasca committed Apr 24, 2015
1 parent 7c5d845 commit 0a40d6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rdftools/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
#
__author__ = 'basca'

version = (0, 9, 3)
version = (0, 9, 4)
str_version = '.'.join([str(v) for v in version])
15 changes: 12 additions & 3 deletions rdftools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -22,6 +22,7 @@
from rdftools.datagen import LubmUni2One, LubmHorizontal, LubmSeedPropagation, LubmUni2Many, DISTRIBUTIONS, \
LubmGenerator
from rdftools.log import logger
import numpy as np

__author__ = 'basca'

Expand Down Expand Up @@ -79,7 +80,8 @@ def genlubmdistro():
parser.add_argument('--ontology', dest='ontology', action='store', type=str, default=None,
help='the lubm ontology')
parser.add_argument('--pdist', dest='pdist', action='store', type=str, default=None,
help='the probabilities used for the uni2many distribution, valid choices are %s ' % DISTRIBUTIONS.keys())
help='the probabilities used for the uni2many distribution, valid choices are {0} or file '
'with probabilities split by line'.format(DISTRIBUTIONS.keys()))
parser.add_argument('--sites', dest='sites', action='store', type=long, default=1,
help='the number of sites')
parser.add_argument('--clean', dest='clean', action='store_true',
Expand All @@ -98,8 +100,15 @@ def genlubmdistro():
_DistributionClass = Distros[args.distro]
if not issubclass(_DistributionClass, LubmGenerator):
raise ValueError('_DistributionClass must be a LubmGenerator')
pdist = DISTRIBUTIONS.get(args.pdist, None)
if not pdist:
try:
with open(args.dist, 'r+') as PDIST_FILE:
pdist = np.array(map(float, PDIST_FILE.readlines()))
except Exception:
logger.error('failed to read distribution from {0}'.format(args.dist))
distro = _DistributionClass(args.output, args.sites, universities=args.univ, index=args.index, clean=args.clean,
workers=args.workers, pdist=DISTRIBUTIONS.get(args.pdist, None))
workers=args.workers, pdist=pdist)
logger.info('run distribution process')
distro()
logger.info('done')
Expand Down

0 comments on commit 0a40d6e

Please sign in to comment.