text stringlengths 0 828 |
|---|
while i >= 0: |
if not np.isnan(x[i]): |
return i |
i -= 1 |
return -1" |
4226,"def census(self, *scales): |
""""""Current World Census data. |
By default returns data on today's featured World Census |
scale, use arguments to get results on specific scales. In |
order to request data on all scales at once you can do |
``x.census(*range(81))``. |
Parameters |
---------- |
scales : int |
World Census scales, integers between 0 and 85 inclusive. |
Returns |
------- |
an :class:`ApiQuery` of a list of :class:`CensusScaleCurrent` |
"""""" |
params = {'mode': 'score+rank+rrank+prank+prrank'} |
if scales: |
params['scale'] = '+'.join(str(x) for x in scales) |
@api_query('census', **params) |
async def result(_, root): |
return [ |
CensusScaleCurrent(scale_elem) |
for scale_elem in root.find('CENSUS') |
] |
return result(self)" |
4227,"def censushistory(self, *scales): |
""""""Historical World Census data. |
Was split into its own method for the sake of simplicity. |
By default returns data on today's featured World Census |
scale, use arguments to get results on specific scales. In |
order to request data on all scales at once you can do |
``x.censushistory(*range(81))``. |
Returns data for the entire length of history NationStates |
stores. There is no way to override that. |
Parameters |
---------- |
scales : int |
World Census scales, integers between 0 and 85 inclusive. |
Returns |
------- |
an :class:`ApiQuery` of a list of :class:`CensusScaleHistory` |
"""""" |
params = {'mode': 'history'} |
if scales: |
params['scale'] = '+'.join(str(x) for x in scales) |
@api_query('census', **params) |
async def result(_, root): |
return [ |
CensusScaleHistory(scale_elem) |
for scale_elem in root.find('CENSUS') |
] |
return result(self)" |
4228,"async def censusranks(self, scale): |
""""""Iterate through nations ranked on the World Census scale. |
If the ranks change while you interate over them, they may be |
inconsistent. |
Parameters |
---------- |
scale : int |
A World Census scale, an integer between 0 and 85 inclusive. |
Returns |
------- |
asynchronous iterator of :class:`CensusRank` |
"""""" |
order = count(1) |
for offset in count(1, 20): |
census_ranks = await self._get_censusranks( |
scale=scale, start=offset) |
for census_rank in census_ranks: |
assert census_rank.rank == next(order) |
yield census_rank |
if len(census_ranks) < 20: |
break" |
4229,"def loads(astring): |
""""""Decompress and deserialize string into Python object via marshal."""""" |
try: |
return marshal.loads(zlib.decompress(astring)) |
except zlib.error as e: |
raise SerializerError( |
'Cannot decompress object (""{}"")'.format(str(e)) |
) |
except Exception as e: |
# marshal module does not provide a proper Exception model |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.