Dataset Viewer
Auto-converted to Parquet Duplicate
code
stringlengths
10
2.58M
original_code
stringlengths
3
3.18M
original_language
stringclasses
1 value
source
stringclasses
7 values
function record_vote self obj user vote begin set ctype = call get_for_model obj try begin set v = get self user=user content_type=ctype object_id=call _get_pk_val if vote == false begin delete end end except ObjectDoesNotExist begin if vote == false begin return end call create user=user content_type=ctype object_id=c...
def record_vote(self, obj, user, vote): ctype = ContentType.objects.get_for_model(obj) try: v = self.get(user=user, content_type=ctype, object_id=obj._get_pk_val()) if vote == False: v.delete() except models.ObjectDoesNotExist: if vote == False: return self.create(user=user, content_type=ctype...
Python
nomic_cornstack_python_v1
comment %% import math from math import sqrt import warnings import sympy as smp import sys from itertools import count import random from subprocess import check_call import os from PIL import Image from random import randint import unittest append path directory name path absolute path path __file__ + sep + string .....
#%% import math from math import sqrt import warnings import sympy as smp import sys from itertools import count import random from subprocess import check_call import os from PIL import Image from random import randint import unittest sys.path.append(os.path.dirname(os.path.abspath(__file__)) + (os.path.sep + "..") * ...
Python
zaydzuhri_stack_edu_python
import numpy as np import matplotlib.pyplot as plt import keras as k function plot_functions x y func1 begin set model1 = call load_model func1 set predict1 = predict model1 x plot x predict1 label=string model plot x y label=string target legend show end function function plot_loss model1 begin set history1 = load np ...
import numpy as np import matplotlib.pyplot as plt import keras as k def plot_functions(x,y,func1): model1 = k.models.load_model(func1) predict1 = model1.predict(x) plt.plot(x, predict1, label = "model") plt.plot(x, y,label = "target") plt.legend() plt.show() def plot_loss(model1): history1...
Python
zaydzuhri_stack_edu_python
comment !/usr/bin/env python from time import time from math import sqrt function is_natural_number n begin return n % 1.0 == 0 and n > 0 end function function solve_quadratic_equation a b c begin set root1 = - 1.0 * b + square root b ^ 2 - 4.0 * a * c / 2.0 * a set root2 = - 1.0 * b - square root b ^ 2 - 4.0 * a * c /...
#!/usr/bin/env python from time import time from math import sqrt def is_natural_number(n): return n % 1.0 == 0 and n > 0 def solve_quadratic_equation(a, b, c): root1 = (-1.0 * b + sqrt(b**2 - 4.0 * a * c)) / (2.0 * a) root2 = (-1.0 * b - sqrt(b**2 - 4.0 * a * c)) / (2.0 * a) return root1, root2 de...
Python
zaydzuhri_stack_edu_python
comment coding: utf-8 import os , time import numpy as np import librosa import soundfile as sf import model comment =========================================== comment 初始化模型 comment =========================================== class Mymodel extends object begin string docstring for Mymodel function __init__ self networ...
# coding: utf-8 import os, time import numpy as np import librosa import soundfile as sf import model # =========================================== # 初始化模型 # =========================================== class Mymodel(object): """docstring for Mymodel""" def __init__(self, network): super(Mym...
Python
zaydzuhri_stack_edu_python
function find_workers self worker_name=none provider_type=none begin with table_access_condition begin set conn = call _get_connection set c = call cursor execute c string SELECT * from workers WHERE (?1 IS NULL OR worker_name = ?1) AND (?2 IS NULL OR provider_type = ?2) tuple worker_name provider_type set rows = call ...
def find_workers( self, worker_name: Optional[str] = None, provider_type: Optional[str] = None ) -> List[Worker]: with self.table_access_condition: conn = self._get_connection() c = conn.cursor() c.execute( """ SELECT * from workers...
Python
nomic_cornstack_python_v1
function arguments self begin set barsplits = call _not_in_subspans_split_spans string | at slice 1 : : set arguments = list set spans = _spans set lststr = _lststr set typeindex = string ta + string _index if typeindex not in spans begin set spans at typeindex = list end set aspans = spans at typeindex if barsplit...
def arguments(self): barsplits = self._not_in_subspans_split_spans('|')[1:] arguments = [] spans = self._spans lststr = self._lststr typeindex = 'ta' + str(self._index) if typeindex not in spans: spans[typeindex] = [] aspans = spans[typeindex] ...
Python
nomic_cornstack_python_v1
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import metrics , preprocessing from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix function plot_confusion_matrix cm target_names title=string Confusion matrix cmap=none normalize=true begin s...
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import metrics,preprocessing from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix def plot_confusion_matrix(cm, target_names, title='Confus...
Python
zaydzuhri_stack_edu_python
function request self button begin put button block=false end function
def request(self, button): self.requests.put(button, block=False)
Python
nomic_cornstack_python_v1
function get_calibration self name shape chunks=none begin string Get the calibration array. set data_items = find all string .//calibrationVector set tuple data low_res_coords = call read_xml_array data_items name return call interpolate_xml_array data low_res_coords shape chunks=chunks end function
def get_calibration(self, name, shape, chunks=None): """Get the calibration array.""" data_items = self.root.findall(".//calibrationVector") data, low_res_coords = self.read_xml_array(data_items, name) return self.interpolate_xml_array(data, low_res_coords, shape, chunks=chunks)
Python
jtatman_500k
function copy self begin return call Interval start end end function
def copy(self): return Interval(self.start, self.end)
Python
nomic_cornstack_python_v1
function to_grayscale self begin comment Get current image set tuple curr_img _ = undoStack at - 1 comment Convert to grayscale set new_img = as type call to_grayscale curr_img uint8 set new_img_path = call _internal_save call fromarray new_img append undoStack tuple new_img new_img_path call display_image new_img_path...
def to_grayscale(self): curr_img, _ = self.undoStack[-1] # Get current image new_img = to_grayscale(curr_img).astype(np.uint8) # Convert to grayscale new_img_path = self._internal_save(Image.fromarray(new_img)) self.undoStack.append((new_img, new_img_path)) self.display_image(new...
Python
nomic_cornstack_python_v1
comment Componente que se dedica a comprender un lenguaje natural ## comment -----------------------------------------------------------## comment Convierte textos de un lenguaje natural en intents ## comment Importamos metodos de la libreria de utilidades from libraries.lib_utils import count_words , multi_split , mer...
############################################################### ## Componente que se dedica a comprender un lenguaje natural ## ##-----------------------------------------------------------## ## Convierte textos de un lenguaje natural en intents ## ############################################################### ...
Python
zaydzuhri_stack_edu_python
function test_sub_i_less_0 begin set a : list at int = list 1 2 3 4 set i : int = - 1 set j : int = 3 assert sub a i j == list 1 2 3 end function
def test_sub_i_less_0() -> None: a: list[int] = [1, 2, 3, 4] i: int = -1 j: int = 3 assert sub(a, i, j) == [1, 2, 3]
Python
nomic_cornstack_python_v1
function is_hidden self path begin return false end function
def is_hidden(self, path): return False
Python
nomic_cornstack_python_v1
comment !/usr/bin/python import sys function solve A B K begin comment Catalina owns any number less than K. comment For her to win, random numbers must be such that no comment bit is 1 for bits in positions greater than len(bin(K)). comment 3 ^ shared length of A,B + 2 ^ overflow of max(A,B). comment of course, discou...
#!/usr/bin/python import sys def solve(A, B, K): # Catalina owns any number less than K. # For her to win, random numbers must be such that no # bit is 1 for bits in positions greater than len(bin(K)). # 3 ^ shared length of A,B + 2 ^ overflow of max(A,B). # of course, discounting the number of 1's there a...
Python
zaydzuhri_stack_edu_python
comment !/usr/bin/env python import sys import os import datetime from contextlib import contextmanager from sqlalchemy import BigInteger , Text , Integer , DateTime , DECIMAL , BOOLEAN , ForeignKey , Column from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.schema import MetaData from sqlalchemy.o...
#!/usr/bin/env python import sys import os import datetime from contextlib import contextmanager from sqlalchemy import ( BigInteger, Text, Integer, DateTime, DECIMAL, BOOLEAN, ForeignKey, Column ) from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.schema import MetaData from sqlalch...
Python
zaydzuhri_stack_edu_python
from flask import Flask , render_template , request , send_from_directory import matplotlib.pyplot as plt import requests import numpy as np set app = call Flask __name__ set config at string upload_folder = string ./ decorator call route string / function home begin return call render_template string home.htm end func...
from flask import Flask, render_template, request, send_from_directory import matplotlib.pyplot as plt import requests import numpy as np app=Flask(__name__) app.config['upload_folder']='./' @app.route('/') def home(): return render_template('home.htm') @app.route('/grafik', methods=['POST','GET']) def grafik():...
Python
zaydzuhri_stack_edu_python
from abc import ABCMeta class AudioTranscriber begin string Abstract class for VideoPipeline.audio_transcriber set __metaclass__ = ABCMeta function transcribe self audio begin string Transcribe an audio clip into text. Args: audio: The audio file loaded as bytes. You might do this by loading the file using open(file, "...
from abc import ABCMeta class AudioTranscriber: """ Abstract class for VideoPipeline.audio_transcriber """ __metaclass__ = ABCMeta def transcribe(self, audio): """ Transcribe an audio clip into text. Args: audio: The audio file loaded as bytes. You might do thi...
Python
zaydzuhri_stack_edu_python
comment !/usr/bin/env python comment coding: utf-8 comment In[1]: comment Código para minimizar as linhas de código from IPython.display import HTML call HTML string <script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( doc...
#!/usr/bin/env python # coding: utf-8 # In[1]: # Código para minimizar as linhas de código from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( doc...
Python
zaydzuhri_stack_edu_python
string ' You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i]. Example: Input: [5,2,6,1] Output: [2,1,1,0] Explanation: To the right of 5 there are 2 smaller elements (2 and 1). To the r...
'''' You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i]. Example: Input: [5,2,6,1] Output: [2,1,1,0] Explanation: To the right of 5 there are 2 smaller elements (2 and 1). To the r...
Python
zaydzuhri_stack_edu_python
comment - encapsulation: hide delegate from client comment client -> wrapper -> delegate comment decouple client and delegate: client need not to change accordingly when delegate changes comment - replace inheritance with delegation comment when a class (client) needs to use another class (delegate) but wants more cont...
# - encapsulation: hide delegate from client # client -> wrapper -> delegate # decouple client and delegate: client need not to change accordingly when delegate changes # - replace inheritance with delegation # when a class (client) needs to use another class (delegate) but wants more control over its interface #...
Python
zaydzuhri_stack_edu_python
string Created on Thu Sep 4 14:52:32 2020 @author: Mukilan string Using different Alogorithmn to find the best algorithmn for regression Problem statement. I used algorithmn like Linear, Random Forest, Gradient Boost Regression. And I visualize the data using seaborn. import pandas as pd import numpy as np import seabo...
""" Created on Thu Sep 4 14:52:32 2020 @author: Mukilan """ """ Using different Alogorithmn to find the best algorithmn for regression Problem statement. I used algorithmn like Linear, Random Forest, Gradient Boost Regression. And I visualize the data using seaborn.""" import pandas as pd import numpy as np ...
Python
zaydzuhri_stack_edu_python
function filenames self begin return call filenames end function
def filenames(self): return self.latest()[0].filenames()
Python
nomic_cornstack_python_v1
function init_map city begin global map try begin set map = call load_graph city + string _map end except FileNotFoundError begin print string downloading... set map = call download_graph city call save_graph map city + string _map print string downloaded! end end function
def init_map(city): global map try: map = guide.load_graph(city + "_map") except FileNotFoundError: print("downloading...") map = guide.download_graph(city) guide.save_graph(map, city + "_map") print("downloaded!")
Python
nomic_cornstack_python_v1
function readboards filename begin set f = open filename string r set n = integer strip read line f set boards = list for i in range n begin yield list comprehension strip read line f for b in range 4 read line f end end function function row b a begin for r in b begin if call win r a begin return true end end return ...
def readboards(filename): f = open(filename, 'r') n = int(f.readline().strip()) boards = [] for i in range(n): yield [f.readline().strip() for b in range(4)] f.readline() def row(b, a): for r in b: if win(r,a): return True return False def win(...
Python
zaydzuhri_stack_edu_python
function overlap_conflict out *inputs begin from import _bh for i in inputs begin if not call isscalar i begin if call may_share_memory out i and not call same_view out i begin return true end end end return false end function
def overlap_conflict(out, *inputs): from . import _bh for i in inputs: if not np.isscalar(i): if np.may_share_memory(out, i) and not _bh.same_view(out, i): return True return False
Python
nomic_cornstack_python_v1
End of preview. Expand in Data Studio

Axiomic Banner

NPset

A normalized semi-sythetic Python dataset for training small language models on code logic without the overhead of raw code syntax.

Tokenizer chart

Why

Small language models trained on natural language corpora develop latent representations of logical constructs -- iteration, conditionals, data flow, function composition -- yet struggle to apply this reasoning to source code, where syntactic overhead (delimiters, indentation conventions, language-specific idioms) occupies a disproportionate share of the token budget, requires a vocabulary of code-specific tokens rarely encountered during pretraining, and introduces a surface-form distribution shift relative to the model's prior knowledge. NPset addresses this by normalizing Python source through an AST-based converter that strips syntactic noise while preserving the full logical structure of each program, producing a pseudocode representation composed entirely of natural language tokens that aligns more directly with the semantic representations already present in small models, allowing them to reason about what code does rather than expending capacity learning what it looks like.

Format

Parquet, shuffled. Each row:

Field Type Description
code string Normalized pseudocode
original_code string Original Python source
original_language string Always Python
source string Origin dataset identifier

Sources

Source Dataset Rows
nomic_cornstack_python_v1 nomic-ai/cornstack-python-v1 3,498,845
zaydzuhri_stack_edu_python zaydzuhri/stack-edu-python (license_type=no_license) 3,543,752
jtatman_500k jtatman/python-code-dataset-500k 32,590
iamtarun_python_18k_alpaca iamtarun/python_code_instructions_18k_alpaca 17,496
flytech_python_25k flytech/python-codes-25k 42,968
dbands_pythonMath dbands/pythonMath 5,726
greatdarklord_python_dataset greatdarklord/python_dataset 18,452
Total 7,159,829
Downloads last month
117

Collection including AxiomicLabs/NPset-python